aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2008-01-30 19:25:51 -0500
committerPaul Mackerras <paulus@samba.org>2008-01-30 19:25:51 -0500
commitbd45ac0c5daae35e7c71138172e63df5cf644cf6 (patch)
tree5eb5a599bf6a9d7a8a34e802db932aa9e9555de4 /Documentation
parent4eece4ccf997c0e6d8fdad3d842e37b16b8d705f (diff)
parent5bdeae46be6dfe9efa44a548bd622af325f4bdb4 (diff)
Merge branch 'linux-2.6'
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/DocBook/Makefile2
-rw-r--r--Documentation/DocBook/kernel-api.tmpl8
-rw-r--r--Documentation/DocBook/s390-drivers.tmpl1
-rw-r--r--Documentation/DocBook/scsi.tmpl409
-rw-r--r--Documentation/DocBook/videobook.tmpl9
-rw-r--r--Documentation/RCU/RTFP.txt210
-rw-r--r--Documentation/RCU/rcu.txt19
-rw-r--r--Documentation/RCU/torture.txt11
-rw-r--r--Documentation/cpu-freq/user-guide.txt1
-rw-r--r--Documentation/cpu-hotplug.txt13
-rw-r--r--Documentation/crypto/api-intro.txt41
-rw-r--r--Documentation/debugging-via-ohci1394.txt179
-rw-r--r--Documentation/dontdiff2
-rw-r--r--Documentation/dvb/bt8xx.txt12
-rw-r--r--Documentation/feature-removal-schedule.txt123
-rw-r--r--Documentation/filesystems/ext4.txt20
-rw-r--r--Documentation/filesystems/ocfs2.txt16
-rw-r--r--Documentation/filesystems/proc.txt39
-rw-r--r--Documentation/i2c/busses/i2c-i8015
-rw-r--r--Documentation/i2c/busses/i2c-viapro3
-rw-r--r--Documentation/i2c/chips/pcf857572
-rw-r--r--Documentation/i2c/i2c-stub6
-rw-r--r--Documentation/i2c/writing-clients6
-rw-r--r--Documentation/ide.txt13
-rw-r--r--Documentation/ioctl-number.txt1
-rw-r--r--Documentation/kbuild/kconfig-language.txt111
-rw-r--r--Documentation/kernel-parameters.txt73
-rw-r--r--Documentation/kobject.txt489
-rw-r--r--Documentation/kprobes.txt1
-rw-r--r--Documentation/lguest/lguest.c49
-rw-r--r--Documentation/m68k/kernel-options.txt60
-rw-r--r--Documentation/mips/00-INDEX2
-rw-r--r--Documentation/mips/GT64120.README65
-rw-r--r--Documentation/networking/00-INDEX4
-rw-r--r--Documentation/networking/bonding.txt204
-rw-r--r--Documentation/networking/can.txt629
-rw-r--r--Documentation/networking/dccp.txt39
-rw-r--r--Documentation/networking/ip-sysctl.txt27
-rw-r--r--Documentation/networking/shaper.txt48
-rw-r--r--Documentation/networking/udplite.txt2
-rw-r--r--Documentation/networking/xfrm_proc.txt70
-rw-r--r--Documentation/pnp.txt4
-rw-r--r--Documentation/s390/CommonIO5
-rw-r--r--Documentation/s390/cds.txt2
-rw-r--r--Documentation/scsi/00-INDEX2
-rw-r--r--Documentation/scsi/ChangeLog.megaraid_sas159
-rw-r--r--Documentation/scsi/aacraid.txt4
-rw-r--r--Documentation/scsi/hptiop.txt30
-rw-r--r--Documentation/scsi/ncr53c7xx.txt40
-rw-r--r--Documentation/video4linux/CARDLIST.cx238854
-rw-r--r--Documentation/video4linux/CARDLIST.cx881
-rw-r--r--Documentation/video4linux/CARDLIST.em28xx17
-rw-r--r--Documentation/video4linux/CARDLIST.ivtv6
-rw-r--r--Documentation/video4linux/CARDLIST.saa713417
-rw-r--r--Documentation/video4linux/CARDLIST.tuner5
-rw-r--r--Documentation/video4linux/CARDLIST.usbvision1
-rw-r--r--Documentation/video4linux/extract_xc3028.pl926
-rw-r--r--Documentation/video4linux/sn9c102.txt1
-rw-r--r--Documentation/vm/slabinfo.c2
-rw-r--r--Documentation/vm/slub.txt2
-rw-r--r--Documentation/x86_64/boot-options.txt8
-rw-r--r--Documentation/x86_64/uefi.txt9
-rw-r--r--Documentation/zh_CN/CodingStyle701
-rw-r--r--Documentation/zh_CN/HOWTO10
-rw-r--r--Documentation/zh_CN/SubmittingDrivers168
-rw-r--r--Documentation/zh_CN/SubmittingPatches416
-rw-r--r--Documentation/zh_CN/oops-tracing.txt212
-rw-r--r--Documentation/zh_CN/sparse.txt100
-rw-r--r--Documentation/zh_CN/stable_kernel_rules.txt66
-rw-r--r--Documentation/zh_CN/volatile-considered-harmful.txt113
70 files changed, 5460 insertions, 665 deletions
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 4953bc258729..6a0ad4715e9f 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -11,7 +11,7 @@ DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \
11 procfs-guide.xml writing_usb_driver.xml \ 11 procfs-guide.xml writing_usb_driver.xml \
12 kernel-api.xml filesystems.xml lsm.xml usb.xml \ 12 kernel-api.xml filesystems.xml lsm.xml usb.xml \
13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \ 13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
14 genericirq.xml s390-drivers.xml uio-howto.xml 14 genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml
15 15
16### 16###
17# The build process is as follows (targets): 17# The build process is as follows (targets):
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index aa38cc5692a0..77436d735013 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -419,7 +419,13 @@ X!Edrivers/pnp/system.c
419 419
420 <chapter id="blkdev"> 420 <chapter id="blkdev">
421 <title>Block Devices</title> 421 <title>Block Devices</title>
422!Eblock/ll_rw_blk.c 422!Eblock/blk-core.c
423!Eblock/blk-map.c
424!Iblock/blk-sysfs.c
425!Eblock/blk-settings.c
426!Eblock/blk-exec.c
427!Eblock/blk-barrier.c
428!Eblock/blk-tag.c
423 </chapter> 429 </chapter>
424 430
425 <chapter id="chrdev"> 431 <chapter id="chrdev">
diff --git a/Documentation/DocBook/s390-drivers.tmpl b/Documentation/DocBook/s390-drivers.tmpl
index 254e769282a4..3d2f31b99dd9 100644
--- a/Documentation/DocBook/s390-drivers.tmpl
+++ b/Documentation/DocBook/s390-drivers.tmpl
@@ -116,6 +116,7 @@
116!Iinclude/asm-s390/ccwdev.h 116!Iinclude/asm-s390/ccwdev.h
117!Edrivers/s390/cio/device.c 117!Edrivers/s390/cio/device.c
118!Edrivers/s390/cio/device_ops.c 118!Edrivers/s390/cio/device_ops.c
119!Edrivers/s390/cio/airq.c
119 </sect1> 120 </sect1>
120 <sect1 id="cmf"> 121 <sect1 id="cmf">
121 <title>The channel-measurement facility</title> 122 <title>The channel-measurement facility</title>
diff --git a/Documentation/DocBook/scsi.tmpl b/Documentation/DocBook/scsi.tmpl
new file mode 100644
index 000000000000..f299ab182bbe
--- /dev/null
+++ b/Documentation/DocBook/scsi.tmpl
@@ -0,0 +1,409 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="scsimid">
6 <bookinfo>
7 <title>SCSI Interfaces Guide</title>
8
9 <authorgroup>
10 <author>
11 <firstname>James</firstname>
12 <surname>Bottomley</surname>
13 <affiliation>
14 <address>
15 <email>James.Bottomley@steeleye.com</email>
16 </address>
17 </affiliation>
18 </author>
19
20 <author>
21 <firstname>Rob</firstname>
22 <surname>Landley</surname>
23 <affiliation>
24 <address>
25 <email>rob@landley.net</email>
26 </address>
27 </affiliation>
28 </author>
29
30 </authorgroup>
31
32 <copyright>
33 <year>2007</year>
34 <holder>Linux Foundation</holder>
35 </copyright>
36
37 <legalnotice>
38 <para>
39 This documentation is free software; you can redistribute
40 it and/or modify it under the terms of the GNU General Public
41 License version 2.
42 </para>
43
44 <para>
45 This program is distributed in the hope that it will be
46 useful, but WITHOUT ANY WARRANTY; without even the implied
47 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
48 For more details see the file COPYING in the source
49 distribution of Linux.
50 </para>
51 </legalnotice>
52 </bookinfo>
53
54 <toc></toc>
55
56 <chapter id="intro">
57 <title>Introduction</title>
58 <sect1 id="protocol_vs_bus">
59 <title>Protocol vs bus</title>
60 <para>
61 Once upon a time, the Small Computer Systems Interface defined both
62 a parallel I/O bus and a data protocol to connect a wide variety of
63 peripherals (disk drives, tape drives, modems, printers, scanners,
64 optical drives, test equipment, and medical devices) to a host
65 computer.
66 </para>
67 <para>
68 Although the old parallel (fast/wide/ultra) SCSI bus has largely
69 fallen out of use, the SCSI command set is more widely used than ever
70 to communicate with devices over a number of different busses.
71 </para>
72 <para>
73 The <ulink url='http://www.t10.org/scsi-3.htm'>SCSI protocol</ulink>
74 is a big-endian peer-to-peer packet based protocol. SCSI commands
75 are 6, 10, 12, or 16 bytes long, often followed by an associated data
76 payload.
77 </para>
78 <para>
79 SCSI commands can be transported over just about any kind of bus, and
80 are the default protocol for storage devices attached to USB, SATA,
81 SAS, Fibre Channel, FireWire, and ATAPI devices. SCSI packets are
82 also commonly exchanged over Infiniband,
83 <ulink url='http://i2o.shadowconnect.com/faq.php'>I20</ulink>, TCP/IP
84 (<ulink url='http://en.wikipedia.org/wiki/ISCSI'>iSCSI</ulink>), even
85 <ulink url='http://cyberelk.net/tim/parport/parscsi.html'>Parallel
86 ports</ulink>.
87 </para>
88 </sect1>
89 <sect1 id="subsystem_design">
90 <title>Design of the Linux SCSI subsystem</title>
91 <para>
92 The SCSI subsystem uses a three layer design, with upper, mid, and low
93 layers. Every operation involving the SCSI subsystem (such as reading
94 a sector from a disk) uses one driver at each of the 3 levels: one
95 upper layer driver, one lower layer driver, and the SCSI midlayer.
96 </para>
97 <para>
98 The SCSI upper layer provides the interface between userspace and the
99 kernel, in the form of block and char device nodes for I/O and
100 ioctl(). The SCSI lower layer contains drivers for specific hardware
101 devices.
102 </para>
103 <para>
104 In between is the SCSI mid-layer, analogous to a network routing
105 layer such as the IPv4 stack. The SCSI mid-layer routes a packet
106 based data protocol between the upper layer's /dev nodes and the
107 corresponding devices in the lower layer. It manages command queues,
108 provides error handling and power management functions, and responds
109 to ioctl() requests.
110 </para>
111 </sect1>
112 </chapter>
113
114 <chapter id="upper_layer">
115 <title>SCSI upper layer</title>
116 <para>
117 The upper layer supports the user-kernel interface by providing
118 device nodes.
119 </para>
120 <sect1 id="sd">
121 <title>sd (SCSI Disk)</title>
122 <para>sd (sd_mod.o)</para>
123<!-- !Idrivers/scsi/sd.c -->
124 </sect1>
125 <sect1 id="sr">
126 <title>sr (SCSI CD-ROM)</title>
127 <para>sr (sr_mod.o)</para>
128 </sect1>
129 <sect1 id="st">
130 <title>st (SCSI Tape)</title>
131 <para>st (st.o)</para>
132 </sect1>
133 <sect1 id="sg">
134 <title>sg (SCSI Generic)</title>
135 <para>sg (sg.o)</para>
136 </sect1>
137 <sect1 id="ch">
138 <title>ch (SCSI Media Changer)</title>
139 <para>ch (ch.c)</para>
140 </sect1>
141 </chapter>
142
143 <chapter id="mid_layer">
144 <title>SCSI mid layer</title>
145
146 <sect1 id="midlayer_implementation">
147 <title>SCSI midlayer implementation</title>
148 <sect2 id="scsi_device.h">
149 <title>include/scsi/scsi_device.h</title>
150 <para>
151 </para>
152!Iinclude/scsi/scsi_device.h
153 </sect2>
154
155 <sect2 id="scsi.c">
156 <title>drivers/scsi/scsi.c</title>
157 <para>Main file for the SCSI midlayer.</para>
158!Edrivers/scsi/scsi.c
159 </sect2>
160 <sect2 id="scsicam.c">
161 <title>drivers/scsi/scsicam.c</title>
162 <para>
163 <ulink url='http://www.t10.org/ftp/t10/drafts/cam/cam-r12b.pdf'>SCSI
164 Common Access Method</ulink> support functions, for use with
165 HDIO_GETGEO, etc.
166 </para>
167!Edrivers/scsi/scsicam.c
168 </sect2>
169 <sect2 id="scsi_error.c">
170 <title>drivers/scsi/scsi_error.c</title>
171 <para>Common SCSI error/timeout handling routines.</para>
172!Edrivers/scsi/scsi_error.c
173 </sect2>
174 <sect2 id="scsi_devinfo.c">
175 <title>drivers/scsi/scsi_devinfo.c</title>
176 <para>
177 Manage scsi_dev_info_list, which tracks blacklisted and whitelisted
178 devices.
179 </para>
180!Idrivers/scsi/scsi_devinfo.c
181 </sect2>
182 <sect2 id="scsi_ioctl.c">
183 <title>drivers/scsi/scsi_ioctl.c</title>
184 <para>
185 Handle ioctl() calls for SCSI devices.
186 </para>
187!Edrivers/scsi/scsi_ioctl.c
188 </sect2>
189 <sect2 id="scsi_lib.c">
190 <title>drivers/scsi/scsi_lib.c</title>
191 <para>
192 SCSI queuing library.
193 </para>
194!Edrivers/scsi/scsi_lib.c
195 </sect2>
196 <sect2 id="scsi_lib_dma.c">
197 <title>drivers/scsi/scsi_lib_dma.c</title>
198 <para>
199 SCSI library functions depending on DMA
200 (map and unmap scatter-gather lists).
201 </para>
202!Edrivers/scsi/scsi_lib_dma.c
203 </sect2>
204 <sect2 id="scsi_module.c">
205 <title>drivers/scsi/scsi_module.c</title>
206 <para>
207 The file drivers/scsi/scsi_module.c contains legacy support for
208 old-style host templates. It should never be used by any new driver.
209 </para>
210 </sect2>
211 <sect2 id="scsi_proc.c">
212 <title>drivers/scsi/scsi_proc.c</title>
213 <para>
214 The functions in this file provide an interface between
215 the PROC file system and the SCSI device drivers
216 It is mainly used for debugging, statistics and to pass
217 information directly to the lowlevel driver.
218
219 I.E. plumbing to manage /proc/scsi/*
220 </para>
221!Idrivers/scsi/scsi_proc.c
222 </sect2>
223 <sect2 id="scsi_netlink.c">
224 <title>drivers/scsi/scsi_netlink.c</title>
225 <para>
226 Infrastructure to provide async events from transports to userspace
227 via netlink, using a single NETLINK_SCSITRANSPORT protocol for all
228 transports.
229
230 See <ulink url='http://marc.info/?l=linux-scsi&amp;m=115507374832500&amp;w=2'>the
231 original patch submission</ulink> for more details.
232 </para>
233!Idrivers/scsi/scsi_netlink.c
234 </sect2>
235 <sect2 id="scsi_scan.c">
236 <title>drivers/scsi/scsi_scan.c</title>
237 <para>
238 Scan a host to determine which (if any) devices are attached.
239
240 The general scanning/probing algorithm is as follows, exceptions are
241 made to it depending on device specific flags, compilation options,
242 and global variable (boot or module load time) settings.
243
244 A specific LUN is scanned via an INQUIRY command; if the LUN has a
245 device attached, a scsi_device is allocated and setup for it.
246
247 For every id of every channel on the given host, start by scanning
248 LUN 0. Skip hosts that don't respond at all to a scan of LUN 0.
249 Otherwise, if LUN 0 has a device attached, allocate and setup a
250 scsi_device for it. If target is SCSI-3 or up, issue a REPORT LUN,
251 and scan all of the LUNs returned by the REPORT LUN; else,
252 sequentially scan LUNs up until some maximum is reached, or a LUN is
253 seen that cannot have a device attached to it.
254 </para>
255!Idrivers/scsi/scsi_scan.c
256 </sect2>
257 <sect2 id="scsi_sysctl.c">
258 <title>drivers/scsi/scsi_sysctl.c</title>
259 <para>
260 Set up the sysctl entry: "/dev/scsi/logging_level"
261 (DEV_SCSI_LOGGING_LEVEL) which sets/returns scsi_logging_level.
262 </para>
263 </sect2>
264 <sect2 id="scsi_sysfs.c">
265 <title>drivers/scsi/scsi_sysfs.c</title>
266 <para>
267 SCSI sysfs interface routines.
268 </para>
269!Edrivers/scsi/scsi_sysfs.c
270 </sect2>
271 <sect2 id="hosts.c">
272 <title>drivers/scsi/hosts.c</title>
273 <para>
274 mid to lowlevel SCSI driver interface
275 </para>
276!Edrivers/scsi/hosts.c
277 </sect2>
278 <sect2 id="constants.c">
279 <title>drivers/scsi/constants.c</title>
280 <para>
281 mid to lowlevel SCSI driver interface
282 </para>
283!Edrivers/scsi/constants.c
284 </sect2>
285 </sect1>
286
287 <sect1 id="Transport_classes">
288 <title>Transport classes</title>
289 <para>
290 Transport classes are service libraries for drivers in the SCSI
291 lower layer, which expose transport attributes in sysfs.
292 </para>
293 <sect2 id="Fibre_Channel_transport">
294 <title>Fibre Channel transport</title>
295 <para>
296 The file drivers/scsi/scsi_transport_fc.c defines transport attributes
297 for Fibre Channel.
298 </para>
299!Edrivers/scsi/scsi_transport_fc.c
300 </sect2>
301 <sect2 id="iSCSI_transport">
302 <title>iSCSI transport class</title>
303 <para>
304 The file drivers/scsi/scsi_transport_iscsi.c defines transport
305 attributes for the iSCSI class, which sends SCSI packets over TCP/IP
306 connections.
307 </para>
308!Edrivers/scsi/scsi_transport_iscsi.c
309 </sect2>
310 <sect2 id="SAS_transport">
311 <title>Serial Attached SCSI (SAS) transport class</title>
312 <para>
313 The file drivers/scsi/scsi_transport_sas.c defines transport
314 attributes for Serial Attached SCSI, a variant of SATA aimed at
315 large high-end systems.
316 </para>
317 <para>
318 The SAS transport class contains common code to deal with SAS HBAs,
319 an aproximated representation of SAS topologies in the driver model,
320 and various sysfs attributes to expose these topologies and managment
321 interfaces to userspace.
322 </para>
323 <para>
324 In addition to the basic SCSI core objects this transport class
325 introduces two additional intermediate objects: The SAS PHY
326 as represented by struct sas_phy defines an "outgoing" PHY on
327 a SAS HBA or Expander, and the SAS remote PHY represented by
328 struct sas_rphy defines an "incoming" PHY on a SAS Expander or
329 end device. Note that this is purely a software concept, the
330 underlying hardware for a PHY and a remote PHY is the exactly
331 the same.
332 </para>
333 <para>
334 There is no concept of a SAS port in this code, users can see
335 what PHYs form a wide port based on the port_identifier attribute,
336 which is the same for all PHYs in a port.
337 </para>
338!Edrivers/scsi/scsi_transport_sas.c
339 </sect2>
340 <sect2 id="SATA_transport">
341 <title>SATA transport class</title>
342 <para>
343 The SATA transport is handled by libata, which has its own book of
344 documentation in this directory.
345 </para>
346 </sect2>
347 <sect2 id="SPI_transport">
348 <title>Parallel SCSI (SPI) transport class</title>
349 <para>
350 The file drivers/scsi/scsi_transport_spi.c defines transport
351 attributes for traditional (fast/wide/ultra) SCSI busses.
352 </para>
353!Edrivers/scsi/scsi_transport_spi.c
354 </sect2>
355 <sect2 id="SRP_transport">
356 <title>SCSI RDMA (SRP) transport class</title>
357 <para>
358 The file drivers/scsi/scsi_transport_srp.c defines transport
359 attributes for SCSI over Remote Direct Memory Access.
360 </para>
361!Edrivers/scsi/scsi_transport_srp.c
362 </sect2>
363 </sect1>
364
365 </chapter>
366
367 <chapter id="lower_layer">
368 <title>SCSI lower layer</title>
369 <sect1 id="hba_drivers">
370 <title>Host Bus Adapter transport types</title>
371 <para>
372 Many modern device controllers use the SCSI command set as a protocol to
373 communicate with their devices through many different types of physical
374 connections.
375 </para>
376 <para>
377 In SCSI language a bus capable of carrying SCSI commands is
378 called a "transport", and a controller connecting to such a bus is
379 called a "host bus adapter" (HBA).
380 </para>
381 <sect2 id="scsi_debug.c">
382 <title>Debug transport</title>
383 <para>
384 The file drivers/scsi/scsi_debug.c simulates a host adapter with a
385 variable number of disks (or disk like devices) attached, sharing a
386 common amount of RAM. Does a lot of checking to make sure that we are
387 not getting blocks mixed up, and panics the kernel if anything out of
388 the ordinary is seen.
389 </para>
390 <para>
391 To be more realistic, the simulated devices have the transport
392 attributes of SAS disks.
393 </para>
394 <para>
395 For documentation see
396 <ulink url='http://www.torque.net/sg/sdebug26.html'>http://www.torque.net/sg/sdebug26.html</ulink>
397 </para>
398<!-- !Edrivers/scsi/scsi_debug.c -->
399 </sect2>
400 <sect2 id="todo">
401 <title>todo</title>
402 <para>Parallel (fast/wide/ultra) SCSI, USB, SATA,
403 SAS, Fibre Channel, FireWire, ATAPI devices, Infiniband,
404 I20, iSCSI, Parallel ports, netlink...
405 </para>
406 </sect2>
407 </sect1>
408 </chapter>
409</book>
diff --git a/Documentation/DocBook/videobook.tmpl b/Documentation/DocBook/videobook.tmpl
index b629da33951d..b3d93ee27693 100644
--- a/Documentation/DocBook/videobook.tmpl
+++ b/Documentation/DocBook/videobook.tmpl
@@ -96,7 +96,6 @@ static struct video_device my_radio
96{ 96{
97 "My radio", 97 "My radio",
98 VID_TYPE_TUNER, 98 VID_TYPE_TUNER,
99 VID_HARDWARE_MYRADIO,
100 radio_open. 99 radio_open.
101 radio_close, 100 radio_close,
102 NULL, /* no read */ 101 NULL, /* no read */
@@ -119,13 +118,6 @@ static struct video_device my_radio
119 way to change channel so it is tuneable. 118 way to change channel so it is tuneable.
120 </para> 119 </para>
121 <para> 120 <para>
122 The VID_HARDWARE_ types are unique to each device. Numbers are assigned by
123 <email>alan@redhat.com</email> when device drivers are going to be released. Until then you
124 can pull a suitably large number out of your hat and use it. 10000 should be
125 safe for a very long time even allowing for the huge number of vendors
126 making new and different radio cards at the moment.
127 </para>
128 <para>
129 We declare an open and close routine, but we do not need read or write, 121 We declare an open and close routine, but we do not need read or write,
130 which are used to read and write video data to or from the card itself. As 122 which are used to read and write video data to or from the card itself. As
131 we have no read or write there is no poll function. 123 we have no read or write there is no poll function.
@@ -844,7 +836,6 @@ static struct video_device my_camera
844 "My Camera", 836 "My Camera",
845 VID_TYPE_OVERLAY|VID_TYPE_SCALES|\ 837 VID_TYPE_OVERLAY|VID_TYPE_SCALES|\
846 VID_TYPE_CAPTURE|VID_TYPE_CHROMAKEY, 838 VID_TYPE_CAPTURE|VID_TYPE_CHROMAKEY,
847 VID_HARDWARE_MYCAMERA,
848 camera_open. 839 camera_open.
849 camera_close, 840 camera_close,
850 camera_read, /* no read */ 841 camera_read, /* no read */
diff --git a/Documentation/RCU/RTFP.txt b/Documentation/RCU/RTFP.txt
index 6221464d1a7e..39ad8f56783a 100644
--- a/Documentation/RCU/RTFP.txt
+++ b/Documentation/RCU/RTFP.txt
@@ -9,8 +9,8 @@ The first thing resembling RCU was published in 1980, when Kung and Lehman
9[Kung80] recommended use of a garbage collector to defer destruction 9[Kung80] recommended use of a garbage collector to defer destruction
10of nodes in a parallel binary search tree in order to simplify its 10of nodes in a parallel binary search tree in order to simplify its
11implementation. This works well in environments that have garbage 11implementation. This works well in environments that have garbage
12collectors, but current production garbage collectors incur significant 12collectors, but most production garbage collectors incur significant
13read-side overhead. 13overhead.
14 14
15In 1982, Manber and Ladner [Manber82,Manber84] recommended deferring 15In 1982, Manber and Ladner [Manber82,Manber84] recommended deferring
16destruction until all threads running at that time have terminated, again 16destruction until all threads running at that time have terminated, again
@@ -99,16 +99,25 @@ locking, reduces contention, reduces memory latency for readers, and
99parallelizes pipeline stalls and memory latency for writers. However, 99parallelizes pipeline stalls and memory latency for writers. However,
100these techniques still impose significant read-side overhead in the 100these techniques still impose significant read-side overhead in the
101form of memory barriers. Researchers at Sun worked along similar lines 101form of memory barriers. Researchers at Sun worked along similar lines
102in the same timeframe [HerlihyLM02,HerlihyLMS03]. These techniques 102in the same timeframe [HerlihyLM02]. These techniques can be thought
103can be thought of as inside-out reference counts, where the count is 103of as inside-out reference counts, where the count is represented by the
104represented by the number of hazard pointers referencing a given data 104number of hazard pointers referencing a given data structure (rather than
105structure (rather than the more conventional counter field within the 105the more conventional counter field within the data structure itself).
106data structure itself). 106
107By the same token, RCU can be thought of as a "bulk reference count",
108where some form of reference counter covers all reference by a given CPU
109or thread during a set timeframe. This timeframe is related to, but
110not necessarily exactly the same as, an RCU grace period. In classic
111RCU, the reference counter is the per-CPU bit in the "bitmask" field,
112and each such bit covers all references that might have been made by
113the corresponding CPU during the prior grace period. Of course, RCU
114can be thought of in other terms as well.
107 115
108In 2003, the K42 group described how RCU could be used to create 116In 2003, the K42 group described how RCU could be used to create
109hot-pluggable implementations of operating-system functions. Later that 117hot-pluggable implementations of operating-system functions [Appavoo03a].
110year saw a paper describing an RCU implementation of System V IPC 118Later that year saw a paper describing an RCU implementation of System
111[Arcangeli03], and an introduction to RCU in Linux Journal [McKenney03a]. 119V IPC [Arcangeli03], and an introduction to RCU in Linux Journal
120[McKenney03a].
112 121
1132004 has seen a Linux-Journal article on use of RCU in dcache 1222004 has seen a Linux-Journal article on use of RCU in dcache
114[McKenney04a], a performance comparison of locking to RCU on several 123[McKenney04a], a performance comparison of locking to RCU on several
@@ -117,10 +126,19 @@ number of operating-system kernels [PaulEdwardMcKenneyPhD], a paper
117describing how to make RCU safe for soft-realtime applications [Sarma04c], 126describing how to make RCU safe for soft-realtime applications [Sarma04c],
118and a paper describing SELinux performance with RCU [JamesMorris04b]. 127and a paper describing SELinux performance with RCU [JamesMorris04b].
119 128
1202005 has seen further adaptation of RCU to realtime use, permitting 1292005 brought further adaptation of RCU to realtime use, permitting
121preemption of RCU realtime critical sections [PaulMcKenney05a, 130preemption of RCU realtime critical sections [PaulMcKenney05a,
122PaulMcKenney05b]. 131PaulMcKenney05b].
123 132
1332006 saw the first best-paper award for an RCU paper [ThomasEHart2006a],
134as well as further work on efficient implementations of preemptible
135RCU [PaulEMcKenney2006b], but priority-boosting of RCU read-side critical
136sections proved elusive. An RCU implementation permitting general
137blocking in read-side critical sections appeared [PaulEMcKenney2006c],
138Robert Olsson described an RCU-protected trie-hash combination
139[RobertOlsson2006a].
140
141
124Bibtex Entries 142Bibtex Entries
125 143
126@article{Kung80 144@article{Kung80
@@ -203,6 +221,41 @@ Bibtex Entries
203,Address="New Orleans, LA" 221,Address="New Orleans, LA"
204} 222}
205 223
224@conference{Pu95a,
225Author = "Calton Pu and Tito Autrey and Andrew Black and Charles Consel and
226Crispin Cowan and Jon Inouye and Lakshmi Kethana and Jonathan Walpole and
227Ke Zhang",
228Title = "Optimistic Incremental Specialization: Streamlining a Commercial
229Operating System",
230Booktitle = "15\textsuperscript{th} ACM Symposium on
231Operating Systems Principles (SOSP'95)",
232address = "Copper Mountain, CO",
233month="December",
234year="1995",
235pages="314-321",
236annotation="
237 Uses a replugger, but with a flag to signal when people are
238 using the resource at hand. Only one reader at a time.
239"
240}
241
242@conference{Cowan96a,
243Author = "Crispin Cowan and Tito Autrey and Charles Krasic and
244Calton Pu and Jonathan Walpole",
245Title = "Fast Concurrent Dynamic Linking for an Adaptive Operating System",
246Booktitle = "International Conference on Configurable Distributed Systems
247(ICCDS'96)",
248address = "Annapolis, MD",
249month="May",
250year="1996",
251pages="108",
252isbn="0-8186-7395-8",
253annotation="
254 Uses a replugger, but with a counter to signal when people are
255 using the resource at hand. Allows multiple readers.
256"
257}
258
206@techreport{Slingwine95 259@techreport{Slingwine95
207,author="John D. Slingwine and Paul E. McKenney" 260,author="John D. Slingwine and Paul E. McKenney"
208,title="Apparatus and Method for Achieving Reduced Overhead Mutual 261,title="Apparatus and Method for Achieving Reduced Overhead Mutual
@@ -312,6 +365,49 @@ Andrea Arcangeli and Andi Kleen and Orran Krieger and Rusty Russell"
312[Viewed June 23, 2004]" 365[Viewed June 23, 2004]"
313} 366}
314 367
368@conference{Michael02a
369,author="Maged M. Michael"
370,title="Safe Memory Reclamation for Dynamic Lock-Free Objects Using Atomic
371Reads and Writes"
372,Year="2002"
373,Month="August"
374,booktitle="{Proceedings of the 21\textsuperscript{st} Annual ACM
375Symposium on Principles of Distributed Computing}"
376,pages="21-30"
377,annotation="
378 Each thread keeps an array of pointers to items that it is
379 currently referencing. Sort of an inside-out garbage collection
380 mechanism, but one that requires the accessing code to explicitly
381 state its needs. Also requires read-side memory barriers on
382 most architectures.
383"
384}
385
386@conference{Michael02b
387,author="Maged M. Michael"
388,title="High Performance Dynamic Lock-Free Hash Tables and List-Based Sets"
389,Year="2002"
390,Month="August"
391,booktitle="{Proceedings of the 14\textsuperscript{th} Annual ACM
392Symposium on Parallel
393Algorithms and Architecture}"
394,pages="73-82"
395,annotation="
396 Like the title says...
397"
398}
399
400@InProceedings{HerlihyLM02
401,author={Maurice Herlihy and Victor Luchangco and Mark Moir}
402,title="The Repeat Offender Problem: A Mechanism for Supporting Dynamic-Sized,
403Lock-Free Data Structures"
404,booktitle={Proceedings of 16\textsuperscript{th} International
405Symposium on Distributed Computing}
406,year=2002
407,month="October"
408,pages="339-353"
409}
410
315@article{Appavoo03a 411@article{Appavoo03a
316,author="J. Appavoo and K. Hui and C. A. N. Soules and R. W. Wisniewski and 412,author="J. Appavoo and K. Hui and C. A. N. Soules and R. W. Wisniewski and
317D. M. {Da Silva} and O. Krieger and M. A. Auslander and D. J. Edelsohn and 413D. M. {Da Silva} and O. Krieger and M. A. Auslander and D. J. Edelsohn and
@@ -447,3 +543,95 @@ Oregon Health and Sciences University"
447 Realtime turns into making RCU yet more realtime friendly. 543 Realtime turns into making RCU yet more realtime friendly.
448" 544"
449} 545}
546
547@conference{ThomasEHart2006a
548,Author="Thomas E. Hart and Paul E. McKenney and Angela Demke Brown"
549,Title="Making Lockless Synchronization Fast: Performance Implications
550of Memory Reclamation"
551,Booktitle="20\textsuperscript{th} {IEEE} International Parallel and
552Distributed Processing Symposium"
553,month="April"
554,year="2006"
555,day="25-29"
556,address="Rhodes, Greece"
557,annotation="
558 Compares QSBR (AKA "classic RCU"), HPBR, EBR, and lock-free
559 reference counting.
560"
561}
562
563@Conference{PaulEMcKenney2006b
564,Author="Paul E. McKenney and Dipankar Sarma and Ingo Molnar and
565Suparna Bhattacharya"
566,Title="Extending RCU for Realtime and Embedded Workloads"
567,Booktitle="{Ottawa Linux Symposium}"
568,Month="July"
569,Year="2006"
570,pages="v2 123-138"
571,note="Available:
572\url{http://www.linuxsymposium.org/2006/view_abstract.php?content_key=184}
573\url{http://www.rdrop.com/users/paulmck/RCU/OLSrtRCU.2006.08.11a.pdf}
574[Viewed January 1, 2007]"
575,annotation="
576 Described how to improve the -rt implementation of realtime RCU.
577"
578}
579
580@unpublished{PaulEMcKenney2006c
581,Author="Paul E. McKenney"
582,Title="Sleepable {RCU}"
583,month="October"
584,day="9"
585,year="2006"
586,note="Available:
587\url{http://lwn.net/Articles/202847/}
588Revised:
589\url{http://www.rdrop.com/users/paulmck/RCU/srcu.2007.01.14a.pdf}
590[Viewed August 21, 2006]"
591,annotation="
592 LWN article introducing SRCU.
593"
594}
595
596@unpublished{RobertOlsson2006a
597,Author="Robert Olsson and Stefan Nilsson"
598,Title="{TRASH}: A dynamic {LC}-trie and hash data structure"
599,month="August"
600,day="18"
601,year="2006"
602,note="Available:
603\url{http://www.nada.kth.se/~snilsson/public/papers/trash/trash.pdf}
604[Viewed February 24, 2007]"
605,annotation="
606 RCU-protected dynamic trie-hash combination.
607"
608}
609
610@unpublished{ThomasEHart2007a
611,Author="Thomas E. Hart and Paul E. McKenney and Angela Demke Brown and Jonathan Walpole"
612,Title="Performance of memory reclamation for lockless synchronization"
613,journal="J. Parallel Distrib. Comput."
614,year="2007"
615,note="To appear in J. Parallel Distrib. Comput.
616 \url{doi=10.1016/j.jpdc.2007.04.010}"
617,annotation={
618 Compares QSBR (AKA "classic RCU"), HPBR, EBR, and lock-free
619 reference counting. Journal version of ThomasEHart2006a.
620}
621}
622
623@unpublished{PaulEMcKenney2007QRCUspin
624,Author="Paul E. McKenney"
625,Title="Using Promela and Spin to verify parallel algorithms"
626,month="August"
627,day="1"
628,year="2007"
629,note="Available:
630\url{http://lwn.net/Articles/243851/}
631[Viewed September 8, 2007]"
632,annotation="
633 LWN article describing Promela and spin, and also using Oleg
634 Nesterov's QRCU as an example (with Paul McKenney's fastpath).
635"
636}
637
diff --git a/Documentation/RCU/rcu.txt b/Documentation/RCU/rcu.txt
index f84407cba816..95821a29ae41 100644
--- a/Documentation/RCU/rcu.txt
+++ b/Documentation/RCU/rcu.txt
@@ -36,6 +36,14 @@ o How can the updater tell when a grace period has completed
36 executed in user mode, or executed in the idle loop, we can 36 executed in user mode, or executed in the idle loop, we can
37 safely free up that item. 37 safely free up that item.
38 38
39 Preemptible variants of RCU (CONFIG_PREEMPT_RCU) get the
40 same effect, but require that the readers manipulate CPU-local
41 counters. These counters allow limited types of blocking
42 within RCU read-side critical sections. SRCU also uses
43 CPU-local counters, and permits general blocking within
44 RCU read-side critical sections. These two variants of
45 RCU detect grace periods by sampling these counters.
46
39o If I am running on a uniprocessor kernel, which can only do one 47o If I am running on a uniprocessor kernel, which can only do one
40 thing at a time, why should I wait for a grace period? 48 thing at a time, why should I wait for a grace period?
41 49
@@ -46,7 +54,10 @@ o How can I see where RCU is currently used in the Linux kernel?
46 Search for "rcu_read_lock", "rcu_read_unlock", "call_rcu", 54 Search for "rcu_read_lock", "rcu_read_unlock", "call_rcu",
47 "rcu_read_lock_bh", "rcu_read_unlock_bh", "call_rcu_bh", 55 "rcu_read_lock_bh", "rcu_read_unlock_bh", "call_rcu_bh",
48 "srcu_read_lock", "srcu_read_unlock", "synchronize_rcu", 56 "srcu_read_lock", "srcu_read_unlock", "synchronize_rcu",
49 "synchronize_net", and "synchronize_srcu". 57 "synchronize_net", "synchronize_srcu", and the other RCU
58 primitives. Or grab one of the cscope databases from:
59
60 http://www.rdrop.com/users/paulmck/RCU/linuxusage/rculocktab.html
50 61
51o What guidelines should I follow when writing code that uses RCU? 62o What guidelines should I follow when writing code that uses RCU?
52 63
@@ -67,7 +78,11 @@ o I hear that RCU is patented? What is with that?
67 78
68o I hear that RCU needs work in order to support realtime kernels? 79o I hear that RCU needs work in order to support realtime kernels?
69 80
70 Yes, work in progress. 81 This work is largely completed. Realtime-friendly RCU can be
82 enabled via the CONFIG_PREEMPT_RCU kernel configuration parameter.
83 However, work is in progress for enabling priority boosting of
84 preempted RCU read-side critical sections.This is needed if you
85 have CPU-bound realtime threads.
71 86
72o Where can I find more information on RCU? 87o Where can I find more information on RCU?
73 88
diff --git a/Documentation/RCU/torture.txt b/Documentation/RCU/torture.txt
index 25a3c3f7d378..2967a65269d8 100644
--- a/Documentation/RCU/torture.txt
+++ b/Documentation/RCU/torture.txt
@@ -46,12 +46,13 @@ stat_interval The number of seconds between output of torture
46 46
47shuffle_interval 47shuffle_interval
48 The number of seconds to keep the test threads affinitied 48 The number of seconds to keep the test threads affinitied
49 to a particular subset of the CPUs. Used in conjunction 49 to a particular subset of the CPUs, defaults to 5 seconds.
50 with test_no_idle_hz. 50 Used in conjunction with test_no_idle_hz.
51 51
52test_no_idle_hz Whether or not to test the ability of RCU to operate in 52test_no_idle_hz Whether or not to test the ability of RCU to operate in
53 a kernel that disables the scheduling-clock interrupt to 53 a kernel that disables the scheduling-clock interrupt to
54 idle CPUs. Boolean parameter, "1" to test, "0" otherwise. 54 idle CPUs. Boolean parameter, "1" to test, "0" otherwise.
55 Defaults to omitting this test.
55 56
56torture_type The type of RCU to test: "rcu" for the rcu_read_lock() API, 57torture_type The type of RCU to test: "rcu" for the rcu_read_lock() API,
57 "rcu_sync" for rcu_read_lock() with synchronous reclamation, 58 "rcu_sync" for rcu_read_lock() with synchronous reclamation,
@@ -82,8 +83,6 @@ be evident. ;-)
82 83
83The entries are as follows: 84The entries are as follows:
84 85
85o "ggp": The number of counter flips (or batches) since boot.
86
87o "rtc": The hexadecimal address of the structure currently visible 86o "rtc": The hexadecimal address of the structure currently visible
88 to readers. 87 to readers.
89 88
@@ -117,8 +116,8 @@ o "Reader Pipe": Histogram of "ages" of structures seen by readers.
117o "Reader Batch": Another histogram of "ages" of structures seen 116o "Reader Batch": Another histogram of "ages" of structures seen
118 by readers, but in terms of counter flips (or batches) rather 117 by readers, but in terms of counter flips (or batches) rather
119 than in terms of grace periods. The legal number of non-zero 118 than in terms of grace periods. The legal number of non-zero
120 entries is again two. The reason for this separate view is 119 entries is again two. The reason for this separate view is that
121 that it is easier to get the third entry to show up in the 120 it is sometimes easier to get the third entry to show up in the
122 "Reader Batch" list than in the "Reader Pipe" list. 121 "Reader Batch" list than in the "Reader Pipe" list.
123 122
124o "Free-Block Circulation": Shows the number of torture structures 123o "Free-Block Circulation": Shows the number of torture structures
diff --git a/Documentation/cpu-freq/user-guide.txt b/Documentation/cpu-freq/user-guide.txt
index 555c8cf3650a..af3b925ece08 100644
--- a/Documentation/cpu-freq/user-guide.txt
+++ b/Documentation/cpu-freq/user-guide.txt
@@ -45,6 +45,7 @@ The following ARM processors are supported by cpufreq:
45ARM Integrator 45ARM Integrator
46ARM-SA1100 46ARM-SA1100
47ARM-SA1110 47ARM-SA1110
48Intel PXA
48 49
49 50
501.2 x86 511.2 x86
diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt
index a741f658a3c9..ba0aacde94fb 100644
--- a/Documentation/cpu-hotplug.txt
+++ b/Documentation/cpu-hotplug.txt
@@ -50,7 +50,7 @@ additional_cpus=n (*) Use this to limit hotpluggable cpus. This option sets
50 cpu_possible_map = cpu_present_map + additional_cpus 50 cpu_possible_map = cpu_present_map + additional_cpus
51 51
52(*) Option valid only for following architectures 52(*) Option valid only for following architectures
53- x86_64, ia64, s390 53- x86_64, ia64
54 54
55ia64 and x86_64 use the number of disabled local apics in ACPI tables MADT 55ia64 and x86_64 use the number of disabled local apics in ACPI tables MADT
56to determine the number of potentially hot-pluggable cpus. The implementation 56to determine the number of potentially hot-pluggable cpus. The implementation
@@ -109,12 +109,13 @@ Never use anything other than cpumask_t to represent bitmap of CPUs.
109 for_each_cpu_mask(x,mask) - Iterate over some random collection of cpu mask. 109 for_each_cpu_mask(x,mask) - Iterate over some random collection of cpu mask.
110 110
111 #include <linux/cpu.h> 111 #include <linux/cpu.h>
112 lock_cpu_hotplug() and unlock_cpu_hotplug(): 112 get_online_cpus() and put_online_cpus():
113 113
114The above calls are used to inhibit cpu hotplug operations. While holding the 114The above calls are used to inhibit cpu hotplug operations. While the
115cpucontrol mutex, cpu_online_map will not change. If you merely need to avoid 115cpu_hotplug.refcount is non zero, the cpu_online_map will not change.
116cpus going away, you could also use preempt_disable() and preempt_enable() 116If you merely need to avoid cpus going away, you could also use
117for those sections. Just remember the critical section cannot call any 117preempt_disable() and preempt_enable() for those sections.
118Just remember the critical section cannot call any
118function that can sleep or schedule this process away. The preempt_disable() 119function that can sleep or schedule this process away. The preempt_disable()
119will work as long as stop_machine_run() is used to take a cpu down. 120will work as long as stop_machine_run() is used to take a cpu down.
120 121
diff --git a/Documentation/crypto/api-intro.txt b/Documentation/crypto/api-intro.txt
index a2ac6d294793..8b49302712a8 100644
--- a/Documentation/crypto/api-intro.txt
+++ b/Documentation/crypto/api-intro.txt
@@ -33,9 +33,16 @@ The idea is to make the user interface and algorithm registration API
33very simple, while hiding the core logic from both. Many good ideas 33very simple, while hiding the core logic from both. Many good ideas
34from existing APIs such as Cryptoapi and Nettle have been adapted for this. 34from existing APIs such as Cryptoapi and Nettle have been adapted for this.
35 35
36The API currently supports three types of transforms: Ciphers, Digests and 36The API currently supports five main types of transforms: AEAD (Authenticated
37Compressors. The compression algorithms especially seem to be performing 37Encryption with Associated Data), Block Ciphers, Ciphers, Compressors and
38very well so far. 38Hashes.
39
40Please note that Block Ciphers is somewhat of a misnomer. It is in fact
41meant to support all ciphers including stream ciphers. The difference
42between Block Ciphers and Ciphers is that the latter operates on exactly
43one block while the former can operate on an arbitrary amount of data,
44subject to block size requirements (i.e., non-stream ciphers can only
45process multiples of blocks).
39 46
40Support for hardware crypto devices via an asynchronous interface is 47Support for hardware crypto devices via an asynchronous interface is
41under development. 48under development.
@@ -69,29 +76,12 @@ Here's an example of how to use the API:
69Many real examples are available in the regression test module (tcrypt.c). 76Many real examples are available in the regression test module (tcrypt.c).
70 77
71 78
72CONFIGURATION NOTES
73
74As Triple DES is part of the DES module, for those using modular builds,
75add the following line to /etc/modprobe.conf:
76
77 alias des3_ede des
78
79The Null algorithms reside in the crypto_null module, so these lines
80should also be added:
81
82 alias cipher_null crypto_null
83 alias digest_null crypto_null
84 alias compress_null crypto_null
85
86The SHA384 algorithm shares code within the SHA512 module, so you'll
87also need:
88 alias sha384 sha512
89
90
91DEVELOPER NOTES 79DEVELOPER NOTES
92 80
93Transforms may only be allocated in user context, and cryptographic 81Transforms may only be allocated in user context, and cryptographic
94methods may only be called from softirq and user contexts. 82methods may only be called from softirq and user contexts. For
83transforms with a setkey method it too should only be called from
84user context.
95 85
96When using the API for ciphers, performance will be optimal if each 86When using the API for ciphers, performance will be optimal if each
97scatterlist contains data which is a multiple of the cipher's block 87scatterlist contains data which is a multiple of the cipher's block
@@ -130,8 +120,9 @@ might already be working on.
130BUGS 120BUGS
131 121
132Send bug reports to: 122Send bug reports to:
133Herbert Xu <herbert@gondor.apana.org.au> 123linux-crypto@vger.kernel.org
134Cc: David S. Miller <davem@redhat.com> 124Cc: Herbert Xu <herbert@gondor.apana.org.au>,
125 David S. Miller <davem@redhat.com>
135 126
136 127
137FURTHER INFORMATION 128FURTHER INFORMATION
diff --git a/Documentation/debugging-via-ohci1394.txt b/Documentation/debugging-via-ohci1394.txt
new file mode 100644
index 000000000000..de4804e8b396
--- /dev/null
+++ b/Documentation/debugging-via-ohci1394.txt
@@ -0,0 +1,179 @@
1
2 Using physical DMA provided by OHCI-1394 FireWire controllers for debugging
3 ---------------------------------------------------------------------------
4
5Introduction
6------------
7
8Basically all FireWire controllers which are in use today are compliant
9to the OHCI-1394 specification which defines the controller to be a PCI
10bus master which uses DMA to offload data transfers from the CPU and has
11a "Physical Response Unit" which executes specific requests by employing
12PCI-Bus master DMA after applying filters defined by the OHCI-1394 driver.
13
14Once properly configured, remote machines can send these requests to
15ask the OHCI-1394 controller to perform read and write requests on
16physical system memory and, for read requests, send the result of
17the physical memory read back to the requester.
18
19With that, it is possible to debug issues by reading interesting memory
20locations such as buffers like the printk buffer or the process table.
21
22Retrieving a full system memory dump is also possible over the FireWire,
23using data transfer rates in the order of 10MB/s or more.
24
25Memory access is currently limited to the low 4G of physical address
26space which can be a problem on IA64 machines where memory is located
27mostly above that limit, but it is rarely a problem on more common
28hardware such as hardware based on x86, x86-64 and PowerPC.
29
30Together with a early initialization of the OHCI-1394 controller for debugging,
31this facility proved most useful for examining long debugs logs in the printk
32buffer on to debug early boot problems in areas like ACPI where the system
33fails to boot and other means for debugging (serial port) are either not
34available (notebooks) or too slow for extensive debug information (like ACPI).
35
36Drivers
37-------
38
39The OHCI-1394 drivers in drivers/firewire and drivers/ieee1394 initialize
40the OHCI-1394 controllers to a working state and can be used to enable
41physical DMA. By default you only have to load the driver, and physical
42DMA access will be granted to all remote nodes, but it can be turned off
43when using the ohci1394 driver.
44
45Because these drivers depend on the PCI enumeration to be completed, an
46initialization routine which can runs pretty early (long before console_init(),
47which makes the printk buffer appear on the console can be called) was written.
48
49To activate it, enable CONFIG_PROVIDE_OHCI1394_DMA_INIT (Kernel hacking menu:
50Provide code for enabling DMA over FireWire early on boot) and pass the
51parameter "ohci1394_dma=early" to the recompiled kernel on boot.
52
53Tools
54-----
55
56firescope - Originally developed by Benjamin Herrenschmidt, Andi Kleen ported
57it from PowerPC to x86 and x86_64 and added functionality, firescope can now
58be used to view the printk buffer of a remote machine, even with live update.
59
60Bernhard Kaindl enhanced firescope to support accessing 64-bit machines
61from 32-bit firescope and vice versa:
62- ftp://ftp.suse.de/private/bk/firewire/tools/firescope-0.2.2.tar.bz2
63
64and he implemented fast system dump (alpha version - read README.txt):
65- ftp://ftp.suse.de/private/bk/firewire/tools/firedump-0.1.tar.bz2
66
67There is also a gdb proxy for firewire which allows to use gdb to access
68data which can be referenced from symbols found by gdb in vmlinux:
69- ftp://ftp.suse.de/private/bk/firewire/tools/fireproxy-0.33.tar.bz2
70
71The latest version of this gdb proxy (fireproxy-0.34) can communicate (not
72yet stable) with kgdb over an memory-based communication module (kgdbom).
73
74Getting Started
75---------------
76
77The OHCI-1394 specification regulates that the OHCI-1394 controller must
78disable all physical DMA on each bus reset.
79
80This means that if you want to debug an issue in a system state where
81interrupts are disabled and where no polling of the OHCI-1394 controller
82for bus resets takes place, you have to establish any FireWire cable
83connections and fully initialize all FireWire hardware __before__ the
84system enters such state.
85
86Step-by-step instructions for using firescope with early OHCI initialization:
87
881) Verify that your hardware is supported:
89
90 Load the ohci1394 or the fw-ohci module and check your kernel logs.
91 You should see a line similar to
92
93 ohci1394: fw-host0: OHCI-1394 1.1 (PCI): IRQ=[18] MMIO=[fe9ff800-fe9fffff]
94 ... Max Packet=[2048] IR/IT contexts=[4/8]
95
96 when loading the driver. If you have no supported controller, many PCI,
97 CardBus and even some Express cards which are fully compliant to OHCI-1394
98 specification are available. If it requires no driver for Windows operating
99 systems, it most likely is. Only specialized shops have cards which are not
100 compliant, they are based on TI PCILynx chips and require drivers for Win-
101 dows operating systems.
102
1032) Establish a working FireWire cable connection:
104
105 Any FireWire cable, as long at it provides electrically and mechanically
106 stable connection and has matching connectors (there are small 4-pin and
107 large 6-pin FireWire ports) will do.
108
109 If an driver is running on both machines you should see a line like
110
111 ieee1394: Node added: ID:BUS[0-01:1023] GUID[0090270001b84bba]
112
113 on both machines in the kernel log when the cable is plugged in
114 and connects the two machines.
115
1163) Test physical DMA using firescope:
117
118 On the debug host,
119 - load the raw1394 module,
120 - make sure that /dev/raw1394 is accessible,
121 then start firescope:
122
123 $ firescope
124 Port 0 (ohci1394) opened, 2 nodes detected
125
126 FireScope
127 ---------
128 Target : <unspecified>
129 Gen : 1
130 [Ctrl-T] choose target
131 [Ctrl-H] this menu
132 [Ctrl-Q] quit
133
134 ------> Press Ctrl-T now, the output should be similar to:
135
136 2 nodes available, local node is: 0
137 0: ffc0, uuid: 00000000 00000000 [LOCAL]
138 1: ffc1, uuid: 00279000 ba4bb801
139
140 Besides the [LOCAL] node, it must show another node without error message.
141
1424) Prepare for debugging with early OHCI-1394 initialization:
143
144 4.1) Kernel compilation and installation on debug target
145
146 Compile the kernel to be debugged with CONFIG_PROVIDE_OHCI1394_DMA_INIT
147 (Kernel hacking: Provide code for enabling DMA over FireWire early on boot)
148 enabled and install it on the machine to be debugged (debug target).
149
150 4.2) Transfer the System.map of the debugged kernel to the debug host
151
152 Copy the System.map of the kernel be debugged to the debug host (the host
153 which is connected to the debugged machine over the FireWire cable).
154
1555) Retrieving the printk buffer contents:
156
157 With the FireWire cable connected, the OHCI-1394 driver on the debugging
158 host loaded, reboot the debugged machine, booting the kernel which has
159 CONFIG_PROVIDE_OHCI1394_DMA_INIT enabled, with the option ohci1394_dma=early.
160
161 Then, on the debugging host, run firescope, for example by using -A:
162
163 firescope -A System.map-of-debug-target-kernel
164
165 Note: -A automatically attaches to the first non-local node. It only works
166 reliably if only connected two machines are connected using FireWire.
167
168 After having attached to the debug target, press Ctrl-D to view the
169 complete printk buffer or Ctrl-U to enter auto update mode and get an
170 updated live view of recent kernel messages logged on the debug target.
171
172 Call "firescope -h" to get more information on firescope's options.
173
174Notes
175-----
176Documentation and specifications: ftp://ftp.suse.de/private/bk/firewire/docs
177
178FireWire is a trademark of Apple Inc. - for more information please refer to:
179http://en.wikipedia.org/wiki/FireWire
diff --git a/Documentation/dontdiff b/Documentation/dontdiff
index f2d658a6a942..c09a96b99354 100644
--- a/Documentation/dontdiff
+++ b/Documentation/dontdiff
@@ -46,8 +46,6 @@
46.mailmap 46.mailmap
47.mm 47.mm
4853c700_d.h 4853c700_d.h
4953c7xx_d.h
5053c7xx_u.h
5153c8xx_d.h* 4953c8xx_d.h*
52BitKeeper 50BitKeeper
53COPYING 51COPYING
diff --git a/Documentation/dvb/bt8xx.txt b/Documentation/dvb/bt8xx.txt
index ecb47adda063..b7b1d1b1da46 100644
--- a/Documentation/dvb/bt8xx.txt
+++ b/Documentation/dvb/bt8xx.txt
@@ -78,6 +78,18 @@ Example:
78For a full list of card ID's please see Documentation/video4linux/CARDLIST.bttv. 78For a full list of card ID's please see Documentation/video4linux/CARDLIST.bttv.
79In case of further problems please subscribe and send questions to the mailing list: linux-dvb@linuxtv.org. 79In case of further problems please subscribe and send questions to the mailing list: linux-dvb@linuxtv.org.
80 80
812c) Probing the cards with broken PCI subsystem ID
82--------------------------------------------------
83There are some TwinHan cards that the EEPROM has become corrupted for some
84reason. The cards do not have correct PCI subsystem ID. But we can force
85probing the cards with broken PCI subsystem ID
86
87 $ echo 109e 0878 $subvendor $subdevice > \
88 /sys/bus/pci/drivers/bt878/new_id
89
90109e: PCI_VENDOR_ID_BROOKTREE
910878: PCI_DEVICE_ID_BROOKTREE_878
92
81Authors: Richard Walker, 93Authors: Richard Walker,
82 Jamie Honan, 94 Jamie Honan,
83 Michael Hunold, 95 Michael Hunold,
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 20c4c8bac9d7..181bff005167 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -191,15 +191,6 @@ Who: Kay Sievers <kay.sievers@suse.de>
191 191
192--------------------------- 192---------------------------
193 193
194What: i2c_adapter.list
195When: July 2007
196Why: Superfluous, this list duplicates the one maintained by the driver
197 core.
198Who: Jean Delvare <khali@linux-fr.org>,
199 David Brownell <dbrownell@users.sourceforge.net>
200
201---------------------------
202
203What: ACPI procfs interface 194What: ACPI procfs interface
204When: July 2008 195When: July 2008
205Why: ACPI sysfs conversion should be finished by January 2008. 196Why: ACPI sysfs conversion should be finished by January 2008.
@@ -225,14 +216,6 @@ Who: Len Brown <len.brown@intel.com>
225 216
226--------------------------- 217---------------------------
227 218
228What: i2c-ixp2000, i2c-ixp4xx and scx200_i2c drivers
229When: September 2007
230Why: Obsolete. The new i2c-gpio driver replaces all hardware-specific
231 I2C-over-GPIO drivers.
232Who: Jean Delvare <khali@linux-fr.org>
233
234---------------------------
235
236What: 'time' kernel boot parameter 219What: 'time' kernel boot parameter
237When: January 2008 220When: January 2008
238Why: replaced by 'printk.time=<value>' so that printk timestamps can be 221Why: replaced by 'printk.time=<value>' so that printk timestamps can be
@@ -266,22 +249,6 @@ Who: Tejun Heo <htejun@gmail.com>
266 249
267--------------------------- 250---------------------------
268 251
269What: Legacy RTC drivers (under drivers/i2c/chips)
270When: November 2007
271Why: Obsolete. We have a RTC subsystem with better drivers.
272Who: Jean Delvare <khali@linux-fr.org>
273
274---------------------------
275
276What: iptables SAME target
277When: 1.1. 2008
278Files: net/ipv4/netfilter/ipt_SAME.c, include/linux/netfilter_ipv4/ipt_SAME.h
279Why: Obsolete for multiple years now, NAT core provides the same behaviour.
280 Unfixable broken wrt. 32/64 bit cleanness.
281Who: Patrick McHardy <kaber@trash.net>
282
283---------------------------
284
285What: The arch/ppc and include/asm-ppc directories 252What: The arch/ppc and include/asm-ppc directories
286When: Jun 2008 253When: Jun 2008
287Why: The arch/powerpc tree is the merged architecture for ppc32 and ppc64 254Why: The arch/powerpc tree is the merged architecture for ppc32 and ppc64
@@ -295,16 +262,6 @@ Who: linuxppc-dev@ozlabs.org
295 262
296--------------------------- 263---------------------------
297 264
298What: mthca driver's MSI support
299When: January 2008
300Files: drivers/infiniband/hw/mthca/*.[ch]
301Why: All mthca hardware also supports MSI-X, which provides
302 strictly more functionality than MSI. So there is no point in
303 having both MSI-X and MSI support in the driver.
304Who: Roland Dreier <rolandd@cisco.com>
305
306---------------------------
307
308What: sk98lin network driver 265What: sk98lin network driver
309When: Feburary 2008 266When: Feburary 2008
310Why: In kernel tree version of driver is unmaintained. Sk98lin driver 267Why: In kernel tree version of driver is unmaintained. Sk98lin driver
@@ -323,13 +280,77 @@ Who: Thomas Gleixner <tglx@linutronix.de>
323 280
324--------------------------- 281---------------------------
325 282
326What: shaper network driver 283---------------------------
327When: January 2008 284
328Files: drivers/net/shaper.c, include/linux/if_shaper.h 285What: i2c-i810, i2c-prosavage and i2c-savage4
329Why: This driver has been marked obsolete for many years. 286When: May 2008
330 It was only designed to work on lower speed links and has design 287Why: These drivers are superseded by i810fb, intelfb and savagefb.
331 flaws that lead to machine crashes. The qdisc infrastructure in 288Who: Jean Delvare <khali@linux-fr.org>
332 2.4 or later kernels, provides richer features and is more robust.
333Who: Stephen Hemminger <shemminger@linux-foundation.org>
334 289
335--------------------------- 290---------------------------
291
292What: bcm43xx wireless network driver
293When: 2.6.26
294Files: drivers/net/wireless/bcm43xx
295Why: This driver's functionality has been replaced by the
296 mac80211-based b43 and b43legacy drivers.
297Who: John W. Linville <linville@tuxdriver.com>
298
299---------------------------
300
301What: ieee80211 softmac wireless networking component
302When: 2.6.26 (or after removal of bcm43xx and port of zd1211rw to mac80211)
303Files: net/ieee80211/softmac
304Why: No in-kernel drivers will depend on it any longer.
305Who: John W. Linville <linville@tuxdriver.com>
306
307---------------------------
308
309What: rc80211-simple rate control algorithm for mac80211
310When: 2.6.26
311Files: net/mac80211/rc80211-simple.c
312Why: This algorithm was provided for reference but always exhibited bad
313 responsiveness and performance and has some serious flaws. It has been
314 replaced by rc80211-pid.
315Who: Stefano Brivio <stefano.brivio@polimi.it>
316
317---------------------------
318
319What (Why):
320 - include/linux/netfilter_ipv4/ipt_TOS.h ipt_tos.h header files
321 (superseded by xt_TOS/xt_tos target & match)
322
323 - "forwarding" header files like ipt_mac.h in
324 include/linux/netfilter_ipv4/ and include/linux/netfilter_ipv6/
325
326 - xt_CONNMARK match revision 0
327 (superseded by xt_CONNMARK match revision 1)
328
329 - xt_MARK target revisions 0 and 1
330 (superseded by xt_MARK match revision 2)
331
332 - xt_connmark match revision 0
333 (superseded by xt_connmark match revision 1)
334
335 - xt_conntrack match revision 0
336 (superseded by xt_conntrack match revision 1)
337
338 - xt_iprange match revision 0,
339 include/linux/netfilter_ipv4/ipt_iprange.h
340 (superseded by xt_iprange match revision 1)
341
342 - xt_mark match revision 0
343 (superseded by xt_mark match revision 1)
344
345When: January 2009 or Linux 2.7.0, whichever comes first
346Why: Superseded by newer revisions or modules
347Who: Jan Engelhardt <jengelh@computergmbh.de>
348
349---------------------------
350
351What: b43 support for firmware revision < 410
352When: July 2008
353Why: The support code for the old firmware hurts code readability/maintainability
354 and slightly hurts runtime performance. Bugfixes for the old firmware
355 are not provided by Broadcom anymore.
356Who: Michael Buesch <mb@bu3sch.de>
diff --git a/Documentation/filesystems/ext4.txt b/Documentation/filesystems/ext4.txt
index 6a4adcae9f9a..560f88dc7090 100644
--- a/Documentation/filesystems/ext4.txt
+++ b/Documentation/filesystems/ext4.txt
@@ -86,9 +86,21 @@ Alex is working on a new set of patches right now.
86When mounting an ext4 filesystem, the following option are accepted: 86When mounting an ext4 filesystem, the following option are accepted:
87(*) == default 87(*) == default
88 88
89extents ext4 will use extents to address file data. The 89extents (*) ext4 will use extents to address file data. The
90 file system will no longer be mountable by ext3. 90 file system will no longer be mountable by ext3.
91 91
92noextents ext4 will not use extents for newly created files
93
94journal_checksum Enable checksumming of the journal transactions.
95 This will allow the recovery code in e2fsck and the
96 kernel to detect corruption in the kernel. It is a
97 compatible change and will be ignored by older kernels.
98
99journal_async_commit Commit block can be written to disk without waiting
100 for descriptor blocks. If enabled older kernels cannot
101 mount the device. This will enable 'journal_checksum'
102 internally.
103
92journal=update Update the ext4 file system's journal to the current 104journal=update Update the ext4 file system's journal to the current
93 format. 105 format.
94 106
@@ -196,6 +208,12 @@ nobh (a) cache disk block mapping information
196 "nobh" option tries to avoid associating buffer 208 "nobh" option tries to avoid associating buffer
197 heads (supported only for "writeback" mode). 209 heads (supported only for "writeback" mode).
198 210
211mballoc (*) Use the multiple block allocator for block allocation
212nomballoc disabled multiple block allocator for block allocation.
213stripe=n Number of filesystem blocks that mballoc will try
214 to use for allocation size and alignment. For RAID5/6
215 systems this should be the number of data
216 disks * RAID chunk size in file system blocks.
199 217
200Data Mode 218Data Mode
201--------- 219---------
diff --git a/Documentation/filesystems/ocfs2.txt b/Documentation/filesystems/ocfs2.txt
index ed55238023a9..c318a8bbb1ef 100644
--- a/Documentation/filesystems/ocfs2.txt
+++ b/Documentation/filesystems/ocfs2.txt
@@ -35,7 +35,6 @@ Features which OCFS2 does not support yet:
35 - Directory change notification (F_NOTIFY) 35 - Directory change notification (F_NOTIFY)
36 - Distributed Caching (F_SETLEASE/F_GETLEASE/break_lease) 36 - Distributed Caching (F_SETLEASE/F_GETLEASE/break_lease)
37 - POSIX ACLs 37 - POSIX ACLs
38 - readpages / writepages (not user visible)
39 38
40Mount options 39Mount options
41============= 40=============
@@ -62,3 +61,18 @@ data=writeback Data ordering is not preserved, data may be written
62preferred_slot=0(*) During mount, try to use this filesystem slot first. If 61preferred_slot=0(*) During mount, try to use this filesystem slot first. If
63 it is in use by another node, the first empty one found 62 it is in use by another node, the first empty one found
64 will be chosen. Invalid values will be ignored. 63 will be chosen. Invalid values will be ignored.
64commit=nrsec (*) Ocfs2 can be told to sync all its data and metadata
65 every 'nrsec' seconds. The default value is 5 seconds.
66 This means that if you lose your power, you will lose
67 as much as the latest 5 seconds of work (your
68 filesystem will not be damaged though, thanks to the
69 journaling). This default value (or any low value)
70 will hurt performance, but it's good for data-safety.
71 Setting it to 0 will have the same effect as leaving
72 it at the default (5 seconds).
73 Setting it to very large values will improve
74 performance.
75localalloc=8(*) Allows custom localalloc size in MB. If the value is too
76 large, the fs will silently revert it to the default.
77 Localalloc is not enabled for local mounts.
78localflocks This disables cluster aware flock.
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index dec99455321f..4413a2d4646f 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -857,6 +857,45 @@ CPUs.
857The "procs_blocked" line gives the number of processes currently blocked, 857The "procs_blocked" line gives the number of processes currently blocked,
858waiting for I/O to complete. 858waiting for I/O to complete.
859 859
8601.9 Ext4 file system parameters
861------------------------------
862Ext4 file system have one directory per partition under /proc/fs/ext4/
863# ls /proc/fs/ext4/hdc/
864group_prealloc max_to_scan mb_groups mb_history min_to_scan order2_req
865stats stream_req
866
867mb_groups:
868This file gives the details of mutiblock allocator buddy cache of free blocks
869
870mb_history:
871Multiblock allocation history.
872
873stats:
874This file indicate whether the multiblock allocator should start collecting
875statistics. The statistics are shown during unmount
876
877group_prealloc:
878The multiblock allocator normalize the block allocation request to
879group_prealloc filesystem blocks if we don't have strip value set.
880The stripe value can be specified at mount time or during mke2fs.
881
882max_to_scan:
883How long multiblock allocator can look for a best extent (in found extents)
884
885min_to_scan:
886How long multiblock allocator must look for a best extent
887
888order2_req:
889Multiblock allocator use 2^N search using buddies only for requests greater
890than or equal to order2_req. The request size is specfied in file system
891blocks. A value of 2 indicate only if the requests are greater than or equal
892to 4 blocks.
893
894stream_req:
895Files smaller than stream_req are served by the stream allocator, whose
896purpose is to pack requests as close each to other as possible to
897produce smooth I/O traffic. Avalue of 16 indicate that file smaller than 16
898filesystem block size will use group based preallocation.
860 899
861------------------------------------------------------------------------------ 900------------------------------------------------------------------------------
862Summary 901Summary
diff --git a/Documentation/i2c/busses/i2c-i801 b/Documentation/i2c/busses/i2c-i801
index fde4420e3f75..3bd958360159 100644
--- a/Documentation/i2c/busses/i2c-i801
+++ b/Documentation/i2c/busses/i2c-i801
@@ -17,9 +17,8 @@ Supported adapters:
17 Datasheets: Publicly available at the Intel website 17 Datasheets: Publicly available at the Intel website
18 18
19Authors: 19Authors:
20 Frodo Looijaard <frodol@dds.nl>,
21 Philip Edelbrock <phil@netroedge.com>,
22 Mark Studebaker <mdsxyz123@yahoo.com> 20 Mark Studebaker <mdsxyz123@yahoo.com>
21 Jean Delvare <khali@linux-fr.org>
23 22
24 23
25Module Parameters 24Module Parameters
@@ -62,7 +61,7 @@ Not supported.
62I2C Block Read Support 61I2C Block Read Support
63---------------------- 62----------------------
64 63
65Not supported at the moment. 64I2C block read is supported on the 82801EB (ICH5) and later chips.
66 65
67 66
68SMBus 2.0 Support 67SMBus 2.0 Support
diff --git a/Documentation/i2c/busses/i2c-viapro b/Documentation/i2c/busses/i2c-viapro
index 06b4be3ef6d8..1405fb69984c 100644
--- a/Documentation/i2c/busses/i2c-viapro
+++ b/Documentation/i2c/busses/i2c-viapro
@@ -10,7 +10,7 @@ Supported adapters:
10 * VIA Technologies, Inc. VT8231, VT8233, VT8233A 10 * VIA Technologies, Inc. VT8231, VT8233, VT8233A
11 Datasheet: available on request from VIA 11 Datasheet: available on request from VIA
12 12
13 * VIA Technologies, Inc. VT8235, VT8237R, VT8237A, VT8251 13 * VIA Technologies, Inc. VT8235, VT8237R, VT8237A, VT8237S, VT8251
14 Datasheet: available on request and under NDA from VIA 14 Datasheet: available on request and under NDA from VIA
15 15
16 * VIA Technologies, Inc. CX700 16 * VIA Technologies, Inc. CX700
@@ -46,6 +46,7 @@ Your lspci -n listing must show one of these :
46 device 1106:3177 (VT8235) 46 device 1106:3177 (VT8235)
47 device 1106:3227 (VT8237R) 47 device 1106:3227 (VT8237R)
48 device 1106:3337 (VT8237A) 48 device 1106:3337 (VT8237A)
49 device 1106:3372 (VT8237S)
49 device 1106:3287 (VT8251) 50 device 1106:3287 (VT8251)
50 device 1106:8324 (CX700) 51 device 1106:8324 (CX700)
51 52
diff --git a/Documentation/i2c/chips/pcf8575 b/Documentation/i2c/chips/pcf8575
new file mode 100644
index 000000000000..25f5698a61cf
--- /dev/null
+++ b/Documentation/i2c/chips/pcf8575
@@ -0,0 +1,72 @@
1About the PCF8575 chip and the pcf8575 kernel driver
2====================================================
3
4The PCF8575 chip is produced by the following manufacturers:
5
6 * Philips NXP
7 http://www.nxp.com/#/pip/cb=[type=product,path=50807/41735/41850,final=PCF8575_3]|pip=[pip=PCF8575_3][0]
8
9 * Texas Instruments
10 http://focus.ti.com/docs/prod/folders/print/pcf8575.html
11
12
13Some vendors sell small PCB's with the PCF8575 mounted on it. You can connect
14such a board to a Linux host via e.g. an USB to I2C interface. Examples of
15PCB boards with a PCF8575:
16
17 * SFE Breakout Board for PCF8575 I2C Expander by RobotShop
18 http://www.robotshop.ca/home/products/robot-parts/electronics/adapters-converters/sfe-pcf8575-i2c-expander-board.html
19
20 * Breakout Board for PCF8575 I2C Expander by Spark Fun Electronics
21 http://www.sparkfun.com/commerce/product_info.php?products_id=8130
22
23
24Description
25-----------
26The PCF8575 chip is a 16-bit I/O expander for the I2C bus. Up to eight of
27these chips can be connected to the same I2C bus. You can find this
28chip on some custom designed hardware, but you won't find it on PC
29motherboards.
30
31The PCF8575 chip consists of a 16-bit quasi-bidirectional port and an I2C-bus
32interface. Each of the sixteen I/O's can be independently used as an input or
33an output. To set up an I/O pin as an input, you have to write a 1 to the
34corresponding output.
35
36For more information please see the datasheet.
37
38
39Detection
40---------
41
42There is no method known to detect whether a chip on a given I2C address is
43a PCF8575 or whether it is any other I2C device. So there are two alternatives
44to let the driver find the installed PCF8575 devices:
45- Load this driver after any other I2C driver for I2C devices with addresses
46 in the range 0x20 .. 0x27.
47- Pass the I2C bus and address of the installed PCF8575 devices explicitly to
48 the driver at load time via the probe=... or force=... parameters.
49
50/sys interface
51--------------
52
53For each address on which a PCF8575 chip was found or forced the following
54files will be created under /sys:
55* /sys/bus/i2c/devices/<bus>-<address>/read
56* /sys/bus/i2c/devices/<bus>-<address>/write
57where bus is the I2C bus number (0, 1, ...) and address is the four-digit
58hexadecimal representation of the 7-bit I2C address of the PCF8575
59(0020 .. 0027).
60
61The read file is read-only. Reading it will trigger an I2C read and will hence
62report the current input state for the pins configured as inputs, and the
63current output value for the pins configured as outputs.
64
65The write file is read-write. Writing a value to it will configure all pins
66as output for which the corresponding bit is zero. Reading the write file will
67return the value last written, or -EAGAIN if no value has yet been written to
68the write file.
69
70On module initialization the configuration of the chip is not changed -- the
71chip is left in the state it was already configured in through either power-up
72or through previous I2C write actions.
diff --git a/Documentation/i2c/i2c-stub b/Documentation/i2c/i2c-stub
index 89e69ad3436c..0d8be1c20c16 100644
--- a/Documentation/i2c/i2c-stub
+++ b/Documentation/i2c/i2c-stub
@@ -25,6 +25,9 @@ The typical use-case is like this:
25 3. load the target sensors chip driver module 25 3. load the target sensors chip driver module
26 4. observe its behavior in the kernel log 26 4. observe its behavior in the kernel log
27 27
28There's a script named i2c-stub-from-dump in the i2c-tools package which
29can load register values automatically from a chip dump.
30
28PARAMETERS: 31PARAMETERS:
29 32
30int chip_addr[10]: 33int chip_addr[10]:
@@ -32,9 +35,6 @@ int chip_addr[10]:
32 35
33CAVEATS: 36CAVEATS:
34 37
35There are independent arrays for byte/data and word/data commands. Depending
36on if/how a target driver mixes them, you'll need to be careful.
37
38If your target driver polls some byte or word waiting for it to change, the 38If your target driver polls some byte or word waiting for it to change, the
39stub could lock it up. Use i2cset to unlock it. 39stub could lock it up. Use i2cset to unlock it.
40 40
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index 2c170032bf37..bfb0a5520817 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -267,9 +267,9 @@ insmod parameter of the form force_<kind>.
267Fortunately, as a module writer, you just have to define the `normal_i2c' 267Fortunately, as a module writer, you just have to define the `normal_i2c'
268parameter. The complete declaration could look like this: 268parameter. The complete declaration could look like this:
269 269
270 /* Scan 0x37, and 0x48 to 0x4f */ 270 /* Scan 0x4c to 0x4f */
271 static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 271 static const unsigned short normal_i2c[] = { 0x4c, 0x4d, 0x4e, 0x4f,
272 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 272 I2C_CLIENT_END };
273 273
274 /* Magic definition of all other variables and things */ 274 /* Magic definition of all other variables and things */
275 I2C_CLIENT_INSMOD; 275 I2C_CLIENT_INSMOD;
diff --git a/Documentation/ide.txt b/Documentation/ide.txt
index 1d50f23a5cab..94e2e3b9e77f 100644
--- a/Documentation/ide.txt
+++ b/Documentation/ide.txt
@@ -30,7 +30,7 @@
30*** 30***
31*** The CMD640 is also used on some Vesa Local Bus (VLB) cards, and is *NOT* 31*** The CMD640 is also used on some Vesa Local Bus (VLB) cards, and is *NOT*
32*** automatically detected by Linux. For safe, reliable operation with such 32*** automatically detected by Linux. For safe, reliable operation with such
33*** interfaces, one *MUST* use the "ide0=cmd640_vlb" kernel option. 33*** interfaces, one *MUST* use the "cmd640.probe_vlb" kernel option.
34*** 34***
35*** Use of the "serialize" option is no longer necessary. 35*** Use of the "serialize" option is no longer necessary.
36 36
@@ -244,10 +244,6 @@ Summary of ide driver parameters for kernel command line
244 244
245 "hdx=nodma" : disallow DMA 245 "hdx=nodma" : disallow DMA
246 246
247 "hdx=swapdata" : when the drive is a disk, byte swap all data
248
249 "hdx=bswap" : same as above..........
250
251 "hdx=scsi" : the return of the ide-scsi flag, this is useful for 247 "hdx=scsi" : the return of the ide-scsi flag, this is useful for
252 allowing ide-floppy, ide-tape, and ide-cdrom|writers 248 allowing ide-floppy, ide-tape, and ide-cdrom|writers
253 to use ide-scsi emulation on a device specific option. 249 to use ide-scsi emulation on a device specific option.
@@ -292,9 +288,6 @@ The following are valid ONLY on ide0, which usually corresponds
292to the first ATA interface found on the particular host, and the defaults for 288to the first ATA interface found on the particular host, and the defaults for
293the base,ctl ports must not be altered. 289the base,ctl ports must not be altered.
294 290
295 "ide0=cmd640_vlb" : *REQUIRED* for VLB cards with the CMD640 chip
296 (not for PCI -- automatically detected)
297
298 "ide=doubler" : probe/support IDE doublers on Amiga 291 "ide=doubler" : probe/support IDE doublers on Amiga
299 292
300There may be more options than shown -- use the source, Luke! 293There may be more options than shown -- use the source, Luke!
@@ -310,6 +303,10 @@ i.e. to enable probing for ALI M14xx chipsets (ali14xx host driver) use:
310* "probe" module parameter when ali14xx driver is compiled as module 303* "probe" module parameter when ali14xx driver is compiled as module
311 ("modprobe ali14xx probe") 304 ("modprobe ali14xx probe")
312 305
306Also for legacy CMD640 host driver (cmd640) you need to use "probe_vlb"
307kernel paremeter to enable probing for VLB version of the chipset (PCI ones
308are detected automatically).
309
313================================================================================ 310================================================================================
314 311
315IDE ATAPI streaming tape driver 312IDE ATAPI streaming tape driver
diff --git a/Documentation/ioctl-number.txt b/Documentation/ioctl-number.txt
index 5c7fbf9d96b4..c18363bd8d11 100644
--- a/Documentation/ioctl-number.txt
+++ b/Documentation/ioctl-number.txt
@@ -138,6 +138,7 @@ Code Seq# Include File Comments
138'm' 00-1F net/irda/irmod.h conflict! 138'm' 00-1F net/irda/irmod.h conflict!
139'n' 00-7F linux/ncp_fs.h 139'n' 00-7F linux/ncp_fs.h
140'n' E0-FF video/matrox.h matroxfb 140'n' E0-FF video/matrox.h matroxfb
141'o' 00-1F fs/ocfs2/ocfs2_fs.h OCFS2
141'p' 00-0F linux/phantom.h conflict! (OpenHaptics needs this) 142'p' 00-0F linux/phantom.h conflict! (OpenHaptics needs this)
142'p' 00-3F linux/mc146818rtc.h conflict! 143'p' 00-3F linux/mc146818rtc.h conflict!
143'p' 40-7F linux/nvram.h 144'p' 40-7F linux/nvram.h
diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt
index 616043a6da99..649cb8799890 100644
--- a/Documentation/kbuild/kconfig-language.txt
+++ b/Documentation/kbuild/kconfig-language.txt
@@ -24,7 +24,7 @@ visible if its parent entry is also visible.
24Menu entries 24Menu entries
25------------ 25------------
26 26
27Most entries define a config option, all other entries help to organize 27Most entries define a config option; all other entries help to organize
28them. A single configuration option is defined like this: 28them. A single configuration option is defined like this:
29 29
30config MODVERSIONS 30config MODVERSIONS
@@ -50,7 +50,7 @@ applicable everywhere (see syntax).
50 50
51- type definition: "bool"/"tristate"/"string"/"hex"/"int" 51- type definition: "bool"/"tristate"/"string"/"hex"/"int"
52 Every config option must have a type. There are only two basic types: 52 Every config option must have a type. There are only two basic types:
53 tristate and string, the other types are based on these two. The type 53 tristate and string; the other types are based on these two. The type
54 definition optionally accepts an input prompt, so these two examples 54 definition optionally accepts an input prompt, so these two examples
55 are equivalent: 55 are equivalent:
56 56
@@ -108,7 +108,7 @@ applicable everywhere (see syntax).
108 equal to 'y' without visiting the dependencies. So abusing 108 equal to 'y' without visiting the dependencies. So abusing
109 select you are able to select a symbol FOO even if FOO depends 109 select you are able to select a symbol FOO even if FOO depends
110 on BAR that is not set. In general use select only for 110 on BAR that is not set. In general use select only for
111 non-visible symbols (no promts anywhere) and for symbols with 111 non-visible symbols (no prompts anywhere) and for symbols with
112 no dependencies. That will limit the usefulness but on the 112 no dependencies. That will limit the usefulness but on the
113 other hand avoid the illegal configurations all over. kconfig 113 other hand avoid the illegal configurations all over. kconfig
114 should one day warn about such things. 114 should one day warn about such things.
@@ -127,6 +127,27 @@ applicable everywhere (see syntax).
127 used to help visually separate configuration logic from help within 127 used to help visually separate configuration logic from help within
128 the file as an aid to developers. 128 the file as an aid to developers.
129 129
130- misc options: "option" <symbol>[=<value>]
131 Various less common options can be defined via this option syntax,
132 which can modify the behaviour of the menu entry and its config
133 symbol. These options are currently possible:
134
135 - "defconfig_list"
136 This declares a list of default entries which can be used when
137 looking for the default configuration (which is used when the main
138 .config doesn't exists yet.)
139
140 - "modules"
141 This declares the symbol to be used as the MODULES symbol, which
142 enables the third modular state for all config symbols.
143
144 - "env"=<value>
145 This imports the environment variable into Kconfig. It behaves like
146 a default, except that the value comes from the environment, this
147 also means that the behaviour when mixing it with normal defaults is
148 undefined at this point. The symbol is currently not exported back
149 to the build environment (if this is desired, it can be done via
150 another symbol).
130 151
131Menu dependencies 152Menu dependencies
132----------------- 153-----------------
@@ -162,9 +183,9 @@ An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2
162respectively for calculations). A menu entry becomes visible when it's 183respectively for calculations). A menu entry becomes visible when it's
163expression evaluates to 'm' or 'y'. 184expression evaluates to 'm' or 'y'.
164 185
165There are two types of symbols: constant and nonconstant symbols. 186There are two types of symbols: constant and non-constant symbols.
166Nonconstant symbols are the most common ones and are defined with the 187Non-constant symbols are the most common ones and are defined with the
167'config' statement. Nonconstant symbols consist entirely of alphanumeric 188'config' statement. Non-constant symbols consist entirely of alphanumeric
168characters or underscores. 189characters or underscores.
169Constant symbols are only part of expressions. Constant symbols are 190Constant symbols are only part of expressions. Constant symbols are
170always surrounded by single or double quotes. Within the quote, any 191always surrounded by single or double quotes. Within the quote, any
@@ -301,3 +322,81 @@ mainmenu:
301 322
302This sets the config program's title bar if the config program chooses 323This sets the config program's title bar if the config program chooses
303to use it. 324to use it.
325
326
327Kconfig hints
328-------------
329This is a collection of Kconfig tips, most of which aren't obvious at
330first glance and most of which have become idioms in several Kconfig
331files.
332
333Adding common features and make the usage configurable
334~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335It is a common idiom to implement a feature/functionality that are
336relevant for some architectures but not all.
337The recommended way to do so is to use a config variable named HAVE_*
338that is defined in a common Kconfig file and selected by the relevant
339architectures.
340An example is the generic IOMAP functionality.
341
342We would in lib/Kconfig see:
343
344# Generic IOMAP is used to ...
345config HAVE_GENERIC_IOMAP
346
347config GENERIC_IOMAP
348 depends on HAVE_GENERIC_IOMAP && FOO
349
350And in lib/Makefile we would see:
351obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
352
353For each architecture using the generic IOMAP functionality we would see:
354
355config X86
356 select ...
357 select HAVE_GENERIC_IOMAP
358 select ...
359
360Note: we use the existing config option and avoid creating a new
361config variable to select HAVE_GENERIC_IOMAP.
362
363Note: the use of the internal config variable HAVE_GENERIC_IOMAP, it is
364introduced to overcome the limitation of select which will force a
365config option to 'y' no matter the dependencies.
366The dependencies are moved to the symbol GENERIC_IOMAP and we avoid the
367situation where select forces a symbol equals to 'y'.
368
369Build as module only
370~~~~~~~~~~~~~~~~~~~~
371To restrict a component build to module-only, qualify its config symbol
372with "depends on m". E.g.:
373
374config FOO
375 depends on BAR && m
376
377limits FOO to module (=m) or disabled (=n).
378
379
380Build limited by a third config symbol which may be =y or =m
381~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
382A common idiom that we see (and sometimes have problems with) is this:
383
384When option C in B (module or subsystem) uses interfaces from A (module
385or subsystem), and both A and B are tristate (could be =y or =m if they
386were independent of each other, but they aren't), then we need to limit
387C such that it cannot be built statically if A is built as a loadable
388module. (C already depends on B, so there is no dependency issue to
389take care of here.)
390
391If A is linked statically into the kernel image, C can be built
392statically or as loadable module(s). However, if A is built as loadable
393module(s), then C must be restricted to loadable module(s) also. This
394can be expressed in kconfig language as:
395
396config C
397 depends on A = y || A = B
398
399or for real examples, use this command in a kernel tree:
400
401$ find . -name Kconfig\* | xargs grep -ns "depends on.*=.*||.*=" | grep -v orig
402
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index db122df5e77d..92c40d174355 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -34,6 +34,7 @@ parameter is applicable:
34 ALSA ALSA sound support is enabled. 34 ALSA ALSA sound support is enabled.
35 APIC APIC support is enabled. 35 APIC APIC support is enabled.
36 APM Advanced Power Management support is enabled. 36 APM Advanced Power Management support is enabled.
37 AVR32 AVR32 architecture is enabled.
37 AX25 Appropriate AX.25 support is enabled. 38 AX25 Appropriate AX.25 support is enabled.
38 BLACKFIN Blackfin architecture is enabled. 39 BLACKFIN Blackfin architecture is enabled.
39 DRM Direct Rendering Management support is enabled. 40 DRM Direct Rendering Management support is enabled.
@@ -369,7 +370,8 @@ and is between 256 and 4096 characters. It is defined in the file
369 configured. Potentially dangerous and should only be 370 configured. Potentially dangerous and should only be
370 used if you are entirely sure of the consequences. 371 used if you are entirely sure of the consequences.
371 372
372 chandev= [HW,NET] Generic channel device initialisation 373 ccw_timeout_log [S390]
374 See Documentation/s390/CommonIO for details.
373 375
374 checkreqprot [SELINUX] Set initial checkreqprot flag value. 376 checkreqprot [SELINUX] Set initial checkreqprot flag value.
375 Format: { "0" | "1" } 377 Format: { "0" | "1" }
@@ -381,6 +383,12 @@ and is between 256 and 4096 characters. It is defined in the file
381 Value can be changed at runtime via 383 Value can be changed at runtime via
382 /selinux/checkreqprot. 384 /selinux/checkreqprot.
383 385
386 cio_ignore= [S390]
387 See Documentation/s390/CommonIO for details.
388
389 cio_msg= [S390]
390 See Documentation/s390/CommonIO for details.
391
384 clock= [BUGS=X86-32, HW] gettimeofday clocksource override. 392 clock= [BUGS=X86-32, HW] gettimeofday clocksource override.
385 [Deprecated] 393 [Deprecated]
386 Forces specified clocksource (if available) to be used 394 Forces specified clocksource (if available) to be used
@@ -408,8 +416,21 @@ and is between 256 and 4096 characters. It is defined in the file
408 [SPARC64] tick 416 [SPARC64] tick
409 [X86-64] hpet,tsc 417 [X86-64] hpet,tsc
410 418
411 code_bytes [IA32] How many bytes of object code to print in an 419 clearcpuid=BITNUM [X86]
412 oops report. 420 Disable CPUID feature X for the kernel. See
421 include/asm-x86/cpufeature.h for the valid bit numbers.
422 Note the Linux specific bits are not necessarily
423 stable over kernel options, but the vendor specific
424 ones should be.
425 Also note that user programs calling CPUID directly
426 or using the feature without checking anything
427 will still see it. This just prevents it from
428 being used by the kernel or shown in /proc/cpuinfo.
429 Also note the kernel might malfunction if you disable
430 some critical bits.
431
432 code_bytes [IA32/X86_64] How many bytes of object code to print
433 in an oops report.
413 Range: 0 - 8192 434 Range: 0 - 8192
414 Default: 64 435 Default: 64
415 436
@@ -562,6 +583,12 @@ and is between 256 and 4096 characters. It is defined in the file
562 See drivers/char/README.epca and 583 See drivers/char/README.epca and
563 Documentation/digiepca.txt. 584 Documentation/digiepca.txt.
564 585
586 disable_mtrr_trim [X86, Intel and AMD only]
587 By default the kernel will trim any uncacheable
588 memory out of your available memory pool based on
589 MTRR settings. This parameter disables that behavior,
590 possibly causing your machine to run very slowly.
591
565 dmasound= [HW,OSS] Sound subsystem buffers 592 dmasound= [HW,OSS] Sound subsystem buffers
566 593
567 dscc4.setup= [NET] 594 dscc4.setup= [NET]
@@ -652,6 +679,10 @@ and is between 256 and 4096 characters. It is defined in the file
652 679
653 gamma= [HW,DRM] 680 gamma= [HW,DRM]
654 681
682 gart_fix_e820= [X86_64] disable the fix e820 for K8 GART
683 Format: off | on
684 default: on
685
655 gdth= [HW,SCSI] 686 gdth= [HW,SCSI]
656 See header of drivers/scsi/gdth.c. 687 See header of drivers/scsi/gdth.c.
657 688
@@ -787,6 +818,16 @@ and is between 256 and 4096 characters. It is defined in the file
787 for translation below 32 bit and if not available 818 for translation below 32 bit and if not available
788 then look in the higher range. 819 then look in the higher range.
789 820
821 io_delay= [X86-32,X86-64] I/O delay method
822 0x80
823 Standard port 0x80 based delay
824 0xed
825 Alternate port 0xed based delay (needed on some systems)
826 udelay
827 Simple two microseconds delay
828 none
829 No delay
830
790 io7= [HW] IO7 for Marvel based alpha systems 831 io7= [HW] IO7 for Marvel based alpha systems
791 See comment before marvel_specify_io7 in 832 See comment before marvel_specify_io7 in
792 arch/alpha/kernel/core_marvel.c. 833 arch/alpha/kernel/core_marvel.c.
@@ -1052,6 +1093,11 @@ and is between 256 and 4096 characters. It is defined in the file
1052 Multi-Function General Purpose Timers on AMD Geode 1093 Multi-Function General Purpose Timers on AMD Geode
1053 platforms. 1094 platforms.
1054 1095
1096 mfgptfix [X86-32] Fix MFGPT timers on AMD Geode platforms when
1097 the BIOS has incorrectly applied a workaround. TinyBIOS
1098 version 0.98 is known to be affected, 0.99 fixes the
1099 problem by letting the user disable the workaround.
1100
1055 mga= [HW,DRM] 1101 mga= [HW,DRM]
1056 1102
1057 mousedev.tap_time= 1103 mousedev.tap_time=
@@ -1124,6 +1170,10 @@ and is between 256 and 4096 characters. It is defined in the file
1124 of returning the full 64-bit number. 1170 of returning the full 64-bit number.
1125 The default is to return 64-bit inode numbers. 1171 The default is to return 64-bit inode numbers.
1126 1172
1173 nmi_debug= [KNL,AVR32] Specify one or more actions to take
1174 when a NMI is triggered.
1175 Format: [state][,regs][,debounce][,die]
1176
1127 nmi_watchdog= [KNL,BUGS=X86-32] Debugging features for SMP kernels 1177 nmi_watchdog= [KNL,BUGS=X86-32] Debugging features for SMP kernels
1128 1178
1129 no387 [BUGS=X86-32] Tells the kernel to use the 387 maths 1179 no387 [BUGS=X86-32] Tells the kernel to use the 387 maths
@@ -1148,6 +1198,8 @@ and is between 256 and 4096 characters. It is defined in the file
1148 1198
1149 nodisconnect [HW,SCSI,M68K] Disables SCSI disconnects. 1199 nodisconnect [HW,SCSI,M68K] Disables SCSI disconnects.
1150 1200
1201 noefi [X86-32,X86-64] Disable EFI runtime services support.
1202
1151 noexec [IA-64] 1203 noexec [IA-64]
1152 1204
1153 noexec [X86-32,X86-64] 1205 noexec [X86-32,X86-64]
@@ -1158,6 +1210,8 @@ and is between 256 and 4096 characters. It is defined in the file
1158 register save and restore. The kernel will only save 1210 register save and restore. The kernel will only save
1159 legacy floating-point registers on task switch. 1211 legacy floating-point registers on task switch.
1160 1212
1213 noclflush [BUGS=X86] Don't use the CLFLUSH instruction
1214
1161 nohlt [BUGS=ARM] 1215 nohlt [BUGS=ARM]
1162 1216
1163 no-hlt [BUGS=X86-32] Tells the kernel that the hlt 1217 no-hlt [BUGS=X86-32] Tells the kernel that the hlt
@@ -1594,7 +1648,13 @@ and is between 256 and 4096 characters. It is defined in the file
1594 Format: <vendor>:<model>:<flags> 1648 Format: <vendor>:<model>:<flags>
1595 (flags are integer value) 1649 (flags are integer value)
1596 1650
1597 scsi_logging= [SCSI] 1651 scsi_logging_level= [SCSI] a bit mask of logging levels
1652 See drivers/scsi/scsi_logging.h for bits. Also
1653 settable via sysctl at dev.scsi.logging_level
1654 (/proc/sys/dev/scsi/logging_level).
1655 There is also a nice 'scsi_logging_level' script in the
1656 S390-tools package, available for download at
1657 http://www-128.ibm.com/developerworks/linux/linux390/s390-tools-1.5.4.html
1598 1658
1599 scsi_mod.scan= [SCSI] sync (default) scans SCSI busses as they are 1659 scsi_mod.scan= [SCSI] sync (default) scans SCSI busses as they are
1600 discovered. async scans them in kernel threads, 1660 discovered. async scans them in kernel threads,
@@ -1961,6 +2021,11 @@ and is between 256 and 4096 characters. It is defined in the file
1961 vdso=1: enable VDSO (default) 2021 vdso=1: enable VDSO (default)
1962 vdso=0: disable VDSO mapping 2022 vdso=0: disable VDSO mapping
1963 2023
2024 vdso32= [X86-32,X86-64]
2025 vdso32=2: enable compat VDSO (default with COMPAT_VDSO)
2026 vdso32=1: enable 32-bit VDSO (default)
2027 vdso32=0: disable 32-bit VDSO mapping
2028
1964 vector= [IA-64,SMP] 2029 vector= [IA-64,SMP]
1965 vector=percpu: enable percpu vector domain 2030 vector=percpu: enable percpu vector domain
1966 2031
diff --git a/Documentation/kobject.txt b/Documentation/kobject.txt
index ca86a885ad8f..bf3256e04027 100644
--- a/Documentation/kobject.txt
+++ b/Documentation/kobject.txt
@@ -1,289 +1,386 @@
1The kobject Infrastructure 1Everything you never wanted to know about kobjects, ksets, and ktypes
2 2
3Patrick Mochel <mochel@osdl.org> 3Greg Kroah-Hartman <gregkh@suse.de>
4 4
5Updated: 3 June 2003 5Based on an original article by Jon Corbet for lwn.net written October 1,
62003 and located at http://lwn.net/Articles/51437/
6 7
8Last updated December 19, 2007
7 9
8Copyright (c) 2003 Patrick Mochel
9Copyright (c) 2003 Open Source Development Labs
10 10
11Part of the difficulty in understanding the driver model - and the kobject
12abstraction upon which it is built - is that there is no obvious starting
13place. Dealing with kobjects requires understanding a few different types,
14all of which make reference to each other. In an attempt to make things
15easier, we'll take a multi-pass approach, starting with vague terms and
16adding detail as we go. To that end, here are some quick definitions of
17some terms we will be working with.
11 18
120. Introduction 19 - A kobject is an object of type struct kobject. Kobjects have a name
20 and a reference count. A kobject also has a parent pointer (allowing
21 objects to be arranged into hierarchies), a specific type, and,
22 usually, a representation in the sysfs virtual filesystem.
13 23
14The kobject infrastructure performs basic object management that larger 24 Kobjects are generally not interesting on their own; instead, they are
15data structures and subsystems can leverage, rather than reimplement 25 usually embedded within some other structure which contains the stuff
16similar functionality. This functionality primarily concerns: 26 the code is really interested in.
17 27
18- Object reference counting. 28 No structure should EVER have more than one kobject embedded within it.
19- Maintaining lists (sets) of objects. 29 If it does, the reference counting for the object is sure to be messed
20- Object set locking. 30 up and incorrect, and your code will be buggy. So do not do this.
21- Userspace representation.
22 31
23The infrastructure consists of a number of object types to support 32 - A ktype is the type of object that embeds a kobject. Every structure
24this functionality. Their programming interfaces are described below 33 that embeds a kobject needs a corresponding ktype. The ktype controls
25in detail, and briefly here: 34 what happens to the kobject when it is created and destroyed.
26 35
27- kobjects a simple object. 36 - A kset is a group of kobjects. These kobjects can be of the same ktype
28- kset a set of objects of a certain type. 37 or belong to different ktypes. The kset is the basic container type for
29- ktype a set of helpers for objects of a common type. 38 collections of kobjects. Ksets contain their own kobjects, but you can
39 safely ignore that implementation detail as the kset core code handles
40 this kobject automatically.
30 41
42 When you see a sysfs directory full of other directories, generally each
43 of those directories corresponds to a kobject in the same kset.
31 44
32The kobject infrastructure maintains a close relationship with the 45We'll look at how to create and manipulate all of these types. A bottom-up
33sysfs filesystem. Each kobject that is registered with the kobject 46approach will be taken, so we'll go back to kobjects.
34core receives a directory in sysfs. Attributes about the kobject can
35then be exported. Please see Documentation/filesystems/sysfs.txt for
36more information.
37 47
38The kobject infrastructure provides a flexible programming interface,
39and allows kobjects and ksets to be used without being registered
40(i.e. with no sysfs representation). This is also described later.
41 48
49Embedding kobjects
42 50
431. kobjects 51It is rare for kernel code to create a standalone kobject, with one major
52exception explained below. Instead, kobjects are used to control access to
53a larger, domain-specific object. To this end, kobjects will be found
54embedded in other structures. If you are used to thinking of things in
55object-oriented terms, kobjects can be seen as a top-level, abstract class
56from which other classes are derived. A kobject implements a set of
57capabilities which are not particularly useful by themselves, but which are
58nice to have in other objects. The C language does not allow for the
59direct expression of inheritance, so other techniques - such as structure
60embedding - must be used.
44 61
451.1 Description 62So, for example, the UIO code has a structure that defines the memory
63region associated with a uio device:
46 64
65struct uio_mem {
66 struct kobject kobj;
67 unsigned long addr;
68 unsigned long size;
69 int memtype;
70 void __iomem *internal_addr;
71};
47 72
48struct kobject is a simple data type that provides a foundation for 73If you have a struct uio_mem structure, finding its embedded kobject is
49more complex object types. It provides a set of basic fields that 74just a matter of using the kobj member. Code that works with kobjects will
50almost all complex data types share. kobjects are intended to be 75often have the opposite problem, however: given a struct kobject pointer,
51embedded in larger data structures and replace fields they duplicate. 76what is the pointer to the containing structure? You must avoid tricks
77(such as assuming that the kobject is at the beginning of the structure)
78and, instead, use the container_of() macro, found in <linux/kernel.h>:
52 79
531.2 Definition 80 container_of(pointer, type, member)
54 81
55struct kobject { 82where pointer is the pointer to the embedded kobject, type is the type of
56 const char * k_name; 83the containing structure, and member is the name of the structure field to
57 struct kref kref; 84which pointer points. The return value from container_of() is a pointer to
58 struct list_head entry; 85the given type. So, for example, a pointer "kp" to a struct kobject
59 struct kobject * parent; 86embedded within a struct uio_mem could be converted to a pointer to the
60 struct kset * kset; 87containing uio_mem structure with:
61 struct kobj_type * ktype;
62 struct sysfs_dirent * sd;
63 wait_queue_head_t poll;
64};
65 88
66void kobject_init(struct kobject *); 89 struct uio_mem *u_mem = container_of(kp, struct uio_mem, kobj);
67int kobject_add(struct kobject *);
68int kobject_register(struct kobject *);
69 90
70void kobject_del(struct kobject *); 91Programmers often define a simple macro for "back-casting" kobject pointers
71void kobject_unregister(struct kobject *); 92to the containing type.
72 93
73struct kobject * kobject_get(struct kobject *);
74void kobject_put(struct kobject *);
75 94
95Initialization of kobjects
76 96
771.3 kobject Programming Interface 97Code which creates a kobject must, of course, initialize that object. Some
98of the internal fields are setup with a (mandatory) call to kobject_init():
78 99
79kobjects may be dynamically added and removed from the kobject core 100 void kobject_init(struct kobject *kobj, struct kobj_type *ktype);
80using kobject_register() and kobject_unregister(). Registration
81includes inserting the kobject in the list of its dominant kset and
82creating a directory for it in sysfs.
83 101
84Alternatively, one may use a kobject without adding it to its kset's list 102The ktype is required for a kobject to be created properly, as every kobject
85or exporting it via sysfs, by simply calling kobject_init(). An 103must have an associated kobj_type. After calling kobject_init(), to
86initialized kobject may later be added to the object hierarchy by 104register the kobject with sysfs, the function kobject_add() must be called:
87calling kobject_add(). An initialized kobject may be used for
88reference counting.
89 105
90Note: calling kobject_init() then kobject_add() is functionally 106 int kobject_add(struct kobject *kobj, struct kobject *parent, const char *fmt, ...);
91equivalent to calling kobject_register().
92 107
93When a kobject is unregistered, it is removed from its kset's list, 108This sets up the parent of the kobject and the name for the kobject
94removed from the sysfs filesystem, and its reference count is decremented. 109properly. If the kobject is to be associated with a specific kset,
95List and sysfs removal happen in kobject_del(), and may be called 110kobj->kset must be assigned before calling kobject_add(). If a kset is
96manually. kobject_put() decrements the reference count, and may also 111associated with a kobject, then the parent for the kobject can be set to
97be called manually. 112NULL in the call to kobject_add() and then the kobject's parent will be the
113kset itself.
98 114
99A kobject's reference count may be incremented with kobject_get(), 115As the name of the kobject is set when it is added to the kernel, the name
100which returns a valid reference to a kobject; and decremented with 116of the kobject should never be manipulated directly. If you must change
101kobject_put(). An object's reference count may only be incremented if 117the name of the kobject, call kobject_rename():
102it is already positive.
103 118
104When a kobject's reference count reaches 0, the method struct 119 int kobject_rename(struct kobject *kobj, const char *new_name);
105kobj_type::release() (which the kobject's kset points to) is called.
106This allows any memory allocated for the object to be freed.
107 120
121There is a function called kobject_set_name() but that is legacy cruft and
122is being removed. If your code needs to call this function, it is
123incorrect and needs to be fixed.
108 124
109NOTE!!! 125To properly access the name of the kobject, use the function
126kobject_name():
110 127
111It is _imperative_ that you supply a destructor for dynamically 128 const char *kobject_name(const struct kobject * kobj);
112allocated kobjects to free them if you are using kobject reference
113counts. The reference count controls the lifetime of the object.
114If it goes to 0, then it is assumed that the object will
115be freed and cannot be used.
116 129
117More importantly, you must free the object there, and not immediately 130There is a helper function to both initialize and add the kobject to the
118after an unregister call. If someone else is referencing the object 131kernel at the same time, called supprisingly enough kobject_init_and_add():
119(e.g. through a sysfs file), they will obtain a reference to the
120object, assume it's valid and operate on it. If the object is
121unregistered and freed in the meantime, the operation will then
122reference freed memory and go boom.
123 132
124This can be prevented, in the simplest case, by defining a release 133 int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype,
125method and freeing the object from there only. Note that this will not 134 struct kobject *parent, const char *fmt, ...);
126secure reference count/object management models that use a dual
127reference count or do other wacky things with the reference count
128(like the networking layer).
129 135
136The arguments are the same as the individual kobject_init() and
137kobject_add() functions described above.
130 138
1311.4 sysfs
132 139
133Each kobject receives a directory in sysfs. This directory is created 140Uevents
134under the kobject's parent directory.
135 141
136If a kobject does not have a parent when it is registered, its parent 142After a kobject has been registered with the kobject core, you need to
137becomes its dominant kset. 143announce to the world that it has been created. This can be done with a
144call to kobject_uevent():
138 145
139If a kobject does not have a parent nor a dominant kset, its directory 146 int kobject_uevent(struct kobject *kobj, enum kobject_action action);
140is created at the top-level of the sysfs partition.
141 147
148Use the KOBJ_ADD action for when the kobject is first added to the kernel.
149This should be done only after any attributes or children of the kobject
150have been initialized properly, as userspace will instantly start to look
151for them when this call happens.
142 152
153When the kobject is removed from the kernel (details on how to do that is
154below), the uevent for KOBJ_REMOVE will be automatically created by the
155kobject core, so the caller does not have to worry about doing that by
156hand.
143 157
1442. ksets
145 158
1462.1 Description 159Reference counts
147 160
148A kset is a set of kobjects that are embedded in the same type. 161One of the key functions of a kobject is to serve as a reference counter
162for the object in which it is embedded. As long as references to the object
163exist, the object (and the code which supports it) must continue to exist.
164The low-level functions for manipulating a kobject's reference counts are:
149 165
166 struct kobject *kobject_get(struct kobject *kobj);
167 void kobject_put(struct kobject *kobj);
150 168
151struct kset { 169A successful call to kobject_get() will increment the kobject's reference
152 struct kobj_type * ktype; 170counter and return the pointer to the kobject.
153 struct list_head list;
154 struct kobject kobj;
155 struct kset_uevent_ops * uevent_ops;
156};
157 171
172When a reference is released, the call to kobject_put() will decrement the
173reference count and, possibly, free the object. Note that kobject_init()
174sets the reference count to one, so the code which sets up the kobject will
175need to do a kobject_put() eventually to release that reference.
158 176
159void kset_init(struct kset * k); 177Because kobjects are dynamic, they must not be declared statically or on
160int kset_add(struct kset * k); 178the stack, but instead, always allocated dynamically. Future versions of
161int kset_register(struct kset * k); 179the kernel will contain a run-time check for kobjects that are created
162void kset_unregister(struct kset * k); 180statically and will warn the developer of this improper usage.
163 181
164struct kset * kset_get(struct kset * k); 182If all that you want to use a kobject for is to provide a reference counter
165void kset_put(struct kset * k); 183for your structure, please use the struct kref instead; a kobject would be
184overkill. For more information on how to use struct kref, please see the
185file Documentation/kref.txt in the Linux kernel source tree.
166 186
167struct kobject * kset_find_obj(struct kset *, char *);
168 187
188Creating "simple" kobjects
169 189
170The type that the kobjects are embedded in is described by the ktype 190Sometimes all that a developer wants is a way to create a simple directory
171pointer. 191in the sysfs hierarchy, and not have to mess with the whole complication of
192ksets, show and store functions, and other details. This is the one
193exception where a single kobject should be created. To create such an
194entry, use the function:
172 195
173A kset contains a kobject itself, meaning that it may be registered in 196 struct kobject *kobject_create_and_add(char *name, struct kobject *parent);
174the kobject hierarchy and exported via sysfs. More importantly, the
175kset may be embedded in a larger data type, and may be part of another
176kset (of that object type).
177 197
178For example, a block device is an object (struct gendisk) that is 198This function will create a kobject and place it in sysfs in the location
179contained in a set of block devices. It may also contain a set of 199underneath the specified parent kobject. To create simple attributes
180partitions (struct hd_struct) that have been found on the device. The 200associated with this kobject, use:
181following code snippet illustrates how to express this properly.
182 201
183 struct gendisk * disk; 202 int sysfs_create_file(struct kobject *kobj, struct attribute *attr);
184 ... 203or
185 disk->kset.kobj.kset = &block_kset; 204 int sysfs_create_group(struct kobject *kobj, struct attribute_group *grp);
186 disk->kset.ktype = &partition_ktype;
187 kset_register(&disk->kset);
188 205
189- The kset that the disk's embedded object belongs to is the 206Both types of attributes used here, with a kobject that has been created
190 block_kset, and is pointed to by disk->kset.kobj.kset. 207with the kobject_create_and_add(), can be of type kobj_attribute, so no
208special custom attribute is needed to be created.
191 209
192- The type of objects on the disk's _subordinate_ list are partitions, 210See the example module, samples/kobject/kobject-example.c for an
193 and is set in disk->kset.ktype. 211implementation of a simple kobject and attributes.
194 212
195- The kset is then registered, which handles initializing and adding
196 the embedded kobject to the hierarchy.
197 213
198 214
1992.2 kset Programming Interface 215ktypes and release methods
200 216
201All kset functions, except kset_find_obj(), eventually forward the 217One important thing still missing from the discussion is what happens to a
202calls to their embedded kobjects after performing kset-specific 218kobject when its reference count reaches zero. The code which created the
203operations. ksets offer a similar programming model to kobjects: they 219kobject generally does not know when that will happen; if it did, there
204may be used after they are initialized, without registering them in 220would be little point in using a kobject in the first place. Even
205the hierarchy. 221predictable object lifecycles become more complicated when sysfs is brought
222in as other portions of the kernel can get a reference on any kobject that
223is registered in the system.
206 224
207kset_find_obj() may be used to locate a kobject with a particular 225The end result is that a structure protected by a kobject cannot be freed
208name. The kobject, if found, is returned. 226before its reference count goes to zero. The reference count is not under
227the direct control of the code which created the kobject. So that code must
228be notified asynchronously whenever the last reference to one of its
229kobjects goes away.
209 230
210There are also some helper functions which names point to the formerly 231Once you registered your kobject via kobject_add(), you must never use
211existing "struct subsystem", whose functions have been taken over by 232kfree() to free it directly. The only safe way is to use kobject_put(). It
212ksets. 233is good practice to always use kobject_put() after kobject_init() to avoid
234errors creeping in.
213 235
236This notification is done through a kobject's release() method. Usually
237such a method has a form like:
214 238
215decl_subsys(name,type,uevent_ops) 239 void my_object_release(struct kobject *kobj)
240 {
241 struct my_object *mine = container_of(kobj, struct my_object, kobj);
216 242
217Declares a kset named '<name>_subsys' of type <type> with 243 /* Perform any additional cleanup on this object, then... */
218uevent_ops <uevent_ops>. For example, 244 kfree(mine);
245 }
219 246
220decl_subsys(devices, &ktype_device, &device_uevent_ops); 247One important point cannot be overstated: every kobject must have a
248release() method, and the kobject must persist (in a consistent state)
249until that method is called. If these constraints are not met, the code is
250flawed. Note that the kernel will warn you if you forget to provide a
251release() method. Do not try to get rid of this warning by providing an
252"empty" release function; you will be mocked mercilessly by the kobject
253maintainer if you attempt this.
221 254
222is equivalent to doing: 255Note, the name of the kobject is available in the release function, but it
256must NOT be changed within this callback. Otherwise there will be a memory
257leak in the kobject core, which makes people unhappy.
223 258
224struct kset devices_subsys = { 259Interestingly, the release() method is not stored in the kobject itself;
225 .ktype = &ktype_devices, 260instead, it is associated with the ktype. So let us introduce struct
226 .uevent_ops = &device_uevent_ops, 261kobj_type:
227}; 262
228kobject_set_name(&devices_subsys, name); 263 struct kobj_type {
264 void (*release)(struct kobject *);
265 struct sysfs_ops *sysfs_ops;
266 struct attribute **default_attrs;
267 };
229 268
230The objects that are registered with a subsystem that use the 269This structure is used to describe a particular type of kobject (or, more
231subsystem's default list must have their kset ptr set properly. These 270correctly, of containing object). Every kobject needs to have an associated
232objects may have embedded kobjects or ksets. The 271kobj_type structure; a pointer to that structure must be specified when you
233following helper makes setting the kset easier: 272call kobject_init() or kobject_init_and_add().
234 273
274The release field in struct kobj_type is, of course, a pointer to the
275release() method for this type of kobject. The other two fields (sysfs_ops
276and default_attrs) control how objects of this type are represented in
277sysfs; they are beyond the scope of this document.
235 278
236kobj_set_kset_s(obj,subsys) 279The default_attrs pointer is a list of default attributes that will be
280automatically created for any kobject that is registered with this ktype.
237 281
238- Assumes that obj->kobj exists, and is a struct kobject.
239- Sets the kset of that kobject to the kset <subsys>.
240 282
241int subsystem_register(struct kset *s); 283ksets
242void subsystem_unregister(struct kset *s);
243 284
244These are just wrappers around the respective kset_* functions. 285A kset is merely a collection of kobjects that want to be associated with
286each other. There is no restriction that they be of the same ktype, but be
287very careful if they are not.
245 288
2462.3 sysfs 289A kset serves these functions:
247 290
248ksets are represented in sysfs when their embedded kobjects are 291 - It serves as a bag containing a group of objects. A kset can be used by
249registered. They follow the same rules of parenting, with one 292 the kernel to track "all block devices" or "all PCI device drivers."
250exception. If a kset does not have a parent, nor is its embedded
251kobject part of another kset, the kset's parent becomes its dominant
252subsystem.
253 293
254If the kset does not have a parent, its directory is created at the 294 - A kset is also a subdirectory in sysfs, where the associated kobjects
255sysfs root. This should only happen when the kset registered is 295 with the kset can show up. Every kset contains a kobject which can be
256embedded in a subsystem itself. 296 set up to be the parent of other kobjects; the top-level directories of
297 the sysfs hierarchy are constructed in this way.
257 298
299 - Ksets can support the "hotplugging" of kobjects and influence how
300 uevent events are reported to user space.
258 301
2593. struct ktype 302In object-oriented terms, "kset" is the top-level container class; ksets
303contain their own kobject, but that kobject is managed by the kset code and
304should not be manipulated by any other user.
260 305
2613.1. Description 306A kset keeps its children in a standard kernel linked list. Kobjects point
307back to their containing kset via their kset field. In almost all cases,
308the kobjects belonging to a ket have that kset (or, strictly, its embedded
309kobject) in their parent.
262 310
263struct kobj_type { 311As a kset contains a kobject within it, it should always be dynamically
264 void (*release)(struct kobject *); 312created and never declared statically or on the stack. To create a new
265 struct sysfs_ops * sysfs_ops; 313kset use:
266 struct attribute ** default_attrs; 314 struct kset *kset_create_and_add(const char *name,
315 struct kset_uevent_ops *u,
316 struct kobject *parent);
317
318When you are finished with the kset, call:
319 void kset_unregister(struct kset *kset);
320to destroy it.
321
322An example of using a kset can be seen in the
323samples/kobject/kset-example.c file in the kernel tree.
324
325If a kset wishes to control the uevent operations of the kobjects
326associated with it, it can use the struct kset_uevent_ops to handle it:
327
328struct kset_uevent_ops {
329 int (*filter)(struct kset *kset, struct kobject *kobj);
330 const char *(*name)(struct kset *kset, struct kobject *kobj);
331 int (*uevent)(struct kset *kset, struct kobject *kobj,
332 struct kobj_uevent_env *env);
267}; 333};
268 334
269 335
270Object types require specific functions for converting between the 336The filter function allows a kset to prevent a uevent from being emitted to
271generic object and the more complex type. struct kobj_type provides 337userspace for a specific kobject. If the function returns 0, the uevent
272the object-specific fields, which include: 338will not be emitted.
339
340The name function will be called to override the default name of the kset
341that the uevent sends to userspace. By default, the name will be the same
342as the kset itself, but this function, if present, can override that name.
343
344The uevent function will be called when the uevent is about to be sent to
345userspace to allow more environment variables to be added to the uevent.
346
347One might ask how, exactly, a kobject is added to a kset, given that no
348functions which perform that function have been presented. The answer is
349that this task is handled by kobject_add(). When a kobject is passed to
350kobject_add(), its kset member should point to the kset to which the
351kobject will belong. kobject_add() will handle the rest.
352
353If the kobject belonging to a kset has no parent kobject set, it will be
354added to the kset's directory. Not all members of a kset do necessarily
355live in the kset directory. If an explicit parent kobject is assigned
356before the kobject is added, the kobject is registered with the kset, but
357added below the parent kobject.
358
359
360Kobject removal
273 361
274- release: Called when the kobject's reference count reaches 0. This 362After a kobject has been registered with the kobject core successfully, it
275 should convert the object to the more complex type and free it. 363must be cleaned up when the code is finished with it. To do that, call
364kobject_put(). By doing this, the kobject core will automatically clean up
365all of the memory allocated by this kobject. If a KOBJ_ADD uevent has been
366sent for the object, a corresponding KOBJ_REMOVE uevent will be sent, and
367any other sysfs housekeeping will be handled for the caller properly.
276 368
277- sysfs_ops: Provides conversion functions for sysfs access. Please 369If you need to do a two-stage delete of the kobject (say you are not
278 see the sysfs documentation for more information. 370allowed to sleep when you need to destroy the object), then call
371kobject_del() which will unregister the kobject from sysfs. This makes the
372kobject "invisible", but it is not cleaned up, and the reference count of
373the object is still the same. At a later time call kobject_put() to finish
374the cleanup of the memory associated with the kobject.
279 375
280- default_attrs: Default attributes to be exported via sysfs when the 376kobject_del() can be used to drop the reference to the parent object, if
281 object is registered.Note that the last attribute has to be 377circular references are constructed. It is valid in some cases, that a
282 initialized to NULL ! You can find a complete implementation 378parent objects references a child. Circular references _must_ be broken
283 in block/genhd.c 379with an explicit call to kobject_del(), so that a release functions will be
380called, and the objects in the former circle release each other.
284 381
285 382
286Instances of struct kobj_type are not registered; only referenced by 383Example code to copy from
287the kset. A kobj_type may be referenced by an arbitrary number of
288ksets, as there may be disparate sets of identical objects.
289 384
385For a more complete example of using ksets and kobjects properly, see the
386sample/kobject/kset-example.c code.
diff --git a/Documentation/kprobes.txt b/Documentation/kprobes.txt
index cb12ae175aa2..53a63890aea4 100644
--- a/Documentation/kprobes.txt
+++ b/Documentation/kprobes.txt
@@ -141,6 +141,7 @@ architectures:
141- ppc64 141- ppc64
142- ia64 (Does not support probes on instruction slot1.) 142- ia64 (Does not support probes on instruction slot1.)
143- sparc64 (Return probes not yet implemented.) 143- sparc64 (Return probes not yet implemented.)
144- arm
144 145
1453. Configuring Kprobes 1463. Configuring Kprobes
146 147
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c
index 9b0e322118b5..6c8a2386cd50 100644
--- a/Documentation/lguest/lguest.c
+++ b/Documentation/lguest/lguest.c
@@ -79,6 +79,9 @@ static void *guest_base;
79/* The maximum guest physical address allowed, and maximum possible. */ 79/* The maximum guest physical address allowed, and maximum possible. */
80static unsigned long guest_limit, guest_max; 80static unsigned long guest_limit, guest_max;
81 81
82/* a per-cpu variable indicating whose vcpu is currently running */
83static unsigned int __thread cpu_id;
84
82/* This is our list of devices. */ 85/* This is our list of devices. */
83struct device_list 86struct device_list
84{ 87{
@@ -153,6 +156,9 @@ struct virtqueue
153 void (*handle_output)(int fd, struct virtqueue *me); 156 void (*handle_output)(int fd, struct virtqueue *me);
154}; 157};
155 158
159/* Remember the arguments to the program so we can "reboot" */
160static char **main_args;
161
156/* Since guest is UP and we don't run at the same time, we don't need barriers. 162/* Since guest is UP and we don't run at the same time, we don't need barriers.
157 * But I include them in the code in case others copy it. */ 163 * But I include them in the code in case others copy it. */
158#define wmb() 164#define wmb()
@@ -554,7 +560,7 @@ static void wake_parent(int pipefd, int lguest_fd)
554 else 560 else
555 FD_CLR(-fd - 1, &devices.infds); 561 FD_CLR(-fd - 1, &devices.infds);
556 } else /* Send LHREQ_BREAK command. */ 562 } else /* Send LHREQ_BREAK command. */
557 write(lguest_fd, args, sizeof(args)); 563 pwrite(lguest_fd, args, sizeof(args), cpu_id);
558 } 564 }
559} 565}
560 566
@@ -1489,7 +1495,9 @@ static void setup_block_file(const char *filename)
1489 1495
1490 /* Create stack for thread and run it */ 1496 /* Create stack for thread and run it */
1491 stack = malloc(32768); 1497 stack = malloc(32768);
1492 if (clone(io_thread, stack + 32768, CLONE_VM, dev) == -1) 1498 /* SIGCHLD - We dont "wait" for our cloned thread, so prevent it from
1499 * becoming a zombie. */
1500 if (clone(io_thread, stack + 32768, CLONE_VM | SIGCHLD, dev) == -1)
1493 err(1, "Creating clone"); 1501 err(1, "Creating clone");
1494 1502
1495 /* We don't need to keep the I/O thread's end of the pipes open. */ 1503 /* We don't need to keep the I/O thread's end of the pipes open. */
@@ -1499,7 +1507,21 @@ static void setup_block_file(const char *filename)
1499 verbose("device %u: virtblock %llu sectors\n", 1507 verbose("device %u: virtblock %llu sectors\n",
1500 devices.device_num, cap); 1508 devices.device_num, cap);
1501} 1509}
1502/* That's the end of device setup. */ 1510/* That's the end of device setup. :*/
1511
1512/* Reboot */
1513static void __attribute__((noreturn)) restart_guest(void)
1514{
1515 unsigned int i;
1516
1517 /* Closing pipes causes the waker thread and io_threads to die, and
1518 * closing /dev/lguest cleans up the Guest. Since we don't track all
1519 * open fds, we simply close everything beyond stderr. */
1520 for (i = 3; i < FD_SETSIZE; i++)
1521 close(i);
1522 execv(main_args[0], main_args);
1523 err(1, "Could not exec %s", main_args[0]);
1524}
1503 1525
1504/*L:220 Finally we reach the core of the Launcher, which runs the Guest, serves 1526/*L:220 Finally we reach the core of the Launcher, which runs the Guest, serves
1505 * its input and output, and finally, lays it to rest. */ 1527 * its input and output, and finally, lays it to rest. */
@@ -1511,7 +1533,8 @@ static void __attribute__((noreturn)) run_guest(int lguest_fd)
1511 int readval; 1533 int readval;
1512 1534
1513 /* We read from the /dev/lguest device to run the Guest. */ 1535 /* We read from the /dev/lguest device to run the Guest. */
1514 readval = read(lguest_fd, &notify_addr, sizeof(notify_addr)); 1536 readval = pread(lguest_fd, &notify_addr,
1537 sizeof(notify_addr), cpu_id);
1515 1538
1516 /* One unsigned long means the Guest did HCALL_NOTIFY */ 1539 /* One unsigned long means the Guest did HCALL_NOTIFY */
1517 if (readval == sizeof(notify_addr)) { 1540 if (readval == sizeof(notify_addr)) {
@@ -1521,16 +1544,23 @@ static void __attribute__((noreturn)) run_guest(int lguest_fd)
1521 /* ENOENT means the Guest died. Reading tells us why. */ 1544 /* ENOENT means the Guest died. Reading tells us why. */
1522 } else if (errno == ENOENT) { 1545 } else if (errno == ENOENT) {
1523 char reason[1024] = { 0 }; 1546 char reason[1024] = { 0 };
1524 read(lguest_fd, reason, sizeof(reason)-1); 1547 pread(lguest_fd, reason, sizeof(reason)-1, cpu_id);
1525 errx(1, "%s", reason); 1548 errx(1, "%s", reason);
1549 /* ERESTART means that we need to reboot the guest */
1550 } else if (errno == ERESTART) {
1551 restart_guest();
1526 /* EAGAIN means the Waker wanted us to look at some input. 1552 /* EAGAIN means the Waker wanted us to look at some input.
1527 * Anything else means a bug or incompatible change. */ 1553 * Anything else means a bug or incompatible change. */
1528 } else if (errno != EAGAIN) 1554 } else if (errno != EAGAIN)
1529 err(1, "Running guest failed"); 1555 err(1, "Running guest failed");
1530 1556
1557 /* Only service input on thread for CPU 0. */
1558 if (cpu_id != 0)
1559 continue;
1560
1531 /* Service input, then unset the BREAK to release the Waker. */ 1561 /* Service input, then unset the BREAK to release the Waker. */
1532 handle_input(lguest_fd); 1562 handle_input(lguest_fd);
1533 if (write(lguest_fd, args, sizeof(args)) < 0) 1563 if (pwrite(lguest_fd, args, sizeof(args), cpu_id) < 0)
1534 err(1, "Resetting break"); 1564 err(1, "Resetting break");
1535 } 1565 }
1536} 1566}
@@ -1571,6 +1601,12 @@ int main(int argc, char *argv[])
1571 /* If they specify an initrd file to load. */ 1601 /* If they specify an initrd file to load. */
1572 const char *initrd_name = NULL; 1602 const char *initrd_name = NULL;
1573 1603
1604 /* Save the args: we "reboot" by execing ourselves again. */
1605 main_args = argv;
1606 /* We don't "wait" for the children, so prevent them from becoming
1607 * zombies. */
1608 signal(SIGCHLD, SIG_IGN);
1609
1574 /* First we initialize the device list. Since console and network 1610 /* First we initialize the device list. Since console and network
1575 * device receive input from a file descriptor, we keep an fdset 1611 * device receive input from a file descriptor, we keep an fdset
1576 * (infds) and the maximum fd number (max_infd) with the head of the 1612 * (infds) and the maximum fd number (max_infd) with the head of the
@@ -1582,6 +1618,7 @@ int main(int argc, char *argv[])
1582 devices.lastdev = &devices.dev; 1618 devices.lastdev = &devices.dev;
1583 devices.next_irq = 1; 1619 devices.next_irq = 1;
1584 1620
1621 cpu_id = 0;
1585 /* We need to know how much memory so we can set up the device 1622 /* We need to know how much memory so we can set up the device
1586 * descriptor and memory pages for the devices as we parse the command 1623 * descriptor and memory pages for the devices as we parse the command
1587 * line. So we quickly look through the arguments to find the amount 1624 * line. So we quickly look through the arguments to find the amount
diff --git a/Documentation/m68k/kernel-options.txt b/Documentation/m68k/kernel-options.txt
index 248589e8bcf5..c93bed66e25d 100644
--- a/Documentation/m68k/kernel-options.txt
+++ b/Documentation/m68k/kernel-options.txt
@@ -867,66 +867,6 @@ controller and should be autodetected by the driver. An example is the
86724 bit region which is specified by a mask of 0x00fffffe. 86724 bit region which is specified by a mask of 0x00fffffe.
868 868
869 869
8705.5) 53c7xx=
871------------
872
873Syntax: 53c7xx=<sub-options...>
874
875These options affect the A4000T, A4091, WarpEngine, Blizzard 603e+,
876and GForce 040/060 SCSI controllers on the Amiga, as well as the
877builtin MVME 16x SCSI controller.
878
879The <sub-options> is a comma-separated list of the sub-options listed
880below.
881
8825.5.1) nosync
883-------------
884
885Syntax: nosync:0
886
887 Disables sync negotiation for all devices. Any value after the
888 colon is acceptable (and has the same effect).
889
8905.5.2) noasync
891--------------
892
893[OBSOLETE, REMOVED]
894
8955.5.3) nodisconnect
896-------------------
897
898Syntax: nodisconnect:0
899
900 Disables SCSI disconnects. Any value after the colon is acceptable
901 (and has the same effect).
902
9035.5.4) validids
904---------------
905
906Syntax: validids:0xNN
907
908 Specify which SCSI ids the driver should pay attention to. This is
909 a bitmask (i.e. to only pay attention to ID#4, you'd use 0x10).
910 Default is 0x7f (devices 0-6).
911
9125.5.5) opthi
9135.5.6) optlo
914------------
915
916Syntax: opthi:M,optlo:N
917
918 Specify options for "hostdata->options". The acceptable definitions
919 are listed in drivers/scsi/53c7xx.h; the 32 high bits should be in
920 opthi and the 32 low bits in optlo. They must be specified in the
921 order opthi=M,optlo=N.
922
9235.5.7) next
924-----------
925
926 No argument. Used to separate blocks of keywords when there's more
927 than one 53c7xx host adapter in the system.
928
929
930/* Local Variables: */ 870/* Local Variables: */
931/* mode: text */ 871/* mode: text */
932/* End: */ 872/* End: */
diff --git a/Documentation/mips/00-INDEX b/Documentation/mips/00-INDEX
index 3f13bf8043d2..8ae9cffc2262 100644
--- a/Documentation/mips/00-INDEX
+++ b/Documentation/mips/00-INDEX
@@ -2,5 +2,3 @@
2 - this file. 2 - this file.
3AU1xxx_IDE.README 3AU1xxx_IDE.README
4 - README for MIPS AU1XXX IDE driver. 4 - README for MIPS AU1XXX IDE driver.
5GT64120.README
6 - README for dir with info on MIPS boards using GT-64120 or GT-64120A.
diff --git a/Documentation/mips/GT64120.README b/Documentation/mips/GT64120.README
deleted file mode 100644
index 2d0eec91dc59..000000000000
--- a/Documentation/mips/GT64120.README
+++ /dev/null
@@ -1,65 +0,0 @@
1README for arch/mips/gt64120 directory and subdirectories
2
3Jun Sun, jsun@mvista.com or jsun@junsun.net
401/27, 2001
5
6MOTIVATION
7----------
8
9Many MIPS boards share the same system controller (or CPU companian chip),
10such as GT-64120. It is highly desirable to let these boards share
11the same controller code instead of duplicating them.
12
13This directory is meant to hold all MIPS boards that use GT-64120 or GT-64120A.
14
15
16HOW TO ADD A BOARD
17------------------
18
19. Create a subdirectory include/asm/gt64120/<board>.
20
21. Create a file called gt64120_dep.h under that directory.
22
23. Modify include/asm/gt64120/gt64120.h file to include the new gt64120_dep.h
24 based on config options. The board-dep section is at the end of
25 include/asm/gt64120/gt64120.h file. There you can find all required
26 definitions include/asm/gt64120/<board>/gt64120_dep.h file must supply.
27
28. Create a subdirectory arch/mips/gt64120/<board> directory to hold
29 board specific routines.
30
31. The GT-64120 common code is supplied under arch/mips/gt64120/common directory.
32 It includes:
33 1) arch/mips/gt64120/pci.c -
34 common PCI routine, include the top-level pcibios_init()
35 2) arch/mips/gt64120/irq.c -
36 common IRQ routine, include the top-level do_IRQ()
37 [This part really belongs to arch/mips/kernel. jsun]
38 3) arch/mips/gt64120/gt_irq.c -
39 common IRQ routines for GT-64120 chip. Currently it only handles
40 the timer interrupt.
41
42. Board-specific routines are supplied under arch/mips/gt64120/<board> dir.
43 1) arch/mips/gt64120/<board>/pci.c - it provides bus fixup routine
44 2) arch/mips/gt64120/<board>/irq.c - it provides enable/disable irqs
45 and board irq setup routine (irq_setup)
46 3) arch/mips/gt64120/<board>/int-handler.S -
47 The first-level interrupt dispatching routine.
48 4) a bunch of other "normal" stuff (setup, prom, dbg_io, reset, etc)
49
50. Follow other "normal" procedure to modify configuration files, etc.
51
52
53TO-DO LIST
54----------
55
56. Expand arch/mips/gt64120/gt_irq.c to handle all GT-64120 interrupts.
57 We probably need to introduce GT_IRQ_BASE in board-dep header file,
58 which is used the starting irq_nr for all GT irqs.
59
60 A function, gt64120_handle_irq(), will be added so that the first-level
61 irq dispatcher will call this function if it detects an interrupt
62 from GT-64120.
63
64. More support for GT-64120 PCI features (2nd PCI bus, perhaps)
65
diff --git a/Documentation/networking/00-INDEX b/Documentation/networking/00-INDEX
index 563e442f2d42..02e56d447a8f 100644
--- a/Documentation/networking/00-INDEX
+++ b/Documentation/networking/00-INDEX
@@ -24,6 +24,8 @@ baycom.txt
24 - info on the driver for Baycom style amateur radio modems 24 - info on the driver for Baycom style amateur radio modems
25bridge.txt 25bridge.txt
26 - where to get user space programs for ethernet bridging with Linux. 26 - where to get user space programs for ethernet bridging with Linux.
27can.txt
28 - documentation on CAN protocol family.
27cops.txt 29cops.txt
28 - info on the COPS LocalTalk Linux driver 30 - info on the COPS LocalTalk Linux driver
29cs89x0.txt 31cs89x0.txt
@@ -82,8 +84,6 @@ policy-routing.txt
82 - IP policy-based routing 84 - IP policy-based routing
83ray_cs.txt 85ray_cs.txt
84 - Raylink Wireless LAN card driver info. 86 - Raylink Wireless LAN card driver info.
85shaper.txt
86 - info on the module that can shape/limit transmitted traffic.
87sk98lin.txt 87sk98lin.txt
88 - Marvell Yukon Chipset / SysKonnect SK-98xx compliant Gigabit 88 - Marvell Yukon Chipset / SysKonnect SK-98xx compliant Gigabit
89 Ethernet Adapter family driver info 89 Ethernet Adapter family driver info
diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index 6cc30e0d5795..a0cda062bc33 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -1,7 +1,7 @@
1 1
2 Linux Ethernet Bonding Driver HOWTO 2 Linux Ethernet Bonding Driver HOWTO
3 3
4 Latest update: 24 April 2006 4 Latest update: 12 November 2007
5 5
6Initial release : Thomas Davis <tadavis at lbl.gov> 6Initial release : Thomas Davis <tadavis at lbl.gov>
7Corrections, HA extensions : 2000/10/03-15 : 7Corrections, HA extensions : 2000/10/03-15 :
@@ -166,12 +166,17 @@ to use ifenslave.
1662. Bonding Driver Options 1662. Bonding Driver Options
167========================= 167=========================
168 168
169 Options for the bonding driver are supplied as parameters to 169 Options for the bonding driver are supplied as parameters to the
170the bonding module at load time. They may be given as command line 170bonding module at load time, or are specified via sysfs.
171arguments to the insmod or modprobe command, but are usually specified 171
172in either the /etc/modules.conf or /etc/modprobe.conf configuration 172 Module options may be given as command line arguments to the
173file, or in a distro-specific configuration file (some of which are 173insmod or modprobe command, but are usually specified in either the
174detailed in the next section). 174/etc/modules.conf or /etc/modprobe.conf configuration file, or in a
175distro-specific configuration file (some of which are detailed in the next
176section).
177
178 Details on bonding support for sysfs is provided in the
179"Configuring Bonding Manually via Sysfs" section, below.
175 180
176 The available bonding driver parameters are listed below. If a 181 The available bonding driver parameters are listed below. If a
177parameter is not specified the default value is used. When initially 182parameter is not specified the default value is used. When initially
@@ -812,11 +817,13 @@ the system /etc/modules.conf or /etc/modprobe.conf configuration file.
8123.2 Configuration with Initscripts Support 8173.2 Configuration with Initscripts Support
813------------------------------------------ 818------------------------------------------
814 819
815 This section applies to distros using a version of initscripts 820 This section applies to distros using a recent version of
816with bonding support, for example, Red Hat Linux 9 or Red Hat 821initscripts with bonding support, for example, Red Hat Enterprise Linux
817Enterprise Linux version 3 or 4. On these systems, the network 822version 3 or later, Fedora, etc. On these systems, the network
818initialization scripts have some knowledge of bonding, and can be 823initialization scripts have knowledge of bonding, and can be configured to
819configured to control bonding devices. 824control bonding devices. Note that older versions of the initscripts
825package have lower levels of support for bonding; this will be noted where
826applicable.
820 827
821 These distros will not automatically load the network adapter 828 These distros will not automatically load the network adapter
822driver unless the ethX device is configured with an IP address. 829driver unless the ethX device is configured with an IP address.
@@ -864,11 +871,31 @@ USERCTL=no
864 Be sure to change the networking specific lines (IPADDR, 871 Be sure to change the networking specific lines (IPADDR,
865NETMASK, NETWORK and BROADCAST) to match your network configuration. 872NETMASK, NETWORK and BROADCAST) to match your network configuration.
866 873
867 Finally, it is necessary to edit /etc/modules.conf (or 874 For later versions of initscripts, such as that found with Fedora
868/etc/modprobe.conf, depending upon your distro) to load the bonding 8757 and Red Hat Enterprise Linux version 5 (or later), it is possible, and,
869module with your desired options when the bond0 interface is brought 876indeed, preferable, to specify the bonding options in the ifcfg-bond0
870up. The following lines in /etc/modules.conf (or modprobe.conf) will 877file, e.g. a line of the format:
871load the bonding module, and select its options: 878
879BONDING_OPTS="mode=active-backup arp_interval=60 arp_ip_target=+192.168.1.254"
880
881 will configure the bond with the specified options. The options
882specified in BONDING_OPTS are identical to the bonding module parameters
883except for the arp_ip_target field. Each target should be included as a
884separate option and should be preceded by a '+' to indicate it should be
885added to the list of queried targets, e.g.,
886
887 arp_ip_target=+192.168.1.1 arp_ip_target=+192.168.1.2
888
889 is the proper syntax to specify multiple targets. When specifying
890options via BONDING_OPTS, it is not necessary to edit /etc/modules.conf or
891/etc/modprobe.conf.
892
893 For older versions of initscripts that do not support
894BONDING_OPTS, it is necessary to edit /etc/modules.conf (or
895/etc/modprobe.conf, depending upon your distro) to load the bonding module
896with your desired options when the bond0 interface is brought up. The
897following lines in /etc/modules.conf (or modprobe.conf) will load the
898bonding module, and select its options:
872 899
873alias bond0 bonding 900alias bond0 bonding
874options bond0 mode=balance-alb miimon=100 901options bond0 mode=balance-alb miimon=100
@@ -883,9 +910,10 @@ up and running.
8833.2.1 Using DHCP with Initscripts 9103.2.1 Using DHCP with Initscripts
884--------------------------------- 911---------------------------------
885 912
886 Recent versions of initscripts (the version supplied with 913 Recent versions of initscripts (the versions supplied with Fedora
887Fedora Core 3 and Red Hat Enterprise Linux 4 is reported to work) do 914Core 3 and Red Hat Enterprise Linux 4, or later versions, are reported to
888have support for assigning IP information to bonding devices via DHCP. 915work) have support for assigning IP information to bonding devices via
916DHCP.
889 917
890 To configure bonding for DHCP, configure it as described 918 To configure bonding for DHCP, configure it as described
891above, except replace the line "BOOTPROTO=none" with "BOOTPROTO=dhcp" 919above, except replace the line "BOOTPROTO=none" with "BOOTPROTO=dhcp"
@@ -895,18 +923,14 @@ is case sensitive.
8953.2.2 Configuring Multiple Bonds with Initscripts 9233.2.2 Configuring Multiple Bonds with Initscripts
896------------------------------------------------- 924-------------------------------------------------
897 925
898 At this writing, the initscripts package does not directly 926 Initscripts packages that are included with Fedora 7 and Red Hat
899support loading the bonding driver multiple times, so the process for 927Enterprise Linux 5 support multiple bonding interfaces by simply
900doing so is the same as described in the "Configuring Multiple Bonds 928specifying the appropriate BONDING_OPTS= in ifcfg-bondX where X is the
901Manually" section, below. 929number of the bond. This support requires sysfs support in the kernel,
902 930and a bonding driver of version 3.0.0 or later. Other configurations may
903 NOTE: It has been observed that some Red Hat supplied kernels 931not support this method for specifying multiple bonding interfaces; for
904are apparently unable to rename modules at load time (the "-o bond1" 932those instances, see the "Configuring Multiple Bonds Manually" section,
905part). Attempts to pass that option to modprobe will produce an 933below.
906"Operation not permitted" error. This has been reported on some
907Fedora Core kernels, and has been seen on RHEL 4 as well. On kernels
908exhibiting this problem, it will be impossible to configure multiple
909bonds with differing parameters.
910 934
9113.3 Configuring Bonding Manually with Ifenslave 9353.3 Configuring Bonding Manually with Ifenslave
912----------------------------------------------- 936-----------------------------------------------
@@ -977,15 +1001,58 @@ initialization scripts lack support for configuring multiple bonds.
977options, you may wish to use the "max_bonds" module parameter, 1001options, you may wish to use the "max_bonds" module parameter,
978documented above. 1002documented above.
979 1003
980 To create multiple bonding devices with differing options, it 1004 To create multiple bonding devices with differing options, it is
981is necessary to use bonding parameters exported by sysfs, documented 1005preferrable to use bonding parameters exported by sysfs, documented in the
982in the section below. 1006section below.
1007
1008 For versions of bonding without sysfs support, the only means to
1009provide multiple instances of bonding with differing options is to load
1010the bonding driver multiple times. Note that current versions of the
1011sysconfig network initialization scripts handle this automatically; if
1012your distro uses these scripts, no special action is needed. See the
1013section Configuring Bonding Devices, above, if you're not sure about your
1014network initialization scripts.
1015
1016 To load multiple instances of the module, it is necessary to
1017specify a different name for each instance (the module loading system
1018requires that every loaded module, even multiple instances of the same
1019module, have a unique name). This is accomplished by supplying multiple
1020sets of bonding options in /etc/modprobe.conf, for example:
1021
1022alias bond0 bonding
1023options bond0 -o bond0 mode=balance-rr miimon=100
1024
1025alias bond1 bonding
1026options bond1 -o bond1 mode=balance-alb miimon=50
1027
1028 will load the bonding module two times. The first instance is
1029named "bond0" and creates the bond0 device in balance-rr mode with an
1030miimon of 100. The second instance is named "bond1" and creates the
1031bond1 device in balance-alb mode with an miimon of 50.
1032
1033 In some circumstances (typically with older distributions),
1034the above does not work, and the second bonding instance never sees
1035its options. In that case, the second options line can be substituted
1036as follows:
1037
1038install bond1 /sbin/modprobe --ignore-install bonding -o bond1 \
1039 mode=balance-alb miimon=50
983 1040
1041 This may be repeated any number of times, specifying a new and
1042unique name in place of bond1 for each subsequent instance.
1043
1044 It has been observed that some Red Hat supplied kernels are unable
1045to rename modules at load time (the "-o bond1" part). Attempts to pass
1046that option to modprobe will produce an "Operation not permitted" error.
1047This has been reported on some Fedora Core kernels, and has been seen on
1048RHEL 4 as well. On kernels exhibiting this problem, it will be impossible
1049to configure multiple bonds with differing parameters (as they are older
1050kernels, and also lack sysfs support).
984 1051
9853.4 Configuring Bonding Manually via Sysfs 10523.4 Configuring Bonding Manually via Sysfs
986------------------------------------------ 1053------------------------------------------
987 1054
988 Starting with version 3.0, Channel Bonding may be configured 1055 Starting with version 3.0.0, Channel Bonding may be configured
989via the sysfs interface. This interface allows dynamic configuration 1056via the sysfs interface. This interface allows dynamic configuration
990of all bonds in the system without unloading the module. It also 1057of all bonds in the system without unloading the module. It also
991allows for adding and removing bonds at runtime. Ifenslave is no 1058allows for adding and removing bonds at runtime. Ifenslave is no
@@ -1030,9 +1097,6 @@ To enslave interface eth0 to bond bond0:
1030To free slave eth0 from bond bond0: 1097To free slave eth0 from bond bond0:
1031# echo -eth0 > /sys/class/net/bond0/bonding/slaves 1098# echo -eth0 > /sys/class/net/bond0/bonding/slaves
1032 1099
1033 NOTE: The bond must be up before slaves can be added. All
1034slaves are freed when the interface is brought down.
1035
1036 When an interface is enslaved to a bond, symlinks between the 1100 When an interface is enslaved to a bond, symlinks between the
1037two are created in the sysfs filesystem. In this case, you would get 1101two are created in the sysfs filesystem. In this case, you would get
1038/sys/class/net/bond0/slave_eth0 pointing to /sys/class/net/eth0, and 1102/sys/class/net/bond0/slave_eth0 pointing to /sys/class/net/eth0, and
@@ -1622,6 +1686,15 @@ one for each switch in the network). This will insure that,
1622regardless of which switch is active, the ARP monitor has a suitable 1686regardless of which switch is active, the ARP monitor has a suitable
1623target to query. 1687target to query.
1624 1688
1689 Note, also, that of late many switches now support a functionality
1690generally referred to as "trunk failover." This is a feature of the
1691switch that causes the link state of a particular switch port to be set
1692down (or up) when the state of another switch port goes down (or up).
1693It's purpose is to propogate link failures from logically "exterior" ports
1694to the logically "interior" ports that bonding is able to monitor via
1695miimon. Availability and configuration for trunk failover varies by
1696switch, but this can be a viable alternative to the ARP monitor when using
1697suitable switches.
1625 1698
162612. Configuring Bonding for Maximum Throughput 169912. Configuring Bonding for Maximum Throughput
1627============================================== 1700==============================================
@@ -1709,7 +1782,7 @@ balance-rr: This mode is the only mode that will permit a single
1709 interfaces. It is therefore the only mode that will allow a 1782 interfaces. It is therefore the only mode that will allow a
1710 single TCP/IP stream to utilize more than one interface's 1783 single TCP/IP stream to utilize more than one interface's
1711 worth of throughput. This comes at a cost, however: the 1784 worth of throughput. This comes at a cost, however: the
1712 striping often results in peer systems receiving packets out 1785 striping generally results in peer systems receiving packets out
1713 of order, causing TCP/IP's congestion control system to kick 1786 of order, causing TCP/IP's congestion control system to kick
1714 in, often by retransmitting segments. 1787 in, often by retransmitting segments.
1715 1788
@@ -1721,22 +1794,20 @@ balance-rr: This mode is the only mode that will permit a single
1721 interface's worth of throughput, even after adjusting 1794 interface's worth of throughput, even after adjusting
1722 tcp_reordering. 1795 tcp_reordering.
1723 1796
1724 Note that this out of order delivery occurs when both the 1797 Note that the fraction of packets that will be delivered out of
1725 sending and receiving systems are utilizing a multiple 1798 order is highly variable, and is unlikely to be zero. The level
1726 interface bond. Consider a configuration in which a 1799 of reordering depends upon a variety of factors, including the
1727 balance-rr bond feeds into a single higher capacity network 1800 networking interfaces, the switch, and the topology of the
1728 channel (e.g., multiple 100Mb/sec ethernets feeding a single 1801 configuration. Speaking in general terms, higher speed network
1729 gigabit ethernet via an etherchannel capable switch). In this 1802 cards produce more reordering (due to factors such as packet
1730 configuration, traffic sent from the multiple 100Mb devices to 1803 coalescing), and a "many to many" topology will reorder at a
1731 a destination connected to the gigabit device will not see 1804 higher rate than a "many slow to one fast" configuration.
1732 packets out of order. However, traffic sent from the gigabit 1805
1733 device to the multiple 100Mb devices may or may not see 1806 Many switches do not support any modes that stripe traffic
1734 traffic out of order, depending upon the balance policy of the 1807 (instead choosing a port based upon IP or MAC level addresses);
1735 switch. Many switches do not support any modes that stripe 1808 for those devices, traffic for a particular connection flowing
1736 traffic (instead choosing a port based upon IP or MAC level 1809 through the switch to a balance-rr bond will not utilize greater
1737 addresses); for those devices, traffic flowing from the 1810 than one interface's worth of bandwidth.
1738 gigabit device to the many 100Mb devices will only utilize one
1739 interface.
1740 1811
1741 If you are utilizing protocols other than TCP/IP, UDP for 1812 If you are utilizing protocols other than TCP/IP, UDP for
1742 example, and your application can tolerate out of order 1813 example, and your application can tolerate out of order
@@ -1936,6 +2007,10 @@ Failover may be delayed via the downdelay bonding module option.
193613.2 Duplicated Incoming Packets 200713.2 Duplicated Incoming Packets
1937-------------------------------- 2008--------------------------------
1938 2009
2010 NOTE: Starting with version 3.0.2, the bonding driver has logic to
2011suppress duplicate packets, which should largely eliminate this problem.
2012The following description is kept for reference.
2013
1939 It is not uncommon to observe a short burst of duplicated 2014 It is not uncommon to observe a short burst of duplicated
1940traffic when the bonding device is first used, or after it has been 2015traffic when the bonding device is first used, or after it has been
1941idle for some period of time. This is most easily observed by issuing 2016idle for some period of time. This is most easily observed by issuing
@@ -2096,6 +2171,9 @@ The new driver was designed to be SMP safe from the start.
2096EtherExpress PRO/100 and a 3com 3c905b, for example). For most modes, 2171EtherExpress PRO/100 and a 3com 3c905b, for example). For most modes,
2097devices need not be of the same speed. 2172devices need not be of the same speed.
2098 2173
2174 Starting with version 3.2.1, bonding also supports Infiniband
2175slaves in active-backup mode.
2176
20993. How many bonding devices can I have? 21773. How many bonding devices can I have?
2100 2178
2101 There is no limit. 2179 There is no limit.
@@ -2154,11 +2232,15 @@ switches currently available support 802.3ad.
2154 2232
21558. Where does a bonding device get its MAC address from? 22338. Where does a bonding device get its MAC address from?
2156 2234
2157 If not explicitly configured (with ifconfig or ip link), the 2235 When using slave devices that have fixed MAC addresses, or when
2158MAC address of the bonding device is taken from its first slave 2236the fail_over_mac option is enabled, the bonding device's MAC address is
2159device. This MAC address is then passed to all following slaves and 2237the MAC address of the active slave.
2160remains persistent (even if the first slave is removed) until the 2238
2161bonding device is brought down or reconfigured. 2239 For other configurations, if not explicitly configured (with
2240ifconfig or ip link), the MAC address of the bonding device is taken from
2241its first slave device. This MAC address is then passed to all following
2242slaves and remains persistent (even if the first slave is removed) until
2243the bonding device is brought down or reconfigured.
2162 2244
2163 If you wish to change the MAC address, you can set it with 2245 If you wish to change the MAC address, you can set it with
2164ifconfig or ip link: 2246ifconfig or ip link:
diff --git a/Documentation/networking/can.txt b/Documentation/networking/can.txt
new file mode 100644
index 000000000000..f1b2de170929
--- /dev/null
+++ b/Documentation/networking/can.txt
@@ -0,0 +1,629 @@
1============================================================================
2
3can.txt
4
5Readme file for the Controller Area Network Protocol Family (aka Socket CAN)
6
7This file contains
8
9 1 Overview / What is Socket CAN
10
11 2 Motivation / Why using the socket API
12
13 3 Socket CAN concept
14 3.1 receive lists
15 3.2 local loopback of sent frames
16 3.3 network security issues (capabilities)
17 3.4 network problem notifications
18
19 4 How to use Socket CAN
20 4.1 RAW protocol sockets with can_filters (SOCK_RAW)
21 4.1.1 RAW socket option CAN_RAW_FILTER
22 4.1.2 RAW socket option CAN_RAW_ERR_FILTER
23 4.1.3 RAW socket option CAN_RAW_LOOPBACK
24 4.1.4 RAW socket option CAN_RAW_RECV_OWN_MSGS
25 4.2 Broadcast Manager protocol sockets (SOCK_DGRAM)
26 4.3 connected transport protocols (SOCK_SEQPACKET)
27 4.4 unconnected transport protocols (SOCK_DGRAM)
28
29 5 Socket CAN core module
30 5.1 can.ko module params
31 5.2 procfs content
32 5.3 writing own CAN protocol modules
33
34 6 CAN network drivers
35 6.1 general settings
36 6.2 local loopback of sent frames
37 6.3 CAN controller hardware filters
38 6.4 currently supported CAN hardware
39 6.5 todo
40
41 7 Credits
42
43============================================================================
44
451. Overview / What is Socket CAN
46--------------------------------
47
48The socketcan package is an implementation of CAN protocols
49(Controller Area Network) for Linux. CAN is a networking technology
50which has widespread use in automation, embedded devices, and
51automotive fields. While there have been other CAN implementations
52for Linux based on character devices, Socket CAN uses the Berkeley
53socket API, the Linux network stack and implements the CAN device
54drivers as network interfaces. The CAN socket API has been designed
55as similar as possible to the TCP/IP protocols to allow programmers,
56familiar with network programming, to easily learn how to use CAN
57sockets.
58
592. Motivation / Why using the socket API
60----------------------------------------
61
62There have been CAN implementations for Linux before Socket CAN so the
63question arises, why we have started another project. Most existing
64implementations come as a device driver for some CAN hardware, they
65are based on character devices and provide comparatively little
66functionality. Usually, there is only a hardware-specific device
67driver which provides a character device interface to send and
68receive raw CAN frames, directly to/from the controller hardware.
69Queueing of frames and higher-level transport protocols like ISO-TP
70have to be implemented in user space applications. Also, most
71character-device implementations support only one single process to
72open the device at a time, similar to a serial interface. Exchanging
73the CAN controller requires employment of another device driver and
74often the need for adaption of large parts of the application to the
75new driver's API.
76
77Socket CAN was designed to overcome all of these limitations. A new
78protocol family has been implemented which provides a socket interface
79to user space applications and which builds upon the Linux network
80layer, so to use all of the provided queueing functionality. A device
81driver for CAN controller hardware registers itself with the Linux
82network layer as a network device, so that CAN frames from the
83controller can be passed up to the network layer and on to the CAN
84protocol family module and also vice-versa. Also, the protocol family
85module provides an API for transport protocol modules to register, so
86that any number of transport protocols can be loaded or unloaded
87dynamically. In fact, the can core module alone does not provide any
88protocol and cannot be used without loading at least one additional
89protocol module. Multiple sockets can be opened at the same time,
90on different or the same protocol module and they can listen/send
91frames on different or the same CAN IDs. Several sockets listening on
92the same interface for frames with the same CAN ID are all passed the
93same received matching CAN frames. An application wishing to
94communicate using a specific transport protocol, e.g. ISO-TP, just
95selects that protocol when opening the socket, and then can read and
96write application data byte streams, without having to deal with
97CAN-IDs, frames, etc.
98
99Similar functionality visible from user-space could be provided by a
100character device, too, but this would lead to a technically inelegant
101solution for a couple of reasons:
102
103* Intricate usage. Instead of passing a protocol argument to
104 socket(2) and using bind(2) to select a CAN interface and CAN ID, an
105 application would have to do all these operations using ioctl(2)s.
106
107* Code duplication. A character device cannot make use of the Linux
108 network queueing code, so all that code would have to be duplicated
109 for CAN networking.
110
111* Abstraction. In most existing character-device implementations, the
112 hardware-specific device driver for a CAN controller directly
113 provides the character device for the application to work with.
114 This is at least very unusual in Unix systems for both, char and
115 block devices. For example you don't have a character device for a
116 certain UART of a serial interface, a certain sound chip in your
117 computer, a SCSI or IDE controller providing access to your hard
118 disk or tape streamer device. Instead, you have abstraction layers
119 which provide a unified character or block device interface to the
120 application on the one hand, and a interface for hardware-specific
121 device drivers on the other hand. These abstractions are provided
122 by subsystems like the tty layer, the audio subsystem or the SCSI
123 and IDE subsystems for the devices mentioned above.
124
125 The easiest way to implement a CAN device driver is as a character
126 device without such a (complete) abstraction layer, as is done by most
127 existing drivers. The right way, however, would be to add such a
128 layer with all the functionality like registering for certain CAN
129 IDs, supporting several open file descriptors and (de)multiplexing
130 CAN frames between them, (sophisticated) queueing of CAN frames, and
131 providing an API for device drivers to register with. However, then
132 it would be no more difficult, or may be even easier, to use the
133 networking framework provided by the Linux kernel, and this is what
134 Socket CAN does.
135
136 The use of the networking framework of the Linux kernel is just the
137 natural and most appropriate way to implement CAN for Linux.
138
1393. Socket CAN concept
140---------------------
141
142 As described in chapter 2 it is the main goal of Socket CAN to
143 provide a socket interface to user space applications which builds
144 upon the Linux network layer. In contrast to the commonly known
145 TCP/IP and ethernet networking, the CAN bus is a broadcast-only(!)
146 medium that has no MAC-layer addressing like ethernet. The CAN-identifier
147 (can_id) is used for arbitration on the CAN-bus. Therefore the CAN-IDs
148 have to be chosen uniquely on the bus. When designing a CAN-ECU
149 network the CAN-IDs are mapped to be sent by a specific ECU.
150 For this reason a CAN-ID can be treated best as a kind of source address.
151
152 3.1 receive lists
153
154 The network transparent access of multiple applications leads to the
155 problem that different applications may be interested in the same
156 CAN-IDs from the same CAN network interface. The Socket CAN core
157 module - which implements the protocol family CAN - provides several
158 high efficient receive lists for this reason. If e.g. a user space
159 application opens a CAN RAW socket, the raw protocol module itself
160 requests the (range of) CAN-IDs from the Socket CAN core that are
161 requested by the user. The subscription and unsubscription of
162 CAN-IDs can be done for specific CAN interfaces or for all(!) known
163 CAN interfaces with the can_rx_(un)register() functions provided to
164 CAN protocol modules by the SocketCAN core (see chapter 5).
165 To optimize the CPU usage at runtime the receive lists are split up
166 into several specific lists per device that match the requested
167 filter complexity for a given use-case.
168
169 3.2 local loopback of sent frames
170
171 As known from other networking concepts the data exchanging
172 applications may run on the same or different nodes without any
173 change (except for the according addressing information):
174
175 ___ ___ ___ _______ ___
176 | _ | | _ | | _ | | _ _ | | _ |
177 ||A|| ||B|| ||C|| ||A| |B|| ||C||
178 |___| |___| |___| |_______| |___|
179 | | | | |
180 -----------------(1)- CAN bus -(2)---------------
181
182 To ensure that application A receives the same information in the
183 example (2) as it would receive in example (1) there is need for
184 some kind of local loopback of the sent CAN frames on the appropriate
185 node.
186
187 The Linux network devices (by default) just can handle the
188 transmission and reception of media dependent frames. Due to the
189 arbritration on the CAN bus the transmission of a low prio CAN-ID
190 may be delayed by the reception of a high prio CAN frame. To
191 reflect the correct* traffic on the node the loopback of the sent
192 data has to be performed right after a successful transmission. If
193 the CAN network interface is not capable of performing the loopback for
194 some reason the SocketCAN core can do this task as a fallback solution.
195 See chapter 6.2 for details (recommended).
196
197 The loopback functionality is enabled by default to reflect standard
198 networking behaviour for CAN applications. Due to some requests from
199 the RT-SocketCAN group the loopback optionally may be disabled for each
200 separate socket. See sockopts from the CAN RAW sockets in chapter 4.1.
201
202 * = you really like to have this when you're running analyser tools
203 like 'candump' or 'cansniffer' on the (same) node.
204
205 3.3 network security issues (capabilities)
206
207 The Controller Area Network is a local field bus transmitting only
208 broadcast messages without any routing and security concepts.
209 In the majority of cases the user application has to deal with
210 raw CAN frames. Therefore it might be reasonable NOT to restrict
211 the CAN access only to the user root, as known from other networks.
212 Since the currently implemented CAN_RAW and CAN_BCM sockets can only
213 send and receive frames to/from CAN interfaces it does not affect
214 security of others networks to allow all users to access the CAN.
215 To enable non-root users to access CAN_RAW and CAN_BCM protocol
216 sockets the Kconfig options CAN_RAW_USER and/or CAN_BCM_USER may be
217 selected at kernel compile time.
218
219 3.4 network problem notifications
220
221 The use of the CAN bus may lead to several problems on the physical
222 and media access control layer. Detecting and logging of these lower
223 layer problems is a vital requirement for CAN users to identify
224 hardware issues on the physical transceiver layer as well as
225 arbitration problems and error frames caused by the different
226 ECUs. The occurrence of detected errors are important for diagnosis
227 and have to be logged together with the exact timestamp. For this
228 reason the CAN interface driver can generate so called Error Frames
229 that can optionally be passed to the user application in the same
230 way as other CAN frames. Whenever an error on the physical layer
231 or the MAC layer is detected (e.g. by the CAN controller) the driver
232 creates an appropriate error frame. Error frames can be requested by
233 the user application using the common CAN filter mechanisms. Inside
234 this filter definition the (interested) type of errors may be
235 selected. The reception of error frames is disabled by default.
236
2374. How to use Socket CAN
238------------------------
239
240 Like TCP/IP, you first need to open a socket for communicating over a
241 CAN network. Since Socket CAN implements a new protocol family, you
242 need to pass PF_CAN as the first argument to the socket(2) system
243 call. Currently, there are two CAN protocols to choose from, the raw
244 socket protocol and the broadcast manager (BCM). So to open a socket,
245 you would write
246
247 s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
248
249 and
250
251 s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM);
252
253 respectively. After the successful creation of the socket, you would
254 normally use the bind(2) system call to bind the socket to a CAN
255 interface (which is different from TCP/IP due to different addressing
256 - see chapter 3). After binding (CAN_RAW) or connecting (CAN_BCM)
257 the socket, you can read(2) and write(2) from/to the socket or use
258 send(2), sendto(2), sendmsg(2) and the recv* counterpart operations
259 on the socket as usual. There are also CAN specific socket options
260 described below.
261
262 The basic CAN frame structure and the sockaddr structure are defined
263 in include/linux/can.h:
264
265 struct can_frame {
266 canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
267 __u8 can_dlc; /* data length code: 0 .. 8 */
268 __u8 data[8] __attribute__((aligned(8)));
269 };
270
271 The alignment of the (linear) payload data[] to a 64bit boundary
272 allows the user to define own structs and unions to easily access the
273 CAN payload. There is no given byteorder on the CAN bus by
274 default. A read(2) system call on a CAN_RAW socket transfers a
275 struct can_frame to the user space.
276
277 The sockaddr_can structure has an interface index like the
278 PF_PACKET socket, that also binds to a specific interface:
279
280 struct sockaddr_can {
281 sa_family_t can_family;
282 int can_ifindex;
283 union {
284 struct { canid_t rx_id, tx_id; } tp16;
285 struct { canid_t rx_id, tx_id; } tp20;
286 struct { canid_t rx_id, tx_id; } mcnet;
287 struct { canid_t rx_id, tx_id; } isotp;
288 } can_addr;
289 };
290
291 To determine the interface index an appropriate ioctl() has to
292 be used (example for CAN_RAW sockets without error checking):
293
294 int s;
295 struct sockaddr_can addr;
296 struct ifreq ifr;
297
298 s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
299
300 strcpy(ifr.ifr_name, "can0" );
301 ioctl(s, SIOCGIFINDEX, &ifr);
302
303 addr.can_family = AF_CAN;
304 addr.can_ifindex = ifr.ifr_ifindex;
305
306 bind(s, (struct sockaddr *)&addr, sizeof(addr));
307
308 (..)
309
310 To bind a socket to all(!) CAN interfaces the interface index must
311 be 0 (zero). In this case the socket receives CAN frames from every
312 enabled CAN interface. To determine the originating CAN interface
313 the system call recvfrom(2) may be used instead of read(2). To send
314 on a socket that is bound to 'any' interface sendto(2) is needed to
315 specify the outgoing interface.
316
317 Reading CAN frames from a bound CAN_RAW socket (see above) consists
318 of reading a struct can_frame:
319
320 struct can_frame frame;
321
322 nbytes = read(s, &frame, sizeof(struct can_frame));
323
324 if (nbytes < 0) {
325 perror("can raw socket read");
326 return 1;
327 }
328
329 /* paraniod check ... */
330 if (nbytes < sizeof(struct can_frame)) {
331 fprintf(stderr, "read: incomplete CAN frame\n");
332 return 1;
333 }
334
335 /* do something with the received CAN frame */
336
337 Writing CAN frames can be done similarly, with the write(2) system call:
338
339 nbytes = write(s, &frame, sizeof(struct can_frame));
340
341 When the CAN interface is bound to 'any' existing CAN interface
342 (addr.can_ifindex = 0) it is recommended to use recvfrom(2) if the
343 information about the originating CAN interface is needed:
344
345 struct sockaddr_can addr;
346 struct ifreq ifr;
347 socklen_t len = sizeof(addr);
348 struct can_frame frame;
349
350 nbytes = recvfrom(s, &frame, sizeof(struct can_frame),
351 0, (struct sockaddr*)&addr, &len);
352
353 /* get interface name of the received CAN frame */
354 ifr.ifr_ifindex = addr.can_ifindex;
355 ioctl(s, SIOCGIFNAME, &ifr);
356 printf("Received a CAN frame from interface %s", ifr.ifr_name);
357
358 To write CAN frames on sockets bound to 'any' CAN interface the
359 outgoing interface has to be defined certainly.
360
361 strcpy(ifr.ifr_name, "can0");
362 ioctl(s, SIOCGIFINDEX, &ifr);
363 addr.can_ifindex = ifr.ifr_ifindex;
364 addr.can_family = AF_CAN;
365
366 nbytes = sendto(s, &frame, sizeof(struct can_frame),
367 0, (struct sockaddr*)&addr, sizeof(addr));
368
369 4.1 RAW protocol sockets with can_filters (SOCK_RAW)
370
371 Using CAN_RAW sockets is extensively comparable to the commonly
372 known access to CAN character devices. To meet the new possibilities
373 provided by the multi user SocketCAN approach, some reasonable
374 defaults are set at RAW socket binding time:
375
376 - The filters are set to exactly one filter receiving everything
377 - The socket only receives valid data frames (=> no error frames)
378 - The loopback of sent CAN frames is enabled (see chapter 3.2)
379 - The socket does not receive its own sent frames (in loopback mode)
380
381 These default settings may be changed before or after binding the socket.
382 To use the referenced definitions of the socket options for CAN_RAW
383 sockets, include <linux/can/raw.h>.
384
385 4.1.1 RAW socket option CAN_RAW_FILTER
386
387 The reception of CAN frames using CAN_RAW sockets can be controlled
388 by defining 0 .. n filters with the CAN_RAW_FILTER socket option.
389
390 The CAN filter structure is defined in include/linux/can.h:
391
392 struct can_filter {
393 canid_t can_id;
394 canid_t can_mask;
395 };
396
397 A filter matches, when
398
399 <received_can_id> & mask == can_id & mask
400
401 which is analogous to known CAN controllers hardware filter semantics.
402 The filter can be inverted in this semantic, when the CAN_INV_FILTER
403 bit is set in can_id element of the can_filter structure. In
404 contrast to CAN controller hardware filters the user may set 0 .. n
405 receive filters for each open socket separately:
406
407 struct can_filter rfilter[2];
408
409 rfilter[0].can_id = 0x123;
410 rfilter[0].can_mask = CAN_SFF_MASK;
411 rfilter[1].can_id = 0x200;
412 rfilter[1].can_mask = 0x700;
413
414 setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));
415
416 To disable the reception of CAN frames on the selected CAN_RAW socket:
417
418 setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0);
419
420 To set the filters to zero filters is quite obsolete as not read
421 data causes the raw socket to discard the received CAN frames. But
422 having this 'send only' use-case we may remove the receive list in the
423 Kernel to save a little (really a very little!) CPU usage.
424
425 4.1.2 RAW socket option CAN_RAW_ERR_FILTER
426
427 As described in chapter 3.4 the CAN interface driver can generate so
428 called Error Frames that can optionally be passed to the user
429 application in the same way as other CAN frames. The possible
430 errors are divided into different error classes that may be filtered
431 using the appropriate error mask. To register for every possible
432 error condition CAN_ERR_MASK can be used as value for the error mask.
433 The values for the error mask are defined in linux/can/error.h .
434
435 can_err_mask_t err_mask = ( CAN_ERR_TX_TIMEOUT | CAN_ERR_BUSOFF );
436
437 setsockopt(s, SOL_CAN_RAW, CAN_RAW_ERR_FILTER,
438 &err_mask, sizeof(err_mask));
439
440 4.1.3 RAW socket option CAN_RAW_LOOPBACK
441
442 To meet multi user needs the local loopback is enabled by default
443 (see chapter 3.2 for details). But in some embedded use-cases
444 (e.g. when only one application uses the CAN bus) this loopback
445 functionality can be disabled (separately for each socket):
446
447 int loopback = 0; /* 0 = disabled, 1 = enabled (default) */
448
449 setsockopt(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK, &loopback, sizeof(loopback));
450
451 4.1.4 RAW socket option CAN_RAW_RECV_OWN_MSGS
452
453 When the local loopback is enabled, all the sent CAN frames are
454 looped back to the open CAN sockets that registered for the CAN
455 frames' CAN-ID on this given interface to meet the multi user
456 needs. The reception of the CAN frames on the same socket that was
457 sending the CAN frame is assumed to be unwanted and therefore
458 disabled by default. This default behaviour may be changed on
459 demand:
460
461 int recv_own_msgs = 1; /* 0 = disabled (default), 1 = enabled */
462
463 setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS,
464 &recv_own_msgs, sizeof(recv_own_msgs));
465
466 4.2 Broadcast Manager protocol sockets (SOCK_DGRAM)
467 4.3 connected transport protocols (SOCK_SEQPACKET)
468 4.4 unconnected transport protocols (SOCK_DGRAM)
469
470
4715. Socket CAN core module
472-------------------------
473
474 The Socket CAN core module implements the protocol family
475 PF_CAN. CAN protocol modules are loaded by the core module at
476 runtime. The core module provides an interface for CAN protocol
477 modules to subscribe needed CAN IDs (see chapter 3.1).
478
479 5.1 can.ko module params
480
481 - stats_timer: To calculate the Socket CAN core statistics
482 (e.g. current/maximum frames per second) this 1 second timer is
483 invoked at can.ko module start time by default. This timer can be
484 disabled by using stattimer=0 on the module comandline.
485
486 - debug: (removed since SocketCAN SVN r546)
487
488 5.2 procfs content
489
490 As described in chapter 3.1 the Socket CAN core uses several filter
491 lists to deliver received CAN frames to CAN protocol modules. These
492 receive lists, their filters and the count of filter matches can be
493 checked in the appropriate receive list. All entries contain the
494 device and a protocol module identifier:
495
496 foo@bar:~$ cat /proc/net/can/rcvlist_all
497
498 receive list 'rx_all':
499 (vcan3: no entry)
500 (vcan2: no entry)
501 (vcan1: no entry)
502 device can_id can_mask function userdata matches ident
503 vcan0 000 00000000 f88e6370 f6c6f400 0 raw
504 (any: no entry)
505
506 In this example an application requests any CAN traffic from vcan0.
507
508 rcvlist_all - list for unfiltered entries (no filter operations)
509 rcvlist_eff - list for single extended frame (EFF) entries
510 rcvlist_err - list for error frames masks
511 rcvlist_fil - list for mask/value filters
512 rcvlist_inv - list for mask/value filters (inverse semantic)
513 rcvlist_sff - list for single standard frame (SFF) entries
514
515 Additional procfs files in /proc/net/can
516
517 stats - Socket CAN core statistics (rx/tx frames, match ratios, ...)
518 reset_stats - manual statistic reset
519 version - prints the Socket CAN core version and the ABI version
520
521 5.3 writing own CAN protocol modules
522
523 To implement a new protocol in the protocol family PF_CAN a new
524 protocol has to be defined in include/linux/can.h .
525 The prototypes and definitions to use the Socket CAN core can be
526 accessed by including include/linux/can/core.h .
527 In addition to functions that register the CAN protocol and the
528 CAN device notifier chain there are functions to subscribe CAN
529 frames received by CAN interfaces and to send CAN frames:
530
531 can_rx_register - subscribe CAN frames from a specific interface
532 can_rx_unregister - unsubscribe CAN frames from a specific interface
533 can_send - transmit a CAN frame (optional with local loopback)
534
535 For details see the kerneldoc documentation in net/can/af_can.c or
536 the source code of net/can/raw.c or net/can/bcm.c .
537
5386. CAN network drivers
539----------------------
540
541 Writing a CAN network device driver is much easier than writing a
542 CAN character device driver. Similar to other known network device
543 drivers you mainly have to deal with:
544
545 - TX: Put the CAN frame from the socket buffer to the CAN controller.
546 - RX: Put the CAN frame from the CAN controller to the socket buffer.
547
548 See e.g. at Documentation/networking/netdevices.txt . The differences
549 for writing CAN network device driver are described below:
550
551 6.1 general settings
552
553 dev->type = ARPHRD_CAN; /* the netdevice hardware type */
554 dev->flags = IFF_NOARP; /* CAN has no arp */
555
556 dev->mtu = sizeof(struct can_frame);
557
558 The struct can_frame is the payload of each socket buffer in the
559 protocol family PF_CAN.
560
561 6.2 local loopback of sent frames
562
563 As described in chapter 3.2 the CAN network device driver should
564 support a local loopback functionality similar to the local echo
565 e.g. of tty devices. In this case the driver flag IFF_ECHO has to be
566 set to prevent the PF_CAN core from locally echoing sent frames
567 (aka loopback) as fallback solution:
568
569 dev->flags = (IFF_NOARP | IFF_ECHO);
570
571 6.3 CAN controller hardware filters
572
573 To reduce the interrupt load on deep embedded systems some CAN
574 controllers support the filtering of CAN IDs or ranges of CAN IDs.
575 These hardware filter capabilities vary from controller to
576 controller and have to be identified as not feasible in a multi-user
577 networking approach. The use of the very controller specific
578 hardware filters could make sense in a very dedicated use-case, as a
579 filter on driver level would affect all users in the multi-user
580 system. The high efficient filter sets inside the PF_CAN core allow
581 to set different multiple filters for each socket separately.
582 Therefore the use of hardware filters goes to the category 'handmade
583 tuning on deep embedded systems'. The author is running a MPC603e
584 @133MHz with four SJA1000 CAN controllers from 2002 under heavy bus
585 load without any problems ...
586
587 6.4 currently supported CAN hardware (September 2007)
588
589 On the project website http://developer.berlios.de/projects/socketcan
590 there are different drivers available:
591
592 vcan: Virtual CAN interface driver (if no real hardware is available)
593 sja1000: Philips SJA1000 CAN controller (recommended)
594 i82527: Intel i82527 CAN controller
595 mscan: Motorola/Freescale CAN controller (e.g. inside SOC MPC5200)
596 ccan: CCAN controller core (e.g. inside SOC h7202)
597 slcan: For a bunch of CAN adaptors that are attached via a
598 serial line ASCII protocol (for serial / USB adaptors)
599
600 Additionally the different CAN adaptors (ISA/PCI/PCMCIA/USB/Parport)
601 from PEAK Systemtechnik support the CAN netdevice driver model
602 since Linux driver v6.0: http://www.peak-system.com/linux/index.htm
603
604 Please check the Mailing Lists on the berlios OSS project website.
605
606 6.5 todo (September 2007)
607
608 The configuration interface for CAN network drivers is still an open
609 issue that has not been finalized in the socketcan project. Also the
610 idea of having a library module (candev.ko) that holds functions
611 that are needed by all CAN netdevices is not ready to ship.
612 Your contribution is welcome.
613
6147. Credits
615----------
616
617 Oliver Hartkopp (PF_CAN core, filters, drivers, bcm)
618 Urs Thuermann (PF_CAN core, kernel integration, socket interfaces, raw, vcan)
619 Jan Kizka (RT-SocketCAN core, Socket-API reconciliation)
620 Wolfgang Grandegger (RT-SocketCAN core & drivers, Raw Socket-API reviews)
621 Robert Schwebel (design reviews, PTXdist integration)
622 Marc Kleine-Budde (design reviews, Kernel 2.6 cleanups, drivers)
623 Benedikt Spranger (reviews)
624 Thomas Gleixner (LKML reviews, coding style, posting hints)
625 Andrey Volkov (kernel subtree structure, ioctls, mscan driver)
626 Matthias Brukner (first SJA1000 CAN netdevice implementation Q2/2003)
627 Klaus Hitschler (PEAK driver integration)
628 Uwe Koppe (CAN netdevices with PF_PACKET approach)
629 Michael Schulze (driver layer loopback requirement, RT CAN drivers review)
diff --git a/Documentation/networking/dccp.txt b/Documentation/networking/dccp.txt
index afb66f9a8aff..39131a3c78f8 100644
--- a/Documentation/networking/dccp.txt
+++ b/Documentation/networking/dccp.txt
@@ -14,24 +14,35 @@ Introduction
14============ 14============
15 15
16Datagram Congestion Control Protocol (DCCP) is an unreliable, connection 16Datagram Congestion Control Protocol (DCCP) is an unreliable, connection
17based protocol designed to solve issues present in UDP and TCP particularly 17oriented protocol designed to solve issues present in UDP and TCP, particularly
18for real time and multimedia traffic. 18for real-time and multimedia (streaming) traffic.
19It divides into a base protocol (RFC 4340) and plugable congestion control
20modules called CCIDs. Like plugable TCP congestion control, at least one CCID
21needs to be enabled in order for the protocol to function properly. In the Linux
22implementation, this is the TCP-like CCID2 (RFC 4341). Additional CCIDs, such as
23the TCP-friendly CCID3 (RFC 4342), are optional.
24For a brief introduction to CCIDs and suggestions for choosing a CCID to match
25given applications, see section 10 of RFC 4340.
19 26
20It has a base protocol and pluggable congestion control IDs (CCIDs). 27It has a base protocol and pluggable congestion control IDs (CCIDs).
21 28
22It is at proposed standard RFC status and the homepage for DCCP as a protocol 29DCCP is a Proposed Standard (RFC 2026), and the homepage for DCCP as a protocol
23is at: 30is at http://www.ietf.org/html.charters/dccp-charter.html
24 http://www.read.cs.ucla.edu/dccp/
25 31
26Missing features 32Missing features
27================ 33================
28 34
29The DCCP implementation does not currently have all the features that are in 35The Linux DCCP implementation does not currently support all the features that are
30the RFC. 36specified in RFCs 4340...42.
31 37
32The known bugs are at: 38The known bugs are at:
33 http://linux-net.osdl.org/index.php/TODO#DCCP 39 http://linux-net.osdl.org/index.php/TODO#DCCP
34 40
41For more up-to-date versions of the DCCP implementation, please consider using
42the experimental DCCP test tree; instructions for checking this out are on:
43http://linux-net.osdl.org/index.php/DCCP_Testing#Experimental_DCCP_source_tree
44
45
35Socket options 46Socket options
36============== 47==============
37 48
@@ -46,6 +57,12 @@ can be set before calling bind().
46DCCP_SOCKOPT_GET_CUR_MPS is read-only and retrieves the current maximum packet 57DCCP_SOCKOPT_GET_CUR_MPS is read-only and retrieves the current maximum packet
47size (application payload size) in bytes, see RFC 4340, section 14. 58size (application payload size) in bytes, see RFC 4340, section 14.
48 59
60DCCP_SOCKOPT_SERVER_TIMEWAIT enables the server (listening socket) to hold
61timewait state when closing the connection (RFC 4340, 8.3). The usual case is
62that the closing server sends a CloseReq, whereupon the client holds timewait
63state. When this boolean socket option is on, the server sends a Close instead
64and will enter TIMEWAIT. This option must be set after accept() returns.
65
49DCCP_SOCKOPT_SEND_CSCOV and DCCP_SOCKOPT_RECV_CSCOV are used for setting the 66DCCP_SOCKOPT_SEND_CSCOV and DCCP_SOCKOPT_RECV_CSCOV are used for setting the
50partial checksum coverage (RFC 4340, sec. 9.2). The default is that checksums 67partial checksum coverage (RFC 4340, sec. 9.2). The default is that checksums
51always cover the entire packet and that only fully covered application data is 68always cover the entire packet and that only fully covered application data is
@@ -72,6 +89,8 @@ DCCP_SOCKOPT_CCID_TX_INFO
72 Returns a `struct tfrc_tx_info' in optval; the buffer for optval and 89 Returns a `struct tfrc_tx_info' in optval; the buffer for optval and
73 optlen must be set to at least sizeof(struct tfrc_tx_info). 90 optlen must be set to at least sizeof(struct tfrc_tx_info).
74 91
92On unidirectional connections it is useful to close the unused half-connection
93via shutdown (SHUT_WR or SHUT_RD): this will reduce per-packet processing costs.
75 94
76Sysctl variables 95Sysctl variables
77================ 96================
@@ -123,6 +142,12 @@ sync_ratelimit = 125 ms
123 sequence-invalid packets on the same socket (RFC 4340, 7.5.4). The unit 142 sequence-invalid packets on the same socket (RFC 4340, 7.5.4). The unit
124 of this parameter is milliseconds; a value of 0 disables rate-limiting. 143 of this parameter is milliseconds; a value of 0 disables rate-limiting.
125 144
145IOCTLS
146======
147FIONREAD
148 Works as in udp(7): returns in the `int' argument pointer the size of
149 the next pending datagram in bytes, or 0 when no datagram is pending.
150
126Notes 151Notes
127===== 152=====
128 153
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 6f7872ba1def..17a6e46fbd43 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -446,6 +446,33 @@ tcp_dma_copybreak - INTEGER
446 and CONFIG_NET_DMA is enabled. 446 and CONFIG_NET_DMA is enabled.
447 Default: 4096 447 Default: 4096
448 448
449UDP variables:
450
451udp_mem - vector of 3 INTEGERs: min, pressure, max
452 Number of pages allowed for queueing by all UDP sockets.
453
454 min: Below this number of pages UDP is not bothered about its
455 memory appetite. When amount of memory allocated by UDP exceeds
456 this number, UDP starts to moderate memory usage.
457
458 pressure: This value was introduced to follow format of tcp_mem.
459
460 max: Number of pages allowed for queueing by all UDP sockets.
461
462 Default is calculated at boot time from amount of available memory.
463
464udp_rmem_min - INTEGER
465 Minimal size of receive buffer used by UDP sockets in moderation.
466 Each UDP socket is able to use the size for receiving data, even if
467 total pages of UDP sockets exceed udp_mem pressure. The unit is byte.
468 Default: 4096
469
470udp_wmem_min - INTEGER
471 Minimal size of send buffer used by UDP sockets in moderation.
472 Each UDP socket is able to use the size for sending data, even if
473 total pages of UDP sockets exceed udp_mem pressure. The unit is byte.
474 Default: 4096
475
449CIPSOv4 Variables: 476CIPSOv4 Variables:
450 477
451cipso_cache_enable - BOOLEAN 478cipso_cache_enable - BOOLEAN
diff --git a/Documentation/networking/shaper.txt b/Documentation/networking/shaper.txt
deleted file mode 100644
index 6c4ebb66a906..000000000000
--- a/Documentation/networking/shaper.txt
+++ /dev/null
@@ -1,48 +0,0 @@
1Traffic Shaper For Linux
2
3This is the current BETA release of the traffic shaper for Linux. It works
4within the following limits:
5
6o Minimum shaping speed is currently about 9600 baud (it can only
7shape down to 1 byte per clock tick)
8
9o Maximum is about 256K, it will go above this but get a bit blocky.
10
11o If you ifconfig the master device that a shaper is attached to down
12then your machine will follow.
13
14o The shaper must be a module.
15
16
17Setup:
18
19 A shaper device is configured using the shapeconfig program.
20Typically you will do something like this
21
22shapecfg attach shaper0 eth1
23shapecfg speed shaper0 64000
24ifconfig shaper0 myhost netmask 255.255.255.240 broadcast 1.2.3.4.255 up
25route add -net some.network netmask a.b.c.d dev shaper0
26
27The shaper should have the same IP address as the device it is attached to
28for normal use.
29
30Gotchas:
31
32 The shaper shapes transmitted traffic. It's rather impossible to
33shape received traffic except at the end (or a router) transmitting it.
34
35 Gated/routed/rwhod/mrouted all see the shaper as an additional device
36and will treat it as such unless patched. Note that for mrouted you can run
37mrouted tunnels via a traffic shaper to control bandwidth usage.
38
39 The shaper is device/route based. This makes it very easy to use
40with any setup BUT less flexible. You may need to use iproute2 to set up
41multiple route tables to get the flexibility.
42
43 There is no "borrowing" or "sharing" scheme. This is a simple
44traffic limiter. We implement Van Jacobson and Sally Floyd's CBQ
45architecture into Linux 2.2. This is the preferred solution. Shaper is
46for simple or back compatible setups.
47
48Alan
diff --git a/Documentation/networking/udplite.txt b/Documentation/networking/udplite.txt
index b6409cab075c..3870f280280b 100644
--- a/Documentation/networking/udplite.txt
+++ b/Documentation/networking/udplite.txt
@@ -236,7 +236,7 @@
236 236
237 This displays UDP-Lite statistics variables, whose meaning is as follows. 237 This displays UDP-Lite statistics variables, whose meaning is as follows.
238 238
239 InDatagrams: Total number of received datagrams. 239 InDatagrams: The total number of datagrams delivered to users.
240 240
241 NoPorts: Number of packets received to an unknown port. 241 NoPorts: Number of packets received to an unknown port.
242 These cases are counted separately (not as InErrors). 242 These cases are counted separately (not as InErrors).
diff --git a/Documentation/networking/xfrm_proc.txt b/Documentation/networking/xfrm_proc.txt
new file mode 100644
index 000000000000..53c1a58b02f1
--- /dev/null
+++ b/Documentation/networking/xfrm_proc.txt
@@ -0,0 +1,70 @@
1XFRM proc - /proc/net/xfrm_* files
2==================================
3Masahide NAKAMURA <nakam@linux-ipv6.org>
4
5
6Transformation Statistics
7-------------------------
8xfrm_proc is a statistics shown factor dropped by transformation
9for developer.
10It is a counter designed from current transformation source code
11and defined like linux private MIB.
12
13Inbound statistics
14~~~~~~~~~~~~~~~~~~
15XfrmInError:
16 All errors which is not matched others
17XfrmInBufferError:
18 No buffer is left
19XfrmInHdrError:
20 Header error
21XfrmInNoStates:
22 No state is found
23 i.e. Either inbound SPI, address, or IPsec protocol at SA is wrong
24XfrmInStateProtoError:
25 Transformation protocol specific error
26 e.g. SA key is wrong
27XfrmInStateModeError:
28 Transformation mode specific error
29XfrmInSeqOutOfWindow:
30 Sequence out of window
31XfrmInStateExpired:
32 State is expired
33XfrmInStateMismatch:
34 State has mismatch option
35 e.g. UDP encapsulation type is mismatch
36XfrmInStateInvalid:
37 State is invalid
38XfrmInTmplMismatch:
39 No matching template for states
40 e.g. Inbound SAs are correct but SP rule is wrong
41XfrmInNoPols:
42 No policy is found for states
43 e.g. Inbound SAs are correct but no SP is found
44XfrmInPolBlock:
45 Policy discards
46XfrmInPolError:
47 Policy error
48
49Outbound errors
50~~~~~~~~~~~~~~~
51XfrmOutError:
52 All errors which is not matched others
53XfrmOutBundleGenError:
54 Bundle generation error
55XfrmOutBundleCheckError:
56 Bundle check error
57XfrmOutNoStates:
58 No state is found
59XfrmOutStateProtoError:
60 Transformation protocol specific error
61XfrmOutStateModeError:
62 Transformation mode specific error
63XfrmOutStateExpired:
64 State is expired
65XfrmOutPolBlock:
66 Policy discards
67XfrmOutPolDead:
68 Policy is dead
69XfrmOutPolError:
70 Policy error
diff --git a/Documentation/pnp.txt b/Documentation/pnp.txt
index 481faf515d53..a327db67782a 100644
--- a/Documentation/pnp.txt
+++ b/Documentation/pnp.txt
@@ -17,9 +17,9 @@ The User Interface
17------------------ 17------------------
18 The Linux Plug and Play user interface provides a means to activate PnP devices 18 The Linux Plug and Play user interface provides a means to activate PnP devices
19for legacy and user level drivers that do not support Linux Plug and Play. The 19for legacy and user level drivers that do not support Linux Plug and Play. The
20user interface is integrated into driverfs. 20user interface is integrated into sysfs.
21 21
22In addition to the standard driverfs file the following are created in each 22In addition to the standard sysfs file the following are created in each
23device's directory: 23device's directory:
24id - displays a list of support EISA IDs 24id - displays a list of support EISA IDs
25options - displays possible resource configurations 25options - displays possible resource configurations
diff --git a/Documentation/s390/CommonIO b/Documentation/s390/CommonIO
index 86320aa3fb0b..8fbc0a852870 100644
--- a/Documentation/s390/CommonIO
+++ b/Documentation/s390/CommonIO
@@ -4,6 +4,11 @@ S/390 common I/O-Layer - command line parameters, procfs and debugfs entries
4Command line parameters 4Command line parameters
5----------------------- 5-----------------------
6 6
7* ccw_timeout_log
8
9 Enable logging of debug information in case of ccw device timeouts.
10
11
7* cio_msg = yes | no 12* cio_msg = yes | no
8 13
9 Determines whether information on found devices and sensed device 14 Determines whether information on found devices and sensed device
diff --git a/Documentation/s390/cds.txt b/Documentation/s390/cds.txt
index 3081927cc2d6..c4b7b2bd369a 100644
--- a/Documentation/s390/cds.txt
+++ b/Documentation/s390/cds.txt
@@ -133,7 +133,7 @@ During its startup the Linux/390 system checks for peripheral devices. Each
133of those devices is uniquely defined by a so called subchannel by the ESA/390 133of those devices is uniquely defined by a so called subchannel by the ESA/390
134channel subsystem. While the subchannel numbers are system generated, each 134channel subsystem. While the subchannel numbers are system generated, each
135subchannel also takes a user defined attribute, the so called device number. 135subchannel also takes a user defined attribute, the so called device number.
136Both subchannel number and device number cannot exceed 65535. During driverfs 136Both subchannel number and device number cannot exceed 65535. During sysfs
137initialisation, the information about control unit type and device types that 137initialisation, the information about control unit type and device types that
138imply specific I/O commands (channel command words - CCWs) in order to operate 138imply specific I/O commands (channel command words - CCWs) in order to operate
139the device are gathered. Device drivers can retrieve this set of hardware 139the device are gathered. Device drivers can retrieve this set of hardware
diff --git a/Documentation/scsi/00-INDEX b/Documentation/scsi/00-INDEX
index aa1f7e927834..c2e18e109858 100644
--- a/Documentation/scsi/00-INDEX
+++ b/Documentation/scsi/00-INDEX
@@ -64,8 +64,6 @@ lpfc.txt
64 - LPFC driver release notes 64 - LPFC driver release notes
65megaraid.txt 65megaraid.txt
66 - Common Management Module, shared code handling ioctls for LSI drivers 66 - Common Management Module, shared code handling ioctls for LSI drivers
67ncr53c7xx.txt
68 - info on driver for NCR53c7xx based adapters
69ncr53c8xx.txt 67ncr53c8xx.txt
70 - info on driver for NCR53c8xx based adapters 68 - info on driver for NCR53c8xx based adapters
71osst.txt 69osst.txt
diff --git a/Documentation/scsi/ChangeLog.megaraid_sas b/Documentation/scsi/ChangeLog.megaraid_sas
index 5eb927544990..91c81db0ba71 100644
--- a/Documentation/scsi/ChangeLog.megaraid_sas
+++ b/Documentation/scsi/ChangeLog.megaraid_sas
@@ -1,3 +1,162 @@
11 Release Date : Thur. Nov. 07 16:30:43 PST 2007 -
2 (emaild-id:megaraidlinux@lsi.com)
3 Sumant Patro
4 Bo Yang
5
62 Current Version : 00.00.03.16
73 Older Version : 00.00.03.15
8
91. Increased MFI_POLL_TIMEOUT_SECS to 60 seconds from 10. FW may take
10 a max of 60 seconds to respond to the INIT cmd.
11
121 Release Date : Fri. Sep. 07 16:30:43 PST 2007 -
13 (emaild-id:megaraidlinux@lsi.com)
14 Sumant Patro
15 Bo Yang
16
172 Current Version : 00.00.03.15
183 Older Version : 00.00.03.14
19
201. Added module parameter "poll_mode_io" to support for "polling"
21 (reduced interrupt operation). In this mode, IO completion
22 interrupts are delayed. At the end of initiating IOs, the
23 driver schedules for cmd completion if there are pending cmds
24 to be completed. A timer-based interrupt has also been added
25 to prevent IO completion processing from being delayed
26 indefinitely in the case that no new IOs are initiated.
27
281 Release Date : Fri. Sep. 07 16:30:43 PST 2007 -
29 (emaild-id:megaraidlinux@lsi.com)
30 Sumant Patro
31 Bo Yang
32
332 Current Version : 00.00.03.14
343 Older Version : 00.00.03.13
35
361. Setting the max_sectors_per_req based on max SGL supported by the
37 FW. Prior versions calculated this value from controller info
38 (max_sectors_1, max_sectors_2). For certain controllers/FW,
39 this was resulting in a value greater than max SGL supported
40 by the FW. Issue was first reported by users running LUKS+XFS
41 with megaraid_sas. Thanks to RB for providing the logs and
42 duplication steps that helped to get to the root cause of the
43 issue. 2. Increased MFI_POLL_TIMEOUT_SECS to 60 seconds from
44 10. FW may take a max of 60 seconds to respond to the INIT
45 cmd.
46
471 Release Date : Fri. June. 15 16:30:43 PST 2007 -
48 (emaild-id:megaraidlinux@lsi.com)
49 Sumant Patro
50 Bo Yang
51
522 Current Version : 00.00.03.13
533 Older Version : 00.00.03.12
54
551. Added the megasas_reset_timer routine to intercept cmd timeout and throttle io.
56
57On Fri, 2007-03-16 at 16:44 -0600, James Bottomley wrote:
58It looks like megaraid_sas at least needs this to throttle its commands
59> as they begin to time out. The code keeps the existing transport
60> template use of eh_timed_out (and allows the transport to override the
61> host if they both have this callback).
62>
63> James
64
651 Release Date : Sat May. 12 16:30:43 PST 2007 -
66 (emaild-id:megaraidlinux@lsi.com)
67 Sumant Patro
68 Bo Yang
69
702 Current Version : 00.00.03.12
713 Older Version : 00.00.03.11
72
731. When MegaSAS driver receives reset call from OS, driver waits in reset
74routine for max 3 minutes for all pending command completion. Now driver will
75call completion routine every 5 seconds from the reset routine instead of
76waiting for depending on cmd completion from isr path.
77
781 Release Date : Mon Apr. 30 10:25:52 PST 2007 -
79 (emaild-id:megaraidlinux@lsi.com)
80 Sumant Patro
81 Bo Yang
82
832 Current Version : 00.00.03.11
843 Older Version : 00.00.03.09
85
86 1. Memory Manager for IOCTL removed for 2.6 kernels.
87 pci_alloc_consistent replaced by dma_alloc_coherent. With this
88 change there is no need of memory manager in the driver code
89
90 On Wed, 2007-02-07 at 13:30 -0800, Andrew Morton wrote:
91 > I suspect all this horror is due to stupidity in the DMA API.
92 >
93 > pci_alloc_consistent() just goes and assumes GFP_ATOMIC, whereas
94 > the caller (megasas_mgmt_fw_ioctl) would have been perfectly happy
95 > to use GFP_KERNEL.
96 >
97 > I bet this fixes it
98
99 It does, but the DMA API was expanded to cope with this exact case, so
100 use dma_alloc_coherent() directly in the megaraid code instead. The dev
101 is just &pci_dev->dev.
102
103 James <James.Bottomley@SteelEye.com>
104
105 3. SYNCHRONIZE_CACHE is not supported by FW and thus blocked by driver.
106 4. Hibernation support added
107 5. Performing diskdump while running IO in RHEL 4 was failing. Fixed.
108
1091 Release Date : Fri Feb. 09 14:36:28 PST 2007 -
110 (emaild-id:megaraidlinux@lsi.com)
111 Sumant Patro
112 Bo Yang
113
1142 Current Version : 00.00.03.09
1153 Older Version : 00.00.03.08
116
117i. Under heavy IO mid-layer prints "DRIVER_TIMEOUT" errors
118
119 The driver now waits for 10 seconds to elapse instead of 5 (as in
120 previous release) to resume IO.
121
1221 Release Date : Mon Feb. 05 11:35:24 PST 2007 -
123 (emaild-id:megaraidlinux@lsi.com)
124 Sumant Patro
125 Bo Yang
1262 Current Version : 00.00.03.08
1273 Older Version : 00.00.03.07
128
129i. Under heavy IO mid-layer prints "DRIVER_TIMEOUT" errors
130
131 Fix: The driver is now throttling IO.
132 Checks added in megasas_queue_command to know if FW is able to
133 process commands within timeout period. If number of retries
134 is 2 or greater,the driver stops sending cmd to FW temporarily. IO is
135 resumed if pending cmd count reduces to 16 or 5 seconds has elapsed
136 from the time cmds were last sent to FW.
137
138ii. FW enables WCE bit in Mode Sense cmd for drives that are configured
139 as WriteBack. The OS may send "SYNCHRONIZE_CACHE" cmd when Logical
140 Disks are exposed with WCE=1. User is advised to enable Write Back
141 mode only when the controller has battery backup. At this time
142 Synhronize cache is not supported by the FW. Driver will short-cycle
143 the cmd and return sucess without sending down to FW.
144
1451 Release Date : Sun Jan. 14 11:21:32 PDT 2007 -
146 Sumant Patro <Sumant.Patro@lsil.com>/Bo Yang
1472 Current Version : 00.00.03.07
1483 Older Version : 00.00.03.06
149
150i. bios_param entry added in scsi_host_template that returns disk geometry
151 information.
152
1531 Release Date : Fri Oct 20 11:21:32 PDT 2006 - Sumant Patro <Sumant.Patro@lsil.com>/Bo Yang
1542 Current Version : 00.00.03.06
1553 Older Version : 00.00.03.05
156
1571. Added new memory management module to support the IOCTL memory allocation. For IOCTL we try to allocate from the memory pool created during driver initialization. If mem pool is empty then we allocate at run time.
1582. Added check in megasas_queue_command and dpc/isr routine to see if we have already declared adapter dead
159 (hw_crit_error=1). If hw_crit_error==1, now we donot accept any processing of pending cmds/accept any cmd from OS
1 160
21 Release Date : Mon Oct 02 11:21:32 PDT 2006 - Sumant Patro <Sumant.Patro@lsil.com> 1611 Release Date : Mon Oct 02 11:21:32 PDT 2006 - Sumant Patro <Sumant.Patro@lsil.com>
32 Current Version : 00.00.03.05 1622 Current Version : 00.00.03.05
diff --git a/Documentation/scsi/aacraid.txt b/Documentation/scsi/aacraid.txt
index a8257840695a..d16011a8618e 100644
--- a/Documentation/scsi/aacraid.txt
+++ b/Documentation/scsi/aacraid.txt
@@ -56,6 +56,10 @@ Supported Cards/Chipsets
56 9005:0285:9005:02d1 Adaptec 5405 (Voodoo40) 56 9005:0285:9005:02d1 Adaptec 5405 (Voodoo40)
57 9005:0285:15d9:02d2 SMC AOC-USAS-S8i-LP 57 9005:0285:15d9:02d2 SMC AOC-USAS-S8i-LP
58 9005:0285:15d9:02d3 SMC AOC-USAS-S8iR-LP 58 9005:0285:15d9:02d3 SMC AOC-USAS-S8iR-LP
59 9005:0285:9005:02d4 Adaptec 2045 (Voodoo04 Lite)
60 9005:0285:9005:02d5 Adaptec 2405 (Voodoo40 Lite)
61 9005:0285:9005:02d6 Adaptec 2445 (Voodoo44 Lite)
62 9005:0285:9005:02d7 Adaptec 2805 (Voodoo80 Lite)
59 1011:0046:9005:0364 Adaptec 5400S (Mustang) 63 1011:0046:9005:0364 Adaptec 5400S (Mustang)
60 9005:0287:9005:0800 Adaptec Themisto (Jupiter) 64 9005:0287:9005:0800 Adaptec Themisto (Jupiter)
61 9005:0200:9005:0200 Adaptec Themisto (Jupiter) 65 9005:0200:9005:0200 Adaptec Themisto (Jupiter)
diff --git a/Documentation/scsi/hptiop.txt b/Documentation/scsi/hptiop.txt
index d28a31247d4c..a6eb4add1be6 100644
--- a/Documentation/scsi/hptiop.txt
+++ b/Documentation/scsi/hptiop.txt
@@ -1,9 +1,9 @@
1HIGHPOINT ROCKETRAID 3xxx RAID DRIVER (hptiop) 1HIGHPOINT ROCKETRAID 3xxx/4xxx ADAPTER DRIVER (hptiop)
2 2
3Controller Register Map 3Controller Register Map
4------------------------- 4-------------------------
5 5
6The controller IOP is accessed via PCI BAR0. 6For Intel IOP based adapters, the controller IOP is accessed via PCI BAR0:
7 7
8 BAR0 offset Register 8 BAR0 offset Register
9 0x10 Inbound Message Register 0 9 0x10 Inbound Message Register 0
@@ -18,6 +18,24 @@ The controller IOP is accessed via PCI BAR0.
18 0x40 Inbound Queue Port 18 0x40 Inbound Queue Port
19 0x44 Outbound Queue Port 19 0x44 Outbound Queue Port
20 20
21For Marvell IOP based adapters, the IOP is accessed via PCI BAR0 and BAR1:
22
23 BAR0 offset Register
24 0x20400 Inbound Doorbell Register
25 0x20404 Inbound Interrupt Mask Register
26 0x20408 Outbound Doorbell Register
27 0x2040C Outbound Interrupt Mask Register
28
29 BAR1 offset Register
30 0x0 Inbound Queue Head Pointer
31 0x4 Inbound Queue Tail Pointer
32 0x8 Outbound Queue Head Pointer
33 0xC Outbound Queue Tail Pointer
34 0x10 Inbound Message Register
35 0x14 Outbound Message Register
36 0x40-0x1040 Inbound Queue
37 0x1040-0x2040 Outbound Queue
38
21 39
22I/O Request Workflow 40I/O Request Workflow
23---------------------- 41----------------------
@@ -73,15 +91,9 @@ The driver exposes following sysfs attributes:
73 driver-version R driver version string 91 driver-version R driver version string
74 firmware-version R firmware version string 92 firmware-version R firmware version string
75 93
76The driver registers char device "hptiop" to communicate with HighPoint RAID
77management software. Its ioctl routine acts as a general binary interface
78between the IOP firmware and HighPoint RAID management software. New management
79functions can be implemented in application/firmware without modification
80in driver code.
81
82 94
83----------------------------------------------------------------------------- 95-----------------------------------------------------------------------------
84Copyright (C) 2006 HighPoint Technologies, Inc. All Rights Reserved. 96Copyright (C) 2006-2007 HighPoint Technologies, Inc. All Rights Reserved.
85 97
86 This file is distributed in the hope that it will be useful, 98 This file is distributed in the hope that it will be useful,
87 but WITHOUT ANY WARRANTY; without even the implied warranty of 99 but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/Documentation/scsi/ncr53c7xx.txt b/Documentation/scsi/ncr53c7xx.txt
deleted file mode 100644
index 91e9552d63e5..000000000000
--- a/Documentation/scsi/ncr53c7xx.txt
+++ /dev/null
@@ -1,40 +0,0 @@
1README for WarpEngine/A4000T/A4091 SCSI kernels.
2
3Use the following options to disable options in the SCSI driver.
4
5Using amiboot for example.....
6
7To disable Synchronous Negotiation....
8
9 amiboot -k kernel 53c7xx=nosync:0
10
11To disable Disconnection....
12
13 amiboot -k kernel 53c7xx=nodisconnect:0
14
15To disable certain SCSI devices...
16
17 amiboot -k kernel 53c7xx=validids:0x3F
18
19 this allows only device ID's 0,1,2,3,4 and 5 for linux to handle.
20 (this is a bitmasked field - i.e. each bit represents a SCSI ID)
21
22These commands work on a per controller basis and use the option 'next' to
23move to the next controller in the system.
24
25e.g.
26 amiboot -k kernel 53c7xx=nodisconnect:0,next,nosync:0
27
28 this uses No Disconnection on the first controller and Asynchronous
29 SCSI on the second controller.
30
31Known Issues:
32
33Two devices are known not to function with the default settings of using
34synchronous SCSI. These are the Archive Viper 150 Tape Drive and the
35SyQuest SQ555 removeable hard drive. When using these devices on a controller
36use the 'nosync:0' option.
37
38Please try these options and post any problems/successes to me.
39
40Alan Hourihane <alanh@fairlite.demon.co.uk>
diff --git a/Documentation/video4linux/CARDLIST.cx23885 b/Documentation/video4linux/CARDLIST.cx23885
index 00cb646a4bde..0924e6e142c4 100644
--- a/Documentation/video4linux/CARDLIST.cx23885
+++ b/Documentation/video4linux/CARDLIST.cx23885
@@ -1,5 +1,7 @@
1 0 -> UNKNOWN/GENERIC [0070:3400] 1 0 -> UNKNOWN/GENERIC [0070:3400]
2 1 -> Hauppauge WinTV-HVR1800lp [0070:7600] 2 1 -> Hauppauge WinTV-HVR1800lp [0070:7600]
3 2 -> Hauppauge WinTV-HVR1800 [0070:7800,0070:7801] 3 2 -> Hauppauge WinTV-HVR1800 [0070:7800,0070:7801,0070:7809]
4 3 -> Hauppauge WinTV-HVR1250 [0070:7911] 4 3 -> Hauppauge WinTV-HVR1250 [0070:7911]
5 4 -> DViCO FusionHDTV5 Express [18ac:d500] 5 4 -> DViCO FusionHDTV5 Express [18ac:d500]
6 5 -> Hauppauge WinTV-HVR1500Q [0070:7790,0070:7797]
7 6 -> Hauppauge WinTV-HVR1500 [0070:7710,0070:7717]
diff --git a/Documentation/video4linux/CARDLIST.cx88 b/Documentation/video4linux/CARDLIST.cx88
index 82ac8250e978..bc5593bd9704 100644
--- a/Documentation/video4linux/CARDLIST.cx88
+++ b/Documentation/video4linux/CARDLIST.cx88
@@ -56,3 +56,4 @@
56 55 -> Shenzhen Tungsten Ages Tech TE-DTV-250 / Swann OEM [c180:c980] 56 55 -> Shenzhen Tungsten Ages Tech TE-DTV-250 / Swann OEM [c180:c980]
57 56 -> Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder [0070:9600,0070:9601,0070:9602] 57 56 -> Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder [0070:9600,0070:9601,0070:9602]
58 57 -> ADS Tech Instant Video PCI [1421:0390] 58 57 -> ADS Tech Instant Video PCI [1421:0390]
59 58 -> Pinnacle PCTV HD 800i [11bd:0051]
diff --git a/Documentation/video4linux/CARDLIST.em28xx b/Documentation/video4linux/CARDLIST.em28xx
index 37f0e3cedf43..6a8469f2bcae 100644
--- a/Documentation/video4linux/CARDLIST.em28xx
+++ b/Documentation/video4linux/CARDLIST.em28xx
@@ -1,14 +1,17 @@
1 0 -> Unknown EM2800 video grabber (em2800) [eb1a:2800] 1 0 -> Unknown EM2800 video grabber (em2800) [eb1a:2800]
2 1 -> Unknown EM2820/2840 video grabber (em2820/em2840) 2 1 -> Unknown EM2750/28xx video grabber (em2820/em2840) [eb1a:2750,eb1a:2820,eb1a:2821,eb1a:2860,eb1a:2861,eb1a:2870,eb1a:2881,eb1a:2883]
3 2 -> Terratec Cinergy 250 USB (em2820/em2840) [0ccd:0036] 3 2 -> Terratec Cinergy 250 USB (em2820/em2840) [0ccd:0036]
4 3 -> Pinnacle PCTV USB 2 (em2820/em2840) [2304:0208] 4 3 -> Pinnacle PCTV USB 2 (em2820/em2840) [2304:0208]
5 4 -> Hauppauge WinTV USB 2 (em2820/em2840) [2040:4200] 5 4 -> Hauppauge WinTV USB 2 (em2820/em2840) [2040:4200,2040:4201]
6 5 -> MSI VOX USB 2.0 (em2820/em2840) [eb1a:2820] 6 5 -> MSI VOX USB 2.0 (em2820/em2840)
7 6 -> Terratec Cinergy 200 USB (em2800) 7 6 -> Terratec Cinergy 200 USB (em2800)
8 7 -> Leadtek Winfast USB II (em2800) 8 7 -> Leadtek Winfast USB II (em2800)
9 8 -> Kworld USB2800 (em2800) 9 8 -> Kworld USB2800 (em2800)
10 9 -> Pinnacle Dazzle DVC 90 (em2820/em2840) [2304:0207] 10 9 -> Pinnacle Dazzle DVC 90/DVC 100 (em2820/em2840) [2304:0207,2304:021a]
11 10 -> Hauppauge WinTV HVR 900 (em2880) 11 10 -> Hauppauge WinTV HVR 900 (em2880) [2040:6500]
12 11 -> Terratec Hybrid XS (em2880) 12 11 -> Terratec Hybrid XS (em2880) [0ccd:0042]
13 12 -> Kworld PVR TV 2800 RF (em2820/em2840) 13 12 -> Kworld PVR TV 2800 RF (em2820/em2840)
14 13 -> Terratec Prodigy XS (em2880) 14 13 -> Terratec Prodigy XS (em2880) [0ccd:0047]
15 14 -> Pixelview Prolink PlayTV USB 2.0 (em2820/em2840)
16 15 -> V-Gear PocketTV (em2800)
17 16 -> Hauppauge WinTV HVR 950 (em2880) [2040:6513]
diff --git a/Documentation/video4linux/CARDLIST.ivtv b/Documentation/video4linux/CARDLIST.ivtv
index ddd76a0eb100..a019e27e42b3 100644
--- a/Documentation/video4linux/CARDLIST.ivtv
+++ b/Documentation/video4linux/CARDLIST.ivtv
@@ -16,3 +16,9 @@
1616 -> GOTVIEW PCI DVD2 Deluxe [ffac:0600] 1616 -> GOTVIEW PCI DVD2 Deluxe [ffac:0600]
1717 -> Yuan MPC622 [ff01:d998] 1717 -> Yuan MPC622 [ff01:d998]
1818 -> Digital Cowboy DCT-MTVP1 [1461:bfff] 1818 -> Digital Cowboy DCT-MTVP1 [1461:bfff]
1919 -> Yuan PG600V2/GotView PCI DVD Lite [ffab:0600,ffad:0600]
2020 -> Club3D ZAP-TV1x01 [ffab:0600]
2121 -> AverTV MCE 116 Plus [1461:c439]
2222 -> ASUS Falcon2 [1043:4b66,1043:462e,1043:4b2e]
2323 -> AverMedia PVR-150 Plus [1461:c035]
2424 -> AverMedia EZMaker PCI Deluxe [1461:c03f]
diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134
index a14545300e4c..5d3b6b4d2515 100644
--- a/Documentation/video4linux/CARDLIST.saa7134
+++ b/Documentation/video4linux/CARDLIST.saa7134
@@ -80,7 +80,7 @@
80 79 -> Sedna/MuchTV PC TV Cardbus TV/Radio (ITO25 Rev:2B) 80 79 -> Sedna/MuchTV PC TV Cardbus TV/Radio (ITO25 Rev:2B)
81 80 -> ASUS Digimatrix TV [1043:0210] 81 80 -> ASUS Digimatrix TV [1043:0210]
82 81 -> Philips Tiger reference design [1131:2018] 82 81 -> Philips Tiger reference design [1131:2018]
83 82 -> MSI TV@Anywhere plus [1462:6231] 83 82 -> MSI TV@Anywhere plus [1462:6231,1462:8624]
84 83 -> Terratec Cinergy 250 PCI TV [153b:1160] 84 83 -> Terratec Cinergy 250 PCI TV [153b:1160]
85 84 -> LifeView FlyDVB Trio [5168:0319] 85 84 -> LifeView FlyDVB Trio [5168:0319]
86 85 -> AverTV DVB-T 777 [1461:2c05,1461:2c05] 86 85 -> AverTV DVB-T 777 [1461:2c05,1461:2c05]
@@ -102,7 +102,7 @@
102101 -> Pinnacle PCTV 310i [11bd:002f] 102101 -> Pinnacle PCTV 310i [11bd:002f]
103102 -> Avermedia AVerTV Studio 507 [1461:9715] 103102 -> Avermedia AVerTV Studio 507 [1461:9715]
104103 -> Compro Videomate DVB-T200A 104103 -> Compro Videomate DVB-T200A
105104 -> Hauppauge WinTV-HVR1110 DVB-T/Hybrid [0070:6701] 105104 -> Hauppauge WinTV-HVR1110 DVB-T/Hybrid [0070:6700,0070:6701,0070:6702,0070:6703,0070:6704,0070:6705]
106105 -> Terratec Cinergy HT PCMCIA [153b:1172] 106105 -> Terratec Cinergy HT PCMCIA [153b:1172]
107106 -> Encore ENLTV [1131:2342,1131:2341,3016:2344] 107106 -> Encore ENLTV [1131:2342,1131:2341,3016:2344]
108107 -> Encore ENLTV-FM [1131:230f] 108107 -> Encore ENLTV-FM [1131:230f]
@@ -116,3 +116,16 @@
116115 -> Sabrent PCMCIA TV-PCB05 [0919:2003] 116115 -> Sabrent PCMCIA TV-PCB05 [0919:2003]
117116 -> 10MOONS TM300 TV Card [1131:2304] 117116 -> 10MOONS TM300 TV Card [1131:2304]
118117 -> Avermedia Super 007 [1461:f01d] 118117 -> Avermedia Super 007 [1461:f01d]
119118 -> Beholder BeholdTV 401 [0000:4016]
120119 -> Beholder BeholdTV 403 [0000:4036]
121120 -> Beholder BeholdTV 403 FM [0000:4037]
122121 -> Beholder BeholdTV 405 [0000:4050]
123122 -> Beholder BeholdTV 405 FM [0000:4051]
124123 -> Beholder BeholdTV 407 [0000:4070]
125124 -> Beholder BeholdTV 407 FM [0000:4071]
126125 -> Beholder BeholdTV 409 [0000:4090]
127126 -> Beholder BeholdTV 505 FM/RDS [0000:5051,0000:505B,5ace:5050]
128127 -> Beholder BeholdTV 507 FM/RDS / BeholdTV 509 FM [0000:5071,0000:507B,5ace:5070,5ace:5090]
129128 -> Beholder BeholdTV Columbus TVFM [0000:5201]
130129 -> Beholder BeholdTV 607 / BeholdTV 609 [5ace:6070,5ace:6071,5ace:6072,5ace:6073,5ace:6090,5ace:6091,5ace:6092,5ace:6093]
131130 -> Beholder BeholdTV M6 / BeholdTV M6 Extra [5ace:6190,5ace:6193]
diff --git a/Documentation/video4linux/CARDLIST.tuner b/Documentation/video4linux/CARDLIST.tuner
index a88c02d23805..0e2394695bb8 100644
--- a/Documentation/video4linux/CARDLIST.tuner
+++ b/Documentation/video4linux/CARDLIST.tuner
@@ -52,7 +52,7 @@ tuner=50 - TCL 2002N
52tuner=51 - Philips PAL/SECAM_D (FM 1256 I-H3) 52tuner=51 - Philips PAL/SECAM_D (FM 1256 I-H3)
53tuner=52 - Thomson DTT 7610 (ATSC/NTSC) 53tuner=52 - Thomson DTT 7610 (ATSC/NTSC)
54tuner=53 - Philips FQ1286 54tuner=53 - Philips FQ1286
55tuner=54 - tda8290+75 55tuner=54 - Philips/NXP TDA 8290/8295 + 8275/8275A/18271
56tuner=55 - TCL 2002MB 56tuner=55 - TCL 2002MB
57tuner=56 - Philips PAL/SECAM multi (FQ1216AME MK4) 57tuner=56 - Philips PAL/SECAM multi (FQ1216AME MK4)
58tuner=57 - Philips FQ1236A MK4 58tuner=57 - Philips FQ1236A MK4
@@ -69,7 +69,8 @@ tuner=67 - Philips TD1316 Hybrid Tuner
69tuner=68 - Philips TUV1236D ATSC/NTSC dual in 69tuner=68 - Philips TUV1236D ATSC/NTSC dual in
70tuner=69 - Tena TNF 5335 and similar models 70tuner=69 - Tena TNF 5335 and similar models
71tuner=70 - Samsung TCPN 2121P30A 71tuner=70 - Samsung TCPN 2121P30A
72tuner=71 - Xceive xc3028 72tuner=71 - Xceive xc2028/xc3028 tuner
73tuner=72 - Thomson FE6600 73tuner=72 - Thomson FE6600
74tuner=73 - Samsung TCPG 6121P30A 74tuner=73 - Samsung TCPG 6121P30A
75tuner=75 - Philips TEA5761 FM Radio 75tuner=75 - Philips TEA5761 FM Radio
76tuner=76 - Xceive 5000 tuner
diff --git a/Documentation/video4linux/CARDLIST.usbvision b/Documentation/video4linux/CARDLIST.usbvision
index 3d6850ef0245..0b72d3fee17e 100644
--- a/Documentation/video4linux/CARDLIST.usbvision
+++ b/Documentation/video4linux/CARDLIST.usbvision
@@ -62,3 +62,4 @@
62 61 -> Pinnacle Studio Linx Video input cable (PAL) [2304:0301] 62 61 -> Pinnacle Studio Linx Video input cable (PAL) [2304:0301]
63 62 -> Pinnacle PCTV Bungee USB (PAL) FM [2304:0419] 63 62 -> Pinnacle PCTV Bungee USB (PAL) FM [2304:0419]
64 63 -> Hauppauge WinTv-USB [2400:4200] 64 63 -> Hauppauge WinTv-USB [2400:4200]
65 64 -> Pinnacle Studio PCTV USB (NTSC) FM V3 [2304:0113]
diff --git a/Documentation/video4linux/extract_xc3028.pl b/Documentation/video4linux/extract_xc3028.pl
new file mode 100644
index 000000000000..cced8ac5c543
--- /dev/null
+++ b/Documentation/video4linux/extract_xc3028.pl
@@ -0,0 +1,926 @@
1#!/usr/bin/perl
2
3# Copyright (c) Mauro Carvalho Chehab <mchehab@infradead.org>
4# Released under GPLv2
5#
6# In order to use, you need to:
7# 1) Download the windows driver with something like:
8# wget http://www.steventoth.net/linux/xc5000/HVR-12x0-14x0-17x0_1_25_25271_WHQL.zip
9# 2) Extract the file hcw85bda.sys from the zip into the current dir:
10# unzip -j HVR-12x0-14x0-17x0_1_25_25271_WHQL.zip Driver85/hcw85bda.sys
11# 3) run the script:
12# ./extract_xc3028.pl
13# 4) copy the generated file:
14# cp xc3028-v27.fw /lib/firmware
15
16#use strict;
17use IO::Handle;
18
19my $debug=0;
20
21sub verify ($$)
22{
23 my ($filename, $hash) = @_;
24 my ($testhash);
25
26 if (system("which md5sum > /dev/null 2>&1")) {
27 die "This firmware requires the md5sum command - see http://www.gnu.org/software/coreutils/\n";
28 }
29
30 open(CMD, "md5sum ".$filename."|");
31 $testhash = <CMD>;
32 $testhash =~ /([a-zA-Z0-9]*)/;
33 $testhash = $1;
34 close CMD;
35 die "Hash of extracted file does not match (found $testhash, expected $hash!\n" if ($testhash ne $hash);
36}
37
38sub get_hunk ($$)
39{
40 my ($offset, $length) = @_;
41 my ($chunklength, $buf, $rcount, $out);
42
43 sysseek(INFILE, $offset, SEEK_SET);
44 while ($length > 0) {
45 # Calc chunk size
46 $chunklength = 2048;
47 $chunklength = $length if ($chunklength > $length);
48
49 $rcount = sysread(INFILE, $buf, $chunklength);
50 die "Ran out of data\n" if ($rcount != $chunklength);
51 $out .= $buf;
52 $length -= $rcount;
53 }
54 return $out;
55}
56
57sub write_le16($)
58{
59 my $val = shift;
60 my $msb = ($val >> 8) &0xff;
61 my $lsb = $val & 0xff;
62
63 syswrite(OUTFILE, chr($lsb).chr($msb));
64}
65
66sub write_le32($)
67{
68 my $val = shift;
69 my $l3 = ($val >> 24) & 0xff;
70 my $l2 = ($val >> 16) & 0xff;
71 my $l1 = ($val >> 8) & 0xff;
72 my $l0 = $val & 0xff;
73
74 syswrite(OUTFILE, chr($l0).chr($l1).chr($l2).chr($l3));
75}
76
77sub write_le64($$)
78{
79 my $msb_val = shift;
80 my $lsb_val = shift;
81 my $l7 = ($msb_val >> 24) & 0xff;
82 my $l6 = ($msb_val >> 16) & 0xff;
83 my $l5 = ($msb_val >> 8) & 0xff;
84 my $l4 = $msb_val & 0xff;
85
86 my $l3 = ($lsb_val >> 24) & 0xff;
87 my $l2 = ($lsb_val >> 16) & 0xff;
88 my $l1 = ($lsb_val >> 8) & 0xff;
89 my $l0 = $lsb_val & 0xff;
90
91 syswrite(OUTFILE,
92 chr($l0).chr($l1).chr($l2).chr($l3).
93 chr($l4).chr($l5).chr($l6).chr($l7));
94}
95
96sub write_hunk($$)
97{
98 my ($offset, $length) = @_;
99 my $out = get_hunk($offset, $length);
100
101 printf "(len %d) ",$length if ($debug);
102
103 for (my $i=0;$i<$length;$i++) {
104 printf "%02x ",ord(substr($out,$i,1)) if ($debug);
105 }
106 printf "\n" if ($debug);
107
108 syswrite(OUTFILE, $out);
109}
110
111sub write_hunk_fix_endian($$)
112{
113 my ($offset, $length) = @_;
114 my $out = get_hunk($offset, $length);
115
116 printf "(len_fix %d) ",$length if ($debug);
117
118 for (my $i=0;$i<$length;$i++) {
119 printf "%02x ",ord(substr($out,$i,1)) if ($debug);
120 }
121 printf "\n" if ($debug);
122
123 my $i=0;
124 while ($i<$length) {
125 my $size = ord(substr($out,$i,1))*256+ord(substr($out,$i+1,1));
126 syswrite(OUTFILE, substr($out,$i+1,1));
127 syswrite(OUTFILE, substr($out,$i,1));
128 $i+=2;
129 if ($size>0 && $size <0x8000) {
130 for (my $j=0;$j<$size;$j++) {
131 syswrite(OUTFILE, substr($out,$j+$i,1));
132 }
133 $i+=$size;
134 }
135 }
136}
137
138sub main_firmware($$$$)
139{
140 my $out;
141 my $j=0;
142 my $outfile = shift;
143 my $name = shift;
144 my $version = shift;
145 my $nr_desc = shift;
146
147 for ($j = length($name); $j <32; $j++) {
148 $name = $name.chr(0);
149}
150
151 open OUTFILE, ">$outfile";
152 syswrite(OUTFILE, $name);
153 write_le16($version);
154 write_le16($nr_desc);
155
156 #
157 # Firmware 0, type: BASE FW F8MHZ (0x00000003), id: (0000000000000000), size: 8718
158 #
159
160 write_le32(0x00000003); # Type
161 write_le64(0x00000000, 0x00000000); # ID
162 write_le32(8718); # Size
163 write_hunk_fix_endian(813432, 8718);
164
165 #
166 # Firmware 1, type: BASE FW F8MHZ MTS (0x00000007), id: (0000000000000000), size: 8712
167 #
168
169 write_le32(0x00000007); # Type
170 write_le64(0x00000000, 0x00000000); # ID
171 write_le32(8712); # Size
172 write_hunk_fix_endian(822152, 8712);
173
174 #
175 # Firmware 2, type: BASE FW FM (0x00000401), id: (0000000000000000), size: 8562
176 #
177
178 write_le32(0x00000401); # Type
179 write_le64(0x00000000, 0x00000000); # ID
180 write_le32(8562); # Size
181 write_hunk_fix_endian(830872, 8562);
182
183 #
184 # Firmware 3, type: BASE FW FM INPUT1 (0x00000c01), id: (0000000000000000), size: 8576
185 #
186
187 write_le32(0x00000c01); # Type
188 write_le64(0x00000000, 0x00000000); # ID
189 write_le32(8576); # Size
190 write_hunk_fix_endian(839440, 8576);
191
192 #
193 # Firmware 4, type: BASE FW (0x00000001), id: (0000000000000000), size: 8706
194 #
195
196 write_le32(0x00000001); # Type
197 write_le64(0x00000000, 0x00000000); # ID
198 write_le32(8706); # Size
199 write_hunk_fix_endian(848024, 8706);
200
201 #
202 # Firmware 5, type: BASE FW MTS (0x00000005), id: (0000000000000000), size: 8682
203 #
204
205 write_le32(0x00000005); # Type
206 write_le64(0x00000000, 0x00000000); # ID
207 write_le32(8682); # Size
208 write_hunk_fix_endian(856736, 8682);
209
210 #
211 # Firmware 6, type: STD FW (0x00000000), id: PAL/BG A2/A (0000000100000007), size: 161
212 #
213
214 write_le32(0x00000000); # Type
215 write_le64(0x00000001, 0x00000007); # ID
216 write_le32(161); # Size
217 write_hunk_fix_endian(865424, 161);
218
219 #
220 # Firmware 7, type: STD FW MTS (0x00000004), id: PAL/BG A2/A (0000000100000007), size: 169
221 #
222
223 write_le32(0x00000004); # Type
224 write_le64(0x00000001, 0x00000007); # ID
225 write_le32(169); # Size
226 write_hunk_fix_endian(865592, 169);
227
228 #
229 # Firmware 8, type: STD FW (0x00000000), id: PAL/BG A2/B (0000000200000007), size: 161
230 #
231
232 write_le32(0x00000000); # Type
233 write_le64(0x00000002, 0x00000007); # ID
234 write_le32(161); # Size
235 write_hunk_fix_endian(865424, 161);
236
237 #
238 # Firmware 9, type: STD FW MTS (0x00000004), id: PAL/BG A2/B (0000000200000007), size: 169
239 #
240
241 write_le32(0x00000004); # Type
242 write_le64(0x00000002, 0x00000007); # ID
243 write_le32(169); # Size
244 write_hunk_fix_endian(865592, 169);
245
246 #
247 # Firmware 10, type: STD FW (0x00000000), id: PAL/BG NICAM/A (0000000400000007), size: 161
248 #
249
250 write_le32(0x00000000); # Type
251 write_le64(0x00000004, 0x00000007); # ID
252 write_le32(161); # Size
253 write_hunk_fix_endian(866112, 161);
254
255 #
256 # Firmware 11, type: STD FW MTS (0x00000004), id: PAL/BG NICAM/A (0000000400000007), size: 169
257 #
258
259 write_le32(0x00000004); # Type
260 write_le64(0x00000004, 0x00000007); # ID
261 write_le32(169); # Size
262 write_hunk_fix_endian(866280, 169);
263
264 #
265 # Firmware 12, type: STD FW (0x00000000), id: PAL/BG NICAM/B (0000000800000007), size: 161
266 #
267
268 write_le32(0x00000000); # Type
269 write_le64(0x00000008, 0x00000007); # ID
270 write_le32(161); # Size
271 write_hunk_fix_endian(866112, 161);
272
273 #
274 # Firmware 13, type: STD FW MTS (0x00000004), id: PAL/BG NICAM/B (0000000800000007), size: 169
275 #
276
277 write_le32(0x00000004); # Type
278 write_le64(0x00000008, 0x00000007); # ID
279 write_le32(169); # Size
280 write_hunk_fix_endian(866280, 169);
281
282 #
283 # Firmware 14, type: STD FW (0x00000000), id: PAL/DK A2 (00000003000000e0), size: 161
284 #
285
286 write_le32(0x00000000); # Type
287 write_le64(0x00000003, 0x000000e0); # ID
288 write_le32(161); # Size
289 write_hunk_fix_endian(866800, 161);
290
291 #
292 # Firmware 15, type: STD FW MTS (0x00000004), id: PAL/DK A2 (00000003000000e0), size: 169
293 #
294
295 write_le32(0x00000004); # Type
296 write_le64(0x00000003, 0x000000e0); # ID
297 write_le32(169); # Size
298 write_hunk_fix_endian(866968, 169);
299
300 #
301 # Firmware 16, type: STD FW (0x00000000), id: PAL/DK NICAM (0000000c000000e0), size: 161
302 #
303
304 write_le32(0x00000000); # Type
305 write_le64(0x0000000c, 0x000000e0); # ID
306 write_le32(161); # Size
307 write_hunk_fix_endian(867144, 161);
308
309 #
310 # Firmware 17, type: STD FW MTS (0x00000004), id: PAL/DK NICAM (0000000c000000e0), size: 169
311 #
312
313 write_le32(0x00000004); # Type
314 write_le64(0x0000000c, 0x000000e0); # ID
315 write_le32(169); # Size
316 write_hunk_fix_endian(867312, 169);
317
318 #
319 # Firmware 18, type: STD FW (0x00000000), id: SECAM/K1 (0000000000200000), size: 161
320 #
321
322 write_le32(0x00000000); # Type
323 write_le64(0x00000000, 0x00200000); # ID
324 write_le32(161); # Size
325 write_hunk_fix_endian(867488, 161);
326
327 #
328 # Firmware 19, type: STD FW MTS (0x00000004), id: SECAM/K1 (0000000000200000), size: 169
329 #
330
331 write_le32(0x00000004); # Type
332 write_le64(0x00000000, 0x00200000); # ID
333 write_le32(169); # Size
334 write_hunk_fix_endian(867656, 169);
335
336 #
337 # Firmware 20, type: STD FW (0x00000000), id: SECAM/K3 (0000000004000000), size: 161
338 #
339
340 write_le32(0x00000000); # Type
341 write_le64(0x00000000, 0x04000000); # ID
342 write_le32(161); # Size
343 write_hunk_fix_endian(867832, 161);
344
345 #
346 # Firmware 21, type: STD FW MTS (0x00000004), id: SECAM/K3 (0000000004000000), size: 169
347 #
348
349 write_le32(0x00000004); # Type
350 write_le64(0x00000000, 0x04000000); # ID
351 write_le32(169); # Size
352 write_hunk_fix_endian(868000, 169);
353
354 #
355 # Firmware 22, type: STD FW D2633 DTV6 ATSC (0x00010030), id: (0000000000000000), size: 149
356 #
357
358 write_le32(0x00010030); # Type
359 write_le64(0x00000000, 0x00000000); # ID
360 write_le32(149); # Size
361 write_hunk_fix_endian(868176, 149);
362
363 #
364 # Firmware 23, type: STD FW D2620 DTV6 QAM (0x00000068), id: (0000000000000000), size: 149
365 #
366
367 write_le32(0x00000068); # Type
368 write_le64(0x00000000, 0x00000000); # ID
369 write_le32(149); # Size
370 write_hunk_fix_endian(868336, 149);
371
372 #
373 # Firmware 24, type: STD FW D2633 DTV6 QAM (0x00000070), id: (0000000000000000), size: 149
374 #
375
376 write_le32(0x00000070); # Type
377 write_le64(0x00000000, 0x00000000); # ID
378 write_le32(149); # Size
379 write_hunk_fix_endian(868488, 149);
380
381 #
382 # Firmware 25, type: STD FW D2620 DTV7 (0x00000088), id: (0000000000000000), size: 149
383 #
384
385 write_le32(0x00000088); # Type
386 write_le64(0x00000000, 0x00000000); # ID
387 write_le32(149); # Size
388 write_hunk_fix_endian(868648, 149);
389
390 #
391 # Firmware 26, type: STD FW D2633 DTV7 (0x00000090), id: (0000000000000000), size: 149
392 #
393
394 write_le32(0x00000090); # Type
395 write_le64(0x00000000, 0x00000000); # ID
396 write_le32(149); # Size
397 write_hunk_fix_endian(868800, 149);
398
399 #
400 # Firmware 27, type: STD FW D2620 DTV78 (0x00000108), id: (0000000000000000), size: 149
401 #
402
403 write_le32(0x00000108); # Type
404 write_le64(0x00000000, 0x00000000); # ID
405 write_le32(149); # Size
406 write_hunk_fix_endian(868960, 149);
407
408 #
409 # Firmware 28, type: STD FW D2633 DTV78 (0x00000110), id: (0000000000000000), size: 149
410 #
411
412 write_le32(0x00000110); # Type
413 write_le64(0x00000000, 0x00000000); # ID
414 write_le32(149); # Size
415 write_hunk_fix_endian(869112, 149);
416
417 #
418 # Firmware 29, type: STD FW D2620 DTV8 (0x00000208), id: (0000000000000000), size: 149
419 #
420
421 write_le32(0x00000208); # Type
422 write_le64(0x00000000, 0x00000000); # ID
423 write_le32(149); # Size
424 write_hunk_fix_endian(868648, 149);
425
426 #
427 # Firmware 30, type: STD FW D2633 DTV8 (0x00000210), id: (0000000000000000), size: 149
428 #
429
430 write_le32(0x00000210); # Type
431 write_le64(0x00000000, 0x00000000); # ID
432 write_le32(149); # Size
433 write_hunk_fix_endian(868800, 149);
434
435 #
436 # Firmware 31, type: STD FW FM (0x00000400), id: (0000000000000000), size: 135
437 #
438
439 write_le32(0x00000400); # Type
440 write_le64(0x00000000, 0x00000000); # ID
441 write_le32(135); # Size
442 write_hunk_fix_endian(869584, 135);
443
444 #
445 # Firmware 32, type: STD FW (0x00000000), id: PAL/I (0000000000000010), size: 161
446 #
447
448 write_le32(0x00000000); # Type
449 write_le64(0x00000000, 0x00000010); # ID
450 write_le32(161); # Size
451 write_hunk_fix_endian(869728, 161);
452
453 #
454 # Firmware 33, type: STD FW MTS (0x00000004), id: PAL/I (0000000000000010), size: 169
455 #
456
457 write_le32(0x00000004); # Type
458 write_le64(0x00000000, 0x00000010); # ID
459 write_le32(169); # Size
460 write_hunk_fix_endian(869896, 169);
461
462 #
463 # Firmware 34, type: STD FW (0x00000000), id: SECAM/L AM (0000001000400000), size: 169
464 #
465
466 write_le32(0x00000000); # Type
467 write_le64(0x00000010, 0x00400000); # ID
468 write_le32(169); # Size
469 write_hunk_fix_endian(870072, 169);
470
471 #
472 # Firmware 35, type: STD FW (0x00000000), id: SECAM/L NICAM (0000000c00400000), size: 161
473 #
474
475 write_le32(0x00000000); # Type
476 write_le64(0x0000000c, 0x00400000); # ID
477 write_le32(161); # Size
478 write_hunk_fix_endian(870248, 161);
479
480 #
481 # Firmware 36, type: STD FW (0x00000000), id: SECAM/Lc (0000000000800000), size: 161
482 #
483
484 write_le32(0x00000000); # Type
485 write_le64(0x00000000, 0x00800000); # ID
486 write_le32(161); # Size
487 write_hunk_fix_endian(870416, 161);
488
489 #
490 # Firmware 37, type: STD FW (0x00000000), id: NTSC/M Kr (0000000000008000), size: 161
491 #
492
493 write_le32(0x00000000); # Type
494 write_le64(0x00000000, 0x00008000); # ID
495 write_le32(161); # Size
496 write_hunk_fix_endian(870584, 161);
497
498 #
499 # Firmware 38, type: STD FW LCD (0x00001000), id: NTSC/M Kr (0000000000008000), size: 161
500 #
501
502 write_le32(0x00001000); # Type
503 write_le64(0x00000000, 0x00008000); # ID
504 write_le32(161); # Size
505 write_hunk_fix_endian(870752, 161);
506
507 #
508 # Firmware 39, type: STD FW LCD NOGD (0x00003000), id: NTSC/M Kr (0000000000008000), size: 161
509 #
510
511 write_le32(0x00003000); # Type
512 write_le64(0x00000000, 0x00008000); # ID
513 write_le32(161); # Size
514 write_hunk_fix_endian(870920, 161);
515
516 #
517 # Firmware 40, type: STD FW MTS (0x00000004), id: NTSC/M Kr (0000000000008000), size: 169
518 #
519
520 write_le32(0x00000004); # Type
521 write_le64(0x00000000, 0x00008000); # ID
522 write_le32(169); # Size
523 write_hunk_fix_endian(871088, 169);
524
525 #
526 # Firmware 41, type: STD FW (0x00000000), id: NTSC PAL/M PAL/N (000000000000b700), size: 161
527 #
528
529 write_le32(0x00000000); # Type
530 write_le64(0x00000000, 0x0000b700); # ID
531 write_le32(161); # Size
532 write_hunk_fix_endian(871264, 161);
533
534 #
535 # Firmware 42, type: STD FW LCD (0x00001000), id: NTSC PAL/M PAL/N (000000000000b700), size: 161
536 #
537
538 write_le32(0x00001000); # Type
539 write_le64(0x00000000, 0x0000b700); # ID
540 write_le32(161); # Size
541 write_hunk_fix_endian(871432, 161);
542
543 #
544 # Firmware 43, type: STD FW LCD NOGD (0x00003000), id: NTSC PAL/M PAL/N (000000000000b700), size: 161
545 #
546
547 write_le32(0x00003000); # Type
548 write_le64(0x00000000, 0x0000b700); # ID
549 write_le32(161); # Size
550 write_hunk_fix_endian(871600, 161);
551
552 #
553 # Firmware 44, type: STD FW (0x00000000), id: NTSC/M Jp (0000000000002000), size: 161
554 #
555
556 write_le32(0x00000000); # Type
557 write_le64(0x00000000, 0x00002000); # ID
558 write_le32(161); # Size
559 write_hunk_fix_endian(871264, 161);
560
561 #
562 # Firmware 45, type: STD FW MTS (0x00000004), id: NTSC PAL/M PAL/N (000000000000b700), size: 169
563 #
564
565 write_le32(0x00000004); # Type
566 write_le64(0x00000000, 0x0000b700); # ID
567 write_le32(169); # Size
568 write_hunk_fix_endian(871936, 169);
569
570 #
571 # Firmware 46, type: STD FW MTS LCD (0x00001004), id: NTSC PAL/M PAL/N (000000000000b700), size: 169
572 #
573
574 write_le32(0x00001004); # Type
575 write_le64(0x00000000, 0x0000b700); # ID
576 write_le32(169); # Size
577 write_hunk_fix_endian(872112, 169);
578
579 #
580 # Firmware 47, type: STD FW MTS LCD NOGD (0x00003004), id: NTSC PAL/M PAL/N (000000000000b700), size: 169
581 #
582
583 write_le32(0x00003004); # Type
584 write_le64(0x00000000, 0x0000b700); # ID
585 write_le32(169); # Size
586 write_hunk_fix_endian(872288, 169);
587
588 #
589 # Firmware 48, type: SCODE FW HAS IF (0x60000000), IF = 3.28 MHz id: (0000000000000000), size: 192
590 #
591
592 write_le32(0x60000000); # Type
593 write_le64(0x00000000, 0x00000000); # ID
594 write_le16(3280); # IF
595 write_le32(192); # Size
596 write_hunk(811896, 192);
597
598 #
599 # Firmware 49, type: SCODE FW HAS IF (0x60000000), IF = 3.30 MHz id: (0000000000000000), size: 192
600 #
601
602 write_le32(0x60000000); # Type
603 write_le64(0x00000000, 0x00000000); # ID
604 write_le16(3300); # IF
605 write_le32(192); # Size
606 write_hunk(813048, 192);
607
608 #
609 # Firmware 50, type: SCODE FW HAS IF (0x60000000), IF = 3.44 MHz id: (0000000000000000), size: 192
610 #
611
612 write_le32(0x60000000); # Type
613 write_le64(0x00000000, 0x00000000); # ID
614 write_le16(3440); # IF
615 write_le32(192); # Size
616 write_hunk(812280, 192);
617
618 #
619 # Firmware 51, type: SCODE FW HAS IF (0x60000000), IF = 3.46 MHz id: (0000000000000000), size: 192
620 #
621
622 write_le32(0x60000000); # Type
623 write_le64(0x00000000, 0x00000000); # ID
624 write_le16(3460); # IF
625 write_le32(192); # Size
626 write_hunk(812472, 192);
627
628 #
629 # Firmware 52, type: SCODE FW DTV6 ATSC OREN36 HAS IF (0x60210020), IF = 3.80 MHz id: (0000000000000000), size: 192
630 #
631
632 write_le32(0x60210020); # Type
633 write_le64(0x00000000, 0x00000000); # ID
634 write_le16(3800); # IF
635 write_le32(192); # Size
636 write_hunk(809784, 192);
637
638 #
639 # Firmware 53, type: SCODE FW HAS IF (0x60000000), IF = 4.00 MHz id: (0000000000000000), size: 192
640 #
641
642 write_le32(0x60000000); # Type
643 write_le64(0x00000000, 0x00000000); # ID
644 write_le16(4000); # IF
645 write_le32(192); # Size
646 write_hunk(812088, 192);
647
648 #
649 # Firmware 54, type: SCODE FW DTV6 ATSC TOYOTA388 HAS IF (0x60410020), IF = 4.08 MHz id: (0000000000000000), size: 192
650 #
651
652 write_le32(0x60410020); # Type
653 write_le64(0x00000000, 0x00000000); # ID
654 write_le16(4080); # IF
655 write_le32(192); # Size
656 write_hunk(809976, 192);
657
658 #
659 # Firmware 55, type: SCODE FW HAS IF (0x60000000), IF = 4.20 MHz id: (0000000000000000), size: 192
660 #
661
662 write_le32(0x60000000); # Type
663 write_le64(0x00000000, 0x00000000); # ID
664 write_le16(4200); # IF
665 write_le32(192); # Size
666 write_hunk(811704, 192);
667
668 #
669 # Firmware 56, type: SCODE FW MONO HAS IF (0x60008000), IF = 4.32 MHz id: NTSC/M Kr (0000000000008000), size: 192
670 #
671
672 write_le32(0x60008000); # Type
673 write_le64(0x00000000, 0x00008000); # ID
674 write_le16(4320); # IF
675 write_le32(192); # Size
676 write_hunk(808056, 192);
677
678 #
679 # Firmware 57, type: SCODE FW HAS IF (0x60000000), IF = 4.45 MHz id: (0000000000000000), size: 192
680 #
681
682 write_le32(0x60000000); # Type
683 write_le64(0x00000000, 0x00000000); # ID
684 write_le16(4450); # IF
685 write_le32(192); # Size
686 write_hunk(812664, 192);
687
688 #
689 # Firmware 58, type: SCODE FW HAS IF (0x60000000), IF = 4.50 MHz id: NTSC/M Jp (0000000000002000), size: 192
690 #
691
692 write_le32(0x60000000); # Type
693 write_le64(0x00000000, 0x00002000); # ID
694 write_le16(4500); # IF
695 write_le32(192); # Size
696 write_hunk(807672, 192);
697
698 #
699 # Firmware 59, type: SCODE FW LCD NOGD IF HAS IF (0x60023000), IF = 4.60 MHz id: NTSC/M Kr (0000000000008000), size: 192
700 #
701
702 write_le32(0x60023000); # Type
703 write_le64(0x00000000, 0x00008000); # ID
704 write_le16(4600); # IF
705 write_le32(192); # Size
706 write_hunk(807864, 192);
707
708 #
709 # Firmware 60, type: SCODE FW DTV78 ZARLINK456 HAS IF (0x62000100), IF = 4.76 MHz id: (0000000000000000), size: 192
710 #
711
712 write_le32(0x62000100); # Type
713 write_le64(0x00000000, 0x00000000); # ID
714 write_le16(4760); # IF
715 write_le32(192); # Size
716 write_hunk(807288, 192);
717
718 #
719 # Firmware 61, type: SCODE FW HAS IF (0x60000000), IF = 4.94 MHz id: (0000000000000000), size: 192
720 #
721
722 write_le32(0x60000000); # Type
723 write_le64(0x00000000, 0x00000000); # ID
724 write_le16(4940); # IF
725 write_le32(192); # Size
726 write_hunk(811512, 192);
727
728 #
729 # Firmware 62, type: SCODE FW DTV7 ZARLINK456 HAS IF (0x62000080), IF = 5.26 MHz id: (0000000000000000), size: 192
730 #
731
732 write_le32(0x62000080); # Type
733 write_le64(0x00000000, 0x00000000); # ID
734 write_le16(5260); # IF
735 write_le32(192); # Size
736 write_hunk(810552, 192);
737
738 #
739 # Firmware 63, type: SCODE FW MONO HAS IF (0x60008000), IF = 5.32 MHz id: PAL/BG NICAM/B (0000000800000007), size: 192
740 #
741
742 write_le32(0x60008000); # Type
743 write_le64(0x00000008, 0x00000007); # ID
744 write_le16(5320); # IF
745 write_le32(192); # Size
746 write_hunk(810744, 192);
747
748 #
749 # Firmware 64, type: SCODE FW DTV8 CHINA HAS IF (0x64000200), IF = 5.40 MHz id: (0000000000000000), size: 192
750 #
751
752 write_le32(0x64000200); # Type
753 write_le64(0x00000000, 0x00000000); # ID
754 write_le16(5400); # IF
755 write_le32(192); # Size
756 write_hunk(807096, 192);
757
758 #
759 # Firmware 65, type: SCODE FW DTV6 ATSC OREN538 HAS IF (0x60110020), IF = 5.58 MHz id: (0000000000000000), size: 192
760 #
761
762 write_le32(0x60110020); # Type
763 write_le64(0x00000000, 0x00000000); # ID
764 write_le16(5580); # IF
765 write_le32(192); # Size
766 write_hunk(809592, 192);
767
768 #
769 # Firmware 66, type: SCODE FW HAS IF (0x60000000), IF = 5.64 MHz id: PAL/BG A2/B (0000000200000007), size: 192
770 #
771
772 write_le32(0x60000000); # Type
773 write_le64(0x00000002, 0x00000007); # ID
774 write_le16(5640); # IF
775 write_le32(192); # Size
776 write_hunk(808440, 192);
777
778 #
779 # Firmware 67, type: SCODE FW HAS IF (0x60000000), IF = 5.74 MHz id: PAL/BG NICAM/B (0000000800000007), size: 192
780 #
781
782 write_le32(0x60000000); # Type
783 write_le64(0x00000008, 0x00000007); # ID
784 write_le16(5740); # IF
785 write_le32(192); # Size
786 write_hunk(808632, 192);
787
788 #
789 # Firmware 68, type: SCODE FW DTV7 DIBCOM52 HAS IF (0x61000080), IF = 5.90 MHz id: (0000000000000000), size: 192
790 #
791
792 write_le32(0x61000080); # Type
793 write_le64(0x00000000, 0x00000000); # ID
794 write_le16(5900); # IF
795 write_le32(192); # Size
796 write_hunk(810360, 192);
797
798 #
799 # Firmware 69, type: SCODE FW MONO HAS IF (0x60008000), IF = 6.00 MHz id: PAL/I (0000000000000010), size: 192
800 #
801
802 write_le32(0x60008000); # Type
803 write_le64(0x00000000, 0x00000010); # ID
804 write_le16(6000); # IF
805 write_le32(192); # Size
806 write_hunk(808824, 192);
807
808 #
809 # Firmware 70, type: SCODE FW DTV6 QAM F6MHZ HAS IF (0x68000060), IF = 6.20 MHz id: (0000000000000000), size: 192
810 #
811
812 write_le32(0x68000060); # Type
813 write_le64(0x00000000, 0x00000000); # ID
814 write_le16(6200); # IF
815 write_le32(192); # Size
816 write_hunk(809400, 192);
817
818 #
819 # Firmware 71, type: SCODE FW HAS IF (0x60000000), IF = 6.24 MHz id: PAL/I (0000000000000010), size: 192
820 #
821
822 write_le32(0x60000000); # Type
823 write_le64(0x00000000, 0x00000010); # ID
824 write_le16(6240); # IF
825 write_le32(192); # Size
826 write_hunk(808248, 192);
827
828 #
829 # Firmware 72, type: SCODE FW MONO HAS IF (0x60008000), IF = 6.32 MHz id: SECAM/K1 (0000000000200000), size: 192
830 #
831
832 write_le32(0x60008000); # Type
833 write_le64(0x00000000, 0x00200000); # ID
834 write_le16(6320); # IF
835 write_le32(192); # Size
836 write_hunk(811320, 192);
837
838 #
839 # Firmware 73, type: SCODE FW HAS IF (0x60000000), IF = 6.34 MHz id: SECAM/K1 (0000000000200000), size: 192
840 #
841
842 write_le32(0x60000000); # Type
843 write_le64(0x00000000, 0x00200000); # ID
844 write_le16(6340); # IF
845 write_le32(192); # Size
846 write_hunk(809208, 192);
847
848 #
849 # Firmware 74, type: SCODE FW MONO HAS IF (0x60008000), IF = 6.50 MHz id: SECAM/K3 (0000000004000000), size: 192
850 #
851
852 write_le32(0x60008000); # Type
853 write_le64(0x00000000, 0x04000000); # ID
854 write_le16(6500); # IF
855 write_le32(192); # Size
856 write_hunk(811128, 192);
857
858 #
859 # Firmware 75, type: SCODE FW DTV6 ATSC ATI638 HAS IF (0x60090020), IF = 6.58 MHz id: (0000000000000000), size: 192
860 #
861
862 write_le32(0x60090020); # Type
863 write_le64(0x00000000, 0x00000000); # ID
864 write_le16(6580); # IF
865 write_le32(192); # Size
866 write_hunk(807480, 192);
867
868 #
869 # Firmware 76, type: SCODE FW HAS IF (0x60000000), IF = 6.60 MHz id: PAL/DK A2 (00000003000000e0), size: 192
870 #
871
872 write_le32(0x60000000); # Type
873 write_le64(0x00000003, 0x000000e0); # ID
874 write_le16(6600); # IF
875 write_le32(192); # Size
876 write_hunk(809016, 192);
877
878 #
879 # Firmware 77, type: SCODE FW MONO HAS IF (0x60008000), IF = 6.68 MHz id: PAL/DK A2 (00000003000000e0), size: 192
880 #
881
882 write_le32(0x60008000); # Type
883 write_le64(0x00000003, 0x000000e0); # ID
884 write_le16(6680); # IF
885 write_le32(192); # Size
886 write_hunk(810936, 192);
887
888 #
889 # Firmware 78, type: SCODE FW DTV6 ATSC TOYOTA794 HAS IF (0x60810020), IF = 8.14 MHz id: (0000000000000000), size: 192
890 #
891
892 write_le32(0x60810020); # Type
893 write_le64(0x00000000, 0x00000000); # ID
894 write_le16(8140); # IF
895 write_le32(192); # Size
896 write_hunk(810168, 192);
897
898 #
899 # Firmware 79, type: SCODE FW HAS IF (0x60000000), IF = 8.20 MHz id: (0000000000000000), size: 192
900 #
901
902 write_le32(0x60000000); # Type
903 write_le64(0x00000000, 0x00000000); # ID
904 write_le16(8200); # IF
905 write_le32(192); # Size
906 write_hunk(812856, 192);
907}
908
909sub extract_firmware {
910 my $sourcefile = "hcw85bda.sys";
911 my $hash = "0e44dbf63bb0169d57446aec21881ff2";
912 my $outfile = "xc3028-v27.fw";
913 my $name = "xc2028 firmware";
914 my $version = 519;
915 my $nr_desc = 80;
916 my $out;
917
918 verify($sourcefile, $hash);
919
920 open INFILE, "<$sourcefile";
921 main_firmware($outfile, $name, $version, $nr_desc);
922 close INFILE;
923}
924
925extract_firmware;
926printf "Firmwares generated.\n";
diff --git a/Documentation/video4linux/sn9c102.txt b/Documentation/video4linux/sn9c102.txt
index 1ffad19ce891..b26f5195af51 100644
--- a/Documentation/video4linux/sn9c102.txt
+++ b/Documentation/video4linux/sn9c102.txt
@@ -568,6 +568,7 @@ the fingerprint is: '88E8 F32F 7244 68BA 3958 5D40 99DA 5D2A FCE6 35A4'.
568Many thanks to following persons for their contribute (listed in alphabetical 568Many thanks to following persons for their contribute (listed in alphabetical
569order): 569order):
570 570
571- David Anderson for the donation of a webcam;
571- Luca Capello for the donation of a webcam; 572- Luca Capello for the donation of a webcam;
572- Philippe Coval for having helped testing the PAS202BCA image sensor; 573- Philippe Coval for having helped testing the PAS202BCA image sensor;
573- Joao Rodrigo Fuzaro, Joao Limirio, Claudio Filho and Caio Begotti for the 574- Joao Rodrigo Fuzaro, Joao Limirio, Claudio Filho and Caio Begotti for the
diff --git a/Documentation/vm/slabinfo.c b/Documentation/vm/slabinfo.c
index 7047696c47a1..488c1f31b992 100644
--- a/Documentation/vm/slabinfo.c
+++ b/Documentation/vm/slabinfo.c
@@ -1021,7 +1021,7 @@ void read_slab_dir(void)
1021 char *t; 1021 char *t;
1022 int count; 1022 int count;
1023 1023
1024 if (chdir("/sys/slab")) 1024 if (chdir("/sys/kernel/slab"))
1025 fatal("SYSFS support for SLUB not active\n"); 1025 fatal("SYSFS support for SLUB not active\n");
1026 1026
1027 dir = opendir("."); 1027 dir = opendir(".");
diff --git a/Documentation/vm/slub.txt b/Documentation/vm/slub.txt
index d17f324db9f5..dcf8bcf846d6 100644
--- a/Documentation/vm/slub.txt
+++ b/Documentation/vm/slub.txt
@@ -63,7 +63,7 @@ In case you forgot to enable debugging on the kernel command line: It is
63possible to enable debugging manually when the kernel is up. Look at the 63possible to enable debugging manually when the kernel is up. Look at the
64contents of: 64contents of:
65 65
66/sys/slab/<slab name>/ 66/sys/kernel/slab/<slab name>/
67 67
68Look at the writable files. Writing 1 to them will enable the 68Look at the writable files. Writing 1 to them will enable the
69corresponding debug option. All options can be set on a slab that does 69corresponding debug option. All options can be set on a slab that does
diff --git a/Documentation/x86_64/boot-options.txt b/Documentation/x86_64/boot-options.txt
index 945311840a10..34abae4e9442 100644
--- a/Documentation/x86_64/boot-options.txt
+++ b/Documentation/x86_64/boot-options.txt
@@ -110,12 +110,18 @@ Idle loop
110 110
111Rebooting 111Rebooting
112 112
113 reboot=b[ios] | t[riple] | k[bd] [, [w]arm | [c]old] 113 reboot=b[ios] | t[riple] | k[bd] | a[cpi] | e[fi] [, [w]arm | [c]old]
114 bios Use the CPU reboot vector for warm reset 114 bios Use the CPU reboot vector for warm reset
115 warm Don't set the cold reboot flag 115 warm Don't set the cold reboot flag
116 cold Set the cold reboot flag 116 cold Set the cold reboot flag
117 triple Force a triple fault (init) 117 triple Force a triple fault (init)
118 kbd Use the keyboard controller. cold reset (default) 118 kbd Use the keyboard controller. cold reset (default)
119 acpi Use the ACPI RESET_REG in the FADT. If ACPI is not configured or the
120 ACPI reset does not work, the reboot path attempts the reset using
121 the keyboard controller.
122 efi Use efi reset_system runtime service. If EFI is not configured or the
123 EFI reset does not work, the reboot path attempts the reset using
124 the keyboard controller.
119 125
120 Using warm reset will be much faster especially on big memory 126 Using warm reset will be much faster especially on big memory
121 systems because the BIOS will not go through the memory check. 127 systems because the BIOS will not go through the memory check.
diff --git a/Documentation/x86_64/uefi.txt b/Documentation/x86_64/uefi.txt
index 91a98edfb588..7d77120a5184 100644
--- a/Documentation/x86_64/uefi.txt
+++ b/Documentation/x86_64/uefi.txt
@@ -19,6 +19,10 @@ Mechanics:
19- Build the kernel with the following configuration. 19- Build the kernel with the following configuration.
20 CONFIG_FB_EFI=y 20 CONFIG_FB_EFI=y
21 CONFIG_FRAMEBUFFER_CONSOLE=y 21 CONFIG_FRAMEBUFFER_CONSOLE=y
22 If EFI runtime services are expected, the following configuration should
23 be selected.
24 CONFIG_EFI=y
25 CONFIG_EFI_VARS=y or m # optional
22- Create a VFAT partition on the disk 26- Create a VFAT partition on the disk
23- Copy the following to the VFAT partition: 27- Copy the following to the VFAT partition:
24 elilo bootloader with x86_64 support, elilo configuration file, 28 elilo bootloader with x86_64 support, elilo configuration file,
@@ -27,3 +31,8 @@ Mechanics:
27 can be found in the elilo sourceforge project. 31 can be found in the elilo sourceforge project.
28- Boot to EFI shell and invoke elilo choosing the kernel image built 32- Boot to EFI shell and invoke elilo choosing the kernel image built
29 in first step. 33 in first step.
34- If some or all EFI runtime services don't work, you can try following
35 kernel command line parameters to turn off some or all EFI runtime
36 services.
37 noefi turn off all EFI runtime services
38 reboot_type=k turn off EFI reboot runtime service
diff --git a/Documentation/zh_CN/CodingStyle b/Documentation/zh_CN/CodingStyle
new file mode 100644
index 000000000000..ecd9307a641f
--- /dev/null
+++ b/Documentation/zh_CN/CodingStyle
@@ -0,0 +1,701 @@
1Chinese translated version of Documentation/CodingStyle
2
3If you have any comment or update to the content, please post to LKML directly.
4However, if you have problem communicating in English you can also ask the
5Chinese maintainer for help. Contact the Chinese maintainer, if this
6translation is outdated or there is problem with translation.
7
8Chinese maintainer: Zhang Le <r0bertz@gentoo.org>
9---------------------------------------------------------------------
10Documentation/CodingStyle的中文翻译
11
12如果想评论或更新本文的内容,请直接发信到LKML。如果你使用英文交流有困难的话,也可
13以向中文版维护者求助。如果本翻译更新不及时或者翻译存在问题,请联系中文版维护者。
14
15中文版维护者: 张乐 Zhang Le <r0bertz@gentoo.org>
16中文版翻译者: 张乐 Zhang Le <r0bertz@gentoo.org>
17中文版校译者: 王聪 Wang Cong <xiyou.wangcong@gmail.com>
18 wheelz <kernel.zeng@gmail.com>
19 管旭东 Xudong Guan <xudong.guan@gmail.com>
20 Li Zefan <lizf@cn.fujitsu.com>
21 Wang Chen <wangchen@cn.fujitsu.com>
22以下为正文
23---------------------------------------------------------------------
24
25 Linux内核代码风格
26
27这是一个简短的文档,描述了linux内核的首选代码风格。代码风格是因人而异的,而且我
28不愿意把我的观点强加给任何人,不过这里所讲述的是我必须要维护的代码所遵守的风格,
29并且我也希望绝大多数其他代码也能遵守这个风格。请在写代码时至少考虑一下本文所述的
30风格。
31
32首先,我建议你打印一份GNU代码规范,然后不要读它。烧了它,这是一个具有重大象征性
33意义的动作。
34
35不管怎样,现在我们开始:
36
37
38 第一章:缩进
39
40制表符是8个字符,所以缩进也是8个字符。有些异端运动试图将缩进变为4(乃至2)个字符
41深,这几乎相当于尝试将圆周率的值定义为3。
42
43理由:缩进的全部意义就在于清楚的定义一个控制块起止于何处。尤其是当你盯着你的屏幕
44连续看了20小时之后,你将会发现大一点的缩进会使你更容易分辨缩进。
45
46现在,有些人会抱怨8个字符的缩进会使代码向右边移动的太远,在80个字符的终端屏幕上
47就很难读这样的代码。这个问题的答案是,如果你需要3级以上的缩进,不管用何种方式你
48的代码已经有问题了,应该修正你的程序。
49
50简而言之,8个字符的缩进可以让代码更容易阅读,还有一个好处是当你的函数嵌套太深的
51时候可以给你警告。留心这个警告。
52
53在switch语句中消除多级缩进的首选的方式是让“switch”和从属于它的“case”标签对齐于同
54一列,而不要“两次缩进”“case”标签。比如:
55
56 switch (suffix) {
57 case 'G':
58 case 'g':
59 mem <<= 30;
60 break;
61 case 'M':
62 case 'm':
63 mem <<= 20;
64 break;
65 case 'K':
66 case 'k':
67 mem <<= 10;
68 /* fall through */
69 default:
70 break;
71 }
72
73
74不要把多个语句放在一行里,除非你有什么东西要隐藏:
75
76 if (condition) do_this;
77 do_something_everytime;
78
79也不要在一行里放多个赋值语句。内核代码风格超级简单。就是避免可能导致别人误读的表
80达式。
81
82除了注释、文档和Kconfig之外,不要使用空格来缩进,前面的例子是例外,是有意为之。
83
84选用一个好的编辑器,不要在行尾留空格。
85
86
87 第二章:把长的行和字符串打散
88
89代码风格的意义就在于使用平常使用的工具来维持代码的可读性和可维护性。
90
91每一行的长度的限制是80列,我们强烈建议您遵守这个惯例。
92
93长于80列的语句要打散成有意义的片段。每个片段要明显短于原来的语句,而且放置的位置
94也明显的靠右。同样的规则也适用于有很长参数列表的函数头。长字符串也要打散成较短的
95字符串。唯一的例外是超过80列可以大幅度提高可读性并且不会隐藏信息的情况。
96
97void fun(int a, int b, int c)
98{
99 if (condition)
100 printk(KERN_WARNING "Warning this is a long printk with "
101 "3 parameters a: %u b: %u "
102 "c: %u \n", a, b, c);
103 else
104 next_statement;
105}
106
107 第三章:大括号和空格的放置
108
109C语言风格中另外一个常见问题是大括号的放置。和缩进大小不同,选择或弃用某种放置策
110略并没有多少技术上的原因,不过首选的方式,就像Kernighan和Ritchie展示给我们的,是
111把起始大括号放在行尾,而把结束大括号放在行首,所以:
112
113 if (x is true) {
114 we do y
115 }
116
117这适用于所有的非函数语句块(if、switch、for、while、do)。比如:
118
119 switch (action) {
120 case KOBJ_ADD:
121 return "add";
122 case KOBJ_REMOVE:
123 return "remove";
124 case KOBJ_CHANGE:
125 return "change";
126 default:
127 return NULL;
128 }
129
130不过,有一个例外,那就是函数:函数的起始大括号放置于下一行的开头,所以:
131
132 int function(int x)
133 {
134 body of function
135 }
136
137全世界的异端可能会抱怨这个不一致性是……呃……不一致的,不过所有思维健全的人都知道(
138a)K&R是_正确的_,并且(b)K&R是正确的。此外,不管怎样函数都是特殊的(在C语言中
139,函数是不能嵌套的)。
140
141注意结束大括号独自占据一行,除非它后面跟着同一个语句的剩余部分,也就是do语句中的
142“while”或者if语句中的“else”,像这样:
143
144 do {
145 body of do-loop
146 } while (condition);
147
148
149
150 if (x == y) {
151 ..
152 } else if (x > y) {
153 ...
154 } else {
155 ....
156 }
157
158理由:K&R。
159
160也请注意这种大括号的放置方式也能使空(或者差不多空的)行的数量最小化,同时不失可
161读性。因此,由于你的屏幕上的新行是不可再生资源(想想25行的终端屏幕),你将会有更
162多的空行来放置注释。
163
164当只有一个单独的语句的时候,不用加不必要的大括号。
165
166if (condition)
167 action();
168
169这点不适用于本身为某个条件语句的一个分支的单独语句。这时需要在两个分支里都使用大
170括号。
171
172if (condition) {
173 do_this();
174 do_that();
175} else {
176 otherwise();
177}
178
179 3.1:空格
180
181Linux内核的空格使用方式(主要)取决于它是用于函数还是关键字。(大多数)关键字后
182要加一个空格。值得注意的例外是sizeof、typeof、alignof和__attribute__,这些关键字
183某些程度上看起来更像函数(它们在Linux里也常常伴随小括号而使用,尽管在C语言里这样
184的小括号不是必需的,就像“struct fileinfo info”声明过后的“sizeof info”)。
185
186所以在这些关键字之后放一个空格:
187 if, switch, case, for, do, while
188但是不要在sizeof、typeof、alignof或者__attribute__这些关键字之后放空格。例如,
189 s = sizeof(struct file);
190
191不要在小括号里的表达式两侧加空格。这是一个反例:
192
193 s = sizeof( struct file );
194
195当声明指针类型或者返回指针类型的函数时,“*”的首选使用方式是使之靠近变量名或者函
196数名,而不是靠近类型名。例子:
197
198 char *linux_banner;
199 unsigned long long memparse(char *ptr, char **retptr);
200 char *match_strdup(substring_t *s);
201
202在大多数二元和三元操作符两侧使用一个空格,例如下面所有这些操作符:
203
204 = + - < > * / % | & ^ <= >= == != ? :
205
206但是一元操作符后不要加空格:
207 & * + - ~ ! sizeof typeof alignof __attribute__ defined
208
209后缀自加和自减一元操作符前不加空格:
210 ++ --
211
212前缀自加和自减一元操作符后不加空格:
213 ++ --
214
215“.”和“->”结构体成员操作符前后不加空格。
216
217不要在行尾留空白。有些可以自动缩进的编辑器会在新行的行首加入适量的空白,然后你
218就可以直接在那一行输入代码。不过假如你最后没有在那一行输入代码,有些编辑器就不
219会移除已经加入的空白,就像你故意留下一个只有空白的行。包含行尾空白的行就这样产
220生了。
221
222当git发现补丁包含了行尾空白的时候会警告你,并且可以应你的要求去掉行尾空白;不过
223如果你是正在打一系列补丁,这样做会导致后面的补丁失败,因为你改变了补丁的上下文。
224
225
226 第四章:命名
227
228C是一个简朴的语言,你的命名也应该这样。和Modula-2和Pascal程序员不同,C程序员不使
229用类似ThisVariableIsATemporaryCounter这样华丽的名字。C程序员会称那个变量为“tmp”
230,这样写起来会更容易,而且至少不会令其难于理解。
231
232不过,虽然混用大小写的名字是不提倡使用的,但是全局变量还是需要一个具描述性的名字
233。称一个全局函数为“foo”是一个难以饶恕的错误。
234
235全局变量(只有当你真正需要它们的时候再用它)需要有一个具描述性的名字,就像全局函
236数。如果你有一个可以计算活动用户数量的函数,你应该叫它“count_active_users()”或者
237类似的名字,你不应该叫它“cntuser()”。
238
239在函数名中包含函数类型(所谓的匈牙利命名法)是脑子出了问题——编译器知道那些类型而
240且能够检查那些类型,这样做只能把程序员弄糊涂了。难怪微软总是制造出有问题的程序。
241
242本地变量名应该简短,而且能够表达相关的含义。如果你有一些随机的整数型的循环计数器
243,它应该被称为“i”。叫它“loop_counter”并无益处,如果它没有被误解的可能的话。类似
244的,“tmp”可以用来称呼任意类型的临时变量。
245
246如果你怕混淆了你的本地变量名,你就遇到另一个问题了,叫做函数增长荷尔蒙失衡综合症
247。请看第六章(函数)。
248
249
250 第五章:Typedef
251
252不要使用类似“vps_t”之类的东西。
253
254对结构体和指针使用typedef是一个错误。当你在代码里看到:
255
256 vps_t a;
257
258这代表什么意思呢?
259
260相反,如果是这样
261
262 struct virtual_container *a;
263
264你就知道“a”是什么了。
265
266很多人认为typedef“能提高可读性”。实际不是这样的。它们只在下列情况下有用:
267
268 (a) 完全不透明的对象(这种情况下要主动使用typedef来隐藏这个对象实际上是什么)。
269
270 例如:“pte_t”等不透明对象,你只能用合适的访问函数来访问它们。
271
272 注意!不透明性和“访问函数”本身是不好的。我们使用pte_t等类型的原因在于真的是
273 完全没有任何共用的可访问信息。
274
275 (b) 清楚的整数类型,如此,这层抽象就可以帮助消除到底是“int”还是“long”的混淆。
276
277 u8/u16/u32是完全没有问题的typedef,不过它们更符合类别(d)而不是这里。
278
279 再次注意!要这样做,必须事出有因。如果某个变量是“unsigned long“,那么没有必要
280
281 typedef unsigned long myflags_t;
282
283 不过如果有一个明确的原因,比如它在某种情况下可能会是一个“unsigned int”而在
284 其他情况下可能为“unsigned long”,那么就不要犹豫,请务必使用typedef。
285
286 (c) 当你使用sparse按字面的创建一个新类型来做类型检查的时候。
287
288 (d) 和标准C99类型相同的类型,在某些例外的情况下。
289
290 虽然让眼睛和脑筋来适应新的标准类型比如“uint32_t”不需要花很多时间,可是有些
291 人仍然拒绝使用它们。
292
293 因此,Linux特有的等同于标准类型的“u8/u16/u32/u64”类型和它们的有符号类型是被
294 允许的——尽管在你自己的新代码中,它们不是强制要求要使用的。
295
296 当编辑已经使用了某个类型集的已有代码时,你应该遵循那些代码中已经做出的选择。
297
298 (e) 可以在用户空间安全使用的类型。
299
300 在某些用户空间可见的结构体里,我们不能要求C99类型而且不能用上面提到的“u32”
301 类型。因此,我们在与用户空间共享的所有结构体中使用__u32和类似的类型。
302
303可能还有其他的情况,不过基本的规则是永远不要使用typedef,除非你可以明确的应用上
304述某个规则中的一个。
305
306总的来说,如果一个指针或者一个结构体里的元素可以合理的被直接访问到,那么它们就不
307应该是一个typedef。
308
309
310 第六章:函数
311
312函数应该简短而漂亮,并且只完成一件事情。函数应该可以一屏或者两屏显示完(我们都知
313道ISO/ANSI屏幕大小是80x24),只做一件事情,而且把它做好。
314
315一个函数的最大长度是和该函数的复杂度和缩进级数成反比的。所以,如果你有一个理论上
316很简单的只有一个很长(但是简单)的case语句的函数,而且你需要在每个case里做很多很
317小的事情,这样的函数尽管很长,但也是可以的。
318
319不过,如果你有一个复杂的函数,而且你怀疑一个天分不是很高的高中一年级学生可能甚至
320搞不清楚这个函数的目的,你应该严格的遵守前面提到的长度限制。使用辅助函数,并为之
321取个具描述性的名字(如果你觉得它们的性能很重要的话,可以让编译器内联它们,这样的
322效果往往会比你写一个复杂函数的效果要好。)
323
324函数的另外一个衡量标准是本地变量的数量。此数量不应超过5-10个,否则你的函数就有
325问题了。重新考虑一下你的函数,把它分拆成更小的函数。人的大脑一般可以轻松的同时跟
326踪7个不同的事物,如果再增多的话,就会糊涂了。即便你聪颖过人,你也可能会记不清你2
327个星期前做过的事情。
328
329在源文件里,使用空行隔开不同的函数。如果该函数需要被导出,它的EXPORT*宏应该紧贴
330在它的结束大括号之下。比如:
331
332int system_is_up(void)
333{
334 return system_state == SYSTEM_RUNNING;
335}
336EXPORT_SYMBOL(system_is_up);
337
338在函数原型中,包含函数名和它们的数据类型。虽然C语言里没有这样的要求,在Linux里这
339是提倡的做法,因为这样可以很简单的给读者提供更多的有价值的信息。
340
341
342 第七章:集中的函数退出途径
343
344虽然被某些人声称已经过时,但是goto语句的等价物还是经常被编译器所使用,具体形式是
345无条件跳转指令。
346
347当一个函数从多个位置退出并且需要做一些通用的清理工作的时候,goto的好处就显现出来
348了。
349
350理由是:
351
352- 无条件语句容易理解和跟踪
353- 嵌套程度减小
354- 可以避免由于修改时忘记更新某个单独的退出点而导致的错误
355- 减轻了编译器的工作,无需删除冗余代码;)
356
357int fun(int a)
358{
359 int result = 0;
360 char *buffer = kmalloc(SIZE);
361
362 if (buffer == NULL)
363 return -ENOMEM;
364
365 if (condition1) {
366 while (loop1) {
367 ...
368 }
369 result = 1;
370 goto out;
371 }
372 ...
373out:
374 kfree(buffer);
375 return result;
376}
377
378 第八章:注释
379
380注释是好的,不过有过度注释的危险。永远不要在注释里解释你的代码是如何运作的:更好
381的做法是让别人一看你的代码就可以明白,解释写的很差的代码是浪费时间。
382
383一般的,你想要你的注释告诉别人你的代码做了什么,而不是怎么做的。也请你不要把注释
384放在一个函数体内部:如果函数复杂到你需要独立的注释其中的一部分,你很可能需要回到
385第六章看一看。你可以做一些小注释来注明或警告某些很聪明(或者槽糕)的做法,但不要
386加太多。你应该做的,是把注释放在函数的头部,告诉人们它做了什么,也可以加上它做这
387些事情的原因。
388
389当注释内核API函数时,请使用kernel-doc格式。请看
390Documentation/kernel-doc-nano-HOWTO.txt和scripts/kernel-doc以获得详细信息。
391
392Linux的注释风格是C89“/* ... */”风格。不要使用C99风格“// ...”注释。
393
394长(多行)的首选注释风格是:
395
396 /*
397 * This is the preferred style for multi-line
398 * comments in the Linux kernel source code.
399 * Please use it consistently.
400 *
401 * Description: A column of asterisks on the left side,
402 * with beginning and ending almost-blank lines.
403 */
404
405注释数据也是很重要的,不管是基本类型还是衍生类型。为了方便实现这一点,每一行应只
406声明一个数据(不要使用逗号来一次声明多个数据)。这样你就有空间来为每个数据写一段
407小注释来解释它们的用途了。
408
409
410 第九章:你已经把事情弄糟了
411
412这没什么,我们都是这样。可能你的使用了很长时间Unix的朋友已经告诉你“GNU emacs”能
413自动帮你格式化C源代码,而且你也注意到了,确实是这样,不过它所使用的默认值和我们
414想要的相去甚远(实际上,甚至比随机打的还要差——无数个猴子在GNU emacs里打字永远不
415会创造出一个好程序)(译注:请参考Infinite Monkey Theorem)
416
417所以你要么放弃GNU emacs,要么改变它让它使用更合理的设定。要采用后一个方案,你可
418以把下面这段粘贴到你的.emacs文件里。
419
420(defun linux-c-mode ()
421 "C mode with adjusted defaults for use with the Linux kernel."
422 (interactive)
423 (c-mode)
424 (c-set-style "K&R")
425 (setq tab-width 8)
426 (setq indent-tabs-mode t)
427 (setq c-basic-offset 8))
428
429这样就定义了M-x linux-c-mode命令。当你hack一个模块的时候,如果你把字符串
430-*- linux-c -*-放在头两行的某个位置,这个模式将会被自动调用。如果你希望在你修改
431/usr/src/linux里的文件时魔术般自动打开linux-c-mode的话,你也可能需要添加
432
433(setq auto-mode-alist (cons '("/usr/src/linux.*/.*\\.[ch]$" . linux-c-mode)
434 auto-mode-alist))
435
436到你的.emacs文件里。
437
438不过就算你尝试让emacs正确的格式化代码失败了,也并不意味着你失去了一切:还可以用“
439indent”。
440
441不过,GNU indent也有和GNU emacs一样有问题的设定,所以你需要给它一些命令选项。不
442过,这还不算太糟糕,因为就算是GNU indent的作者也认同K&R的权威性(GNU的人并不是坏
443人,他们只是在这个问题上被严重的误导了),所以你只要给indent指定选项“-kr -i8”
444(代表“K&R,8个字符缩进”),或者使用“scripts/Lindent”,这样就可以以最时髦的方式
445缩进源代码。
446
447“indent”有很多选项,特别是重新格式化注释的时候,你可能需要看一下它的手册页。不过
448记住:“indent”不能修正坏的编程习惯。
449
450
451 第十章:Kconfig配置文件
452
453对于遍布源码树的所有Kconfig*配置文件来说,它们缩进方式与C代码相比有所不同。紧挨
454在“config”定义下面的行缩进一个制表符,帮助信息则再多缩进2个空格。比如:
455
456config AUDIT
457 bool "Auditing support"
458 depends on NET
459 help
460 Enable auditing infrastructure that can be used with another
461 kernel subsystem, such as SELinux (which requires this for
462 logging of avc messages output). Does not do system-call
463 auditing without CONFIG_AUDITSYSCALL.
464
465仍然被认为不够稳定的功能应该被定义为依赖于“EXPERIMENTAL”:
466
467config SLUB
468 depends on EXPERIMENTAL && !ARCH_USES_SLAB_PAGE_STRUCT
469 bool "SLUB (Unqueued Allocator)"
470 ...
471
472而那些危险的功能(比如某些文件系统的写支持)应该在它们的提示字符串里显著的声明这
473一点:
474
475config ADFS_FS_RW
476 bool "ADFS write support (DANGEROUS)"
477 depends on ADFS_FS
478 ...
479
480要查看配置文件的完整文档,请看Documentation/kbuild/kconfig-language.txt。
481
482
483 第十一章:数据结构
484
485如果一个数据结构,在创建和销毁它的单线执行环境之外可见,那么它必须要有一个引用计
486数器。内核里没有垃圾收集(并且内核之外的垃圾收集慢且效率低下),这意味着你绝对需
487要记录你对这种数据结构的使用情况。
488
489引用计数意味着你能够避免上锁,并且允许多个用户并行访问这个数据结构——而不需要担心
490这个数据结构仅仅因为暂时不被使用就消失了,那些用户可能不过是沉睡了一阵或者做了一
491些其他事情而已。
492
493注意上锁不能取代引用计数。上锁是为了保持数据结构的一致性,而引用计数是一个内存管
494理技巧。通常二者都需要,不要把两个搞混了。
495
496很多数据结构实际上有2级引用计数,它们通常有不同“类”的用户。子类计数器统计子类用
497户的数量,每当子类计数器减至零时,全局计数器减一。
498
499这种“多级引用计数”的例子可以在内存管理(“struct mm_struct”:mm_users和mm_count)
500和文件系统(“struct super_block”:s_count和s_active)中找到。
501
502记住:如果另一个执行线索可以找到你的数据结构,但是这个数据结构没有引用计数器,这
503里几乎肯定是一个bug。
504
505
506 第十二章:宏,枚举和RTL
507
508用于定义常量的宏的名字及枚举里的标签需要大写。
509
510#define CONSTANT 0x12345
511
512在定义几个相关的常量时,最好用枚举。
513
514宏的名字请用大写字母,不过形如函数的宏的名字可以用小写字母。
515
516一般的,如果能写成内联函数就不要写成像函数的宏。
517
518含有多个语句的宏应该被包含在一个do-while代码块里:
519
520#define macrofun(a, b, c) \
521 do { \
522 if (a == 5) \
523 do_this(b, c); \
524 } while (0)
525
526使用宏的时候应避免的事情:
527
5281) 影响控制流程的宏:
529
530#define FOO(x) \
531 do { \
532 if (blah(x) < 0) \
533 return -EBUGGERED; \
534 } while(0)
535
536非常不好。它看起来像一个函数,不过却能导致“调用”它的函数退出;不要打乱读者大脑里
537的语法分析器。
538
5392) 依赖于一个固定名字的本地变量的宏:
540
541#define FOO(val) bar(index, val)
542
543可能看起来像是个不错的东西,不过它非常容易把读代码的人搞糊涂,而且容易导致看起来
544不相关的改动带来错误。
545
5463) 作为左值的带参数的宏: FOO(x) = y;如果有人把FOO变成一个内联函数的话,这种用
547法就会出错了。
548
5494) 忘记了优先级:使用表达式定义常量的宏必须将表达式置于一对小括号之内。带参数的
550宏也要注意此类问题。
551
552#define CONSTANT 0x4000
553#define CONSTEXP (CONSTANT | 3)
554
555cpp手册对宏的讲解很详细。Gcc internals手册也详细讲解了RTL(译注:register
556transfer language),内核里的汇编语言经常用到它。
557
558
559 第十三章:打印内核消息
560
561内核开发者应该是受过良好教育的。请一定注意内核信息的拼写,以给人以好的印象。不要
562用不规范的单词比如“dont”,而要用“do not”或者“don't”。保证这些信息简单、明了、无
563歧义。
564
565内核信息不必以句号(译注:英文句号,即点)结束。
566
567在小括号里打印数字(%d)没有任何价值,应该避免这样做。
568
569<linux/device.h>里有一些驱动模型诊断宏,你应该使用它们,以确保信息对应于正确的
570设备和驱动,并且被标记了正确的消息级别。这些宏有:dev_err(), dev_warn(),
571dev_info()等等。对于那些不和某个特定设备相关连的信息,<linux/kernel.h>定义了
572pr_debug()和pr_info()。
573
574写出好的调试信息可以是一个很大的挑战;当你写出来之后,这些信息在远程除错的时候
575就会成为极大的帮助。当DEBUG符号没有被定义的时候,这些信息不应该被编译进内核里
576(也就是说,默认地,它们不应该被包含在内)。如果你使用dev_dbg()或者pr_debug(),
577就能自动达到这个效果。很多子系统拥有Kconfig选项来启用-DDEBUG。还有一个相关的惯例
578是使用VERBOSE_DEBUG来添加dev_vdbg()消息到那些已经由DEBUG启用的消息之上。
579
580
581 第十四章:分配内存
582
583内核提供了下面的一般用途的内存分配函数:kmalloc(),kzalloc(),kcalloc()和
584vmalloc()。请参考API文档以获取有关它们的详细信息。
585
586传递结构体大小的首选形式是这样的:
587
588 p = kmalloc(sizeof(*p), ...);
589
590另外一种传递方式中,sizeof的操作数是结构体的名字,这样会降低可读性,并且可能会引
591入bug。有可能指针变量类型被改变时,而对应的传递给内存分配函数的sizeof的结果不变。
592
593强制转换一个void指针返回值是多余的。C语言本身保证了从void指针到其他任何指针类型
594的转换是没有问题的。
595
596
597 第十五章:内联弊病
598
599有一个常见的误解是内联函数是gcc提供的可以让代码运行更快的一个选项。虽然使用内联
600函数有时候是恰当的(比如作为一种替代宏的方式,请看第十二章),不过很多情况下不是
601这样。inline关键字的过度使用会使内核变大,从而使整个系统运行速度变慢。因为大内核
602会占用更多的指令高速缓存(译注:一级缓存通常是指令缓存和数据缓存分开的)而且会导
603致pagecache的可用内存减少。想象一下,一次pagecache未命中就会导致一次磁盘寻址,将
604耗时5毫秒。5毫秒的时间内CPU能执行很多很多指令。
605
606一个基本的原则是如果一个函数有3行以上,就不要把它变成内联函数。这个原则的一个例
607外是,如果你知道某个参数是一个编译时常量,而且因为这个常量你确定编译器在编译时能
608优化掉你的函数的大部分代码,那仍然可以给它加上inline关键字。kmalloc()内联函数就
609是一个很好的例子。
610
611人们经常主张给static的而且只用了一次的函数加上inline,如此不会有任何损失,因为没
612有什么好权衡的。虽然从技术上说这是正确的,但是实际上这种情况下即使不加inline gcc
613也可以自动使其内联。而且其他用户可能会要求移除inline,由此而来的争论会抵消inline
614自身的潜在价值,得不偿失。
615
616
617 第十六章:函数返回值及命名
618
619函数可以返回很多种不同类型的值,最常见的一种是表明函数执行成功或者失败的值。这样
620的一个值可以表示为一个错误代码整数(-Exxx=失败,0=成功)或者一个“成功”布尔值(
6210=失败,非0=成功)。
622
623混合使用这两种表达方式是难于发现的bug的来源。如果C语言本身严格区分整形和布尔型变
624量,那么编译器就能够帮我们发现这些错误……不过C语言不区分。为了避免产生这种bug,请
625遵循下面的惯例:
626
627 如果函数的名字是一个动作或者强制性的命令,那么这个函数应该返回错误代码整
628 数。如果是一个判断,那么函数应该返回一个“成功”布尔值。
629
630比如,“add work”是一个命令,所以add_work()函数在成功时返回0,在失败时返回-EBUSY。
631类似的,因为“PCI device present”是一个判断,所以pci_dev_present()函数在成功找到
632一个匹配的设备时应该返回1,如果找不到时应该返回0。
633
634所有导出(译注:EXPORT)的函数都必须遵守这个惯例,所有的公共函数也都应该如此。私
635有(static)函数不需要如此,但是我们也推荐这样做。
636
637返回值是实际计算结果而不是计算是否成功的标志的函数不受此惯例的限制。一般的,他们
638通过返回一些正常值范围之外的结果来表示出错。典型的例子是返回指针的函数,他们使用
639NULL或者ERR_PTR机制来报告错误。
640
641
642 第十七章:不要重新发明内核宏
643
644头文件include/linux/kernel.h包含了一些宏,你应该使用它们,而不要自己写一些它们的
645变种。比如,如果你需要计算一个数组的长度,使用这个宏
646
647 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
648
649类似的,如果你要计算某结构体成员的大小,使用
650
651 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
652
653还有可以做严格的类型检查的min()和max()宏,如果你需要可以使用它们。你可以自己看看
654那个头文件里还定义了什么你可以拿来用的东西,如果有定义的话,你就不应在你的代码里
655自己重新定义。
656
657
658 第十八章:编辑器模式行和其他需要罗嗦的事情
659
660有一些编辑器可以解释嵌入在源文件里的由一些特殊标记标明的配置信息。比如,emacs
661能够解释被标记成这样的行:
662
663-*- mode: c -*-
664
665或者这样的:
666
667/*
668Local Variables:
669compile-command: "gcc -DMAGIC_DEBUG_FLAG foo.c"
670End:
671*/
672
673Vim能够解释这样的标记:
674
675/* vim:set sw=8 noet */
676
677不要在源代码中包含任何这样的内容。每个人都有他自己的编辑器配置,你的源文件不应
678该覆盖别人的配置。这包括有关缩进和模式配置的标记。人们可以使用他们自己定制的模
679式,或者使用其他可以产生正确的缩进的巧妙方法。
680
681
682
683 附录 I:参考
684
685The C Programming Language, 第二版, 作者Brian W. Kernighan和Denni
686M. Ritchie. Prentice Hall, Inc., 1988. ISBN 0-13-110362-8 (软皮),
6870-13-110370-9 (硬皮). URL: http://cm.bell-labs.com/cm/cs/cbook/
688
689The Practice of Programming 作者Brian W. Kernighan和Rob Pike. Addison-Wesley,
690Inc., 1999. ISBN 0-201-61586-X. URL: http://cm.bell-labs.com/cm/cs/tpop/
691
692cpp,gcc,gcc internals和indent的GNU手册——和K&R及本文相符合的部分,全部可以在
693http://www.gnu.org/manual/找到
694
695WG14是C语言的国际标准化工作组,URL: http://www.open-std.org/JTC1/SC22/WG14/
696
697Kernel CodingStyle,作者greg@kroah.com发表于OLS 2002:
698http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/
699
700--
701最后更新于2007年7月13日。
diff --git a/Documentation/zh_CN/HOWTO b/Documentation/zh_CN/HOWTO
index 48fc67bfbe3d..3d80e8af36ec 100644
--- a/Documentation/zh_CN/HOWTO
+++ b/Documentation/zh_CN/HOWTO
@@ -1,10 +1,10 @@
1Chinese translated version of Documentation/HOWTO 1Chinese translated version of Documentation/HOWTO
2 2
3If you have any comment or update to the content, please contact the 3If you have any comment or update to the content, please contact the
4original document maintainer directly. However, if you have problem 4original document maintainer directly. However, if you have a problem
5communicating in English you can also ask the Chinese maintainer for 5communicating in English you can also ask the Chinese maintainer for
6help. Contact the Chinese maintainer, if this translation is outdated 6help. Contact the Chinese maintainer if this translation is outdated
7or there is problem with translation. 7or if there is a problem with the translation.
8 8
9Maintainer: Greg Kroah-Hartman <greg@kroah.com> 9Maintainer: Greg Kroah-Hartman <greg@kroah.com>
10Chinese maintainer: Li Yang <leoli@freescale.com> 10Chinese maintainer: Li Yang <leoli@freescale.com>
@@ -85,7 +85,7 @@ Linux内核源代码都是在GPL(通用公共许可证)的保护下发布的
85Linux内核代码中包含有大量的文档。这些文档对于学习如何与内核社区互动有着 85Linux内核代码中包含有大量的文档。这些文档对于学习如何与内核社区互动有着
86不可估量的价值。当一个新的功能被加入内核,最好把解释如何使用这个功能的文 86不可估量的价值。当一个新的功能被加入内核,最好把解释如何使用这个功能的文
87档也放进内核。当内核的改动导致面向用户空间的接口发生变化时,最好将相关信 87档也放进内核。当内核的改动导致面向用户空间的接口发生变化时,最好将相关信
88息或手册页(manpages)的补丁发到mtk-manpages@gmx.net,以向手册页(manpages) 88息或手册页(manpages)的补丁发到mtk.manpages@gmail.com,以向手册页(manpages)
89的维护者解释这些变化。 89的维护者解释这些变化。
90 90
91以下是内核代码中需要阅读的文档: 91以下是内核代码中需要阅读的文档:
@@ -218,6 +218,8 @@ kernel.org网站的pub/linux/kernel/v2.6/目录下找到它。它的开发遵循
218 时,一个新的-rc版本就会被发布。计划是每周都发布新的-rc版本。 218 时,一个新的-rc版本就会被发布。计划是每周都发布新的-rc版本。
219 - 这个过程一直持续下去直到内核被认为达到足够稳定的状态,持续时间大概是 219 - 这个过程一直持续下去直到内核被认为达到足够稳定的状态,持续时间大概是
220 6个星期。 220 6个星期。
221 - 以下地址跟踪了在每个-rc发布中发现的退步列表:
222 http://kernelnewbies.org/known_regressions
221 223
222关于内核发布,值得一提的是Andrew Morton在linux-kernel邮件列表中如是说: 224关于内核发布,值得一提的是Andrew Morton在linux-kernel邮件列表中如是说:
223 “没有人知道新内核何时会被发布,因为发布是根据已知bug的情况来决定 225 “没有人知道新内核何时会被发布,因为发布是根据已知bug的情况来决定
diff --git a/Documentation/zh_CN/SubmittingDrivers b/Documentation/zh_CN/SubmittingDrivers
new file mode 100644
index 000000000000..5f4815c63ec7
--- /dev/null
+++ b/Documentation/zh_CN/SubmittingDrivers
@@ -0,0 +1,168 @@
1Chinese translated version of Documentation/SubmittingDrivers
2
3If you have any comment or update to the content, please contact the
4original document maintainer directly. However, if you have a problem
5communicating in English you can also ask the Chinese maintainer for
6help. Contact the Chinese maintainer if this translation is outdated
7or if there is a problem with the translation.
8
9Chinese maintainer: Li Yang <leo@zh-kernel.org>
10---------------------------------------------------------------------
11Documentation/SubmittingDrivers 的中文翻译
12
13如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
14交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
15译存在问题,请联系中文版维护者。
16
17中文版维护者: 李阳 Li Yang <leo@zh-kernel.org>
18中文版翻译者: 李阳 Li Yang <leo@zh-kernel.org>
19中文版校译者: 陈琦 Maggie Chen <chenqi@beyondsoft.com>
20 王聪 Wang Cong <xiyou.wangcong@gmail.com>
21 张巍 Zhang Wei <Wei.Zhang@freescale.com>
22
23以下为正文
24---------------------------------------------------------------------
25
26如何向 Linux 内核提交驱动程序
27-----------------------------
28
29这篇文档将会解释如何向不同的内核源码树提交设备驱动程序。请注意,如果你感
30兴趣的是显卡驱动程序,你也许应该访问 XFree86 项目(http://www.xfree86.org/)
31和/或 X.org 项目 (http://x.org)。
32
33另请参阅 Documentation/SubmittingPatches 文档。
34
35
36分配设备号
37----------
38
39块设备和字符设备的主设备号与从设备号是由 Linux 命名编号分配权威 LANANA(
40现在是 Torben Mathiasen)负责分配。申请的网址是 http://www.lanana.org/。
41即使不准备提交到主流内核的设备驱动也需要在这里分配设备号。有关详细信息,
42请参阅 Documentation/devices.txt。
43
44如果你使用的不是已经分配的设备号,那么当你提交设备驱动的时候,它将会被强
45制分配一个新的设备号,即便这个设备号和你之前发给客户的截然不同。
46
47设备驱动的提交对象
48------------------
49
50Linux 2.0:
51 此内核源码树不接受新的驱动程序。
52
53Linux 2.2:
54 此内核源码树不接受新的驱动程序。
55
56Linux 2.4:
57 如果所属的代码领域在内核的 MAINTAINERS 文件中列有一个总维护者,
58 那么请将驱动程序提交给他。如果此维护者没有回应或者你找不到恰当的
59 维护者,那么请联系 Willy Tarreau <w@1wt.eu>。
60
61Linux 2.6:
62 除了遵循和 2.4 版内核同样的规则外,你还需要在 linux-kernel 邮件
63 列表上跟踪最新的 API 变化。向 Linux 2.6 内核提交驱动的顶级联系人
64 是 Andrew Morton <akpm@osdl.org>。
65
66决定设备驱动能否被接受的条件
67----------------------------
68
69许可: 代码必须使用 GNU 通用公开许可证 (GPL) 提交给 Linux,但是
70 我们并不要求 GPL 是唯一的许可。你或许会希望同时使用多种
71 许可证发布,如果希望驱动程序可以被其他开源社区(比如BSD)
72 使用。请参考 include/linux/module.h 文件中所列出的可被
73 接受共存的许可。
74
75版权: 版权所有者必须同意使用 GPL 许可。最好提交者和版权所有者
76 是相同个人或实体。否则,必需列出授权使用 GPL 的版权所有
77 人或实体,以备验证之需。
78
79接口: 如果你的驱动程序使用现成的接口并且和其他同类的驱动程序行
80 为相似,而不是去发明无谓的新接口,那么它将会更容易被接受。
81 如果你需要一个 Linux 和 NT 的通用驱动接口,那么请在用
82 户空间实现它。
83
84代码: 请使用 Documentation/CodingStyle 中所描述的 Linux 代码风
85 格。如果你的某些代码段(例如那些与 Windows 驱动程序包共
86 享的代码段)需要使用其他格式,而你却只希望维护一份代码,
87 那么请将它们很好地区分出来,并且注明原因。
88
89可移植性: 请注意,指针并不永远是 32 位的,不是所有的计算机都使用小
90 尾模式 (little endian) 存储数据,不是所有的人都拥有浮点
91 单元,不要随便在你的驱动程序里嵌入 x86 汇编指令。只能在
92 x86 上运行的驱动程序一般是不受欢迎的。虽然你可能只有 x86
93 硬件,很难测试驱动程序在其他平台上是否可用,但是确保代码
94 可以被轻松地移植却是很简单的。
95
96清晰度: 做到所有人都能修补这个驱动程序将会很有好处,因为这样你将
97 会直接收到修复的补丁而不是 bug 报告。如果你提交一个试图
98 隐藏硬件工作机理的驱动程序,那么它将会被扔进废纸篓。
99
100电源管理: 因为 Linux 正在被很多移动设备和桌面系统使用,所以你的驱
101 动程序也很有可能被使用在这些设备上。它应该支持最基本的电
102 源管理,即在需要的情况下实现系统级休眠和唤醒要用到的
103 .suspend 和 .resume 函数。你应该检查你的驱动程序是否能正
104 确地处理休眠与唤醒,如果实在无法确认,请至少把 .suspend
105 函数定义成返回 -ENOSYS(功能未实现)错误。你还应该尝试确
106 保你的驱动在什么都不干的情况下将耗电降到最低。要获得驱动
107 程序测试的指导,请参阅
108 Documentation/power/drivers-testing.txt。有关驱动程序电
109 源管理问题相对全面的概述,请参阅
110 Documentation/power/devices.txt。
111
112管理: 如果一个驱动程序的作者还在进行有效的维护,那么通常除了那
113 些明显正确且不需要任何检查的补丁以外,其他所有的补丁都会
114 被转发给作者。如果你希望成为驱动程序的联系人和更新者,最
115 好在代码注释中写明并且在 MAINTAINERS 文件中加入这个驱动
116 程序的条目。
117
118不影响设备驱动能否被接受的条件
119------------------------------
120
121供应商: 由硬件供应商来维护驱动程序通常是一件好事。不过,如果源码
122 树里已经有其他人提供了可稳定工作的驱动程序,那么请不要期
123 望“我是供应商”会成为内核改用你的驱动程序的理由。理想的情
124 况是:供应商与现有驱动程序的作者合作,构建一个统一完美的
125 驱动程序。
126
127作者: 驱动程序是由大的 Linux 公司研发还是由你个人编写,并不影
128 响其是否能被内核接受。没有人对内核源码树享有特权。只要你
129 充分了解内核社区,你就会发现这一点。
130
131
132资源列表
133--------
134
135Linux 内核主源码树:
136 ftp.??.kernel.org:/pub/linux/kernel/...
137 ?? == 你的国家代码,例如 "cn"、"us"、"uk"、"fr" 等等
138
139Linux 内核邮件列表:
140 linux-kernel@vger.kernel.org
141 [可通过向majordomo@vger.kernel.org发邮件来订阅]
142
143Linux 设备驱动程序,第三版(探讨 2.6.10 版内核):
144 http://lwn.net/Kernel/LDD3/ (免费版)
145
146LWN.net:
147 每周内核开发活动摘要 - http://lwn.net/
148 2.6 版中 API 的变更:
149 http://lwn.net/Articles/2.6-kernel-api/
150 将旧版内核的驱动程序移植到 2.6 版:
151 http://lwn.net/Articles/driver-porting/
152
153KernelTrap:
154 Linux 内核的最新动态以及开发者访谈
155 http://kerneltrap.org/
156
157内核新手(KernelNewbies):
158 为新的内核开发者提供文档和帮助
159 http://kernelnewbies.org/
160
161Linux USB项目:
162 http://www.linux-usb.org/
163
164写内核驱动的“不要”(Arjan van de Ven著):
165 http://www.fenrus.org/how-to-not-write-a-device-driver-paper.pdf
166
167内核清洁工 (Kernel Janitor):
168 http://janitor.kernelnewbies.org/
diff --git a/Documentation/zh_CN/SubmittingPatches b/Documentation/zh_CN/SubmittingPatches
new file mode 100644
index 000000000000..985c92e20b73
--- /dev/null
+++ b/Documentation/zh_CN/SubmittingPatches
@@ -0,0 +1,416 @@
1Chinese translated version of Documentation/SubmittingPatches
2
3If you have any comment or update to the content, please contact the
4original document maintainer directly. However, if you have a problem
5communicating in English you can also ask the Chinese maintainer for
6help. Contact the Chinese maintainer if this translation is outdated
7or if there is a problem with the translation.
8
9Chinese maintainer: TripleX Chung <triplex@zh-kernel.org>
10---------------------------------------------------------------------
11Documentation/SubmittingPatches 的中文翻译
12
13如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
14交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
15译存在问题,请联系中文版维护者。
16
17中文版维护者: 钟宇 TripleX Chung <triplex@zh-kernel.org>
18中文版翻译者: 钟宇 TripleX Chung <triplex@zh-kernel.org>
19中文版校译者: 李阳 Li Yang <leo@zh-kernel.org>
20 王聪 Wang Cong <xiyou.wangcong@gmail.com>
21
22以下为正文
23---------------------------------------------------------------------
24
25 如何让你的改动进入内核
26 或者
27 获得亲爱的 Linus Torvalds 的关注和处理
28----------------------------------
29
30对于想要将改动提交到 Linux 内核的个人或者公司来说,如果不熟悉“规矩”,
31提交的流程会让人畏惧。本文档收集了一系列建议,这些建议可以大大的提高你
32的改动被接受的机会。
33阅读 Documentation/SubmitChecklist 来获得在提交代码前需要检查的项目的列
34表。如果你在提交一个驱动程序,那么同时阅读一下
35Documentation/SubmittingDrivers 。
36
37
38--------------------------
39第一节 - 创建并发送你的改动
40--------------------------
41
421) "diff -up"
43-----------
44
45使用 "diff -up" 或者 "diff -uprN" 来创建补丁。
46
47所有内核的改动,都是以补丁的形式呈现的,补丁由 diff(1) 生成。创建补丁的
48时候,要确认它是以 "unified diff" 格式创建的,这种格式由 diff(1) 的 '-u'
49参数生成。而且,请使用 '-p' 参数,那样会显示每个改动所在的C函数,使得
50产生的补丁容易读得多。补丁应该基于内核源代码树的根目录,而不是里边的任
51何子目录。
52为一个单独的文件创建补丁,一般来说这样做就够了:
53
54 SRCTREE= linux-2.6
55 MYFILE= drivers/net/mydriver.c
56
57 cd $SRCTREE
58 cp $MYFILE $MYFILE.orig
59 vi $MYFILE # make your change
60 cd ..
61 diff -up $SRCTREE/$MYFILE{.orig,} > /tmp/patch
62
63为多个文件创建补丁,你可以解开一个没有修改过的内核源代码树,然后和你自
64己的代码树之间做 diff 。例如:
65
66 MYSRC= /devel/linux-2.6
67
68 tar xvfz linux-2.6.12.tar.gz
69 mv linux-2.6.12 linux-2.6.12-vanilla
70 diff -uprN -X linux-2.6.12-vanilla/Documentation/dontdiff \
71 linux-2.6.12-vanilla $MYSRC > /tmp/patch
72
73"dontdiff" 是内核在编译的时候产生的文件的列表,列表中的文件在 diff(1)
74产生的补丁里会被跳过。"dontdiff" 文件被包含在2.6.12和之后版本的内核源代
75码树中。对于更早的内核版本,你可以从
76<http://www.xenotime.net/linux/doc/dontdiff> 获取它。
77确定你的补丁里没有包含任何不属于这次补丁提交的额外文件。记得在用diff(1)
78生成补丁之后,审阅一次补丁,以确保准确。
79如果你的改动很散乱,你应该研究一下如何将补丁分割成独立的部分,将改动分
80割成一系列合乎逻辑的步骤。这样更容易让其他内核开发者审核,如果你想你的
81补丁被接受,这是很重要的。下面这些脚本能够帮助你做这件事情:
82Quilt:
83http://savannah.nongnu.org/projects/quilt
84
85Andrew Morton 的补丁脚本:
86http://www.zip.com.au/~akpm/linux/patches/
87作为这些脚本的替代,quilt 是值得推荐的补丁管理工具(看上面的链接)。
88
892)描述你的改动。
90描述你的改动包含的技术细节。
91
92要多具体就写多具体。最糟糕的描述可能是像下面这些语句:“更新了某驱动程
93序”,“修正了某驱动程序的bug”,或者“这个补丁包含了某子系统的修改,请
94使用。”
95
96如果你的描述开始变长,这表示你也许需要拆分你的补丁了,请看第3小节,
97继续。
98
993)拆分你的改动
100
101将改动拆分,逻辑类似的放到同一个补丁文件里。
102
103例如,如果你的改动里同时有bug修正和性能优化,那么把这些改动才分到两个或
104者更多的补丁文件中。如果你的改动包含对API的修改,并且修改了驱动程序来适
105应这些新的API,那么把这些修改分成两个补丁。
106
107另一方面,如果你将一个单独的改动做成多个补丁文件,那么将它们合并成一个
108单独的补丁文件。这样一个逻辑上单独的改动只被包含在一个补丁文件里。
109
110如果有一个补丁依赖另外一个补丁来完成它的改动,那没问题。简单的在你的补
111丁描述里指出“这个补丁依赖某补丁”就好了。
112
113如果你不能将补丁浓缩成更少的文件,那么每次大约发送出15个,然后等待审查
114和整合。
115
1164)选择 e-mail 的收件人
117
118看一遍 MAINTAINERS 文件和源代码,看看你所的改动所在的内核子系统有没有指
119定的维护者。如果有,给他们发e-mail。
120
121如果没有找到维护者,或者维护者没有反馈,将你的补丁发送到内核开发者主邮
122件列表 linux-kernel@vger.kernel.org。大部分的内核开发者都跟踪这个邮件列
123表,可以评价你的改动。
124
125每次不要发送超过15个补丁到 vger 邮件列表!!!
126
127Linus Torvalds 是决定改动能否进入 Linux 内核的最终裁决者。他的 e-mail
128地址是 <torvalds@linux-foundation.org> 。他收到的 e-mail 很多,所以一般
129的说,最好别给他发 e-mail。
130
131那些修正bug,“显而易见”的修改或者是类似的只需要很少讨论的补丁可以直接
132发送或者CC给Linus。那些需要讨论或者没有很清楚的好处的补丁,一般先发送到
133linux-kernel邮件列表。只有当补丁被讨论得差不多了,才提交给Linus。
134
1355)选择CC( e-mail 抄送)列表
136
137除非你有理由不这样做,否则CC linux-kernel@vger.kernel.org。
138
139除了 Linus 之外,其他内核开发者也需要注意到你的改动,这样他们才能评论你
140的改动并提供代码审查和建议。linux-kernel 是 Linux 内核开发者主邮件列表
141。其它的邮件列表为特定的子系统提供服务,比如 USB,framebuffer 设备,虚
142拟文件系统,SCSI 子系统,等等。查看 MAINTAINERS 文件来获得和你的改动有
143关的邮件列表。
144
145Majordomo lists of VGER.KERNEL.ORG at:
146 <http://vger.kernel.org/vger-lists.html>
147
148如果改动影响了用户空间和内核之间的接口,请给 MAN-PAGES 的维护者(列在
149MAITAINERS 文件里的)发送一个手册页(man-pages)补丁,或者至少通知一下改
150变,让一些信息有途径进入手册页。
151
152即使在第四步的时候,维护者没有作出回应,也要确认在修改他们的代码的时候
153,一直将维护者拷贝到CC列表中。
154
155对于小的补丁,你也许会CC到 Adrian Bunk 管理的搜集琐碎补丁的邮件列表
156(Trivial Patch Monkey)trivial@kernel.org,那里专门收集琐碎的补丁。下面这样
157的补丁会被看作“琐碎的”补丁:
158 文档的拼写修正。
159 修正会影响到 grep(1) 的拼写。
160 警告信息修正(频繁的打印无用的警告是不好的。)
161 编译错误修正(代码逻辑的确是对的,只是编译有问题。)
162 运行时修正(只要真的修正了错误。)
163 移除使用了被废弃的函数/宏的代码(例如 check_region。)
164 联系方式和文档修正。
165 用可移植的代码替换不可移植的代码(即使在体系结构相关的代码中,既然有
166 人拷贝,只要它是琐碎的)
167 任何文件的作者/维护者对该文件的改动(例如 patch monkey 在重传模式下)
168
169URL: <http://www.kernel.org/pub/linux/kernel/people/bunk/trivial/>
170
171(译注,关于“琐碎补丁”的一些说明:因为原文的这一部分写得比较简单,所以不得不
172违例写一下译注。"trivial"这个英文单词的本意是“琐碎的,不重要的。”但是在这里
173有稍微有一些变化,例如对一些明显的NULL指针的修正,属于运行时修正,会被归类
174到琐碎补丁里。虽然NULL指针的修正很重要,但是这样的修正往往很小而且很容易得到
175检验,所以也被归入琐碎补丁。琐碎补丁更精确的归类应该是
176“simple, localized & easy to verify”,也就是说简单的,局部的和易于检验的。
177trivial@kernel.org邮件列表的目的是针对这样的补丁,为提交者提供一个中心,来
178降低提交的门槛。)
179
1806)没有 MIME 编码,没有链接,没有压缩,没有附件,只有纯文本。
181
182Linus 和其他的内核开发者需要阅读和评论你提交的改动。对于内核开发者来说
183,可以“引用”你的改动很重要,使用一般的 e-mail 工具,他们就可以在你的
184代码的任何位置添加评论。
185
186因为这个原因,所有的提交的补丁都是 e-mail 中“内嵌”的。
187警告:如果你使用剪切-粘贴你的补丁,小心你的编辑器的自动换行功能破坏你的
188补丁。
189
190不要将补丁作为 MIME 编码的附件,不管是否压缩。很多流行的 e-mail 软件不
191是任何时候都将 MIME 编码的附件当作纯文本发送的,这会使得别人无法在你的
192代码中加评论。另外,MIME 编码的附件会让 Linus 多花一点时间来处理,这就
193降低了你的改动被接受的可能性。
194
195警告:一些邮件软件,比如 Mozilla 会将你的信息以如下格式发送:
196---- 邮件头 ----
197Content-Type: text/plain; charset=us-ascii; format=flowed
198---- 邮件头 ----
199问题在于 “format=flowed” 会让接收端的某些邮件软件将邮件中的制表符替换
200成空格以及做一些类似的替换。这样,你发送的时候看起来没问题的补丁就被破
201坏了。
202
203要修正这个问题,只需要将你的 mozilla 的 defaults/pref/mailnews.js 文件
204里的
205pref("mailnews.send_plaintext_flowed", false); // RFC 2646=======
206修改成
207pref("mailnews.display.disable_format_flowed_support", true);
208就可以了。
209
2107) e-mail 的大小
211
212给 Linus 发送补丁的时候,永远按照第6小节说的做。
213
214大的改动对邮件列表不合适,对某些维护者也不合适。如果你的补丁,在不压缩
215的情况下,超过了40kB,那么你最好将补丁放在一个能通过 internet 访问的服
216务器上,然后用指向你的补丁的 URL 替代。
217
2188) 指出你的内核版本
219
220在标题和在补丁的描述中,指出补丁对应的内核的版本,是很重要的。
221
222如果补丁不能干净的在最新版本的内核上打上,Linus 是不会接受它的。
223
2249) 不要气馁,继续提交。
225
226当你提交了改动以后,耐心地等待。如果 Linus 喜欢你的改动并且同意它,那么
227它将在下一个内核发布版本中出现。
228
229然而,如果你的改动没有出现在下一个版本的内核中,可能有若干原因。减少那
230些原因,修正错误,重新提交更新后的改动,是你自己的工作。
231
232Linus不给出任何评论就“丢弃”你的补丁是常见的事情。在系统中这样的事情很
233平常。如果他没有接受你的补丁,也许是由于以下原本:
234* 你的补丁不能在最新版本的内核上干净的打上。
235* 你的补丁在 linux-kernel 邮件列表中没有得到充分的讨论。
236* 风格问题(参照第2小节)
237* 邮件格式问题(重读本节)
238* 你的改动有技术问题。
239* 他收到了成吨的 e-mail,而你的在混乱中丢失了。
240* 你让人为难。
241
242有疑问的时候,在 linux-kernel 邮件列表上请求评论。
243
24410) 在标题上加上 PATCH 的字样
245
246Linus 和 linux-kernel 邮件列表的 e-mail 流量都很高,一个通常的约定是标
247题行以 [PATCH] 开头。这样可以让 Linus 和其他内核开发人员可以从 e-mail
248的讨论中很轻易的将补丁分辨出来。
249
25011)为你的工作签名
251
252为了加强对谁做了何事的追踪,尤其是对那些透过好几层的维护者的补丁,我们
253建议在发送出去的补丁上加一个 “sign-off” 的过程。
254
255"sign-off" 是在补丁的注释的最后的简单的一行文字,认证你编写了它或者其他
256人有权力将它作为开放源代码的补丁传递。规则很简单:如果你能认证如下信息
257
258 开发者来源证书 1.1
259 对于本项目的贡献,我认证如下信息:
260 (a)这些贡献是完全或者部分的由我创建,我有权利以文件中指出
261 的开放源代码许可证提交它;或者
262 (b)这些贡献基于以前的工作,据我所知,这些以前的工作受恰当的开放
263 源代码许可证保护,而且,根据许可证,我有权提交修改后的贡献,
264 无论是完全还是部分由我创造,这些贡献都使用同一个开放源代码许可证
265 (除非我被允许用其它的许可证),正如文件中指出的;或者
266 (c)这些贡献由认证(a),(b)或者(c)的人直接提供给我,而
267 且我没有修改它。
268 (d)我理解并同意这个项目和贡献是公开的,贡献的记录(包括我
269 一起提交的个人记录,包括 sign-off )被永久维护并且可以和这个项目
270 或者开放源代码的许可证同步地再发行。
271 那么加入这样一行:
272 Signed-off-by: Random J Developer <random@developer.example.org>
273
274使用你的真名(抱歉,不能使用假名或者匿名。)
275
276有人在最后加上标签。现在这些东西会被忽略,但是你可以这样做,来标记公司
277内部的过程,或者只是指出关于 sign-off 的一些特殊细节。
278
27912)标准补丁格式
280
281标准的补丁,标题行是:
282 Subject: [PATCH 001/123] 子系统:一句话概述
283
284标准补丁的信体存在如下部分:
285
286 - 一个 "from" 行指出补丁作者。
287
288 - 一个空行
289
290 - 说明的主体,这些说明文字会被拷贝到描述该补丁的永久改动记录里。
291
292 - 一个由"---"构成的标记行
293
294 - 不合适放到改动记录里的额外的注解。
295
296 - 补丁本身(diff 输出)
297
298标题行的格式,使得对标题行按字母序排序非常的容易 - 很多 e-mail 客户端都
299可以支持 - 因为序列号是用零填充的,所以按数字排序和按字母排序是一样的。
300
301e-mail 标题中的“子系统”标识哪个内核子系统将被打补丁。
302
303e-mail 标题中的“一句话概述”扼要的描述 e-mail 中的补丁。“一句话概述”
304不应该是一个文件名。对于一个补丁系列(“补丁系列”指一系列的多个相关补
305丁),不要对每个补丁都使用同样的“一句话概述”。
306
307记住 e-mail 的“一句话概述”会成为该补丁的全局唯一标识。它会蔓延到 git
308的改动记录里。然后“一句话概述”会被用在开发者的讨论里,用来指代这个补
309丁。用户将希望通过 google 来搜索"一句话概述"来找到那些讨论这个补丁的文
310章。
311
312一些标题的例子:
313
314 Subject: [patch 2/5] ext2: improve scalability of bitmap searching
315 Subject: [PATCHv2 001/207] x86: fix eflags tracking
316
317"from" 行是信体里的最上面一行,具有如下格式:
318 From: Original Author <author@example.com>
319
320"from" 行指明在永久改动日志里,谁会被确认为作者。如果没有 "from" 行,那
321么邮件头里的 "From: " 行会被用来决定改动日志中的作者。
322
323说明的主题将会被提交到永久的源代码改动日志里,因此对那些早已经不记得和
324这个补丁相关的讨论细节的有能力的读者来说,是有意义的。
325
326"---" 标记行对于补丁处理工具要找到哪里是改动日志信息的结束,是不可缺少
327的。
328
329对于 "---" 标记之后的额外注解,一个好的用途就是用来写 diffstat,用来显
330示修改了什么文件和每个文件都增加和删除了多少行。diffstat 对于比较大的补
331丁特别有用。其余那些只是和时刻或者开发者相关的注解,不合适放到永久的改
332动日志里的,也应该放这里。
333使用 diffstat的选项 "-p 1 -w 70" 这样文件名就会从内核源代码树的目录开始
334,不会占用太宽的空间(很容易适合80列的宽度,也许会有一些缩进。)
335
336在后面的参考资料中能看到适当的补丁格式的更多细节。
337
338-------------------------------
339第二节 提示,建议和诀窍
340-------------------------------
341
342本节包含很多和提交到内核的代码有关的通常的"规则"。事情永远有例外...但是
343你必须真的有好的理由这样做。你可以把本节叫做Linus的计算机科学入门课。
344
3451) 读 Document/CodingStyle
346
347Nuff 说过,如果你的代码和这个偏离太多,那么它有可能会被拒绝,没有更多的
348审查,没有更多的评价。
349
3502) #ifdef 是丑陋的
351混杂了 ifdef 的代码难以阅读和维护。别这样做。作为替代,将你的 ifdef 放
352在头文件里,有条件地定义 "static inline" 函数,或者宏,在代码里用这些东
353西。让编译器把那些"空操作"优化掉。
354
355一个简单的例子,不好的代码:
356
357 dev = alloc_etherdev (sizeof(struct funky_private));
358 if (!dev)
359 return -ENODEV;
360 #ifdef CONFIG_NET_FUNKINESS
361 init_funky_net(dev);
362 #endif
363
364清理后的例子:
365
366(头文件里)
367 #ifndef CONFIG_NET_FUNKINESS
368 static inline void init_funky_net (struct net_device *d) {}
369 #endif
370
371(代码文件里)
372 dev = alloc_etherdev (sizeof(struct funky_private));
373 if (!dev)
374 return -ENODEV;
375 init_funky_net(dev);
376
3773) 'static inline' 比宏好
378
379Static inline 函数相比宏来说,是好得多的选择。Static inline 函数提供了
380类型安全,没有长度限制,没有格式限制,在 gcc 下开销和宏一样小。
381
382宏只在 static inline 函数不是最优的时候[在 fast paths 里有很少的独立的
383案例],或者不可能用 static inline 函数的时候[例如字符串分配]。
384应该用 'static inline' 而不是 'static __inline__', 'extern inline' 和
385'extern __inline__' 。
386
3874) 不要过度设计
388
389不要试图预计模糊的未来事情,这些事情也许有用也许没有用:"让事情尽可能的
390简单,而不是更简单"。
391
392----------------
393第三节 参考文献
394----------------
395
396Andrew Morton, "The perfect patch" (tpp).
397 <http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt>
398
399Jeff Garzik, "Linux kernel patch submission format".
400 <http://linux.yyz.us/patch-format.html>
401
402Greg Kroah-Hartman, "How to piss off a kernel subsystem maintainer".
403 <http://www.kroah.com/log/2005/03/31/>
404 <http://www.kroah.com/log/2005/07/08/>
405 <http://www.kroah.com/log/2005/10/19/>
406 <http://www.kroah.com/log/2006/01/11/>
407
408NO!!!! No more huge patch bombs to linux-kernel@vger.kernel.org people!
409 <http://marc.theaimsgroup.com/?l=linux-kernel&m=112112749912944&w=2>
410
411Kernel Documentation/CodingStyle:
412 <http://sosdg.org/~coywolf/lxr/source/Documentation/CodingStyle>
413
414Linus Torvalds's mail on the canonical patch format:
415 <http://lkml.org/lkml/2005/4/7/183>
416--
diff --git a/Documentation/zh_CN/oops-tracing.txt b/Documentation/zh_CN/oops-tracing.txt
new file mode 100644
index 000000000000..9312608ffb8d
--- /dev/null
+++ b/Documentation/zh_CN/oops-tracing.txt
@@ -0,0 +1,212 @@
1Chinese translated version of Documentation/oops-tracing.txt
2
3If you have any comment or update to the content, please contact the
4original document maintainer directly. However, if you have a problem
5communicating in English you can also ask the Chinese maintainer for
6help. Contact the Chinese maintainer if this translation is outdated
7or if there is a problem with the translation.
8
9Chinese maintainer: Dave Young <hidave.darkstar@gmail.com>
10---------------------------------------------------------------------
11Documentation/oops-tracing.txt 的中文翻译
12
13如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
14交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
15译存在问题,请联系中文版维护者。
16
17中文版维护者: 杨瑞 Dave Young <hidave.darkstar@gmail.com>
18中文版翻译者: 杨瑞 Dave Young <hidave.darkstar@gmail.com>
19中文版校译者: 李阳 Li Yang <leo@zh-kernel.org>
20 王聪 Wang Cong <xiyou.wangcong@gmail.com>
21
22以下为正文
23---------------------------------------------------------------------
24
25注意: ksymoops 在2.6中是没有用的。 请以原有格式使用Oops(来自dmesg,等等)。
26忽略任何这样那样关于“解码Oops”或者“通过ksymoops运行”的文档。 如果你贴出运行过
27ksymoops的来自2.6的Oops,人们只会让你重贴一次。
28
29快速总结
30-------------
31
32发现Oops并发送给看似相关的内核领域的维护者。别太担心对不上号。如果你不确定就发给
33和你所做的事情相关的代码的负责人。 如果可重现试着描述怎样重构。 那甚至比oops更有
34价值。
35
36如果你对于发送给谁一无所知, 发给linux-kernel@vger.kernel.org。感谢你帮助Linux
37尽可能地稳定。
38
39Oops在哪里?
40----------------------
41
42通常Oops文本由klogd从内核缓冲区里读取并传给syslogd,由syslogd写到syslog文件中,
43典型地是/var/log/messages(依赖于/etc/syslog.conf)。有时klogd崩溃了,这种情况下你
44能够运行dmesg > file来从内核缓冲区中读取数据并保存下来。 否则你可以
45cat /proc/kmsg > file, 然而你必须介入中止传输, kmsg是一个“永不结束的文件”。如
46果机器崩溃坏到你不能输入命令或者磁盘不可用那么你有三种选择:-
47
48(1) 手抄屏幕上的文本待机器重启后再输入计算机。 麻烦但如果没有针对崩溃的准备,
49这是仅有的选择。 另外,你可以用数码相机把屏幕拍下来-不太好,但比没有强。 如果信
50息滚动到了终端的上面,你会发现以高分辩率启动(比如,vga=791)会让你读到更多的文
51本。(注意:这需要vesafb,所以对‘早期’的oops没有帮助)
52
53(2)用串口终端启动(请参看Documentation/serial-console.txt),运行一个null
54modem到另一台机器并用你喜欢的通讯工具获取输出。Minicom工作地很好。
55
56(3)使用Kdump(请参看Documentation/kdump/kdump.txt),
57使用在Documentation/kdump/gdbmacros.txt中定义的dmesg gdb宏,从旧的内存中提取内核
58环形缓冲区。
59
60完整信息
61----------------
62
63注意:以下来自于Linus的邮件适用于2.4内核。 我因为历史原因保留了它,并且因为其中
64一些信息仍然适用。 特别注意的是,请忽略任何ksymoops的引用。
65
66From: Linus Torvalds <torvalds@osdl.org>
67
68怎样跟踪Oops.. [原发到linux-kernel的一封邮件]
69
70主要的窍门是有五年和这些烦人的oops消息打交道的经验;-)
71
72实际上,你有办法使它更简单。我有两个不同的方法:
73
74 gdb /usr/src/linux/vmlinux
75 gdb> disassemble <offending_function>
76
77那是发现问题的简单办法,至少如果bug报告做的好的情况下(象这个一样-运行ksymoops
78得到oops发生的函数及函数内的偏移)。
79
80哦,如果报告发生的内核以相同的编译器和相似的配置编译它会有帮助的。
81
82另一件要做的事是反汇编bug报告的“Code”部分:ksymoops也会用正确的工具来做这件事,
83但如果没有那些工具你可以写一个傻程序:
84
85 char str[] = "\xXX\xXX\xXX...";
86 main(){}
87
88并用gcc -g编译它然后执行“disassemble str”(XX部分是由Oops报告的值-你可以仅剪切
89粘贴并用“\x”替换空格-我就是这么做的,因为我懒得写程序自动做这一切)。
90
91另外,你可以用scripts/decodecode这个shell脚本。它的使用方法是:
92decodecode < oops.txt
93
94“Code”之后的十六进制字节可能(在某些架构上)有一些当前指令之前的指令字节以及
95当前和之后的指令字节
96
97Code: f9 0f 8d f9 00 00 00 8d 42 0c e8 dd 26 11 c7 a1 60 ea 2b f9 8b 50 08 a1
9864 ea 2b f9 8d 34 82 8b 1e 85 db 74 6d 8b 15 60 ea 2b f9 <8b> 43 04 39 42 54
997e 04 40 89 42 54 8b 43 04 3b 05 00 f6 52 c0
100
101最后,如果你想知道代码来自哪里,你可以:
102
103 cd /usr/src/linux
104 make fs/buffer.s # 或任何产生BUG的文件
105
106然后你会比gdb反汇编更清楚的知道发生了什么。
107
108现在,问题是把你所拥有的所有数据结合起来:C源码(关于它应该怎样的一般知识),
109汇编代码及其反汇编得到的代码(另外还有从“oops”消息得到的寄存器状态-对了解毁坏的
110指针有用,而且当你有了汇编代码你也能拿其它的寄存器和任何它们对应的C表达式做匹配
111)。
112
113实际上,你仅需看看哪里不匹配(这个例子是“Code”反汇编和编译器生成的代码不匹配)。
114然后你须要找出为什么不匹配。通常很简单-你看到代码使用了空指针然后你看代码想知道
115空指针是怎么出现的,还有检查它是否合法..
116
117现在,如果明白这是一项耗时的工作而且需要一丁点儿的专心,没错。这就是我为什么大多
118只是忽略那些没有符号表信息的崩溃报告的原因:简单的说太难查找了(我有一些
119程序用于在内核代码段中搜索特定的模式,而且有时我也已经能找出那些崩溃的地方,但是
120仅仅是找出正确的序列也确实需要相当扎实的内核知识)
121
122_有时_会发生这种情况,我仅看到崩溃中的反汇编代码序列, 然后我马上就明白问题出在
123哪里。这时我才意识到自己干这个工作已经太长时间了;-)
124
125 Linus
126
127
128---------------------------------------------------------------------------
129关于Oops跟踪的注解:
130
131为了帮助Linus和其它内核开发者,klogd纳入了大量的支持来处理保护错误。为了拥有对
132地址解析的完整支持至少应该使用1.3-pl3的sysklogd包。
133
134当保护错误发生时,klogd守护进程自动把内核日志信息中的重要地址翻译成它们相应的符
135号。
136
137klogd执行两种类型的地址解析。首先是静态翻译其次是动态翻译。静态翻译和ksymoops
138一样使用System.map文件。为了做静态翻译klogd守护进程必须在初始化时能找到system
139map文件。关于klogd怎样搜索map文件请参看klogd手册页。
140
141动态地址翻译在使用内核可装载模块时很重要。 因为内核模块的内存是从内核动态内存池
142里分配的,所以不管是模块开始位置还是模块中函数和符号的位置都不是固定的。
143
144内核支持允许程序决定装载哪些模块和它们在内存中位置的系统调用。使用这些系统调用
145klogd守护进程生成一张符号表用于调试发生在可装载模块中的保护错误。
146
147至少klogd会提供产生保护错误的模块名。还可有额外的符号信息供可装载模块开发者选择
148以从模块中输出符号信息。
149
150因为内核模块环境可能是动态的,所以必须有一种机制当模块环境发生改变时来通知klogd
151守护进程。 有一些可用的命令行选项允许klogd向当前执行中的守护进程发送信号,告知符
152号信息应该被刷新了。 更多信息请参看klogd手册页。
153
154sysklogd发布时包含一个补丁修改了modules-2.0.0包,无论何时一个模块装载或者卸载都
155会自动向klogd发送信号。打上这个补丁提供了必要的对调试发生于内核可装载模块的保护
156错误的无缝支持。
157
158以下是被klogd处理过的发生在可装载模块中的一个保护错误例子:
159---------------------------------------------------------------------------
160Aug 29 09:51:01 blizard kernel: Unable to handle kernel paging request at virtual address f15e97cc
161Aug 29 09:51:01 blizard kernel: current->tss.cr3 = 0062d000, %cr3 = 0062d000
162Aug 29 09:51:01 blizard kernel: *pde = 00000000
163Aug 29 09:51:01 blizard kernel: Oops: 0002
164Aug 29 09:51:01 blizard kernel: CPU: 0
165Aug 29 09:51:01 blizard kernel: EIP: 0010:[oops:_oops+16/3868]
166Aug 29 09:51:01 blizard kernel: EFLAGS: 00010212
167Aug 29 09:51:01 blizard kernel: eax: 315e97cc ebx: 003a6f80 ecx: 001be77b edx: 00237c0c
168Aug 29 09:51:01 blizard kernel: esi: 00000000 edi: bffffdb3 ebp: 00589f90 esp: 00589f8c
169Aug 29 09:51:01 blizard kernel: ds: 0018 es: 0018 fs: 002b gs: 002b ss: 0018
170Aug 29 09:51:01 blizard kernel: Process oops_test (pid: 3374, process nr: 21, stackpage=00589000)
171Aug 29 09:51:01 blizard kernel: Stack: 315e97cc 00589f98 0100b0b4 bffffed4 0012e38e 00240c64 003a6f80 00000001
172Aug 29 09:51:01 blizard kernel: 00000000 00237810 bfffff00 0010a7fa 00000003 00000001 00000000 bfffff00
173Aug 29 09:51:01 blizard kernel: bffffdb3 bffffed4 ffffffda 0000002b 0007002b 0000002b 0000002b 00000036
174Aug 29 09:51:01 blizard kernel: Call Trace: [oops:_oops_ioctl+48/80] [_sys_ioctl+254/272] [_system_call+82/128]
175Aug 29 09:51:01 blizard kernel: Code: c7 00 05 00 00 00 eb 08 90 90 90 90 90 90 90 90 89 ec 5d c3
176---------------------------------------------------------------------------
177
178Dr. G.W. Wettstein Oncology Research Div. Computing Facility
179Roger Maris Cancer Center INTERNET: greg@wind.rmcc.com
180820 4th St. N.
181Fargo, ND 58122
182Phone: 701-234-7556
183
184
185---------------------------------------------------------------------------
186受污染的内核
187
188一些oops报告在程序记数器之后包含字符串'Tainted: '。这表明内核已经被一些东西给污
189染了。 该字符串之后紧跟着一系列的位置敏感的字符,每个代表一个特定的污染值。
190
191 1:'G'如果所有装载的模块都有GPL或相容的许可证,'P'如果装载了任何的专有模块。
192没有模块MODULE_LICENSE或者带有insmod认为是与GPL不相容的的MODULE_LICENSE的模块被
193认定是专有的。
194
195 2:'F'如果有任何通过“insmod -f”被强制装载的模块,' '如果所有模块都被正常装载。
196
197 3:'S'如果oops发生在SMP内核中,运行于没有证明安全运行多处理器的硬件。 当前这种
198情况仅限于几种不支持SMP的速龙处理器。
199
200 4:'R'如果模块通过“insmod -f”被强制装载,' '如果所有模块都被正常装载。
201
202 5:'M'如果任何处理器报告了机器检查异常,' '如果没有发生机器检查异常。
203
204 6:'B'如果页释放函数发现了一个错误的页引用或者一些非预期的页标志。
205
206 7:'U'如果用户或者用户应用程序特别请求设置污染标志,否则' '。
207
208 8:'D'如果内核刚刚死掉,比如有OOPS或者BUG。
209
210使用'Tainted: '字符串的主要原因是要告诉内核调试者,这是否是一个干净的内核亦或发
211生了任何的不正常的事。污染是永久的:即使出错的模块已经被卸载了,污染值仍然存在,
212以表明内核不再值得信任。
diff --git a/Documentation/zh_CN/sparse.txt b/Documentation/zh_CN/sparse.txt
new file mode 100644
index 000000000000..75992a603ae3
--- /dev/null
+++ b/Documentation/zh_CN/sparse.txt
@@ -0,0 +1,100 @@
1Chinese translated version of Documentation/sparse.txt
2
3If you have any comment or update to the content, please contact the
4original document maintainer directly. However, if you have a problem
5communicating in English you can also ask the Chinese maintainer for
6help. Contact the Chinese maintainer if this translation is outdated
7or if there is a problem with the translation.
8
9Chinese maintainer: Li Yang <leo@zh-kernel.org>
10---------------------------------------------------------------------
11Documentation/sparse.txt 的中文翻译
12
13如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
14交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
15译存在问题,请联系中文版维护者。
16
17中文版维护者: 李阳 Li Yang <leo@zh-kernel.org>
18中文版翻译者: 李阳 Li Yang <leo@zh-kernel.org>
19
20
21以下为正文
22---------------------------------------------------------------------
23
24Copyright 2004 Linus Torvalds
25Copyright 2004 Pavel Machek <pavel@suse.cz>
26Copyright 2006 Bob Copeland <me@bobcopeland.com>
27
28使用 sparse 工具做类型检查
29~~~~~~~~~~~~~~~~~~~~~~~~~~
30
31"__bitwise" 是一种类型属性,所以你应该这样使用它:
32
33 typedef int __bitwise pm_request_t;
34
35 enum pm_request {
36 PM_SUSPEND = (__force pm_request_t) 1,
37 PM_RESUME = (__force pm_request_t) 2
38 };
39
40这样会使 PM_SUSPEND 和 PM_RESUME 成为位方式(bitwise)整数(使用"__force"
41是因为 sparse 会抱怨改变位方式的类型转换,但是这里我们确实需要强制进行转
42换)。而且因为所有枚举值都使用了相同的类型,这里的"enum pm_request"也将
43会使用那个类型做为底层实现。
44
45而且使用 gcc 编译的时候,所有的 __bitwise/__force 都会消失,最后在 gcc
46看来它们只不过是普通的整数。
47
48坦白来说,你并不需要使用枚举类型。上面那些实际都可以浓缩成一个特殊的"int
49__bitwise"类型。
50
51所以更简单的办法只要这样做:
52
53 typedef int __bitwise pm_request_t;
54
55 #define PM_SUSPEND ((__force pm_request_t) 1)
56 #define PM_RESUME ((__force pm_request_t) 2)
57
58现在你就有了严格的类型检查所需要的所有基础架构。
59
60一个小提醒:常数整数"0"是特殊的。你可以直接把常数零当作位方式整数使用而
61不用担心 sparse 会抱怨。这是因为"bitwise"(恰如其名)是用来确保不同位方
62式类型不会被弄混(小尾模式,大尾模式,cpu尾模式,或者其他),对他们来说
63常数"0"确实是特殊的。
64
65获取 sparse 工具
66~~~~~~~~~~~~~~~~
67
68你可以从 Sparse 的主页获取最新的发布版本:
69
70 http://www.kernel.org/pub/linux/kernel/people/josh/sparse/
71
72或者,你也可以使用 git 克隆最新的 sparse 开发版本:
73
74 git://git.kernel.org/pub/scm/linux/kernel/git/josh/sparse.git
75
76DaveJ 把每小时自动生成的 git 源码树 tar 包放在以下地址:
77
78 http://www.codemonkey.org.uk/projects/git-snapshots/sparse/
79
80一旦你下载了源码,只要以普通用户身份运行:
81
82 make
83 make install
84
85它将会被自动安装到你的 ~/bin 目录下。
86
87使用 sparse 工具
88~~~~~~~~~~~~~~~~
89
90用"make C=1"命令来编译内核,会对所有重新编译的 C 文件使用 sparse 工具。
91或者使用"make C=2"命令,无论文件是否被重新编译都会对其使用 sparse 工具。
92如果你已经编译了内核,用后一种方式可以很快地检查整个源码树。
93
94make 的可选变量 CHECKFLAGS 可以用来向 sparse 工具传递参数。编译系统会自
95动向 sparse 工具传递 -Wbitwise 参数。你可以定义 __CHECK_ENDIAN__ 来进行
96大小尾检查。
97
98 make C=2 CHECKFLAGS="-D__CHECK_ENDIAN__"
99
100这些检查默认都是被关闭的,因为他们通常会产生大量的警告。
diff --git a/Documentation/zh_CN/stable_kernel_rules.txt b/Documentation/zh_CN/stable_kernel_rules.txt
new file mode 100644
index 000000000000..b5b9b0ab02fd
--- /dev/null
+++ b/Documentation/zh_CN/stable_kernel_rules.txt
@@ -0,0 +1,66 @@
1Chinese translated version of Documentation/stable_kernel_rules.txt
2
3If you have any comment or update to the content, please contact the
4original document maintainer directly. However, if you have a problem
5communicating in English you can also ask the Chinese maintainer for
6help. Contact the Chinese maintainer if this translation is outdated
7or if there is a problem with the translation.
8
9Chinese maintainer: TripleX Chung <triplex@zh-kernel.org>
10---------------------------------------------------------------------
11Documentation/stable_kernel_rules.txt 的中文翻译
12
13如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
14交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
15译存在问题,请联系中文版维护者。
16
17
18中文版维护者: 钟宇 TripleX Chung <triplex@zh-kernel.org>
19中文版翻译者: 钟宇 TripleX Chung <triplex@zh-kernel.org>
20中文版校译者: 李阳 Li Yang <leo@zh-kernel.org>
21 Kangkai Yin <e12051@motorola.com>
22
23以下为正文
24---------------------------------------------------------------------
25
26关于Linux 2.6稳定版发布,所有你想知道的事情。
27
28关于哪些类型的补丁可以被接收进入稳定版代码树,哪些不可以的规则:
29
30 - 必须是显而易见的正确,并且经过测试的。
31 - 连同上下文,不能大于100行。
32 - 必须只修正一件事情。
33 - 必须修正了一个给大家带来麻烦的真正的bug(不是“这也许是一个问题...”
34 那样的东西)。
35 - 必须修正带来如下后果的问题:编译错误(对被标记为CONFIG_BROKEN的例外),
36 内核崩溃,挂起,数据损坏,真正的安全问题,或者一些类似“哦,这不
37 好”的问题。简短的说,就是一些致命的问题。
38 - 没有“理论上的竞争条件”,除非能给出竞争条件如何被利用的解释。
39 - 不能存在任何的“琐碎的”修正(拼写修正,去掉多余空格之类的)。
40 - 必须被相关子系统的维护者接受。
41 - 必须遵循Documentation/SubmittingPatches里的规则。
42
43向稳定版代码树提交补丁的过程:
44
45 - 在确认了补丁符合以上的规则后,将补丁发送到stable@kernel.org。
46 - 如果补丁被接受到队列里,发送者会收到一个ACK回复,如果没有被接受,收
47 到的是NAK回复。回复需要几天的时间,这取决于开发者的时间安排。
48 - 被接受的补丁会被加到稳定版本队列里,等待其他开发者的审查。
49 - 安全方面的补丁不要发到这个列表,应该发送到security@kernel.org。
50
51审查周期:
52
53 - 当稳定版的维护者决定开始一个审查周期,补丁将被发送到审查委员会,以
54 及被补丁影响的领域的维护者(除非提交者就是该领域的维护者)并且抄送
55 到linux-kernel邮件列表。
56 - 审查委员会有48小时的时间,用来决定给该补丁回复ACK还是NAK。
57 - 如果委员会中有成员拒绝这个补丁,或者linux-kernel列表上有人反对这个
58 补丁,并提出维护者和审查委员会之前没有意识到的问题,补丁会从队列中
59 丢弃。
60 - 在审查周期结束的时候,那些得到ACK回应的补丁将会被加入到最新的稳定版
61 发布中,一个新的稳定版发布就此产生。
62 - 安全性补丁将从内核安全小组那里直接接收到稳定版代码树中,而不是通过
63 通常的审查周期。请联系内核安全小组以获得关于这个过程的更多细节。
64
65审查委员会:
66 - 由一些自愿承担这项任务的内核开发者,和几个非志愿的组成。
diff --git a/Documentation/zh_CN/volatile-considered-harmful.txt b/Documentation/zh_CN/volatile-considered-harmful.txt
new file mode 100644
index 000000000000..ba8149d2233a
--- /dev/null
+++ b/Documentation/zh_CN/volatile-considered-harmful.txt
@@ -0,0 +1,113 @@
1Chinese translated version of Documentation/volatile-considered-harmful.txt
2
3If you have any comment or update to the content, please contact the
4original document maintainer directly. However, if you have a problem
5communicating in English you can also ask the Chinese maintainer for
6help. Contact the Chinese maintainer if this translation is outdated
7or if there is a problem with the translation.
8
9Maintainer: Jonathan Corbet <corbet@lwn.net>
10Chinese maintainer: Bryan Wu <bryan.wu@analog.com>
11---------------------------------------------------------------------
12Documentation/volatile-considered-harmful.txt 的中文翻译
13
14如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
15交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
16译存在问题,请联系中文版维护者。
17
18英文版维护者: Jonathan Corbet <corbet@lwn.net>
19中文版维护者: 伍鹏 Bryan Wu <bryan.wu@analog.com>
20中文版翻译者: 伍鹏 Bryan Wu <bryan.wu@analog.com>
21中文版校译者: 张汉辉 Eugene Teo <eugeneteo@kernel.sg>
22 杨瑞 Dave Young <hidave.darkstar@gmail.com>
23以下为正文
24---------------------------------------------------------------------
25
26为什么不应该使用“volatile”类型
27------------------------------
28
29C程序员通常认为volatile表示某个变量可以在当前执行的线程之外被改变;因此,在内核
30中用到共享数据结构时,常常会有C程序员喜欢使用volatile这类变量。换句话说,他们经
31常会把volatile类型看成某种简易的原子变量,当然它们不是。在内核中使用volatile几
32乎总是错误的;本文档将解释为什么这样。
33
34理解volatile的关键是知道它的目的是用来消除优化,实际上很少有人真正需要这样的应
35用。在内核中,程序员必须防止意外的并发访问破坏共享的数据结构,这其实是一个完全
36不同的任务。用来防止意外并发访问的保护措施,可以更加高效的避免大多数优化相关的
37问题。
38
39像volatile一样,内核提供了很多原语来保证并发访问时的数据安全(自旋锁, 互斥量,内
40存屏障等等),同样可以防止意外的优化。如果可以正确使用这些内核原语,那么就没有
41必要再使用volatile。如果仍然必须使用volatile,那么几乎可以肯定在代码的某处有一
42个bug。在正确设计的内核代码中,volatile能带来的仅仅是使事情变慢。
43
44思考一下这段典型的内核代码:
45
46 spin_lock(&the_lock);
47 do_something_on(&shared_data);
48 do_something_else_with(&shared_data);
49 spin_unlock(&the_lock);
50
51如果所有的代码都遵循加锁规则,当持有the_lock的时候,不可能意外的改变shared_data的
52值。任何可能访问该数据的其他代码都会在这个锁上等待。自旋锁原语跟内存屏障一样—— 它
53们显式的用来书写成这样 —— 意味着数据访问不会跨越它们而被优化。所以本来编译器认为
54它知道在shared_data里面将有什么,但是因为spin_lock()调用跟内存屏障一样,会强制编
55译器忘记它所知道的一切。那么在访问这些数据时不会有优化的问题。
56
57如果shared_data被声名为volatile,锁操作将仍然是必须的。就算我们知道没有其他人正在
58使用它,编译器也将被阻止优化对临界区内shared_data的访问。在锁有效的同时,
59shared_data不是volatile的。在处理共享数据的时候,适当的锁操作可以不再需要
60volatile —— 并且是有潜在危害的。
61
62volatile的存储类型最初是为那些内存映射的I/O寄存器而定义。在内核里,寄存器访问也应
63该被锁保护,但是人们也不希望编译器“优化”临界区内的寄存器访问。内核里I/O的内存访问
64是通过访问函数完成的;不赞成通过指针对I/O内存的直接访问,并且不是在所有体系架构上
65都能工作。那些访问函数正是为了防止意外优化而写的,因此,再说一次,volatile类型不
66是必需的。
67
68另一种引起用户可能使用volatile的情况是当处理器正忙着等待一个变量的值。正确执行一
69个忙等待的方法是:
70
71 while (my_variable != what_i_want)
72 cpu_relax();
73
74cpu_relax()调用会降低CPU的能量消耗或者让位于超线程双处理器;它也作为内存屏障一样出
75现,所以,再一次,volatile不是必需的。当然,忙等待一开始就是一种反常规的做法。
76
77在内核中,一些稀少的情况下volatile仍然是有意义的:
78
79 - 在一些体系架构的系统上,允许直接的I/0内存访问,那么前面提到的访问函数可以使用
80 volatile。基本上,每一个访问函数调用它自己都是一个小的临界区域并且保证了按照
81 程序员期望的那样发生访问操作。
82
83 - 某些会改变内存的内联汇编代码虽然没有什么其他明显的附作用,但是有被GCC删除的可
84 能性。在汇编声明中加上volatile关键字可以防止这种删除操作。
85
86 - Jiffies变量是一种特殊情况,虽然每次引用它的时候都可以有不同的值,但读jiffies
87 变量时不需要任何特殊的加锁保护。所以jiffies变量可以使用volatile,但是不赞成
88 其他跟jiffies相同类型变量使用volatile。Jiffies被认为是一种“愚蠢的遗留物"
89 (Linus的话)因为解决这个问题比保持现状要麻烦的多。
90
91 - 由于某些I/0设备可能会修改连续一致的内存,所以有时,指向连续一致内存的数据结构
92 的指针需要正确的使用volatile。网络适配器使用的环状缓存区正是这类情形的一个例
93 子,其中适配器用改变指针来表示哪些描述符已经处理过了。
94
95对于大多代码,上述几种可以使用volatile的情况都不适用。所以,使用volatile是一种
96bug并且需要对这样的代码额外仔细检查。那些试图使用volatile的开发人员需要退一步想想
97他们真正想实现的是什么。
98
99非常欢迎删除volatile变量的补丁 - 只要证明这些补丁完整的考虑了并发问题。
100
101注释
102----
103
104[1] http://lwn.net/Articles/233481/
105[2] http://lwn.net/Articles/233482/
106
107致谢
108----
109
110最初由Randy Dunlap推动并作初步研究
111由Jonathan Corbet撰写
112参考Satyam Sharma,Johannes Stezenbach,Jesper Juhl,Heikki Orsila,
113H. Peter Anvin,Philipp Hahn和Stefan Richter的意见改善了本档。