aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/CodingStyle20
-rw-r--r--Documentation/DocBook/Makefile10
-rw-r--r--Documentation/DocBook/kernel-api.tmpl5
-rw-r--r--Documentation/DocBook/uio-howto.tmpl611
-rw-r--r--Documentation/HOWTO3
-rw-r--r--Documentation/connector/cn_test.c3
-rw-r--r--Documentation/console/console.txt2
-rw-r--r--Documentation/driver-model/devres.txt2
-rw-r--r--Documentation/drivers/edac/edac.txt192
-rw-r--r--Documentation/dvb/bt8xx.txt32
-rw-r--r--Documentation/dvb/get_dvb_firmware63
-rw-r--r--Documentation/dvb/opera-firmware.txt27
-rw-r--r--Documentation/feature-removal-schedule.txt56
-rw-r--r--Documentation/filesystems/Locking13
-rw-r--r--Documentation/filesystems/configfs/configfs_example.c6
-rw-r--r--Documentation/filesystems/proc.txt45
-rw-r--r--Documentation/gpio.txt3
-rw-r--r--Documentation/hwmon/abituguru31
-rw-r--r--Documentation/hwmon/abituguru365
-rw-r--r--Documentation/hwmon/dme1737257
-rw-r--r--Documentation/hwmon/f71805f35
-rw-r--r--Documentation/hwmon/it879
-rw-r--r--Documentation/hwmon/lm9036
-rw-r--r--Documentation/hwmon/lm93412
-rw-r--r--Documentation/hwmon/smsc47b3977
-rw-r--r--Documentation/hwmon/sysfs-interface15
-rw-r--r--Documentation/hwmon/w83627ehf6
-rw-r--r--Documentation/ja_JP/HOWTO650
-rw-r--r--Documentation/ja_JP/stable_api_nonsense.txt263
-rw-r--r--Documentation/kbuild/makefiles.txt14
-rw-r--r--Documentation/kernel-parameters.txt7
-rw-r--r--Documentation/kprobes.txt8
-rw-r--r--Documentation/lguest/Makefile27
-rw-r--r--Documentation/lguest/lguest.c1012
-rw-r--r--Documentation/lguest/lguest.txt129
-rw-r--r--Documentation/power/freezing-of-tasks.txt8
-rw-r--r--Documentation/power/notifiers.txt50
-rw-r--r--Documentation/powerpc/booting-without-of.txt6
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt75
-rw-r--r--Documentation/sound/alsa/Audiophile-Usb.txt242
-rw-r--r--Documentation/sound/alsa/OSS-Emulation.txt15
-rw-r--r--Documentation/thinkpad-acpi.txt353
-rw-r--r--Documentation/time_interpolators.txt41
-rw-r--r--Documentation/video4linux/CARDLIST.bttv4
-rw-r--r--Documentation/video4linux/CARDLIST.cx881
-rw-r--r--Documentation/video4linux/CARDLIST.saa71341
-rw-r--r--Documentation/video4linux/CARDLIST.tuner3
-rw-r--r--Documentation/video4linux/sn9c102.txt3
-rw-r--r--Documentation/video4linux/zr364xx.txt2
-rw-r--r--Documentation/x86_64/boot-options.txt14
-rw-r--r--Documentation/x86_64/machinecheck14
-rw-r--r--Documentation/zh_CN/HOWTO536
-rw-r--r--Documentation/zh_CN/stable_api_nonsense.txt157
53 files changed, 5229 insertions, 372 deletions
diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
index a667eb1fc26e..7f1730f1a1ae 100644
--- a/Documentation/CodingStyle
+++ b/Documentation/CodingStyle
@@ -633,12 +633,27 @@ covers RTL which is used frequently with assembly language in the kernel.
633 633
634Kernel developers like to be seen as literate. Do mind the spelling 634Kernel developers like to be seen as literate. Do mind the spelling
635of kernel messages to make a good impression. Do not use crippled 635of kernel messages to make a good impression. Do not use crippled
636words like "dont" and use "do not" or "don't" instead. 636words like "dont"; use "do not" or "don't" instead. Make the messages
637concise, clear, and unambiguous.
637 638
638Kernel messages do not have to be terminated with a period. 639Kernel messages do not have to be terminated with a period.
639 640
640Printing numbers in parentheses (%d) adds no value and should be avoided. 641Printing numbers in parentheses (%d) adds no value and should be avoided.
641 642
643There are a number of driver model diagnostic macros in <linux/device.h>
644which you should use to make sure messages are matched to the right device
645and driver, and are tagged with the right level: dev_err(), dev_warn(),
646dev_info(), and so forth. For messages that aren't associated with a
647particular device, <linux/kernel.h> defines pr_debug() and pr_info().
648
649Coming up with good debugging messages can be quite a challenge; and once
650you have them, they can be a huge help for remote troubleshooting. Such
651messages should be compiled out when the DEBUG symbol is not defined (that
652is, by default they are not included). When you use dev_dbg() or pr_debug(),
653that's automatic. Many subsystems have Kconfig options to turn on -DDEBUG.
654A related convention uses VERBOSE_DEBUG to add dev_vdbg() messages to the
655ones already enabled by DEBUG.
656
642 657
643 Chapter 14: Allocating memory 658 Chapter 14: Allocating memory
644 659
@@ -790,4 +805,5 @@ Kernel CodingStyle, by greg@kroah.com at OLS 2002:
790http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/ 805http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/
791 806
792-- 807--
793Last updated on 2006-December-06. 808Last updated on 2007-July-13.
809
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 6fd1646d3204..08687e45e19d 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -15,11 +15,11 @@ DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \
15 15
16### 16###
17# The build process is as follows (targets): 17# The build process is as follows (targets):
18# (xmldocs) 18# (xmldocs) [by docproc]
19# file.tmpl --> file.xml +--> file.ps (psdocs) 19# file.tmpl --> file.xml +--> file.ps (psdocs) [by db2ps or xmlto]
20# +--> file.pdf (pdfdocs) 20# +--> file.pdf (pdfdocs) [by db2pdf or xmlto]
21# +--> DIR=file (htmldocs) 21# +--> DIR=file (htmldocs) [by xmlto]
22# +--> man/ (mandocs) 22# +--> man/ (mandocs) [by xmlto]
23 23
24 24
25# for PDF and PS output you can choose between xmlto and docbook-utils tools 25# for PDF and PS output you can choose between xmlto and docbook-utils tools
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index fd2ef4d29b6d..eb42bf9847cb 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -159,7 +159,6 @@ X!Ilib/string.c
159!Earch/i386/lib/usercopy.c 159!Earch/i386/lib/usercopy.c
160 </sect1> 160 </sect1>
161 <sect1><title>More Memory Management Functions</title> 161 <sect1><title>More Memory Management Functions</title>
162!Iinclude/linux/rmap.h
163!Emm/readahead.c 162!Emm/readahead.c
164!Emm/filemap.c 163!Emm/filemap.c
165!Emm/memory.c 164!Emm/memory.c
@@ -408,6 +407,10 @@ X!Edrivers/pnp/system.c
408!Edrivers/pnp/manager.c 407!Edrivers/pnp/manager.c
409!Edrivers/pnp/support.c 408!Edrivers/pnp/support.c
410 </sect1> 409 </sect1>
410 <sect1><title>Userspace IO devices</title>
411!Edrivers/uio/uio.c
412!Iinclude/linux/uio_driver.h
413 </sect1>
411 </chapter> 414 </chapter>
412 415
413 <chapter id="blkdev"> 416 <chapter id="blkdev">
diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
new file mode 100644
index 000000000000..e3bb29a8d8dd
--- /dev/null
+++ b/Documentation/DocBook/uio-howto.tmpl
@@ -0,0 +1,611 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" []>
4
5<book id="index">
6<bookinfo>
7<title>The Userspace I/O HOWTO</title>
8
9<author>
10 <firstname>Hans-Jürgen</firstname>
11 <surname>Koch</surname>
12 <authorblurb><para>Linux developer, Linutronix</para></authorblurb>
13 <affiliation>
14 <orgname>
15 <ulink url="http://www.linutronix.de">Linutronix</ulink>
16 </orgname>
17
18 <address>
19 <email>hjk@linutronix.de</email>
20 </address>
21 </affiliation>
22</author>
23
24<pubdate>2006-12-11</pubdate>
25
26<abstract>
27 <para>This HOWTO describes concept and usage of Linux kernel's
28 Userspace I/O system.</para>
29</abstract>
30
31<revhistory>
32 <revision>
33 <revnumber>0.3</revnumber>
34 <date>2007-04-29</date>
35 <authorinitials>hjk</authorinitials>
36 <revremark>Added section about userspace drivers.</revremark>
37 </revision>
38 <revision>
39 <revnumber>0.2</revnumber>
40 <date>2007-02-13</date>
41 <authorinitials>hjk</authorinitials>
42 <revremark>Update after multiple mappings were added.</revremark>
43 </revision>
44 <revision>
45 <revnumber>0.1</revnumber>
46 <date>2006-12-11</date>
47 <authorinitials>hjk</authorinitials>
48 <revremark>First draft.</revremark>
49 </revision>
50</revhistory>
51</bookinfo>
52
53<chapter id="aboutthisdoc">
54<?dbhtml filename="about.html"?>
55<title>About this document</title>
56
57<sect1 id="copyright">
58<?dbhtml filename="copyright.html"?>
59<title>Copyright and License</title>
60<para>
61 Copyright (c) 2006 by Hans-Jürgen Koch.</para>
62<para>
63This documentation is Free Software licensed under the terms of the
64GPL version 2.
65</para>
66</sect1>
67
68<sect1 id="translations">
69<?dbhtml filename="translations.html"?>
70<title>Translations</title>
71
72<para>If you know of any translations for this document, or you are
73interested in translating it, please email me
74<email>hjk@linutronix.de</email>.
75</para>
76</sect1>
77
78<sect1 id="preface">
79<title>Preface</title>
80 <para>
81 For many types of devices, creating a Linux kernel driver is
82 overkill. All that is really needed is some way to handle an
83 interrupt and provide access to the memory space of the
84 device. The logic of controlling the device does not
85 necessarily have to be within the kernel, as the device does
86 not need to take advantage of any of other resources that the
87 kernel provides. One such common class of devices that are
88 like this are for industrial I/O cards.
89 </para>
90 <para>
91 To address this situation, the userspace I/O system (UIO) was
92 designed. For typical industrial I/O cards, only a very small
93 kernel module is needed. The main part of the driver will run in
94 user space. This simplifies development and reduces the risk of
95 serious bugs within a kernel module.
96 </para>
97</sect1>
98
99<sect1 id="thanks">
100<title>Acknowledgments</title>
101 <para>I'd like to thank Thomas Gleixner and Benedikt Spranger of
102 Linutronix, who have not only written most of the UIO code, but also
103 helped greatly writing this HOWTO by giving me all kinds of background
104 information.</para>
105</sect1>
106
107<sect1 id="feedback">
108<title>Feedback</title>
109 <para>Find something wrong with this document? (Or perhaps something
110 right?) I would love to hear from you. Please email me at
111 <email>hjk@linutronix.de</email>.</para>
112</sect1>
113</chapter>
114
115<chapter id="about">
116<?dbhtml filename="about.html"?>
117<title>About UIO</title>
118
119<para>If you use UIO for your card's driver, here's what you get:</para>
120
121<itemizedlist>
122<listitem>
123 <para>only one small kernel module to write and maintain.</para>
124</listitem>
125<listitem>
126 <para>develop the main part of your driver in user space,
127 with all the tools and libraries you're used to.</para>
128</listitem>
129<listitem>
130 <para>bugs in your driver won't crash the kernel.</para>
131</listitem>
132<listitem>
133 <para>updates of your driver can take place without recompiling
134 the kernel.</para>
135</listitem>
136<listitem>
137 <para>if you need to keep some parts of your driver closed source,
138 you can do so without violating the GPL license on the kernel.</para>
139</listitem>
140</itemizedlist>
141
142<sect1 id="how_uio_works">
143<title>How UIO works</title>
144 <para>
145 Each UIO device is accessed through a device file and several
146 sysfs attribute files. The device file will be called
147 <filename>/dev/uio0</filename> for the first device, and
148 <filename>/dev/uio1</filename>, <filename>/dev/uio2</filename>
149 and so on for subsequent devices.
150 </para>
151
152 <para><filename>/dev/uioX</filename> is used to access the
153 address space of the card. Just use
154 <function>mmap()</function> to access registers or RAM
155 locations of your card.
156 </para>
157
158 <para>
159 Interrupts are handled by reading from
160 <filename>/dev/uioX</filename>. A blocking
161 <function>read()</function> from
162 <filename>/dev/uioX</filename> will return as soon as an
163 interrupt occurs. You can also use
164 <function>select()</function> on
165 <filename>/dev/uioX</filename> to wait for an interrupt. The
166 integer value read from <filename>/dev/uioX</filename>
167 represents the total interrupt count. You can use this number
168 to figure out if you missed some interrupts.
169 </para>
170
171 <para>
172 To handle interrupts properly, your custom kernel module can
173 provide its own interrupt handler. It will automatically be
174 called by the built-in handler.
175 </para>
176
177 <para>
178 For cards that don't generate interrupts but need to be
179 polled, there is the possibility to set up a timer that
180 triggers the interrupt handler at configurable time intervals.
181 See <filename>drivers/uio/uio_dummy.c</filename> for an
182 example of this technique.
183 </para>
184
185 <para>
186 Each driver provides attributes that are used to read or write
187 variables. These attributes are accessible through sysfs
188 files. A custom kernel driver module can add its own
189 attributes to the device owned by the uio driver, but not added
190 to the UIO device itself at this time. This might change in the
191 future if it would be found to be useful.
192 </para>
193
194 <para>
195 The following standard attributes are provided by the UIO
196 framework:
197 </para>
198<itemizedlist>
199<listitem>
200 <para>
201 <filename>name</filename>: The name of your device. It is
202 recommended to use the name of your kernel module for this.
203 </para>
204</listitem>
205<listitem>
206 <para>
207 <filename>version</filename>: A version string defined by your
208 driver. This allows the user space part of your driver to deal
209 with different versions of the kernel module.
210 </para>
211</listitem>
212<listitem>
213 <para>
214 <filename>event</filename>: The total number of interrupts
215 handled by the driver since the last time the device node was
216 read.
217 </para>
218</listitem>
219</itemizedlist>
220<para>
221 These attributes appear under the
222 <filename>/sys/class/uio/uioX</filename> directory. Please
223 note that this directory might be a symlink, and not a real
224 directory. Any userspace code that accesses it must be able
225 to handle this.
226</para>
227<para>
228 Each UIO device can make one or more memory regions available for
229 memory mapping. This is necessary because some industrial I/O cards
230 require access to more than one PCI memory region in a driver.
231</para>
232<para>
233 Each mapping has its own directory in sysfs, the first mapping
234 appears as <filename>/sys/class/uio/uioX/maps/map0/</filename>.
235 Subsequent mappings create directories <filename>map1/</filename>,
236 <filename>map2/</filename>, and so on. These directories will only
237 appear if the size of the mapping is not 0.
238</para>
239<para>
240 Each <filename>mapX/</filename> directory contains two read-only files
241 that show start address and size of the memory:
242</para>
243<itemizedlist>
244<listitem>
245 <para>
246 <filename>addr</filename>: The address of memory that can be mapped.
247 </para>
248</listitem>
249<listitem>
250 <para>
251 <filename>size</filename>: The size, in bytes, of the memory
252 pointed to by addr.
253 </para>
254</listitem>
255</itemizedlist>
256
257<para>
258 From userspace, the different mappings are distinguished by adjusting
259 the <varname>offset</varname> parameter of the
260 <function>mmap()</function> call. To map the memory of mapping N, you
261 have to use N times the page size as your offset:
262</para>
263<programlisting format="linespecific">
264offset = N * getpagesize();
265</programlisting>
266
267</sect1>
268</chapter>
269
270<chapter id="using-uio_dummy" xreflabel="Using uio_dummy">
271<?dbhtml filename="using-uio_dummy.html"?>
272<title>Using uio_dummy</title>
273 <para>
274 Well, there is no real use for uio_dummy. Its only purpose is
275 to test most parts of the UIO system (everything except
276 hardware interrupts), and to serve as an example for the
277 kernel module that you will have to write yourself.
278 </para>
279
280<sect1 id="what_uio_dummy_does">
281<title>What uio_dummy does</title>
282 <para>
283 The kernel module <filename>uio_dummy.ko</filename> creates a
284 device that uses a timer to generate periodic interrupts. The
285 interrupt handler does nothing but increment a counter. The
286 driver adds two custom attributes, <varname>count</varname>
287 and <varname>freq</varname>, that appear under
288 <filename>/sys/devices/platform/uio_dummy/</filename>.
289 </para>
290
291 <para>
292 The attribute <varname>count</varname> can be read and
293 written. The associated file
294 <filename>/sys/devices/platform/uio_dummy/count</filename>
295 appears as a normal text file and contains the total number of
296 timer interrupts. If you look at it (e.g. using
297 <function>cat</function>), you'll notice it is slowly counting
298 up.
299 </para>
300
301 <para>
302 The attribute <varname>freq</varname> can be read and written.
303 The content of
304 <filename>/sys/devices/platform/uio_dummy/freq</filename>
305 represents the number of system timer ticks between two timer
306 interrupts. The default value of <varname>freq</varname> is
307 the value of the kernel variable <varname>HZ</varname>, which
308 gives you an interval of one second. Lower values will
309 increase the frequency. Try the following:
310 </para>
311<programlisting format="linespecific">
312cd /sys/devices/platform/uio_dummy/
313echo 100 > freq
314</programlisting>
315 <para>
316 Use <function>cat count</function> to see how the interrupt
317 frequency changes.
318 </para>
319</sect1>
320</chapter>
321
322<chapter id="custom_kernel_module" xreflabel="Writing your own kernel module">
323<?dbhtml filename="custom_kernel_module.html"?>
324<title>Writing your own kernel module</title>
325 <para>
326 Please have a look at <filename>uio_dummy.c</filename> as an
327 example. The following paragraphs explain the different
328 sections of this file.
329 </para>
330
331<sect1 id="uio_info">
332<title>struct uio_info</title>
333 <para>
334 This structure tells the framework the details of your driver,
335 Some of the members are required, others are optional.
336 </para>
337
338<itemizedlist>
339<listitem><para>
340<varname>char *name</varname>: Required. The name of your driver as
341it will appear in sysfs. I recommend using the name of your module for this.
342</para></listitem>
343
344<listitem><para>
345<varname>char *version</varname>: Required. This string appears in
346<filename>/sys/class/uio/uioX/version</filename>.
347</para></listitem>
348
349<listitem><para>
350<varname>struct uio_mem mem[ MAX_UIO_MAPS ]</varname>: Required if you
351have memory that can be mapped with <function>mmap()</function>. For each
352mapping you need to fill one of the <varname>uio_mem</varname> structures.
353See the description below for details.
354</para></listitem>
355
356<listitem><para>
357<varname>long irq</varname>: Required. If your hardware generates an
358interrupt, it's your modules task to determine the irq number during
359initialization. If you don't have a hardware generated interrupt but
360want to trigger the interrupt handler in some other way, set
361<varname>irq</varname> to <varname>UIO_IRQ_CUSTOM</varname>. The
362uio_dummy module does this as it triggers the event mechanism in a timer
363routine. If you had no interrupt at all, you could set
364<varname>irq</varname> to <varname>UIO_IRQ_NONE</varname>, though this
365rarely makes sense.
366</para></listitem>
367
368<listitem><para>
369<varname>unsigned long irq_flags</varname>: Required if you've set
370<varname>irq</varname> to a hardware interrupt number. The flags given
371here will be used in the call to <function>request_irq()</function>.
372</para></listitem>
373
374<listitem><para>
375<varname>int (*mmap)(struct uio_info *info, struct vm_area_struct
376*vma)</varname>: Optional. If you need a special
377<function>mmap()</function> function, you can set it here. If this
378pointer is not NULL, your <function>mmap()</function> will be called
379instead of the built-in one.
380</para></listitem>
381
382<listitem><para>
383<varname>int (*open)(struct uio_info *info, struct inode *inode)
384</varname>: Optional. You might want to have your own
385<function>open()</function>, e.g. to enable interrupts only when your
386device is actually used.
387</para></listitem>
388
389<listitem><para>
390<varname>int (*release)(struct uio_info *info, struct inode *inode)
391</varname>: Optional. If you define your own
392<function>open()</function>, you will probably also want a custom
393<function>release()</function> function.
394</para></listitem>
395</itemizedlist>
396
397<para>
398Usually, your device will have one or more memory regions that can be mapped
399to user space. For each region, you have to set up a
400<varname>struct uio_mem</varname> in the <varname>mem[]</varname> array.
401Here's a description of the fields of <varname>struct uio_mem</varname>:
402</para>
403
404<itemizedlist>
405<listitem><para>
406<varname>int memtype</varname>: Required if the mapping is used. Set this to
407<varname>UIO_MEM_PHYS</varname> if you you have physical memory on your
408card to be mapped. Use <varname>UIO_MEM_LOGICAL</varname> for logical
409memory (e.g. allocated with <function>kmalloc()</function>). There's also
410<varname>UIO_MEM_VIRTUAL</varname> for virtual memory.
411</para></listitem>
412
413<listitem><para>
414<varname>unsigned long addr</varname>: Required if the mapping is used.
415Fill in the address of your memory block. This address is the one that
416appears in sysfs.
417</para></listitem>
418
419<listitem><para>
420<varname>unsigned long size</varname>: Fill in the size of the
421memory block that <varname>addr</varname> points to. If <varname>size</varname>
422is zero, the mapping is considered unused. Note that you
423<emphasis>must</emphasis> initialize <varname>size</varname> with zero for
424all unused mappings.
425</para></listitem>
426
427<listitem><para>
428<varname>void *internal_addr</varname>: If you have to access this memory
429region from within your kernel module, you will want to map it internally by
430using something like <function>ioremap()</function>. Addresses
431returned by this function cannot be mapped to user space, so you must not
432store it in <varname>addr</varname>. Use <varname>internal_addr</varname>
433instead to remember such an address.
434</para></listitem>
435</itemizedlist>
436
437<para>
438Please do not touch the <varname>kobj</varname> element of
439<varname>struct uio_mem</varname>! It is used by the UIO framework
440to set up sysfs files for this mapping. Simply leave it alone.
441</para>
442</sect1>
443
444<sect1 id="adding_irq_handler">
445<title>Adding an interrupt handler</title>
446 <para>
447 What you need to do in your interrupt handler depends on your
448 hardware and on how you want to handle it. You should try to
449 keep the amount of code in your kernel interrupt handler low.
450 If your hardware requires no action that you
451 <emphasis>have</emphasis> to perform after each interrupt,
452 then your handler can be empty.</para> <para>If, on the other
453 hand, your hardware <emphasis>needs</emphasis> some action to
454 be performed after each interrupt, then you
455 <emphasis>must</emphasis> do it in your kernel module. Note
456 that you cannot rely on the userspace part of your driver. Your
457 userspace program can terminate at any time, possibly leaving
458 your hardware in a state where proper interrupt handling is
459 still required.
460 </para>
461
462 <para>
463 There might also be applications where you want to read data
464 from your hardware at each interrupt and buffer it in a piece
465 of kernel memory you've allocated for that purpose. With this
466 technique you could avoid loss of data if your userspace
467 program misses an interrupt.
468 </para>
469
470 <para>
471 A note on shared interrupts: Your driver should support
472 interrupt sharing whenever this is possible. It is possible if
473 and only if your driver can detect whether your hardware has
474 triggered the interrupt or not. This is usually done by looking
475 at an interrupt status register. If your driver sees that the
476 IRQ bit is actually set, it will perform its actions, and the
477 handler returns IRQ_HANDLED. If the driver detects that it was
478 not your hardware that caused the interrupt, it will do nothing
479 and return IRQ_NONE, allowing the kernel to call the next
480 possible interrupt handler.
481 </para>
482
483 <para>
484 If you decide not to support shared interrupts, your card
485 won't work in computers with no free interrupts. As this
486 frequently happens on the PC platform, you can save yourself a
487 lot of trouble by supporting interrupt sharing.
488 </para>
489</sect1>
490
491</chapter>
492
493<chapter id="userspace_driver" xreflabel="Writing a driver in user space">
494<?dbhtml filename="userspace_driver.html"?>
495<title>Writing a driver in userspace</title>
496 <para>
497 Once you have a working kernel module for your hardware, you can
498 write the userspace part of your driver. You don't need any special
499 libraries, your driver can be written in any reasonable language,
500 you can use floating point numbers and so on. In short, you can
501 use all the tools and libraries you'd normally use for writing a
502 userspace application.
503 </para>
504
505<sect1 id="getting_uio_information">
506<title>Getting information about your UIO device</title>
507 <para>
508 Information about all UIO devices is available in sysfs. The
509 first thing you should do in your driver is check
510 <varname>name</varname> and <varname>version</varname> to
511 make sure your talking to the right device and that its kernel
512 driver has the version you expect.
513 </para>
514 <para>
515 You should also make sure that the memory mapping you need
516 exists and has the size you expect.
517 </para>
518 <para>
519 There is a tool called <varname>lsuio</varname> that lists
520 UIO devices and their attributes. It is available here:
521 </para>
522 <para>
523 <ulink url="http://www.osadl.org/projects/downloads/UIO/user/">
524 http://www.osadl.org/projects/downloads/UIO/user/</ulink>
525 </para>
526 <para>
527 With <varname>lsuio</varname> you can quickly check if your
528 kernel module is loaded and which attributes it exports.
529 Have a look at the manpage for details.
530 </para>
531 <para>
532 The source code of <varname>lsuio</varname> can serve as an
533 example for getting information about an UIO device.
534 The file <filename>uio_helper.c</filename> contains a lot of
535 functions you could use in your userspace driver code.
536 </para>
537</sect1>
538
539<sect1 id="mmap_device_memory">
540<title>mmap() device memory</title>
541 <para>
542 After you made sure you've got the right device with the
543 memory mappings you need, all you have to do is to call
544 <function>mmap()</function> to map the device's memory
545 to userspace.
546 </para>
547 <para>
548 The parameter <varname>offset</varname> of the
549 <function>mmap()</function> call has a special meaning
550 for UIO devices: It is used to select which mapping of
551 your device you want to map. To map the memory of
552 mapping N, you have to use N times the page size as
553 your offset:
554 </para>
555<programlisting format="linespecific">
556 offset = N * getpagesize();
557</programlisting>
558 <para>
559 N starts from zero, so if you've got only one memory
560 range to map, set <varname>offset = 0</varname>.
561 A drawback of this technique is that memory is always
562 mapped beginning with its start address.
563 </para>
564</sect1>
565
566<sect1 id="wait_for_interrupts">
567<title>Waiting for interrupts</title>
568 <para>
569 After you successfully mapped your devices memory, you
570 can access it like an ordinary array. Usually, you will
571 perform some initialization. After that, your hardware
572 starts working and will generate an interrupt as soon
573 as it's finished, has some data available, or needs your
574 attention because an error occured.
575 </para>
576 <para>
577 <filename>/dev/uioX</filename> is a read-only file. A
578 <function>read()</function> will always block until an
579 interrupt occurs. There is only one legal value for the
580 <varname>count</varname> parameter of
581 <function>read()</function>, and that is the size of a
582 signed 32 bit integer (4). Any other value for
583 <varname>count</varname> causes <function>read()</function>
584 to fail. The signed 32 bit integer read is the interrupt
585 count of your device. If the value is one more than the value
586 you read the last time, everything is OK. If the difference
587 is greater than one, you missed interrupts.
588 </para>
589 <para>
590 You can also use <function>select()</function> on
591 <filename>/dev/uioX</filename>.
592 </para>
593</sect1>
594
595</chapter>
596
597<appendix id="app1">
598<title>Further information</title>
599<itemizedlist>
600 <listitem><para>
601 <ulink url="http://www.osadl.org">
602 OSADL homepage.</ulink>
603 </para></listitem>
604 <listitem><para>
605 <ulink url="http://www.linutronix.de">
606 Linutronix homepage.</ulink>
607 </para></listitem>
608</itemizedlist>
609</appendix>
610
611</book>
diff --git a/Documentation/HOWTO b/Documentation/HOWTO
index 98e2701c746f..f8cc3f8ed152 100644
--- a/Documentation/HOWTO
+++ b/Documentation/HOWTO
@@ -249,6 +249,9 @@ process is as follows:
249 release a new -rc kernel every week. 249 release a new -rc kernel every week.
250 - Process continues until the kernel is considered "ready", the 250 - Process continues until the kernel is considered "ready", the
251 process should last around 6 weeks. 251 process should last around 6 weeks.
252 - A list of known regressions present in each -rc release is
253 tracked at the following URI:
254 http://kernelnewbies.org/known_regressions
252 255
253It is worth mentioning what Andrew Morton wrote on the linux-kernel 256It is worth mentioning what Andrew Morton wrote on the linux-kernel
254mailing list about kernel releases: 257mailing list about kernel releases:
diff --git a/Documentation/connector/cn_test.c b/Documentation/connector/cn_test.c
index 3e73231695b3..be7af146dd30 100644
--- a/Documentation/connector/cn_test.c
+++ b/Documentation/connector/cn_test.c
@@ -124,9 +124,8 @@ static void cn_test_timer_func(unsigned long __data)
124 struct cn_msg *m; 124 struct cn_msg *m;
125 char data[32]; 125 char data[32];
126 126
127 m = kmalloc(sizeof(*m) + sizeof(data), GFP_ATOMIC); 127 m = kzalloc(sizeof(*m) + sizeof(data), GFP_ATOMIC);
128 if (m) { 128 if (m) {
129 memset(m, 0, sizeof(*m) + sizeof(data));
130 129
131 memcpy(&m->id, &cn_test_id, sizeof(m->id)); 130 memcpy(&m->id, &cn_test_id, sizeof(m->id));
132 m->seq = cn_test_timer_counter; 131 m->seq = cn_test_timer_counter;
diff --git a/Documentation/console/console.txt b/Documentation/console/console.txt
index d3e17447321c..877a1b26cc3d 100644
--- a/Documentation/console/console.txt
+++ b/Documentation/console/console.txt
@@ -29,7 +29,7 @@ In newer kernels, the following are also available:
29 29
30If sysfs is enabled, the contents of /sys/class/vtconsole can be 30If sysfs is enabled, the contents of /sys/class/vtconsole can be
31examined. This shows the console backends currently registered by the 31examined. This shows the console backends currently registered by the
32system which are named vtcon<n> where <n> is an integer fro 0 to 15. Thus: 32system which are named vtcon<n> where <n> is an integer from 0 to 15. Thus:
33 33
34 ls /sys/class/vtconsole 34 ls /sys/class/vtconsole
35 . .. vtcon0 vtcon1 35 . .. vtcon0 vtcon1
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 6c8d8f27db34..8569072fa387 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -207,7 +207,7 @@ responsibility. This is usually non-issue because bus ops and
207resource allocations already do the job. 207resource allocations already do the job.
208 208
209For an example of single-instance devres type, read pcim_iomap_table() 209For an example of single-instance devres type, read pcim_iomap_table()
210in lib/iomap.c. 210in lib/devres.c.
211 211
212All devres interface functions can be called without context if the 212All devres interface functions can be called without context if the
213right gfp mask is given. 213right gfp mask is given.
diff --git a/Documentation/drivers/edac/edac.txt b/Documentation/drivers/edac/edac.txt
index 3c5a9e4297b4..a5c36842ecef 100644
--- a/Documentation/drivers/edac/edac.txt
+++ b/Documentation/drivers/edac/edac.txt
@@ -2,22 +2,42 @@
2 2
3EDAC - Error Detection And Correction 3EDAC - Error Detection And Correction
4 4
5Written by Doug Thompson <norsk5@xmission.com> 5Written by Doug Thompson <dougthompson@xmission.com>
67 Dec 2005 67 Dec 2005
717 Jul 2007 Updated
7 8
8 9
9EDAC was written by: 10EDAC is maintained and written by:
10 Thayne Harbaugh,
11 modified by Dave Peterson, Doug Thompson, et al,
12 from the bluesmoke.sourceforge.net project.
13 11
12 Doug Thompson, Dave Jiang, Dave Peterson et al,
13 original author: Thayne Harbaugh,
14
15Contact:
16 website: bluesmoke.sourceforge.net
17 mailing list: bluesmoke-devel@lists.sourceforge.net
18
19"bluesmoke" was the name for this device driver when it was "out-of-tree"
20and maintained at sourceforge.net. When it was pushed into 2.6.16 for the
21first time, it was renamed to 'EDAC'.
22
23The bluesmoke project at sourceforge.net is now utilized as a 'staging area'
24for EDAC development, before it is sent upstream to kernel.org
25
26At the bluesmoke/EDAC project site, is a series of quilt patches against
27recent kernels, stored in a SVN respository. For easier downloading, there
28is also a tarball snapshot available.
14 29
15============================================================================ 30============================================================================
16EDAC PURPOSE 31EDAC PURPOSE
17 32
18The 'edac' kernel module goal is to detect and report errors that occur 33The 'edac' kernel module goal is to detect and report errors that occur
19within the computer system. In the initial release, memory Correctable Errors 34within the computer system running under linux.
20(CE) and Uncorrectable Errors (UE) are the primary errors being harvested. 35
36MEMORY
37
38In the initial release, memory Correctable Errors (CE) and Uncorrectable
39Errors (UE) are the primary errors being harvested. These types of errors
40are harvested by the 'edac_mc' class of device.
21 41
22Detecting CE events, then harvesting those events and reporting them, 42Detecting CE events, then harvesting those events and reporting them,
23CAN be a predictor of future UE events. With CE events, the system can 43CAN be a predictor of future UE events. With CE events, the system can
@@ -25,9 +45,27 @@ continue to operate, but with less safety. Preventive maintenance and
25proactive part replacement of memory DIMMs exhibiting CEs can reduce 45proactive part replacement of memory DIMMs exhibiting CEs can reduce
26the likelihood of the dreaded UE events and system 'panics'. 46the likelihood of the dreaded UE events and system 'panics'.
27 47
48NON-MEMORY
49
50A new feature for EDAC, the edac_device class of device, was added in
51the 2.6.23 version of the kernel.
52
53This new device type allows for non-memory type of ECC hardware detectors
54to have their states harvested and presented to userspace via the sysfs
55interface.
56
57Some architectures have ECC detectors for L1, L2 and L3 caches, along with DMA
58engines, fabric switches, main data path switches, interconnections,
59and various other hardware data paths. If the hardware reports it, then
60a edac_device device probably can be constructed to harvest and present
61that to userspace.
62
63
64PCI BUS SCANNING
28 65
29In addition, PCI Bus Parity and SERR Errors are scanned for on PCI devices 66In addition, PCI Bus Parity and SERR Errors are scanned for on PCI devices
30in order to determine if errors are occurring on data transfers. 67in order to determine if errors are occurring on data transfers.
68
31The presence of PCI Parity errors must be examined with a grain of salt. 69The presence of PCI Parity errors must be examined with a grain of salt.
32There are several add-in adapters that do NOT follow the PCI specification 70There are several add-in adapters that do NOT follow the PCI specification
33with regards to Parity generation and reporting. The specification says 71with regards to Parity generation and reporting. The specification says
@@ -35,11 +73,17 @@ the vendor should tie the parity status bits to 0 if they do not intend
35to generate parity. Some vendors do not do this, and thus the parity bit 73to generate parity. Some vendors do not do this, and thus the parity bit
36can "float" giving false positives. 74can "float" giving false positives.
37 75
38[There are patches in the kernel queue which will allow for storage of 76In the kernel there is a pci device attribute located in sysfs that is
39quirks of PCI devices reporting false parity positives. The 2.6.18 77checked by the EDAC PCI scanning code. If that attribute is set,
40kernel should have those patches included. When that becomes available, 78PCI parity/error scannining is skipped for that device. The attribute
41then EDAC will be patched to utilize that information to "skip" such 79is:
42devices.] 80
81 broken_parity_status
82
83as is located in /sys/devices/pci<XXX>/0000:XX:YY.Z directorys for
84PCI devices.
85
86FUTURE HARDWARE SCANNING
43 87
44EDAC will have future error detectors that will be integrated with 88EDAC will have future error detectors that will be integrated with
45EDAC or added to it, in the following list: 89EDAC or added to it, in the following list:
@@ -57,13 +101,14 @@ and the like.
57============================================================================ 101============================================================================
58EDAC VERSIONING 102EDAC VERSIONING
59 103
60EDAC is composed of a "core" module (edac_mc.ko) and several Memory 104EDAC is composed of a "core" module (edac_core.ko) and several Memory
61Controller (MC) driver modules. On a given system, the CORE 105Controller (MC) driver modules. On a given system, the CORE
62is loaded and one MC driver will be loaded. Both the CORE and 106is loaded and one MC driver will be loaded. Both the CORE and
63the MC driver have individual versions that reflect current release 107the MC driver (or edac_device driver) have individual versions that reflect
64level of their respective modules. Thus, to "report" on what version 108current release level of their respective modules.
65a system is running, one must report both the CORE's and the 109
66MC driver's versions. 110Thus, to "report" on what version a system is running, one must report both
111the CORE's and the MC driver's versions.
67 112
68 113
69LOADING 114LOADING
@@ -88,8 +133,9 @@ EDAC sysfs INTERFACE
88EDAC presents a 'sysfs' interface for control, reporting and attribute 133EDAC presents a 'sysfs' interface for control, reporting and attribute
89reporting purposes. 134reporting purposes.
90 135
91EDAC lives in the /sys/devices/system/edac directory. Within this directory 136EDAC lives in the /sys/devices/system/edac directory.
92there currently reside 2 'edac' components: 137
138Within this directory there currently reside 2 'edac' components:
93 139
94 mc memory controller(s) system 140 mc memory controller(s) system
95 pci PCI control and status system 141 pci PCI control and status system
@@ -188,7 +234,7 @@ In directory 'mc' are EDAC system overall control and attribute files:
188 234
189Panic on UE control file: 235Panic on UE control file:
190 236
191 'panic_on_ue' 237 'edac_mc_panic_on_ue'
192 238
193 An uncorrectable error will cause a machine panic. This is usually 239 An uncorrectable error will cause a machine panic. This is usually
194 desirable. It is a bad idea to continue when an uncorrectable error 240 desirable. It is a bad idea to continue when an uncorrectable error
@@ -199,12 +245,12 @@ Panic on UE control file:
199 245
200 LOAD TIME: module/kernel parameter: panic_on_ue=[0|1] 246 LOAD TIME: module/kernel parameter: panic_on_ue=[0|1]
201 247
202 RUN TIME: echo "1" >/sys/devices/system/edac/mc/panic_on_ue 248 RUN TIME: echo "1" >/sys/devices/system/edac/mc/edac_mc_panic_on_ue
203 249
204 250
205Log UE control file: 251Log UE control file:
206 252
207 'log_ue' 253 'edac_mc_log_ue'
208 254
209 Generate kernel messages describing uncorrectable errors. These errors 255 Generate kernel messages describing uncorrectable errors. These errors
210 are reported through the system message log system. UE statistics 256 are reported through the system message log system. UE statistics
@@ -212,12 +258,12 @@ Log UE control file:
212 258
213 LOAD TIME: module/kernel parameter: log_ue=[0|1] 259 LOAD TIME: module/kernel parameter: log_ue=[0|1]
214 260
215 RUN TIME: echo "1" >/sys/devices/system/edac/mc/log_ue 261 RUN TIME: echo "1" >/sys/devices/system/edac/mc/edac_mc_log_ue
216 262
217 263
218Log CE control file: 264Log CE control file:
219 265
220 'log_ce' 266 'edac_mc_log_ce'
221 267
222 Generate kernel messages describing correctable errors. These 268 Generate kernel messages describing correctable errors. These
223 errors are reported through the system message log system. 269 errors are reported through the system message log system.
@@ -225,12 +271,12 @@ Log CE control file:
225 271
226 LOAD TIME: module/kernel parameter: log_ce=[0|1] 272 LOAD TIME: module/kernel parameter: log_ce=[0|1]
227 273
228 RUN TIME: echo "1" >/sys/devices/system/edac/mc/log_ce 274 RUN TIME: echo "1" >/sys/devices/system/edac/mc/edac_mc_log_ce
229 275
230 276
231Polling period control file: 277Polling period control file:
232 278
233 'poll_msec' 279 'edac_mc_poll_msec'
234 280
235 The time period, in milliseconds, for polling for error information. 281 The time period, in milliseconds, for polling for error information.
236 Too small a value wastes resources. Too large a value might delay 282 Too small a value wastes resources. Too large a value might delay
@@ -241,7 +287,7 @@ Polling period control file:
241 287
242 LOAD TIME: module/kernel parameter: poll_msec=[0|1] 288 LOAD TIME: module/kernel parameter: poll_msec=[0|1]
243 289
244 RUN TIME: echo "1000" >/sys/devices/system/edac/mc/poll_msec 290 RUN TIME: echo "1000" >/sys/devices/system/edac/mc/edac_mc_poll_msec
245 291
246 292
247============================================================================ 293============================================================================
@@ -587,3 +633,95 @@ Parity Count:
587 633
588 634
589======================================================================= 635=======================================================================
636
637
638EDAC_DEVICE type of device
639
640In the header file, edac_core.h, there is a series of edac_device structures
641and APIs for the EDAC_DEVICE.
642
643User space access to an edac_device is through the sysfs interface.
644
645At the location /sys/devices/system/edac (sysfs) new edac_device devices will
646appear.
647
648There is a three level tree beneath the above 'edac' directory. For example,
649the 'test_device_edac' device (found at the bluesmoke.sourceforget.net website)
650installs itself as:
651
652 /sys/devices/systm/edac/test-instance
653
654in this directory are various controls, a symlink and one or more 'instance'
655directorys.
656
657The standard default controls are:
658
659 log_ce boolean to log CE events
660 log_ue boolean to log UE events
661 panic_on_ue boolean to 'panic' the system if an UE is encountered
662 (default off, can be set true via startup script)
663 poll_msec time period between POLL cycles for events
664
665The test_device_edac device adds at least one of its own custom control:
666
667 test_bits which in the current test driver does nothing but
668 show how it is installed. A ported driver can
669 add one or more such controls and/or attributes
670 for specific uses.
671 One out-of-tree driver uses controls here to allow
672 for ERROR INJECTION operations to hardware
673 injection registers
674
675The symlink points to the 'struct dev' that is registered for this edac_device.
676
677INSTANCES
678
679One or more instance directories are present. For the 'test_device_edac' case:
680
681 test-instance0
682
683
684In this directory there are two default counter attributes, which are totals of
685counter in deeper subdirectories.
686
687 ce_count total of CE events of subdirectories
688 ue_count total of UE events of subdirectories
689
690BLOCKS
691
692At the lowest directory level is the 'block' directory. There can be 0, 1
693or more blocks specified in each instance.
694
695 test-block0
696
697
698In this directory the default attributes are:
699
700 ce_count which is counter of CE events for this 'block'
701 of hardware being monitored
702 ue_count which is counter of UE events for this 'block'
703 of hardware being monitored
704
705
706The 'test_device_edac' device adds 4 attributes and 1 control:
707
708 test-block-bits-0 for every POLL cycle this counter
709 is incremented
710 test-block-bits-1 every 10 cycles, this counter is bumped once,
711 and test-block-bits-0 is set to 0
712 test-block-bits-2 every 100 cycles, this counter is bumped once,
713 and test-block-bits-1 is set to 0
714 test-block-bits-3 every 1000 cycles, this counter is bumped once,
715 and test-block-bits-2 is set to 0
716
717
718 reset-counters writing ANY thing to this control will
719 reset all the above counters.
720
721
722Use of the 'test_device_edac' driver should any others to create their own
723unique drivers for their hardware systems.
724
725The 'test_device_edac' sample driver is located at the
726bluesmoke.sourceforge.net project site for EDAC.
727
diff --git a/Documentation/dvb/bt8xx.txt b/Documentation/dvb/bt8xx.txt
index 4e7614e606c5..ecb47adda063 100644
--- a/Documentation/dvb/bt8xx.txt
+++ b/Documentation/dvb/bt8xx.txt
@@ -9,19 +9,29 @@ for accessing the i2c bus and the gpio pins of the bt8xx chipset.
9Please see Documentation/dvb/cards.txt => o Cards based on the Conexant Bt8xx PCI bridge: 9Please see Documentation/dvb/cards.txt => o Cards based on the Conexant Bt8xx PCI bridge:
10 10
11Compiling kernel please enable: 11Compiling kernel please enable:
12a.)"Device drivers" => "Multimedia devices" => "Video For Linux" => "BT848 Video For Linux" 12a.)"Device drivers" => "Multimedia devices" => "Video For Linux" => "Enable Video for Linux API 1 (DEPRECATED)"
13b.)"Device drivers" => "Multimedia devices" => "Digital Video Broadcasting Devices" 13b.)"Device drivers" => "Multimedia devices" => "Video For Linux" => "Video Capture Adapters" => "BT848 Video For Linux"
14 => "DVB for Linux" "DVB Core Support" "Bt8xx based PCI Cards" 14c.)"Device drivers" => "Multimedia devices" => "Digital Video Broadcasting Devices" => "DVB for Linux" "DVB Core Support" "Bt8xx based PCI Cards"
15 15
162) Loading Modules 16Please use the following options with care as deselection of drivers which are in fact necessary
17================== 17may result in DVB devices that cannot be tuned due to lack of driver support:
18You can save RAM by deselecting every frontend module that your DVB card does not need.
19
20First please remove the static dependency of DVB card drivers on all frontend modules for all possible card variants by enabling:
21d.) "Device drivers" => "Multimedia devices" => "Digital Video Broadcasting Devices"
22 => "DVB for Linux" "DVB Core Support" "Load and attach frontend modules as needed"
18 23
19In default cases bttv is loaded automatically. 24If you know the frontend driver that your card needs please enable:
20To load the backend either place dvb-bt8xx in etc/modules, or apply manually: 25e.)"Device drivers" => "Multimedia devices" => "Digital Video Broadcasting Devices"
26 => "DVB for Linux" "DVB Core Support" "Customise DVB Frontends" => "Customise the frontend modules to build"
27 Then please select your card-specific frontend module.
21 28
22 $ modprobe dvb-bt8xx 292) Loading Modules
30==================
23 31
24All frontends will be loaded automatically. 32Regular case: If the bttv driver detects a bt8xx-based DVB card, all frontend and backend modules will be loaded automatically.
33Exceptions are:
34- Old TwinHan DST cards or clones with or without CA slot and not containing an Eeprom.
25People running udev please see Documentation/dvb/udev.txt. 35People running udev please see Documentation/dvb/udev.txt.
26 36
27In the following cases overriding the PCI type detection for dvb-bt8xx might be necessary: 37In the following cases overriding the PCI type detection for dvb-bt8xx might be necessary:
@@ -30,7 +40,6 @@ In the following cases overriding the PCI type detection for dvb-bt8xx might be
30------------------------------ 40------------------------------
31 41
32 $ modprobe bttv card=113 42 $ modprobe bttv card=113
33 $ modprobe dvb-bt8xx
34 $ modprobe dst 43 $ modprobe dst
35 44
36Useful parameters for verbosity level and debugging the dst module: 45Useful parameters for verbosity level and debugging the dst module:
@@ -65,10 +74,9 @@ DViCO FusionHDTV 5 Lite: 135
65Notice: The order of the card ID should be uprising: 74Notice: The order of the card ID should be uprising:
66Example: 75Example:
67 $ modprobe bttv card=113 card=135 76 $ modprobe bttv card=113 card=135
68 $ modprobe dvb-bt8xx
69 77
70For 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.
71In case of further problems send questions to the mailing list: www.linuxdvb.org. 79In case of further problems please subscribe and send questions to the mailing list: linux-dvb@linuxtv.org.
72 80
73Authors: Richard Walker, 81Authors: Richard Walker,
74 Jamie Honan, 82 Jamie Honan,
diff --git a/Documentation/dvb/get_dvb_firmware b/Documentation/dvb/get_dvb_firmware
index 4820366b6ae8..b4d306ae9234 100644
--- a/Documentation/dvb/get_dvb_firmware
+++ b/Documentation/dvb/get_dvb_firmware
@@ -24,7 +24,8 @@ use IO::Handle;
24@components = ( "sp8870", "sp887x", "tda10045", "tda10046", 24@components = ( "sp8870", "sp887x", "tda10045", "tda10046",
25 "tda10046lifeview", "av7110", "dec2000t", "dec2540t", 25 "tda10046lifeview", "av7110", "dec2000t", "dec2540t",
26 "dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004", 26 "dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004",
27 "or51211", "or51132_qam", "or51132_vsb", "bluebird"); 27 "or51211", "or51132_qam", "or51132_vsb", "bluebird",
28 "opera1");
28 29
29# Check args 30# Check args
30syntax() if (scalar(@ARGV) != 1); 31syntax() if (scalar(@ARGV) != 1);
@@ -56,7 +57,7 @@ syntax();
56 57
57sub sp8870 { 58sub sp8870 {
58 my $sourcefile = "tt_Premium_217g.zip"; 59 my $sourcefile = "tt_Premium_217g.zip";
59 my $url = "http://www.technotrend.de/new/217g/$sourcefile"; 60 my $url = "http://www.softwarepatch.pl/9999ccd06a4813cb827dbb0005071c71/$sourcefile";
60 my $hash = "53970ec17a538945a6d8cb608a7b3899"; 61 my $hash = "53970ec17a538945a6d8cb608a7b3899";
61 my $outfile = "dvb-fe-sp8870.fw"; 62 my $outfile = "dvb-fe-sp8870.fw";
62 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 63 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
@@ -210,6 +211,45 @@ sub dec3000s {
210 211
211 $outfile; 212 $outfile;
212} 213}
214sub opera1{
215 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0);
216
217 checkstandard();
218 my $fwfile1="dvb-usb-opera1-fpga-01.fw";
219 my $fwfile2="dvb-usb-opera-01.fw";
220 extract("2830SCap2.sys", 0x62e8, 55024, "$tmpdir/opera1-fpga.fw");
221 extract("2830SLoad2.sys",0x3178,0x3685-0x3178,"$tmpdir/fw1part1");
222 extract("2830SLoad2.sys",0x0980,0x3150-0x0980,"$tmpdir/fw1part2");
223 delzero("$tmpdir/fw1part1","$tmpdir/fw1part1-1");
224 delzero("$tmpdir/fw1part2","$tmpdir/fw1part2-1");
225 verify("$tmpdir/fw1part1-1","5e0909858fdf0b5b09ad48b9fe622e70");
226 verify("$tmpdir/fw1part2-1","d6e146f321427e931df2c6fcadac37a1");
227 verify("$tmpdir/opera1-fpga.fw","0f8133f5e9051f5f3c1928f7e5a1b07d");
228
229 my $RES1="\x01\x92\x7f\x00\x01\x00";
230 my $RES0="\x01\x92\x7f\x00\x00\x00";
231 my $DAT1="\x01\x00\xe6\x00\x01\x00";
232 my $DAT0="\x01\x00\xe6\x00\x00\x00";
233 open FW,">$tmpdir/opera.fw";
234 print FW "$RES1";
235 print FW "$DAT1";
236 print FW "$RES1";
237 print FW "$DAT1";
238 appendfile(FW,"$tmpdir/fw1part1-1");
239 print FW "$RES0";
240 print FW "$DAT0";
241 print FW "$RES1";
242 print FW "$DAT1";
243 appendfile(FW,"$tmpdir/fw1part2-1");
244 print FW "$RES1";
245 print FW "$DAT1";
246 print FW "$RES0";
247 print FW "$DAT0";
248 copy ("$tmpdir/opera1-fpga.fw",$fwfile1);
249 copy ("$tmpdir/opera.fw",$fwfile2);
250
251 $fwfile1.",".$fwfile2;
252}
213 253
214sub vp7041 { 254sub vp7041 {
215 my $sourcefile = "2.422.zip"; 255 my $sourcefile = "2.422.zip";
@@ -440,6 +480,25 @@ sub appendfile {
440 close(INFILE); 480 close(INFILE);
441} 481}
442 482
483sub delzero{
484 my ($infile,$outfile) =@_;
485
486 open INFILE,"<$infile";
487 open OUTFILE,">$outfile";
488 while (1){
489 $rcount=sysread(INFILE,$buf,22);
490 $len=ord(substr($buf,0,1));
491 print OUTFILE substr($buf,0,1);
492 print OUTFILE substr($buf,2,$len+3);
493 last if ($rcount<1);
494 printf OUTFILE "%c",0;
495#print $len." ".length($buf)."\n";
496
497 }
498 close(INFILE);
499 close(OUTFILE);
500}
501
443sub syntax() { 502sub syntax() {
444 print STDERR "syntax: get_dvb_firmware <component>\n"; 503 print STDERR "syntax: get_dvb_firmware <component>\n";
445 print STDERR "Supported components:\n"; 504 print STDERR "Supported components:\n";
diff --git a/Documentation/dvb/opera-firmware.txt b/Documentation/dvb/opera-firmware.txt
new file mode 100644
index 000000000000..93e784c2607b
--- /dev/null
+++ b/Documentation/dvb/opera-firmware.txt
@@ -0,0 +1,27 @@
1To extract the firmware for the Opera DVB-S1 USB-Box
2you need to copy the files:
3
42830SCap2.sys
52830SLoad2.sys
6
7from the windriver disk into this directory.
8
9Then run
10
11./get_dvb_firware opera1
12
13and after that you have 2 files:
14
15dvb-usb-opera-01.fw
16dvb-usb-opera1-fpga-01.fw
17
18in here.
19
20Copy them into /lib/firmware/ .
21
22After that the driver can load the firmware
23(if you have enabled firmware loading
24in kernel config and have hotplug running).
25
26
27Marco Gittler <g.marco@freenet.de> \ No newline at end of file
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index d05e6243b4df..c175eedadb5f 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -26,9 +26,7 @@ Who: Hans Verkuil <hverkuil@xs4all.nl> and
26 26
27--------------------------- 27---------------------------
28 28
29What: /sys/devices/.../power/state 29What: dev->power.power_state
30 dev->power.power_state
31 dpm_runtime_{suspend,resume)()
32When: July 2007 30When: July 2007
33Why: Broken design for runtime control over driver power states, confusing 31Why: Broken design for runtime control over driver power states, confusing
34 driver-internal runtime power management with: mechanisms to support 32 driver-internal runtime power management with: mechanisms to support
@@ -53,6 +51,7 @@ Who: David Miller <davem@davemloft.net>
53What: Video4Linux API 1 ioctls and video_decoder.h from Video devices. 51What: Video4Linux API 1 ioctls and video_decoder.h from Video devices.
54When: December 2006 52When: December 2006
55Files: include/linux/video_decoder.h 53Files: include/linux/video_decoder.h
54Check: include/linux/video_decoder.h
56Why: V4L1 AP1 was replaced by V4L2 API. during migration from 2.4 to 2.6 55Why: V4L1 AP1 was replaced by V4L2 API. during migration from 2.4 to 2.6
57 series. The old API have lots of drawbacks and don't provide enough 56 series. The old API have lots of drawbacks and don't provide enough
58 means to work with all video and audio standards. The newer API is 57 means to work with all video and audio standards. The newer API is
@@ -86,7 +85,7 @@ Who: Dominik Brodowski <linux@brodo.de>
86What: remove EXPORT_SYMBOL(kernel_thread) 85What: remove EXPORT_SYMBOL(kernel_thread)
87When: August 2006 86When: August 2006
88Files: arch/*/kernel/*_ksyms.c 87Files: arch/*/kernel/*_ksyms.c
89Funcs: kernel_thread 88Check: kernel_thread
90Why: kernel_thread is a low-level implementation detail. Drivers should 89Why: kernel_thread is a low-level implementation detail. Drivers should
91 use the <linux/kthread.h> API instead which shields them from 90 use the <linux/kthread.h> API instead which shields them from
92 implementation details and provides a higherlevel interface that 91 implementation details and provides a higherlevel interface that
@@ -137,6 +136,15 @@ Who: Greg Kroah-Hartman <gregkh@suse.de>
137 136
138--------------------------- 137---------------------------
139 138
139What: vm_ops.nopage
140When: Soon, provided in-kernel callers have been converted
141Why: This interface is replaced by vm_ops.fault, but it has been around
142 forever, is used by a lot of drivers, and doesn't cost much to
143 maintain.
144Who: Nick Piggin <npiggin@suse.de>
145
146---------------------------
147
140What: Interrupt only SA_* flags 148What: Interrupt only SA_* flags
141When: September 2007 149When: September 2007
142Why: The interrupt related SA_* flags are replaced by IRQF_* to move them 150Why: The interrupt related SA_* flags are replaced by IRQF_* to move them
@@ -156,15 +164,6 @@ Who: Kay Sievers <kay.sievers@suse.de>
156 164
157--------------------------- 165---------------------------
158 166
159What: i2c-isa
160When: December 2006
161Why: i2c-isa is a non-sense and doesn't fit in the device driver
162 model. Drivers relying on it are better implemented as platform
163 drivers.
164Who: Jean Delvare <khali@linux-fr.org>
165
166---------------------------
167
168What: i2c_adapter.list 167What: i2c_adapter.list
169When: July 2007 168When: July 2007
170Why: Superfluous, this list duplicates the one maintained by the driver 169Why: Superfluous, this list duplicates the one maintained by the driver
@@ -181,24 +180,11 @@ Who: Adrian Bunk <bunk@stusta.de>
181 180
182--------------------------- 181---------------------------
183 182
184What: /sys/firmware/acpi/namespace
185When: 2.6.21
186Why: The ACPI namespace is effectively the symbol list for
187 the BIOS. The device names are completely arbitrary
188 and have no place being exposed to user-space.
189
190 For those interested in the BIOS ACPI namespace,
191 the BIOS can be extracted and disassembled with acpidump
192 and iasl as documented in the pmtools package here:
193 http://ftp.kernel.org/pub/linux/kernel/people/lenb/acpi/utils
194Who: Len Brown <len.brown@intel.com>
195
196---------------------------
197
198What: ACPI procfs interface 183What: ACPI procfs interface
199When: July 2007 184When: July 2008
200Why: After ACPI sysfs conversion, ACPI attributes will be duplicated 185Why: ACPI sysfs conversion should be finished by January 2008.
201 in sysfs and the ACPI procfs interface should be removed. 186 ACPI procfs interface will be removed in July 2008 so that
187 there is enough time for the user space to catch up.
202Who: Zhang Rui <rui.zhang@intel.com> 188Who: Zhang Rui <rui.zhang@intel.com>
203 189
204--------------------------- 190---------------------------
@@ -310,3 +296,13 @@ Why: The arch/powerpc tree is the merged architecture for ppc32 and ppc64
310Who: linuxppc-dev@ozlabs.org 296Who: linuxppc-dev@ozlabs.org
311 297
312--------------------------- 298---------------------------
299
300What: mthca driver's MSI support
301When: January 2008
302Files: drivers/infiniband/hw/mthca/*.[ch]
303Why: All mthca hardware also supports MSI-X, which provides
304 strictly more functionality than MSI. So there is no point in
305 having both MSI-X and MSI support in the driver.
306Who: Roland Dreier <rolandd@cisco.com>
307
308---------------------------
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index d866551be037..f0f825808ca4 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -510,13 +510,24 @@ More details about quota locking can be found in fs/dquot.c.
510prototypes: 510prototypes:
511 void (*open)(struct vm_area_struct*); 511 void (*open)(struct vm_area_struct*);
512 void (*close)(struct vm_area_struct*); 512 void (*close)(struct vm_area_struct*);
513 int (*fault)(struct vm_area_struct*, struct vm_fault *);
513 struct page *(*nopage)(struct vm_area_struct*, unsigned long, int *); 514 struct page *(*nopage)(struct vm_area_struct*, unsigned long, int *);
515 int (*page_mkwrite)(struct vm_area_struct *, struct page *);
514 516
515locking rules: 517locking rules:
516 BKL mmap_sem 518 BKL mmap_sem PageLocked(page)
517open: no yes 519open: no yes
518close: no yes 520close: no yes
521fault: no yes
519nopage: no yes 522nopage: no yes
523page_mkwrite: no yes no
524
525 ->page_mkwrite() is called when a previously read-only page is
526about to become writeable. The file system is responsible for
527protecting against truncate races. Once appropriate action has been
528taking to lock out truncate, the page range should be verified to be
529within i_size. The page mapping should also be checked that it is not
530NULL.
520 531
521================================================================================ 532================================================================================
522 Dubious stuff 533 Dubious stuff
diff --git a/Documentation/filesystems/configfs/configfs_example.c b/Documentation/filesystems/configfs/configfs_example.c
index e56d49264b39..25151fd5c2c6 100644
--- a/Documentation/filesystems/configfs/configfs_example.c
+++ b/Documentation/filesystems/configfs/configfs_example.c
@@ -277,11 +277,10 @@ static struct config_item *simple_children_make_item(struct config_group *group,
277{ 277{
278 struct simple_child *simple_child; 278 struct simple_child *simple_child;
279 279
280 simple_child = kmalloc(sizeof(struct simple_child), GFP_KERNEL); 280 simple_child = kzalloc(sizeof(struct simple_child), GFP_KERNEL);
281 if (!simple_child) 281 if (!simple_child)
282 return NULL; 282 return NULL;
283 283
284 memset(simple_child, 0, sizeof(struct simple_child));
285 284
286 config_item_init_type_name(&simple_child->item, name, 285 config_item_init_type_name(&simple_child->item, name,
287 &simple_child_type); 286 &simple_child_type);
@@ -364,12 +363,11 @@ static struct config_group *group_children_make_group(struct config_group *group
364{ 363{
365 struct simple_children *simple_children; 364 struct simple_children *simple_children;
366 365
367 simple_children = kmalloc(sizeof(struct simple_children), 366 simple_children = kzalloc(sizeof(struct simple_children),
368 GFP_KERNEL); 367 GFP_KERNEL);
369 if (!simple_children) 368 if (!simple_children)
370 return NULL; 369 return NULL;
371 370
372 memset(simple_children, 0, sizeof(struct simple_children));
373 371
374 config_group_init_type_name(&simple_children->group, name, 372 config_group_init_type_name(&simple_children->group, name,
375 &simple_children_type); 373 &simple_children_type);
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index ebffdffb3d99..4a37e25e694c 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -42,6 +42,7 @@ Table of Contents
42 2.12 /proc/<pid>/oom_adj - Adjust the oom-killer score 42 2.12 /proc/<pid>/oom_adj - Adjust the oom-killer score
43 2.13 /proc/<pid>/oom_score - Display current oom-killer score 43 2.13 /proc/<pid>/oom_score - Display current oom-killer score
44 2.14 /proc/<pid>/io - Display the IO accounting fields 44 2.14 /proc/<pid>/io - Display the IO accounting fields
45 2.15 /proc/<pid>/coredump_filter - Core dump filtering settings
45 46
46------------------------------------------------------------------------------ 47------------------------------------------------------------------------------
47Preface 48Preface
@@ -1065,6 +1066,13 @@ check the amount of free space (value is in seconds). Default settings are: 4,
1065resume it if we have a value of 3 or more percent; consider information about 1066resume it if we have a value of 3 or more percent; consider information about
1066the amount of free space valid for 30 seconds 1067the amount of free space valid for 30 seconds
1067 1068
1069audit_argv_kb
1070-------------
1071
1072The file contains a single value denoting the limit on the argv array size
1073for execve (in KiB). This limit is only applied when system call auditing for
1074execve is enabled, otherwise the value is ignored.
1075
1068ctrl-alt-del 1076ctrl-alt-del
1069------------ 1077------------
1070 1078
@@ -2177,4 +2185,41 @@ those 64-bit counters, process A could see an intermediate result.
2177More information about this can be found within the taskstats documentation in 2185More information about this can be found within the taskstats documentation in
2178Documentation/accounting. 2186Documentation/accounting.
2179 2187
21882.15 /proc/<pid>/coredump_filter - Core dump filtering settings
2189---------------------------------------------------------------
2190When a process is dumped, all anonymous memory is written to a core file as
2191long as the size of the core file isn't limited. But sometimes we don't want
2192to dump some memory segments, for example, huge shared memory. Conversely,
2193sometimes we want to save file-backed memory segments into a core file, not
2194only the individual files.
2195
2196/proc/<pid>/coredump_filter allows you to customize which memory segments
2197will be dumped when the <pid> process is dumped. coredump_filter is a bitmask
2198of memory types. If a bit of the bitmask is set, memory segments of the
2199corresponding memory type are dumped, otherwise they are not dumped.
2200
2201The following 4 memory types are supported:
2202 - (bit 0) anonymous private memory
2203 - (bit 1) anonymous shared memory
2204 - (bit 2) file-backed private memory
2205 - (bit 3) file-backed shared memory
2206
2207 Note that MMIO pages such as frame buffer are never dumped and vDSO pages
2208 are always dumped regardless of the bitmask status.
2209
2210Default value of coredump_filter is 0x3; this means all anonymous memory
2211segments are dumped.
2212
2213If you don't want to dump all shared memory segments attached to pid 1234,
2214write 1 to the process's proc file.
2215
2216 $ echo 0x1 > /proc/1234/coredump_filter
2217
2218When a new process is created, the process inherits the bitmask status from its
2219parent. It is useful to set up coredump_filter before the program runs.
2220For example:
2221
2222 $ echo 0x7 > /proc/self/coredump_filter
2223 $ ./some_program
2224
2180------------------------------------------------------------------------------ 2225------------------------------------------------------------------------------
diff --git a/Documentation/gpio.txt b/Documentation/gpio.txt
index 36af58eba136..218a8650f48d 100644
--- a/Documentation/gpio.txt
+++ b/Documentation/gpio.txt
@@ -75,6 +75,9 @@ using the include file:
75If you stick to this convention then it'll be easier for other developers to 75If you stick to this convention then it'll be easier for other developers to
76see what your code is doing, and help maintain it. 76see what your code is doing, and help maintain it.
77 77
78Note that these operations include I/O barriers on platforms which need to
79use them; drivers don't need to add them explicitly.
80
78 81
79Identifying GPIOs 82Identifying GPIOs
80----------------- 83-----------------
diff --git a/Documentation/hwmon/abituguru b/Documentation/hwmon/abituguru
index b2c0d61b39a2..87ffa0f5ec70 100644
--- a/Documentation/hwmon/abituguru
+++ b/Documentation/hwmon/abituguru
@@ -2,7 +2,7 @@ Kernel driver abituguru
2======================= 2=======================
3 3
4Supported chips: 4Supported chips:
5 * Abit uGuru revision 1-3 (Hardware Monitor part only) 5 * Abit uGuru revision 1 & 2 (Hardware Monitor part only)
6 Prefix: 'abituguru' 6 Prefix: 'abituguru'
7 Addresses scanned: ISA 0x0E0 7 Addresses scanned: ISA 0x0E0
8 Datasheet: Not available, this driver is based on reverse engineering. 8 Datasheet: Not available, this driver is based on reverse engineering.
@@ -20,8 +20,8 @@ Supported chips:
20 uGuru 2.1.0.0 ~ 2.1.2.8 (AS8, AV8, AA8, AG8, AA8XE, AX8) 20 uGuru 2.1.0.0 ~ 2.1.2.8 (AS8, AV8, AA8, AG8, AA8XE, AX8)
21 uGuru 2.2.0.0 ~ 2.2.0.6 (AA8 Fatal1ty) 21 uGuru 2.2.0.0 ~ 2.2.0.6 (AA8 Fatal1ty)
22 uGuru 2.3.0.0 ~ 2.3.0.9 (AN8) 22 uGuru 2.3.0.0 ~ 2.3.0.9 (AN8)
23 uGuru 3.0.0.0 ~ 3.0.1.2 (AW8, AL8, NI8) 23 uGuru 3.0.0.0 ~ 3.0.x.x (AW8, AL8, AT8, NI8 SLI, AT8 32X, AN8 32X,
24 uGuru 4.xxxxx? (AT8 32X) (2) 24 AW9D-MAX) (2)
25 1) For revisions 2 and 3 uGuru's the driver can autodetect the 25 1) For revisions 2 and 3 uGuru's the driver can autodetect the
26 sensortype (Volt or Temp) for bank1 sensors, for revision 1 uGuru's 26 sensortype (Volt or Temp) for bank1 sensors, for revision 1 uGuru's
27 this doesnot always work. For these uGuru's the autodection can 27 this doesnot always work. For these uGuru's the autodection can
@@ -30,8 +30,9 @@ Supported chips:
30 bank1_types=1,1,0,0,0,0,0,2,0,0,0,0,2,0,0,1 30 bank1_types=1,1,0,0,0,0,0,2,0,0,0,0,2,0,0,1
31 You may also need to specify the fan_sensors option for these boards 31 You may also need to specify the fan_sensors option for these boards
32 fan_sensors=5 32 fan_sensors=5
33 2) The current version of the abituguru driver is known to NOT work 33 2) There is a seperate abituguru3 driver for these motherboards,
34 on these Motherboards 34 the abituguru (without the 3 !) driver will not work on these
35 motherboards (and visa versa)!
35 36
36Authors: 37Authors:
37 Hans de Goede <j.w.r.degoede@hhs.nl>, 38 Hans de Goede <j.w.r.degoede@hhs.nl>,
@@ -43,8 +44,10 @@ Module Parameters
43----------------- 44-----------------
44 45
45* force: bool Force detection. Note this parameter only causes the 46* force: bool Force detection. Note this parameter only causes the
46 detection to be skipped, if the uGuru can't be read 47 detection to be skipped, and thus the insmod to
47 the module initialization (insmod) will still fail. 48 succeed. If the uGuru can't be read the actual hwmon
49 driver will not load and thus no hwmon device will get
50 registered.
48* bank1_types: int[] Bank1 sensortype autodetection override: 51* bank1_types: int[] Bank1 sensortype autodetection override:
49 -1 autodetect (default) 52 -1 autodetect (default)
50 0 volt sensor 53 0 volt sensor
@@ -69,13 +72,15 @@ dmesg | grep abituguru
69Description 72Description
70----------- 73-----------
71 74
72This driver supports the hardware monitoring features of the Abit uGuru chip 75This driver supports the hardware monitoring features of the first and
73found on Abit uGuru featuring motherboards (most modern Abit motherboards). 76second revision of the Abit uGuru chip found on Abit uGuru featuring
77motherboards (most modern Abit motherboards).
74 78
75The uGuru chip in reality is a Winbond W83L950D in disguise (despite Abit 79The first and second revision of the uGuru chip in reality is a Winbond
76claiming it is "a new microprocessor designed by the ABIT Engineers"). 80W83L950D in disguise (despite Abit claiming it is "a new microprocessor
77Unfortunatly this doesn't help since the W83L950D is a generic 81designed by the ABIT Engineers"). Unfortunatly this doesn't help since the
78microcontroller with a custom Abit application running on it. 82W83L950D is a generic microcontroller with a custom Abit application running
83on it.
79 84
80Despite Abit not releasing any information regarding the uGuru, Olle 85Despite Abit not releasing any information regarding the uGuru, Olle
81Sandberg <ollebull@gmail.com> has managed to reverse engineer the sensor part 86Sandberg <ollebull@gmail.com> has managed to reverse engineer the sensor part
diff --git a/Documentation/hwmon/abituguru3 b/Documentation/hwmon/abituguru3
new file mode 100644
index 000000000000..fa598aac22fa
--- /dev/null
+++ b/Documentation/hwmon/abituguru3
@@ -0,0 +1,65 @@
1Kernel driver abituguru3
2========================
3
4Supported chips:
5 * Abit uGuru revision 3 (Hardware Monitor part, reading only)
6 Prefix: 'abituguru3'
7 Addresses scanned: ISA 0x0E0
8 Datasheet: Not available, this driver is based on reverse engineering.
9 Note:
10 The uGuru is a microcontroller with onboard firmware which programs
11 it to behave as a hwmon IC. There are many different revisions of the
12 firmware and thus effectivly many different revisions of the uGuru.
13 Below is an incomplete list with which revisions are used for which
14 Motherboards:
15 uGuru 1.00 ~ 1.24 (AI7, KV8-MAX3, AN7)
16 uGuru 2.0.0.0 ~ 2.0.4.2 (KV8-PRO)
17 uGuru 2.1.0.0 ~ 2.1.2.8 (AS8, AV8, AA8, AG8, AA8XE, AX8)
18 uGuru 2.3.0.0 ~ 2.3.0.9 (AN8)
19 uGuru 3.0.0.0 ~ 3.0.x.x (AW8, AL8, AT8, NI8 SLI, AT8 32X, AN8 32X,
20 AW9D-MAX)
21 The abituguru3 driver is only for revison 3.0.x.x motherboards,
22 this driver will not work on older motherboards. For older
23 motherboards use the abituguru (without the 3 !) driver.
24
25Authors:
26 Hans de Goede <j.w.r.degoede@hhs.nl>,
27 (Initial reverse engineering done by Louis Kruger)
28
29
30Module Parameters
31-----------------
32
33* force: bool Force detection. Note this parameter only causes the
34 detection to be skipped, and thus the insmod to
35 succeed. If the uGuru can't be read the actual hwmon
36 driver will not load and thus no hwmon device will get
37 registered.
38* verbose: bool Should the driver be verbose?
39 0/off/false normal output
40 1/on/true + verbose error reporting (default)
41 Default: 1 (the driver is still in the testing phase)
42
43Description
44-----------
45
46This driver supports the hardware monitoring features of the third revision of
47the Abit uGuru chip, found on recent Abit uGuru featuring motherboards.
48
49The 3rd revision of the uGuru chip in reality is a Winbond W83L951G.
50Unfortunatly this doesn't help since the W83L951G is a generic microcontroller
51with a custom Abit application running on it.
52
53Despite Abit not releasing any information regarding the uGuru revision 3,
54Louis Kruger has managed to reverse engineer the sensor part of the uGuru.
55Without his work this driver would not have been possible.
56
57Known Issues
58------------
59
60The voltage and frequency control parts of the Abit uGuru are not supported,
61neither is writing any of the sensor settings and writing / reading the
62fanspeed control registers (FanEQ)
63
64If you encounter any problems please mail me <j.w.r.degoede@hhs.nl> and
65include the output of: "dmesg | grep abituguru"
diff --git a/Documentation/hwmon/dme1737 b/Documentation/hwmon/dme1737
new file mode 100644
index 000000000000..1a0f3d64ab80
--- /dev/null
+++ b/Documentation/hwmon/dme1737
@@ -0,0 +1,257 @@
1Kernel driver dme1737
2=====================
3
4Supported chips:
5 * SMSC DME1737 and compatibles (like Asus A8000)
6 Prefix: 'dme1737'
7 Addresses scanned: I2C 0x2c, 0x2d, 0x2e
8 Datasheet: Provided by SMSC upon request and under NDA
9
10Authors:
11 Juerg Haefliger <juergh@gmail.com>
12
13
14Module Parameters
15-----------------
16
17* force_start: bool Enables the monitoring of voltage, fan and temp inputs
18 and PWM output control functions. Using this parameter
19 shouldn't be required since the BIOS usually takes care
20 of this.
21
22Note that there is no need to use this parameter if the driver loads without
23complaining. The driver will say so if it is necessary.
24
25
26Description
27-----------
28
29This driver implements support for the hardware monitoring capabilities of the
30SMSC DME1737 and Asus A8000 (which are the same) Super-I/O chips. This chip
31features monitoring of 3 temp sensors temp[1-3] (2 remote diodes and 1
32internal), 7 voltages in[0-6] (6 external and 1 internal) and 6 fan speeds
33fan[1-6]. Additionally, the chip implements 5 PWM outputs pwm[1-3,5-6] for
34controlling fan speeds both manually and automatically.
35
36Fan[3-6] and pwm[3,5-6] are optional features and their availability is
37dependent on the configuration of the chip. The driver will detect which
38features are present during initialization and create the sysfs attributes
39accordingly.
40
41
42Voltage Monitoring
43------------------
44
45The voltage inputs are sampled with 12-bit resolution and have internal
46scaling resistors. The values returned by the driver therefore reflect true
47millivolts and don't need scaling. The voltage inputs are mapped as follows
48(the last column indicates the input ranges):
49
50 in0: +5VTR (+5V standby) 0V - 6.64V
51 in1: Vccp (processor core) 0V - 3V
52 in2: VCC (internal +3.3V) 0V - 4.38V
53 in3: +5V 0V - 6.64V
54 in4: +12V 0V - 16V
55 in5: VTR (+3.3V standby) 0V - 4.38V
56 in6: Vbat (+3.0V) 0V - 4.38V
57
58Each voltage input has associated min and max limits which trigger an alarm
59when crossed.
60
61
62Temperature Monitoring
63----------------------
64
65Temperatures are measured with 12-bit resolution and reported in millidegree
66Celsius. The chip also features offsets for all 3 temperature inputs which -
67when programmed - get added to the input readings. The chip does all the
68scaling by itself and the driver therefore reports true temperatures that don't
69need any user-space adjustments. The temperature inputs are mapped as follows
70(the last column indicates the input ranges):
71
72 temp1: Remote diode 1 (3904 type) temperature -127C - +127C
73 temp2: DME1737 internal temperature -127C - +127C
74 temp3: Remote diode 2 (3904 type) temperature -127C - +127C
75
76Each temperature input has associated min and max limits which trigger an alarm
77when crossed. Additionally, each temperature input has a fault attribute that
78returns 1 when a faulty diode or an unconnected input is detected and 0
79otherwise.
80
81
82Fan Monitoring
83--------------
84
85Fan RPMs are measured with 16-bit resolution. The chip provides inputs for 6
86fan tachometers. All 6 inputs have an associated min limit which triggers an
87alarm when crossed. Fan inputs 1-4 provide type attributes that need to be set
88to the number of pulses per fan revolution that the connected tachometer
89generates. Supported values are 1, 2, and 4. Fan inputs 5-6 only support fans
90that generate 2 pulses per revolution. Fan inputs 5-6 also provide a max
91attribute that needs to be set to the maximum attainable RPM (fan at 100% duty-
92cycle) of the input. The chip adjusts the sampling rate based on this value.
93
94
95PWM Output Control
96------------------
97
98This chip features 5 PWM outputs. PWM outputs 1-3 are associated with fan
99inputs 1-3 and PWM outputs 5-6 are associated with fan inputs 5-6. PWM outputs
1001-3 can be configured to operate either in manual or automatic mode by setting
101the appropriate enable attribute accordingly. PWM outputs 5-6 can only operate
102in manual mode, their enable attributes are therefore read-only. When set to
103manual mode, the fan speed is set by writing the duty-cycle value to the
104appropriate PWM attribute. In automatic mode, the PWM attribute returns the
105current duty-cycle as set by the fan controller in the chip. All PWM outputs
106support the setting of the output frequency via the freq attribute.
107
108In automatic mode, the chip supports the setting of the PWM ramp rate which
109defines how fast the PWM output is adjusting to changes of the associated
110temperature input. Associating PWM outputs to temperature inputs is done via
111temperature zones. The chip features 3 zones whose assignments to temperature
112inputs is static and determined during initialization. These assignments can
113be retrieved via the zone[1-3]_auto_channels_temp attributes. Each PWM output
114is assigned to one (or hottest of multiple) temperature zone(s) through the
115pwm[1-3]_auto_channels_zone attributes. Each PWM output has 3 distinct output
116duty-cycles: full, low, and min. Full is internally hard-wired to 255 (100%)
117and low and min can be programmed via pwm[1-3]_auto_point1_pwm and
118pwm[1-3]_auto_pwm_min, respectively. The thermal thresholds of the zones are
119programmed via zone[1-3]_auto_point[1-3]_temp and
120zone[1-3]_auto_point1_temp_hyst:
121
122 pwm[1-3]_auto_point2_pwm full-speed duty-cycle (255, i.e., 100%)
123 pwm[1-3]_auto_point1_pwm low-speed duty-cycle
124 pwm[1-3]_auto_pwm_min min-speed duty-cycle
125
126 zone[1-3]_auto_point3_temp full-speed temp (all outputs)
127 zone[1-3]_auto_point2_temp full-speed temp
128 zone[1-3]_auto_point1_temp low-speed temp
129 zone[1-3]_auto_point1_temp_hyst min-speed temp
130
131The chip adjusts the output duty-cycle linearly in the range of auto_point1_pwm
132to auto_point2_pwm if the temperature of the associated zone is between
133auto_point1_temp and auto_point2_temp. If the temperature drops below the
134auto_point1_temp_hyst value, the output duty-cycle is set to the auto_pwm_min
135value which only supports two values: 0 or auto_point1_pwm. That means that the
136fan either turns completely off or keeps spinning with the low-speed
137duty-cycle. If any of the temperatures rise above the auto_point3_temp value,
138all PWM outputs are set to 100% duty-cycle.
139
140Following is another representation of how the chip sets the output duty-cycle
141based on the temperature of the associated thermal zone:
142
143 Duty-Cycle Duty-Cycle
144 Temperature Rising Temp Falling Temp
145 ----------- ----------- ------------
146 full-speed full-speed full-speed
147
148 < linearly adjusted duty-cycle >
149
150 low-speed low-speed low-speed
151 min-speed low-speed
152 min-speed min-speed min-speed
153 min-speed min-speed
154
155
156Sysfs Attributes
157----------------
158
159Following is a list of all sysfs attributes that the driver provides, their
160permissions and a short description:
161
162Name Perm Description
163---- ---- -----------
164cpu0_vid RO CPU core reference voltage in
165 millivolts.
166vrm RW Voltage regulator module version
167 number.
168
169in[0-6]_input RO Measured voltage in millivolts.
170in[0-6]_min RW Low limit for voltage input.
171in[0-6]_max RW High limit for voltage input.
172in[0-6]_alarm RO Voltage input alarm. Returns 1 if
173 voltage input is or went outside the
174 associated min-max range, 0 otherwise.
175
176temp[1-3]_input RO Measured temperature in millidegree
177 Celsius.
178temp[1-3]_min RW Low limit for temp input.
179temp[1-3]_max RW High limit for temp input.
180temp[1-3]_offset RW Offset for temp input. This value will
181 be added by the chip to the measured
182 temperature.
183temp[1-3]_alarm RO Alarm for temp input. Returns 1 if temp
184 input is or went outside the associated
185 min-max range, 0 otherwise.
186temp[1-3]_fault RO Temp input fault. Returns 1 if the chip
187 detects a faulty thermal diode or an
188 unconnected temp input, 0 otherwise.
189
190zone[1-3]_auto_channels_temp RO Temperature zone to temperature input
191 mapping. This attribute is a bitfield
192 and supports the following values:
193 1: temp1
194 2: temp2
195 4: temp3
196zone[1-3]_auto_point1_temp_hyst RW Auto PWM temp point1 hysteresis. The
197 output of the corresponding PWM is set
198 to the pwm_auto_min value if the temp
199 falls below the auto_point1_temp_hyst
200 value.
201zone[1-3]_auto_point[1-3]_temp RW Auto PWM temp points. Auto_point1 is
202 the low-speed temp, auto_point2 is the
203 full-speed temp, and auto_point3 is the
204 temp at which all PWM outputs are set
205 to full-speed (100% duty-cycle).
206
207fan[1-6]_input RO Measured fan speed in RPM.
208fan[1-6]_min RW Low limit for fan input.
209fan[1-6]_alarm RO Alarm for fan input. Returns 1 if fan
210 input is or went below the associated
211 min value, 0 otherwise.
212fan[1-4]_type RW Type of attached fan. Expressed in
213 number of pulses per revolution that
214 the fan generates. Supported values are
215 1, 2, and 4.
216fan[5-6]_max RW Max attainable RPM at 100% duty-cycle.
217 Required for chip to adjust the
218 sampling rate accordingly.
219
220pmw[1-3,5-6] RO/RW Duty-cycle of PWM output. Supported
221 values are 0-255 (0%-100%). Only
222 writeable if the associated PWM is in
223 manual mode.
224pwm[1-3]_enable RW Enable of PWM outputs 1-3. Supported
225 values are:
226 0: turned off (output @ 100%)
227 1: manual mode
228 2: automatic mode
229pwm[5-6]_enable RO Enable of PWM outputs 5-6. Always
230 returns 1 since these 2 outputs are
231 hard-wired to manual mode.
232pmw[1-3,5-6]_freq RW Frequency of PWM output. Supported
233 values are in the range 11Hz-30000Hz
234 (default is 25000Hz).
235pmw[1-3]_ramp_rate RW Ramp rate of PWM output. Determines how
236 fast the PWM duty-cycle will change
237 when the PWM is in automatic mode.
238 Expressed in ms per PWM step. Supported
239 values are in the range 0ms-206ms
240 (default is 0, which means the duty-
241 cycle changes instantly).
242pwm[1-3]_auto_channels_zone RW PWM output to temperature zone mapping.
243 This attribute is a bitfield and
244 supports the following values:
245 1: zone1
246 2: zone2
247 4: zone3
248 6: highest of zone[2-3]
249 7: highest of zone[1-3]
250pwm[1-3]_auto_pwm_min RW Auto PWM min pwm. Minimum PWM duty-
251 cycle. Supported values are 0 or
252 auto_point1_pwm.
253pwm[1-3]_auto_point1_pwm RW Auto PWM pwm point. Auto_point1 is the
254 low-speed duty-cycle.
255pwm[1-3]_auto_point2_pwm RO Auto PWM pwm point. Auto_point2 is the
256 full-speed duty-cycle which is hard-
257 wired to 255 (100% duty-cycle).
diff --git a/Documentation/hwmon/f71805f b/Documentation/hwmon/f71805f
index bfd0f154959c..94e0d2cbd3d2 100644
--- a/Documentation/hwmon/f71805f
+++ b/Documentation/hwmon/f71805f
@@ -5,11 +5,11 @@ Supported chips:
5 * Fintek F71805F/FG 5 * Fintek F71805F/FG
6 Prefix: 'f71805f' 6 Prefix: 'f71805f'
7 Addresses scanned: none, address read from Super I/O config space 7 Addresses scanned: none, address read from Super I/O config space
8 Datasheet: Provided by Fintek on request 8 Datasheet: Available from the Fintek website
9 * Fintek F71872F/FG 9 * Fintek F71872F/FG
10 Prefix: 'f71872f' 10 Prefix: 'f71872f'
11 Addresses scanned: none, address read from Super I/O config space 11 Addresses scanned: none, address read from Super I/O config space
12 Datasheet: Provided by Fintek on request 12 Datasheet: Available from the Fintek website
13 13
14Author: Jean Delvare <khali@linux-fr.org> 14Author: Jean Delvare <khali@linux-fr.org>
15 15
@@ -128,7 +128,9 @@ it.
128When the PWM method is used, you can select the operating frequency, 128When the PWM method is used, you can select the operating frequency,
129from 187.5 kHz (default) to 31 Hz. The best frequency depends on the 129from 187.5 kHz (default) to 31 Hz. The best frequency depends on the
130fan model. As a rule of thumb, lower frequencies seem to give better 130fan model. As a rule of thumb, lower frequencies seem to give better
131control, but may generate annoying high-pitch noise. Fintek recommends 131control, but may generate annoying high-pitch noise. So a frequency just
132above the audible range, such as 25 kHz, may be a good choice; if this
133doesn't give you good linear control, try reducing it. Fintek recommends
132not going below 1 kHz, as the fan tachometers get confused by lower 134not going below 1 kHz, as the fan tachometers get confused by lower
133frequencies as well. 135frequencies as well.
134 136
@@ -136,16 +138,23 @@ When the DC method is used, Fintek recommends not going below 5 V, which
136corresponds to a pwm value of 106 for the driver. The driver doesn't 138corresponds to a pwm value of 106 for the driver. The driver doesn't
137enforce this limit though. 139enforce this limit though.
138 140
139Three different fan control modes are supported: 141Three different fan control modes are supported; the mode number is written
142to the pwm<n>_enable file.
140 143
141* Manual mode 144* 1: Manual mode
142 You ask for a specific PWM duty cycle or DC voltage. 145 You ask for a specific PWM duty cycle or DC voltage by writing to the
146 pwm<n> file.
143 147
144* Fan speed mode 148* 2: Temperature mode
145 You ask for a specific fan speed. This mode assumes that pwm1 149 You define 3 temperature/fan speed trip points using the
146 corresponds to fan1, pwm2 to fan2 and pwm3 to fan3. 150 pwm<n>_auto_point<m>_temp and _fan files. These define a staircase
151 relationship between temperature and fan speed with two additional points
152 interpolated between the values that you define. When the temperature
153 is below auto_point1_temp the fan is switched off.
147 154
148* Temperature mode 155* 3: Fan speed mode
149 You define 3 temperature/fan speed trip points, and the fan speed is 156 You ask for a specific fan speed by writing to the fan<n>_target file.
150 adjusted depending on the measured temperature, using interpolation. 157
151 This mode is not yet supported by the driver. 158Both of the automatic modes require that pwm1 corresponds to fan1, pwm2 to
159fan2 and pwm3 to fan3. Temperature mode also requires that temp1 corresponds
160to pwm1 and fan1, etc.
diff --git a/Documentation/hwmon/it87 b/Documentation/hwmon/it87
index c0528d6f9ace..81ecc7e41c50 100644
--- a/Documentation/hwmon/it87
+++ b/Documentation/hwmon/it87
@@ -12,11 +12,12 @@ Supported chips:
12 Addresses scanned: from Super I/O config space (8 I/O ports) 12 Addresses scanned: from Super I/O config space (8 I/O ports)
13 Datasheet: Publicly available at the ITE website 13 Datasheet: Publicly available at the ITE website
14 http://www.ite.com.tw/ 14 http://www.ite.com.tw/
15 * IT8716F 15 * IT8716F/IT8726F
16 Prefix: 'it8716' 16 Prefix: 'it8716'
17 Addresses scanned: from Super I/O config space (8 I/O ports) 17 Addresses scanned: from Super I/O config space (8 I/O ports)
18 Datasheet: Publicly available at the ITE website 18 Datasheet: Publicly available at the ITE website
19 http://www.ite.com.tw/product_info/file/pc/IT8716F_V0.3.ZIP 19 http://www.ite.com.tw/product_info/file/pc/IT8716F_V0.3.ZIP
20 http://www.ite.com.tw/product_info/file/pc/IT8726F_V0.3.pdf
20 * IT8718F 21 * IT8718F
21 Prefix: 'it8718' 22 Prefix: 'it8718'
22 Addresses scanned: from Super I/O config space (8 I/O ports) 23 Addresses scanned: from Super I/O config space (8 I/O ports)
@@ -68,7 +69,7 @@ Description
68----------- 69-----------
69 70
70This driver implements support for the IT8705F, IT8712F, IT8716F, 71This driver implements support for the IT8705F, IT8712F, IT8716F,
71IT8718F and SiS950 chips. 72IT8718F, IT8726F and SiS950 chips.
72 73
73These chips are 'Super I/O chips', supporting floppy disks, infrared ports, 74These chips are 'Super I/O chips', supporting floppy disks, infrared ports,
74joysticks and other miscellaneous stuff. For hardware monitoring, they 75joysticks and other miscellaneous stuff. For hardware monitoring, they
@@ -97,6 +98,10 @@ clock divider mess) but not compatible with the older chips and
97revisions. For now, the driver only uses the 16-bit mode on the 98revisions. For now, the driver only uses the 16-bit mode on the
98IT8716F and IT8718F. 99IT8716F and IT8718F.
99 100
101The IT8726F is just bit enhanced IT8716F with additional hardware
102for AMD power sequencing. Therefore the chip will appear as IT8716F
103to userspace applications.
104
100Temperatures are measured in degrees Celsius. An alarm is triggered once 105Temperatures are measured in degrees Celsius. An alarm is triggered once
101when the Overtemperature Shutdown limit is crossed. 106when the Overtemperature Shutdown limit is crossed.
102 107
diff --git a/Documentation/hwmon/lm90 b/Documentation/hwmon/lm90
index 438cb24cee5b..aa4a0ec20081 100644
--- a/Documentation/hwmon/lm90
+++ b/Documentation/hwmon/lm90
@@ -48,6 +48,18 @@ Supported chips:
48 Addresses scanned: I2C 0x4c, 0x4d (unsupported 0x4e) 48 Addresses scanned: I2C 0x4c, 0x4d (unsupported 0x4e)
49 Datasheet: Publicly available at the Maxim website 49 Datasheet: Publicly available at the Maxim website
50 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 50 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578
51 * Maxim MAX6680
52 Prefix: 'max6680'
53 Addresses scanned: I2C 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b,
54 0x4c, 0x4d and 0x4e
55 Datasheet: Publicly available at the Maxim website
56 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3370
57 * Maxim MAX6681
58 Prefix: 'max6680'
59 Addresses scanned: I2C 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b,
60 0x4c, 0x4d and 0x4e
61 Datasheet: Publicly available at the Maxim website
62 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3370
51 63
52 64
53Author: Jean Delvare <khali@linux-fr.org> 65Author: Jean Delvare <khali@linux-fr.org>
@@ -59,11 +71,15 @@ Description
59The LM90 is a digital temperature sensor. It senses its own temperature as 71The LM90 is a digital temperature sensor. It senses its own temperature as
60well as the temperature of up to one external diode. It is compatible 72well as the temperature of up to one external diode. It is compatible
61with many other devices such as the LM86, the LM89, the LM99, the ADM1032, 73with many other devices such as the LM86, the LM89, the LM99, the ADM1032,
62the MAX6657, MAX6658 and the MAX6659 all of which are supported by this driver. 74the MAX6657, MAX6658, MAX6659, MAX6680 and the MAX6681 all of which are
63Note that there is no easy way to differentiate between the last three 75supported by this driver.
64variants. The extra address and features of the MAX6659 are not supported by 76
65this driver. Additionally, the ADT7461 is supported if found in ADM1032 77Note that there is no easy way to differentiate between the MAX6657,
66compatibility mode. 78MAX6658 and MAX6659 variants. The extra address and features of the
79MAX6659 are not supported by this driver. The MAX6680 and MAX6681 only
80differ in their pinout, therefore they obviously can't (and don't need to)
81be distinguished. Additionally, the ADT7461 is supported if found in
82ADM1032 compatibility mode.
67 83
68The specificity of this family of chipsets over the ADM1021/LM84 84The specificity of this family of chipsets over the ADM1021/LM84
69family is that it features critical limits with hysteresis, and an 85family is that it features critical limits with hysteresis, and an
@@ -93,18 +109,22 @@ ADM1032:
93 * ALERT is triggered by open remote sensor. 109 * ALERT is triggered by open remote sensor.
94 * SMBus PEC support for Write Byte and Receive Byte transactions. 110 * SMBus PEC support for Write Byte and Receive Byte transactions.
95 111
96ADT7461 112ADT7461:
97 * Extended temperature range (breaks compatibility) 113 * Extended temperature range (breaks compatibility)
98 * Lower resolution for remote temperature 114 * Lower resolution for remote temperature
99 115
100MAX6657 and MAX6658: 116MAX6657 and MAX6658:
101 * Remote sensor type selection 117 * Remote sensor type selection
102 118
103MAX6659 119MAX6659:
104 * Selectable address 120 * Selectable address
105 * Second critical temperature limit 121 * Second critical temperature limit
106 * Remote sensor type selection 122 * Remote sensor type selection
107 123
124MAX6680 and MAX6681:
125 * Selectable address
126 * Remote sensor type selection
127
108All temperature values are given in degrees Celsius. Resolution 128All temperature values are given in degrees Celsius. Resolution
109is 1.0 degree for the local temperature, 0.125 degree for the remote 129is 1.0 degree for the local temperature, 0.125 degree for the remote
110temperature. 130temperature.
@@ -141,7 +161,7 @@ SMBus Read Byte, and PEC will work properly.
141Additionally, the ADM1032 doesn't support SMBus Send Byte with PEC. 161Additionally, the ADM1032 doesn't support SMBus Send Byte with PEC.
142Instead, it will try to write the PEC value to the register (because the 162Instead, it will try to write the PEC value to the register (because the
143SMBus Send Byte transaction with PEC is similar to a Write Byte transaction 163SMBus Send Byte transaction with PEC is similar to a Write Byte transaction
144without PEC), which is not what we want. Thus, PEC is explicitely disabled 164without PEC), which is not what we want. Thus, PEC is explicitly disabled
145on SMBus Send Byte transactions in the lm90 driver. 165on SMBus Send Byte transactions in the lm90 driver.
146 166
147PEC on byte data transactions represents a significant increase in bandwidth 167PEC on byte data transactions represents a significant increase in bandwidth
diff --git a/Documentation/hwmon/lm93 b/Documentation/hwmon/lm93
new file mode 100644
index 000000000000..4e4a1dc1d2da
--- /dev/null
+++ b/Documentation/hwmon/lm93
@@ -0,0 +1,412 @@
1Kernel driver lm93
2==================
3
4Supported chips:
5 * National Semiconductor LM93
6 Prefix 'lm93'
7 Addresses scanned: I2C 0x2c-0x2e
8 Datasheet: http://www.national.com/ds.cgi/LM/LM93.pdf
9
10Author:
11 Mark M. Hoffman <mhoffman@lightlink.com>
12 Ported to 2.6 by Eric J. Bowersox <ericb@aspsys.com>
13 Adapted to 2.6.20 by Carsten Emde <ce@osadl.org>
14 Modified for mainline integration by Hans J. Koch <hjk@linutronix.de>
15
16Module Parameters
17-----------------
18
19(specific to LM93)
20* init: integer
21 Set to non-zero to force some initializations (default is 0).
22* disable_block: integer
23 A "0" allows SMBus block data transactions if the host supports them. A "1"
24 disables SMBus block data transactions. The default is 0.
25* vccp_limit_type: integer array (2)
26 Configures in7 and in8 limit type, where 0 means absolute and non-zero
27 means relative. "Relative" here refers to "Dynamic Vccp Monitoring using
28 VID" from the datasheet. It greatly simplifies the interface to allow
29 only one set of limits (absolute or relative) to be in operation at a
30 time (even though the hardware is capable of enabling both). There's
31 not a compelling use case for enabling both at once, anyway. The default
32 is "0,0".
33* vid_agtl: integer
34 A "0" configures the VID pins for V(ih) = 2.1V min, V(il) = 0.8V max.
35 A "1" configures the VID pins for V(ih) = 0.8V min, V(il) = 0.4V max.
36 (The latter setting is referred to as AGTL+ Compatible in the datasheet.)
37 I.e. this parameter controls the VID pin input thresholds; if your VID
38 inputs are not working, try changing this. The default value is "0".
39
40(common among sensor drivers)
41* force: short array (min = 1, max = 48)
42 List of adapter,address pairs to assume to be present. Autodetection
43 of the target device will still be attempted. Use one of the more
44 specific force directives below if this doesn't detect the device.
45* force_lm93: short array (min = 1, max = 48)
46 List of adapter,address pairs which are unquestionably assumed to contain
47 a 'lm93' chip
48* ignore: short array (min = 1, max = 48)
49 List of adapter,address pairs not to scan
50* ignore_range: short array (min = 1, max = 48)
51 List of adapter,start-addr,end-addr triples not to scan
52* probe: short array (min = 1, max = 48)
53 List of adapter,address pairs to scan additionally
54* probe_range: short array (min = 1, max = 48)
55 List of adapter,start-addr,end-addr triples to scan additionally
56
57
58Hardware Description
59--------------------
60
61(from the datasheet)
62
63The LM93, hardware monitor, has a two wire digital interface compatible with
64SMBus 2.0. Using an 8-bit ADC, the LM93 measures the temperature of two remote
65diode connected transistors as well as its own die and 16 power supply
66voltages. To set fan speed, the LM93 has two PWM outputs that are each
67controlled by up to four temperature zones. The fancontrol algorithm is lookup
68table based. The LM93 includes a digital filter that can be invoked to smooth
69temperature readings for better control of fan speed. The LM93 has four
70tachometer inputs to measure fan speed. Limit and status registers for all
71measured values are included. The LM93 builds upon the functionality of
72previous motherboard management ASICs and uses some of the LM85 s features
73(i.e. smart tachometer mode). It also adds measurement and control support
74for dynamic Vccp monitoring and PROCHOT. It is designed to monitor a dual
75processor Xeon class motherboard with a minimum of external components.
76
77
78Driver Description
79------------------
80
81This driver implements support for the National Semiconductor LM93.
82
83
84User Interface
85--------------
86
87#PROCHOT:
88
89The LM93 can monitor two #PROCHOT signals. The results are found in the
90sysfs files prochot1, prochot2, prochot1_avg, prochot2_avg, prochot1_max,
91and prochot2_max. prochot1_max and prochot2_max contain the user limits
92for #PROCHOT1 and #PROCHOT2, respectively. prochot1 and prochot2 contain
93the current readings for the most recent complete time interval. The
94value of prochot1_avg and prochot2_avg is something like a 2 period
95exponential moving average (but not quite - check the datasheet). Note
96that this third value is calculated by the chip itself. All values range
97from 0-255 where 0 indicates no throttling, and 255 indicates > 99.6%.
98
99The monitoring intervals for the two #PROCHOT signals is also configurable.
100These intervals can be found in the sysfs files prochot1_interval and
101prochot2_interval. The values in these files specify the intervals for
102#P1_PROCHOT and #P2_PROCHOT, respectively. Selecting a value not in this
103list will cause the driver to use the next largest interval. The available
104intervals are:
105
106#PROCHOT intervals: 0.73, 1.46, 2.9, 5.8, 11.7, 23.3, 46.6, 93.2, 186, 372
107
108It is possible to configure the LM93 to logically short the two #PROCHOT
109signals. I.e. when #P1_PROCHOT is asserted, the LM93 will automatically
110assert #P2_PROCHOT, and vice-versa. This mode is enabled by writing a
111non-zero integer to the sysfs file prochot_short.
112
113The LM93 can also override the #PROCHOT pins by driving a PWM signal onto
114one or both of them. When overridden, the signal has a period of 3.56 mS,
115a minimum pulse width of 5 clocks (at 22.5kHz => 6.25% duty cycle), and
116a maximum pulse width of 80 clocks (at 22.5kHz => 99.88% duty cycle).
117
118The sysfs files prochot1_override and prochot2_override contain boolean
119intgers which enable or disable the override function for #P1_PROCHOT and
120#P2_PROCHOT, respectively. The sysfs file prochot_override_duty_cycle
121contains a value controlling the duty cycle for the PWM signal used when
122the override function is enabled. This value ranges from 0 to 15, with 0
123indicating minimum duty cycle and 15 indicating maximum.
124
125#VRD_HOT:
126
127The LM93 can monitor two #VRD_HOT signals. The results are found in the
128sysfs files vrdhot1 and vrdhot2. There is one value per file: a boolean for
129which 1 indicates #VRD_HOT is asserted and 0 indicates it is negated. These
130files are read-only.
131
132Smart Tach Mode:
133
134(from the datasheet)
135
136 If a fan is driven using a low-side drive PWM, the tachometer
137 output of the fan is corrupted. The LM93 includes smart tachometer
138 circuitry that allows an accurate tachometer reading to be
139 achieved despite the signal corruption. In smart tach mode all
140 four signals are measured within 4 seconds.
141
142Smart tach mode is enabled by the driver by writing 1 or 2 (associating the
143the fan tachometer with a pwm) to the sysfs file fan<n>_smart_tach. A zero
144will disable the function for that fan. Note that Smart tach mode cannot be
145enabled if the PWM output frequency is 22500 Hz (see below).
146
147Manual PWM:
148
149The LM93 has a fixed or override mode for the two PWM outputs (although, there
150are still some conditions that will override even this mode - see section
15115.10.6 of the datasheet for details.) The sysfs files pwm1_override
152and pwm2_override are used to enable this mode; each is a boolean integer
153where 0 disables and 1 enables the manual control mode. The sysfs files pwm1
154and pwm2 are used to set the manual duty cycle; each is an integer (0-255)
155where 0 is 0% duty cycle, and 255 is 100%. Note that the duty cycle values
156are constrained by the hardware. Selecting a value which is not available
157will cause the driver to use the next largest value. Also note: when manual
158PWM mode is disabled, the value of pwm1 and pwm2 indicates the current duty
159cycle chosen by the h/w.
160
161PWM Output Frequency:
162
163The LM93 supports several different frequencies for the PWM output channels.
164The sysfs files pwm1_freq and pwm2_freq are used to select the frequency. The
165frequency values are constrained by the hardware. Selecting a value which is
166not available will cause the driver to use the next largest value. Also note
167that this parameter has implications for the Smart Tach Mode (see above).
168
169PWM Output Frequencies: 12, 36, 48, 60, 72, 84, 96, 22500 (h/w default)
170
171Automatic PWM:
172
173The LM93 is capable of complex automatic fan control, with many different
174points of configuration. To start, each PWM output can be bound to any
175combination of eight control sources. The final PWM is the largest of all
176individual control sources to which the PWM output is bound.
177
178The eight control sources are: temp1-temp4 (aka "zones" in the datasheet),
179#PROCHOT 1 & 2, and #VRDHOT 1 & 2. The bindings are expressed as a bitmask
180in the sysfs files pwm<n>_auto_channels, where a "1" enables the binding, and
181 a "0" disables it. The h/w default is 0x0f (all temperatures bound).
182
183 0x01 - Temp 1
184 0x02 - Temp 2
185 0x04 - Temp 3
186 0x08 - Temp 4
187 0x10 - #PROCHOT 1
188 0x20 - #PROCHOT 2
189 0x40 - #VRDHOT 1
190 0x80 - #VRDHOT 2
191
192The function y = f(x) takes a source temperature x to a PWM output y. This
193function of the LM93 is derived from a base temperature and a table of 12
194temperature offsets. The base temperature is expressed in degrees C in the
195sysfs files temp<n>_auto_base. The offsets are expressed in cumulative
196degrees C, with the value of offset <i> for temperature value <n> being
197contained in the file temp<n>_auto_offset<i>. E.g. if the base temperature
198is 40C:
199
200 offset # temp<n>_auto_offset<i> range pwm
201 1 0 - 25.00%
202 2 0 - 28.57%
203 3 1 40C - 41C 32.14%
204 4 1 41C - 42C 35.71%
205 5 2 42C - 44C 39.29%
206 6 2 44C - 46C 42.86%
207 7 2 48C - 50C 46.43%
208 8 2 50C - 52C 50.00%
209 9 2 52C - 54C 53.57%
210 10 2 54C - 56C 57.14%
211 11 2 56C - 58C 71.43%
212 12 2 58C - 60C 85.71%
213 > 60C 100.00%
214
215Valid offsets are in the range 0C <= x <= 7.5C in 0.5C increments.
216
217There is an independent base temperature for each temperature channel. Note,
218however, there are only two tables of offsets: one each for temp[12] and
219temp[34]. Therefore, any change to e.g. temp1_auto_offset<i> will also
220affect temp2_auto_offset<i>.
221
222The LM93 can also apply hysteresis to the offset table, to prevent unwanted
223oscillation between two steps in the offsets table. These values are found in
224the sysfs files temp<n>_auto_offset_hyst. The value in this file has the
225same representation as in temp<n>_auto_offset<i>.
226
227If a temperature reading falls below the base value for that channel, the LM93
228will use the minimum PWM value. These values are found in the sysfs files
229temp<n>_auto_pwm_min. Note, there are only two minimums: one each for temp[12]
230and temp[34]. Therefore, any change to e.g. temp1_auto_pwm_min will also
231affect temp2_auto_pwm_min.
232
233PWM Spin-Up Cycle:
234
235A spin-up cycle occurs when a PWM output is commanded from 0% duty cycle to
236some value > 0%. The LM93 supports a minimum duty cycle during spin-up. These
237values are found in the sysfs files pwm<n>_auto_spinup_min. The value in this
238file has the same representation as other PWM duty cycle values. The
239duration of the spin-up cycle is also configurable. These values are found in
240the sysfs files pwm<n>_auto_spinup_time. The value in this file is
241the spin-up time in seconds. The available spin-up times are constrained by
242the hardware. Selecting a value which is not available will cause the driver
243to use the next largest value.
244
245Spin-up Durations: 0 (disabled, h/w default), 0.1, 0.25, 0.4, 0.7, 1.0,
246 2.0, 4.0
247
248#PROCHOT and #VRDHOT PWM Ramping:
249
250If the #PROCHOT or #VRDHOT signals are asserted while bound to a PWM output
251channel, the LM93 will ramp the PWM output up to 100% duty cycle in discrete
252steps. The duration of each step is configurable. There are two files, with
253one value each in seconds: pwm_auto_prochot_ramp and pwm_auto_vrdhot_ramp.
254The available ramp times are constrained by the hardware. Selecting a value
255which is not available will cause the driver to use the next largest value.
256
257Ramp Times: 0 (disabled, h/w default) to 0.75 in 0.05 second intervals
258
259Fan Boost:
260
261For each temperature channel, there is a boost temperature: if the channel
262exceeds this limit, the LM93 will immediately drive both PWM outputs to 100%.
263This limit is expressed in degrees C in the sysfs files temp<n>_auto_boost.
264There is also a hysteresis temperature for this function: after the boost
265limit is reached, the temperature channel must drop below this value before
266the boost function is disabled. This temperature is also expressed in degrees
267C in the sysfs files temp<n>_auto_boost_hyst.
268
269GPIO Pins:
270
271The LM93 can monitor the logic level of four dedicated GPIO pins as well as the
272four tach input pins. GPIO0-GPIO3 correspond to (fan) tach 1-4, respectively.
273All eight GPIOs are read by reading the bitmask in the sysfs file gpio. The
274LSB is GPIO0, and the MSB is GPIO7.
275
276
277LM93 Unique sysfs Files
278-----------------------
279
280 file description
281 -------------------------------------------------------------
282
283 prochot<n> current #PROCHOT %
284
285 prochot<n>_avg moving average #PROCHOT %
286
287 prochot<n>_max limit #PROCHOT %
288
289 prochot_short enable or disable logical #PROCHOT pin short
290
291 prochot<n>_override force #PROCHOT assertion as PWM
292
293 prochot_override_duty_cycle
294 duty cycle for the PWM signal used when
295 #PROCHOT is overridden
296
297 prochot<n>_interval #PROCHOT PWM sampling interval
298
299 vrdhot<n> 0 means negated, 1 means asserted
300
301 fan<n>_smart_tach enable or disable smart tach mode
302
303 pwm<n>_auto_channels select control sources for PWM outputs
304
305 pwm<n>_auto_spinup_min minimum duty cycle during spin-up
306
307 pwm<n>_auto_spinup_time duration of spin-up
308
309 pwm_auto_prochot_ramp ramp time per step when #PROCHOT asserted
310
311 pwm_auto_vrdhot_ramp ramp time per step when #VRDHOT asserted
312
313 temp<n>_auto_base temperature channel base
314
315 temp<n>_auto_offset[1-12]
316 temperature channel offsets
317
318 temp<n>_auto_offset_hyst
319 temperature channel offset hysteresis
320
321 temp<n>_auto_boost temperature channel boost (PWMs to 100%) limit
322
323 temp<n>_auto_boost_hyst temperature channel boost hysteresis
324
325 gpio input state of 8 GPIO pins; read-only
326
327
328Sample Configuration File
329-------------------------
330
331Here is a sample LM93 chip config for sensors.conf:
332
333---------- cut here ----------
334chip "lm93-*"
335
336# VOLTAGE INPUTS
337
338 # labels and scaling based on datasheet recommendations
339 label in1 "+12V1"
340 compute in1 @ * 12.945, @ / 12.945
341 set in1_min 12 * 0.90
342 set in1_max 12 * 1.10
343
344 label in2 "+12V2"
345 compute in2 @ * 12.945, @ / 12.945
346 set in2_min 12 * 0.90
347 set in2_max 12 * 1.10
348
349 label in3 "+12V3"
350 compute in3 @ * 12.945, @ / 12.945
351 set in3_min 12 * 0.90
352 set in3_max 12 * 1.10
353
354 label in4 "FSB_Vtt"
355
356 label in5 "3GIO"
357
358 label in6 "ICH_Core"
359
360 label in7 "Vccp1"
361
362 label in8 "Vccp2"
363
364 label in9 "+3.3V"
365 set in9_min 3.3 * 0.90
366 set in9_max 3.3 * 1.10
367
368 label in10 "+5V"
369 set in10_min 5.0 * 0.90
370 set in10_max 5.0 * 1.10
371
372 label in11 "SCSI_Core"
373
374 label in12 "Mem_Core"
375
376 label in13 "Mem_Vtt"
377
378 label in14 "Gbit_Core"
379
380 # Assuming R1/R2 = 4.1143, and 3.3V reference
381 # -12V = (4.1143 + 1) * (@ - 3.3) + 3.3
382 label in15 "-12V"
383 compute in15 @ * 5.1143 - 13.57719, (@ + 13.57719) / 5.1143
384 set in15_min -12 * 0.90
385 set in15_max -12 * 1.10
386
387 label in16 "+3.3VSB"
388 set in16_min 3.3 * 0.90
389 set in16_max 3.3 * 1.10
390
391# TEMPERATURE INPUTS
392
393 label temp1 "CPU1"
394 label temp2 "CPU2"
395 label temp3 "LM93"
396
397# TACHOMETER INPUTS
398
399 label fan1 "Fan1"
400 set fan1_min 3000
401 label fan2 "Fan2"
402 set fan2_min 3000
403 label fan3 "Fan3"
404 set fan3_min 3000
405 label fan4 "Fan4"
406 set fan4_min 3000
407
408# PWM OUTPUTS
409
410 label pwm1 "CPU1"
411 label pwm2 "CPU2"
412
diff --git a/Documentation/hwmon/smsc47b397 b/Documentation/hwmon/smsc47b397
index 20682f15ae41..3a43b6948924 100644
--- a/Documentation/hwmon/smsc47b397
+++ b/Documentation/hwmon/smsc47b397
@@ -4,6 +4,7 @@ Kernel driver smsc47b397
4Supported chips: 4Supported chips:
5 * SMSC LPC47B397-NC 5 * SMSC LPC47B397-NC
6 * SMSC SCH5307-NS 6 * SMSC SCH5307-NS
7 * SMSC SCH5317
7 Prefix: 'smsc47b397' 8 Prefix: 'smsc47b397'
8 Addresses scanned: none, address read from Super I/O config space 9 Addresses scanned: none, address read from Super I/O config space
9 Datasheet: In this file 10 Datasheet: In this file
@@ -18,8 +19,8 @@ The following specification describes the SMSC LPC47B397-NC[1] sensor chip
18provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected 19provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected
19by Mark M. Hoffman <mhoffman@lightlink.com>. 20by Mark M. Hoffman <mhoffman@lightlink.com>.
20 21
21[1] And SMSC SCH5307-NS, which has a different device ID but is otherwise 22[1] And SMSC SCH5307-NS and SCH5317, which have different device IDs but are
22compatible. 23otherwise compatible.
23 24
24* * * * * 25* * * * *
25 26
@@ -131,7 +132,7 @@ OUT DX,AL
131The registers of interest for identifying the SIO on the dc7100 are Device ID 132The registers of interest for identifying the SIO on the dc7100 are Device ID
132(0x20) and Device Rev (0x21). 133(0x20) and Device Rev (0x21).
133 134
134The Device ID will read 0x6F (for SCH5307-NS, 0x81) 135The Device ID will read 0x6F (0x81 for SCH5307-NS, and 0x85 for SCH5317)
135The Device Rev currently reads 0x01 136The Device Rev currently reads 0x01
136 137
137Obtaining the HWM Base Address. 138Obtaining the HWM Base Address.
diff --git a/Documentation/hwmon/sysfs-interface b/Documentation/hwmon/sysfs-interface
index a9a18ad0d17a..b3a9e1b9dbda 100644
--- a/Documentation/hwmon/sysfs-interface
+++ b/Documentation/hwmon/sysfs-interface
@@ -172,11 +172,10 @@ pwm[1-*] Pulse width modulation fan control.
172 255 is max or 100%. 172 255 is max or 100%.
173 173
174pwm[1-*]_enable 174pwm[1-*]_enable
175 Switch PWM on and off. 175 Fan speed control method:
176 Not always present even if pwmN is. 176 0: no fan speed control (i.e. fan at full speed)
177 0: turn off 177 1: manual fan speed control enabled (using pwm[1-*])
178 1: turn on in manual mode 178 2+: automatic fan speed control enabled
179 2+: turn on in automatic mode
180 Check individual chip documentation files for automatic mode 179 Check individual chip documentation files for automatic mode
181 details. 180 details.
182 RW 181 RW
@@ -343,9 +342,9 @@ to notify open diodes, unconnected fans etc. where the hardware
343supports it. When this boolean has value 1, the measurement for that 342supports it. When this boolean has value 1, the measurement for that
344channel should not be trusted. 343channel should not be trusted.
345 344
346in[0-*]_input_fault 345in[0-*]_fault
347fan[1-*]_input_fault 346fan[1-*]_fault
348temp[1-*]_input_fault 347temp[1-*]_fault
349 Input fault condition 348 Input fault condition
350 0: no fault occured 349 0: no fault occured
351 1: fault condition 350 1: fault condition
diff --git a/Documentation/hwmon/w83627ehf b/Documentation/hwmon/w83627ehf
index 030fac6cec7a..ccc2bcb61068 100644
--- a/Documentation/hwmon/w83627ehf
+++ b/Documentation/hwmon/w83627ehf
@@ -22,9 +22,9 @@ This driver implements support for the Winbond W83627EHF, W83627EHG, and
22W83627DHG super I/O chips. We will refer to them collectively as Winbond chips. 22W83627DHG super I/O chips. We will refer to them collectively as Winbond chips.
23 23
24The chips implement three temperature sensors, five fan rotation 24The chips implement three temperature sensors, five fan rotation
25speed sensors, ten analog voltage sensors (only nine for the 627DHG), alarms 25speed sensors, ten analog voltage sensors (only nine for the 627DHG), one
26with beep warnings (control unimplemented), and some automatic fan regulation 26VID (6 pins), alarms with beep warnings (control unimplemented), and
27strategies (plus manual fan control mode). 27some automatic fan regulation strategies (plus manual fan control mode).
28 28
29Temperatures are measured in degrees Celsius and measurement resolution is 1 29Temperatures are measured in degrees Celsius and measurement resolution is 1
30degC for temp1 and 0.5 degC for temp2 and temp3. An alarm is triggered when 30degC for temp1 and 0.5 degC for temp2 and temp3. An alarm is triggered when
diff --git a/Documentation/ja_JP/HOWTO b/Documentation/ja_JP/HOWTO
new file mode 100644
index 000000000000..b2446a090870
--- /dev/null
+++ b/Documentation/ja_JP/HOWTO
@@ -0,0 +1,650 @@
1NOTE:
2This is Japanese translated version of "Documentation/HOWTO".
3This one is maintained by Tsugikazu Shibata <tshibata@ab.jp.nec.com>
4and JF Project team <www.linux.or.jp/JF>.
5If you find difference with original file or problem in translation,
6please contact maintainer of this file or JF project.
7
8Please also note that purpose of this file is easier to read for non
9English natives and not to be intended to fork. So, if you have any
10comments or updates of this file, please try to update Original(English)
11file at first.
12
13Last Updated: 2007/06/04
14==================================
15これは、
16linux-2.6.21/Documentation/HOWTO
17の和訳です。
18
19翻訳団体: JF プロジェクト < http://www.linux.or.jp/JF/ >
20翻訳日: 2007/06/04
21翻訳者: Tsugikazu Shibata <tshibata at ab dot jp dot nec dot com>
22校正者: 松倉さん <nbh--mats at nifty dot com>
23 小林 雅典さん (Masanori Kobayasi) <zap03216 at nifty dot ne dot jp>
24 武井伸光さん、<takei at webmasters dot gr dot jp>
25 かねこさん (Seiji Kaneko) <skaneko at a2 dot mbn dot or dot jp>
26 野口さん (Kenji Noguchi) <tokyo246 at gmail dot com>
27 河内さん (Takayoshi Kochi) <t-kochi at bq dot jp dot nec dot com>
28 岩本さん (iwamoto) <iwamoto.kn at ncos dot nec dot co dot jp>
29==================================
30
31Linux カーネル開発のやり方
32-------------------------------
33
34これは上のトピック( Linux カーネル開発のやり方)の重要な事柄を網羅した
35ドキュメントです。ここには Linux カーネル開発者になるための方法と
36Linux カーネル開発コミュニティと共に活動するやり方を学ぶ方法が含まれて
37います。カーネルプログラミングに関する技術的な項目に関することは何も含
38めないようにしていますが、カーネル開発者となるための正しい方向に向かう
39手助けになります。
40
41もし、このドキュメントのどこかが古くなっていた場合には、このドキュメン
42トの最後にリストしたメンテナーにパッチを送ってください。
43
44はじめに
45---------
46
47あなたは Linux カーネルの開発者になる方法を学びたいのでしょうか? そ
48れともあなたは上司から「このデバイスの Linux ドライバを書くように」と
49言われているのでしょうか? 
50この文書の目的は、あなたが踏むべき手順と、コミュニティと一緒にうまく働
51くヒントを書き下すことで、あなたが知るべき全てのことを教えることです。
52また、このコミュニティがなぜ今うまくまわっているのかという理由の一部も
53説明しようと試みています。
54
55カーネルは 少量のアーキテクチャ依存部分がアセンブリ言語で書かれている
56以外は大部分は C 言語で書かれています。C言語をよく理解していることはカー
57ネル開発者には必要です。アーキテクチャ向けの低レベル部分の開発をするの
58でなければ、(どんなアーキテクチャでも)アセンブリ(訳注: 言語)は必要あり
59ません。以下の本は、C 言語の十分な知識や何年もの経験に取って代わるもの
60ではありませんが、少なくともリファレンスとしてはいい本です。
61 - "The C Programming Language" by Kernighan and Ritchie [Prentice Hall]
62 -『プログラミング言語C第2版』(B.W. カーニハン/D.M. リッチー著 石田晴久訳) [共立出版]
63 - "Practical C Programming" by Steve Oualline [O'Reilly]
64 - 『C実践プログラミング第3版』(Steve Oualline著 望月康司監訳 谷口功訳) [オライリージャパン]
65 - "C: A Reference Manual" by Harbison and Steele [Prentice Hall]
66 - 『新・詳説 C 言語 H&S リファレンス』
67 (サミュエル P ハービソン/ガイ L スティール共著 斉藤 信男監訳)[ソフトバンク]
68
69カーネルは GNU C と GNU ツールチェインを使って書かれています。カーネル
70は ISO C89 仕様に準拠して書く一方で、標準には無い言語拡張を多く使って
71います。カーネルは標準 C ライブラリとは関係がないといった、C 言語フリー
72スタンディング環境です。そのため、C の標準で使えないものもあります。任
73意の long long の除算や浮動小数点は使えません。
74ときどき、カーネルがツールチェインや C 言語拡張に置いている前提がどう
75なっているのかわかりにくいことがあり、また、残念なことに決定的なリファ
76レンスは存在しません。情報を得るには、gcc の info ページ( info gcc )を
77みてください。
78
79あなたは既存の開発コミュニティと一緒に作業する方法を学ぼうとしているこ
80とに留意してください。そのコミュニティは、コーディング、スタイル、
81開発手順について高度な標準を持つ、多様な人の集まりです。
82地理的に分散した大規模なチームに対してもっともうまくいくとわかったこと
83をベースにしながら、これらの標準は長い時間をかけて築かれてきました。
84これらはきちんと文書化されていますから、事前にこれらの標準についてでき
85るだけたくさん学んでください。また皆があなたやあなたの会社のやり方に合わ
86せてくれると思わないでください。
87
88法的問題
89------------
90
91Linux カーネルのソースコードは GPL ライセンスの下でリリースされていま
92す。ライセンスの詳細については、ソースツリーのメインディレクトリに存在
93する、COPYING のファイルをみてください。もしライセンスについてさらに質
94問があれば、Linux Kernel メーリングリストに質問するのではなく、どうぞ
95法律家に相談してください。メーリングリストの人達は法律家ではなく、法的
96問題については彼らの声明はあてにするべきではありません。
97
98GPL に関する共通の質問や回答については、以下を参照してください。
99 http://www.gnu.org/licenses/gpl-faq.html
100
101ドキュメント
102------------
103
104Linux カーネルソースツリーは幅広い範囲のドキュメントを含んでおり、それ
105らはカーネルコミュニティと会話する方法を学ぶのに非常に貴重なものです。
106新しい機能がカーネルに追加される場合、その機能の使い方について説明した
107新しいドキュメントファイルも追加することを勧めます。
108カーネルの変更が、カーネルがユーザ空間に公開しているインターフェイスの
109変更を引き起こす場合、その変更を説明するマニュアルページのパッチや情報
110をマニュアルページのメンテナ mtk-manpages@gmx.net に送ることを勧めます。
111
112以下はカーネルソースツリーに含まれている読んでおくべきファイルの一覧で
113す-
114
115 README
116 このファイルは Linuxカーネルの簡単な背景とカーネルを設定(訳注
117 configure )し、生成(訳注 build )するために必要なことは何かが書かれ
118 ています。カーネルに関して初めての人はここからスタートするとよいで
119 しょう。
120
121 Documentation/Changes
122 このファイルはカーネルをうまく生成(訳注 build )し、走らせるのに最
123 小限のレベルで必要な数々のソフトウェアパッケージの一覧を示してい
124 ます。
125
126 Documentation/CodingStyle
127 これは Linux カーネルのコーディングスタイルと背景にある理由を記述
128 しています。全ての新しいコードはこのドキュメントにあるガイドライン
129 に従っていることを期待されています。大部分のメンテナーはこれらのルー
130 ルに従っているものだけを受け付け、多くの人は正しいスタイルのコード
131 だけをレビューします。
132
133 Documentation/SubmittingPatches
134 Documentation/SubmittingDrivers
135 これらのファイルには、どうやってうまくパッチを作って投稿するかに
136 ついて非常に詳しく書かれており、以下を含みます(これだけに限らない
137 けれども)
138 - Email に含むこと
139 - Email の形式
140 - だれに送るか
141 これらのルールに従えばうまくいくことを保証することではありません
142 が (すべてのパッチは内容とスタイルについて精査を受けるので)、
143 ルールに従わなければ間違いなくうまくいかないでしょう。
144 この他にパッチを作る方法についてのよくできた記述は-
145
146 "The Perfect Patch"
147 http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt
148 "Linux kernel patch submission format"
149 http://linux.yyz.us/patch-format.html
150
151 Documentation/stable_api_nonsense.txt
152 このファイルはカーネルの中に不変のAPIを持たないことにした意識的な
153 決断の背景にある理由について書かれています。以下のようなことを含
154 んでいます-
155 - サブシステムとの間に層を作ること(コンパチビリティのため?)
156 - オペレーティングシステム間のドライバの移植性
157 - カーネルソースツリーの素早い変更を遅らせる(もしくは素早い変更
158 を妨げる)
159 このドキュメントは Linux 開発の思想を理解するのに非常に重要です。
160 そして、他のOSでの開発者が Linux に移る時にとても重要です。
161
162 Documentation/SecurityBugs
163 もし Linux カーネルでセキュリティ問題を発見したように思ったら、こ
164 のドキュメントのステップに従ってカーネル開発者に連絡し、問題解決を
165 支援してください。
166
167 Documentation/ManagementStyle
168 このドキュメントは Linux カーネルのメンテナー達がどう行動するか、
169 彼らの手法の背景にある共有されている精神について記述しています。こ
170 れはカーネル開発の初心者なら(もしくは、単に興味があるだけの人でも)
171 重要です。なぜならこのドキュメントは、カーネルメンテナー達の独特な
172 行動についての多くの誤解や混乱を解消するからです。
173
174 Documentation/stable_kernel_rules.txt
175 このファイルはどのように stable カーネルのリリースが行われるかのルー
176 ルが記述されています。そしてこれらのリリースの中のどこかで変更を取
177 り入れてもらいたい場合に何をすればいいかが示されています。
178
179 Documentation/kernel-docs.txt
180  カーネル開発に付随する外部ドキュメントのリストです。もしあなたが
181 探しているものがカーネル内のドキュメントでみつからなかった場合、
182 このリストをあたってみてください。
183
184 Documentation/applying-patches.txt
185 パッチとはなにか、パッチをどうやって様々なカーネルの開発ブランチに
186 適用するのかについて正確に記述した良い入門書です。
187
188カーネルはソースコードから自動的に生成可能な多数のドキュメントを自分自
189身でもっています。これにはカーネル内 API のすべての記述や、どう正しく
190ロックをかけるかの規則が含まれます。このドキュメントは
191Documentation/DocBook/ ディレクトリに作られ、以下のように
192 make pdfdocs
193 make psdocs
194 make htmldocs
195 make mandocs
196コマンドを実行するとメインカーネルのソースディレクトリから
197それぞれ、PDF, Postscript, HTML, man page の形式で生成されます。
198
199カーネル開発者になるには
200---------------------------
201
202もしあなたが、Linux カーネル開発について何も知らないならば、
203KernelNewbies プロジェクトを見るべきです
204 http://kernelnewbies.org
205
206このサイトには役に立つメーリングリストがあり、基本的なカーネル開発に関
207するほとんどどんな種類の質問もできます (既に回答されているようなことを
208聞く前にまずはアーカイブを調べてください)。
209またここには、リアルタイムで質問を聞くことができる IRC チャネルや、Linux
210カーネルの開発に関して学ぶのに便利なたくさんの役に立つドキュメントがあ
211ります。
212
213web サイトには、コードの構成、サブシステム、現在存在するプロジェクト(ツ
214リーにあるもの無いものの両方)の基本的な管理情報があります。
215ここには、また、カーネルのコンパイルのやり方やパッチの当て方などの間接
216的な基本情報も記述されています。
217
218あなたがどこからスタートしてよいかわからないが、Linux カーネル開発コミュ
219ニティに参加して何かすることをさがしている場合には、Linux kernel
220Janitor's プロジェクトにいけばよいでしょう -
221 http://janitor.kernelnewbies.org/
222ここはそのようなスタートをするのにうってつけの場所です。ここには、
223Linux カーネルソースツリーの中に含まれる、きれいにし、修正しなければな
224らない、単純な問題のリストが記述されています。このプロジェクトに関わる
225開発者と一緒に作業することで、あなたのパッチを Linuxカーネルツリーに入
226れるための基礎を学ぶことができ、そしてもしあなたがまだアイディアを持っ
227ていない場合には、次にやる仕事の方向性が見えてくるかもしれません。
228
229もしあなたが、すでにひとまとまりコードを書いていて、カーネルツリーに入
230れたいと思っていたり、それに関する適切な支援を求めたい場合、カーネル
231メンターズプロジェクトはそのような皆さんを助けるためにできました。
232ここにはメーリングリストがあり、以下から参照できます
233 http://selenic.com/mailman/listinfo/kernel-mentors
234
235実際に Linux カーネルのコードについて修正を加える前に、どうやってその
236コードが動作するのかを理解することが必要です。そのためには、特別なツー
237ルの助けを借りてでも、それを直接よく読むことが最良の方法です(ほとんど
238のトリッキーな部分は十分にコメントしてありますから)。そういうツールで
239特におすすめなのは、Linux クロスリファレンスプロジェクトです。これは、
240自己参照方式で、索引がついた web 形式で、ソースコードを参照することが
241できます。この最新の素晴しいカーネルコードのリポジトリは以下で見つかり
242ます-
243 http://sosdg.org/~coywolf/lxr/
244
245開発プロセス
246-----------------------
247
248Linux カーネルの開発プロセスは現在幾つかの異なるメインカーネル「ブラン
249チ」と多数のサブシステム毎のカーネルブランチから構成されます。
250これらのブランチとは-
251 - メインの 2.6.x カーネルツリー
252 - 2.6.x.y -stable カーネルツリー
253 - 2.6.x -git カーネルパッチ
254 - 2.6.x -mm カーネルパッチ
255 - サブシステム毎のカーネルツリーとパッチ
256
2572.6.x カーネルツリー
258-----------------
259
2602.6.x カーネルは Linus Torvalds によってメンテナンスされ、kernel.org
261の pub/linux/kernel/v2.6/ ディレクトリに存在します。この開発プロセスは
262以下のとおり-
263
264 - 新しいカーネルがリリースされた直後に、2週間の特別期間が設けられ、
265 この期間中に、メンテナー達は Linus に大きな差分を送ることができま
266 す。このような差分は通常 -mm カーネルに数週間含まれてきたパッチで
267 す。 大きな変更は git(カーネルのソース管理ツール、詳細は
268 http://git.or.cz/ 参照) を使って送るのが好ましいやり方ですが、パッ
269 チファイルの形式のまま送るのでも十分です。
270
271 - 2週間後、-rc1 カーネルがリリースされ、この後にはカーネル全体の安定
272 性に影響をあたえるような新機能は含まない類のパッチしか取り込むこと
273 はできません。新しいドライバ(もしくはファイルシステム)のパッチは
274 -rc1 の後で受け付けられることもあることを覚えておいてください。な
275 ぜなら、変更が独立していて、追加されたコードの外の領域に影響を与え
276 ない限り、退行のリスクは無いからです。-rc1 がリリースされた後、
277 Linus へパッチを送付するのに git を使うこともできますが、パッチは
278 レビューのために、パブリックなメーリングリストへも同時に送る必要が
279 あります。
280
281 - 新しい -rc は Linus が、最新の git ツリーがテスト目的であれば十分
282 に安定した状態にあると判断したときにリリースされます。目標は毎週新
283 しい -rc カーネルをリリースすることです。
284
285 - このプロセスはカーネルが 「準備ができた」と考えられるまで継続しま
286 す。このプロセスはだいたい 6週間継続します。
287
288Andrew Morton が Linux-kernel メーリングリストにカーネルリリースについ
289て書いたことをここで言っておくことは価値があります-
290 「カーネルがいつリリースされるかは誰も知りません。なぜなら、これは現
291 実に認識されたバグの状況によりリリースされるのであり、前もって決めら
292 れた計画によってリリースされるものではないからです。」
293
2942.6.x.y -stable カーネルツリー
295---------------------------
296
297バージョンに4つ目の数字がついたカーネルは -stable カーネルです。これに
298は、2.6.x カーネルで見つかったセキュリティ問題や重大な後戻りに対する比
299較的小さい重要な修正が含まれます。
300
301これは、開発/実験的バージョンのテストに協力することに興味が無く、
302最新の安定したカーネルを使いたいユーザに推奨するブランチです。
303
304もし、2.6.x.y カーネルが存在しない場合には、番号が一番大きい 2.6.x
305が最新の安定版カーネルです。
306
3072.6.x.y は "stable" チーム <stable@kernel.org> でメンテされており、だ
308いたい隔週でリリースされています。
309
310カーネルツリーに入っている、Documentation/stable_kernel_rules.txt ファ
311イルにはどのような種類の変更が -stable ツリーに受け入れ可能か、またリ
312リースプロセスがどう動くかが記述されています。
313
3142.6.x -git パッチ
315------------------
316
317git リポジトリで管理されているLinus のカーネルツリーの毎日のスナップ
318ショットがあります。(だから -git という名前がついています)。これらのパッ
319チはおおむね毎日リリースされており、Linus のツリーの現状を表します。こ
320れは -rc カーネルと比べて、パッチが大丈夫かどうかも確認しないで自動的
321に生成されるので、より実験的です。
322
3232.6.x -mm カーネルパッチ
324------------------------
325
326Andrew Morton によってリリースされる実験的なカーネルパッチ群です。
327Andrew は個別のサブシステムカーネルツリーとパッチを全て集めてきて
328linux-kernel メーリングリストで収集された多数のパッチと同時に一つにま
329とめます。
330このツリーは新機能とパッチが検証される場となります。ある期間の間パッチ
331が -mm に入って価値を証明されたら、Andrew やサブシステムメンテナが、メ
332インラインへ入れるように Linus にプッシュします。
333
334メインカーネルツリーに含めるために Linus に送る前に、すべての新しいパッ
335チが -mm ツリーでテストされることが強く推奨されます。
336
337これらのカーネルは安定して動作すべきシステムとして使うのには適切ではあ
338りませんし、カーネルブランチの中でももっとも動作にリスクが高いものです。
339
340もしあなたが、カーネル開発プロセスの支援をしたいと思っているのであれば、
341どうぞこれらのカーネルリリースをテストに使ってみて、そしてもし問題があ
342れば、またもし全てが正しく動作したとしても、linux-kernel メーリングリ
343ストにフィードバックを提供してください。
344
345すべての他の実験的パッチに加えて、これらのカーネルは通常リリース時点で
346メインラインの -git カーネルに含まれる全ての変更も含んでいます。
347
348-mm カーネルは決まったスケジュールではリリースされません、しかし通常幾
349つかの -mm カーネル (1 から 3 が普通)が各-rc カーネルの間にリリースさ
350れます。
351
352サブシステム毎のカーネルツリーとパッチ
353-------------------------------------------
354
355カーネルの様々な領域で何が起きているかを見られるようにするため、多くの
356カーネルサブシステム開発者は彼らの開発ツリーを公開しています。これらの
357ツリーは説明したように -mm カーネルリリースに入れ込まれます。
358
359以下はさまざまなカーネルツリーの中のいくつかのリスト-
360
361 git ツリー-
362 - Kbuild の開発ツリー、Sam Ravnborg <sam@ravnborg.org>
363 kernel.org:/pub/scm/linux/kernel/git/sam/kbuild.git
364
365 - ACPI の開発ツリー、 Len Brown <len.brown@intel.com>
366 kernel.org:/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6.git
367
368 - Block の開発ツリー、Jens Axboe <axboe@suse.de>
369 kernel.org:/pub/scm/linux/kernel/git/axboe/linux-2.6-block.git
370
371 - DRM の開発ツリー、Dave Airlie <airlied@linux.ie>
372 kernel.org:/pub/scm/linux/kernel/git/airlied/drm-2.6.git
373
374 - ia64 の開発ツリー、Tony Luck <tony.luck@intel.com>
375 kernel.org:/pub/scm/linux/kernel/git/aegl/linux-2.6.git
376
377 - ieee1394 の開発ツリー、Jody McIntyre <scjody@modernduck.com>
378 kernel.org:/pub/scm/linux/kernel/git/scjody/ieee1394.git
379
380 - infiniband, Roland Dreier <rolandd@cisco.com>
381 kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git
382
383 - libata, Jeff Garzik <jgarzik@pobox.com>
384 kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git
385
386 - ネットワークドライバ, Jeff Garzik <jgarzik@pobox.com>
387 kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6.git
388
389 - pcmcia, Dominik Brodowski <linux@dominikbrodowski.net>
390 kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6.git
391
392 - SCSI, James Bottomley <James.Bottomley@SteelEye.com>
393 kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git
394
395 その他の git カーネルツリーは http://kernel.org/git に一覧表がありま
396 す。
397
398 quilt ツリー-
399 - USB, PCI ドライバコアと I2C, Greg Kroah-Hartman <gregkh@suse.de>
400 kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/
401
402バグレポート
403-------------
404
405bugzilla.kernel.org は Linux カーネル開発者がカーネルのバグを追跡する
406場所です。ユーザは見つけたバグの全てをこのツールで報告すべきです。
407どう kernel bugzilla を使うかの詳細は、以下を参照してください-
408 http://test.kernel.org/bugzilla/faq.html
409
410メインカーネルソースディレクトリにあるファイル REPORTING-BUGS はカーネ
411ルバグらしいものについてどうレポートするかの良いテンプレートであり、問
412題の追跡を助けるためにカーネル開発者にとってどんな情報が必要なのかの詳
413細が書かれています。
414
415メーリングリスト
416-------------
417
418上のいくつかのドキュメントで述べていますが、コアカーネル開発者の大部分
419は Linux kernel メーリングリストに参加しています。このリストの登録/脱
420退の方法については以下を参照してください-
421 http://vger.kernel.org/vger-lists.html#linux-kernel
422
423このメーリングリストのアーカイブは web 上の多数の場所に存在します。こ
424れらのアーカイブを探すにはサーチエンジンを使いましょう。例えば-
425 http://dir.gmane.org/gmane.linux.kernel
426
427リストに投稿する前にすでにその話題がアーカイブに存在するかどうかを検索
428することを是非やってください。多数の事がすでに詳細に渡って議論されて
429おり、アーカイブにのみ記録されています。
430
431大部分のカーネルサブシステムも自分の個別の開発を実施するメーリングリス
432トを持っています。個々のグループがどんなリストを持っているかは、
433MAINTAINERS ファイルにリストがありますので参照してください。
434
435多くのリストは kernel.org でホストされています。これらの情報は以下にあ
436ります-
437 http://vger.kernel.org/vger-lists.html
438
439メーリングリストを使う場合、良い行動習慣に従うようにしましょう。
440少し安っぽいが、以下の URL は上のリスト(や他のリスト)で会話する場合の
441シンプルなガイドラインを示しています-
442 http://www.albion.com/netiquette/
443
444もし複数の人があなたのメールに返事をした場合、CC: で受ける人のリストは
445だいぶ多くなるでしょう。良い理由がない場合、CC: リストから誰かを削除を
446しないように、また、メーリングリストのアドレスだけにリプライすることの
447ないようにしましょう。1つは送信者から、もう1つはリストからのように、メー
448ルを2回受けることになってもそれに慣れ、しゃれたメールヘッダーを追加し
449てこの状態を変えようとしないように。人々はそのようなことは好みません。
450
451今までのメールでのやりとりとその間のあなたの発言はそのまま残し、
452"John Kernlehacker wrote ...:" の行をあなたのリプライの先頭行にして、
453メールの先頭でなく、各引用行の間にあなたの言いたいことを追加するべきで
454す。
455
456もしパッチをメールに付ける場合は、Documentaion/SubmittingPatches に提
457示されているように、それは プレーンな可読テキストにすることを忘れない
458ようにしましょう。カーネル開発者は 添付や圧縮したパッチを扱いたがりま
459せん-
460彼らはあなたのパッチの行毎にコメントを入れたいので、そのためにはそうす
461るしかありません。あなたのメールプログラムが空白やタブを圧縮しないよう
462に確認した方がいいです。最初の良いテストとしては、自分にメールを送って
463みて、そのパッチを自分で当ててみることです。もしそれがうまく行かないな
464ら、あなたのメールプログラムを直してもらうか、正しく動くように変えるべ
465きです。
466
467とりわけ、他の登録者に対する尊敬を表すようにすることを覚えておいてくだ
468さい。
469
470コミュニティと共に働くこと
471--------------------------
472
473カーネルコミュニティのゴールは可能なかぎり最高のカーネルを提供すること
474です。あなたがパッチを受け入れてもらうために投稿した場合、それは、技術
475的メリットだけがレビューされます。その際、あなたは何を予想すべきでしょ
476うか?
477 - 批判
478 - コメント
479 - 変更の要求
480 - パッチの正当性の証明要求
481 - 沈黙
482
483思い出してください、ここはあなたのパッチをカーネルに入れる話です。あ
484なたは、あなたのパッチに対する批判とコメントを受け入れるべきで、それら
485を技術的レベルで評価して、パッチを再作成するか、なぜそれらの変更をすべ
486きでないかを明確で簡潔な理由の説明を提供してください。
487もし、あなたのパッチに何も反応がない場合、たまにはメールの山に埋もれて
488見逃され、あなたの投稿が忘れられてしまうこともあるので、数日待って再度
489投稿してください。
490
491あなたがやるべきでないものは?
492 - 質問なしにあなたのパッチが受け入れられると想像すること
493 - 守りに入ること
494 - コメントを無視すること
495 - 要求された変更を何もしないでパッチを出し直すこと
496
497可能な限り最高の技術的解決を求めているコミュニティでは、パッチがどのく
498らい有益なのかについては常に異なる意見があります。あなたは協調的である
499べきですし、また、あなたのアイディアをカーネルに対してうまく合わせるよ
500うにすることが望まれています。もしくは、最低限あなたのアイディアがそれ
501だけの価値があるとすすんで証明するようにしなければなりません。
502正しい解決に向かって進もうという意志がある限り、間違うことがあっても許
503容されることを忘れないでください。
504
505あなたの最初のパッチに単に 1ダースもの修正を求めるリストの返答になるこ
506とも普通のことです。これはあなたのパッチが受け入れられないということで
507は *ありません*、そしてあなた自身に反対することを意味するのでも *ありま
508せん*。単に自分のパッチに対して指摘された問題を全て修正して再送すれば
509いいのです。
510
511カーネルコミュニティと企業組織のちがい
512-----------------------------------------------------------------
513
514カーネルコミュニティは大部分の伝統的な会社の開発環境とは異ったやり方で
515動いています。以下は問題を避けるためにできるとよいことののリストです-
516
517 あなたの提案する変更について言うときのうまい言い方:
518
519 - "これは複数の問題を解決します"
520 - "これは2000行のコードを削除します"
521 - "以下のパッチは、私が言おうとしていることを説明するものです"
522 - "私はこれを5つの異なるアーキテクチャでテストしたのですが..."
523 - "以下は一連の小さなパッチ群ですが..."
524 - "これは典型的なマシンでの性能を向上させます.."
525
526 やめた方がいい悪い言い方:
527
528 - このやり方で AIX/ptx/Solaris ではできたので、できるはずだ
529 - 私はこれを20年もの間やってきた、だから
530 - これは、私の会社が金儲けをするために必要だ
531 - これは我々のエンタープライズ向け商品ラインのためである
532 - これは 私が自分のアイディアを記述した、1000ページの設計資料である
533 - 私はこれについて、6ケ月作業している。
534 - 以下は ... に関する5000行のパッチです
535 - 私は現在のぐちゃぐちゃを全部書き直した、それが以下です...
536 - 私は〆切がある、そのためこのパッチは今すぐ適用される必要がある
537
538カーネルコミュニティが大部分の伝統的なソフトウェアエンジニアリングの労
539働環境と異なるもう一つの点は、やりとりに顔を合わせないということです。
540email と irc を第一のコミュニケーションの形とする一つの利点は、性別や
541民族の差別がないことです。Linux カーネルの職場環境は女性や少数民族を受
542容します。なぜなら、email アドレスによってのみあなたが認識されるからで
543す。
544国際的な側面からも活動領域を均等にするようにします。なぜならば、あなた
545は人の名前で性別を想像できないからです。ある男性が アンドレアという名
546前で、女性の名前は パット かもしれません (訳注 Andrea は米国では女性、
547それ以外(欧州など)では男性名として使われることが多い。同様に、Pat は
548Patricia (主に女性名)や Patrick (主に男性名)の略称)。
549Linux カーネルの活動をして、意見を表明したことがある大部分の女性は、前
550向きな経験をもっています。
551
552言葉の壁は英語が得意でない一部の人には問題になります。
553メーリングリストの中できちんとアイディアを交換するには、相当うまく英語
554を操れる必要があることもあります。そのため、あなたは自分のメール
555を送る前に英語で意味が通じているかをチェックすることをお薦めします。
556
557変更を分割する
558---------------------
559
560Linux カーネルコミュニティは、一度に大量のコードの塊を喜んで受容するこ
561とはありません。変更は正確に説明される必要があり、議論され、小さい、個
562別の部分に分割する必要があります。これはこれまで多くの会社がやり慣れて
563きたことと全く正反対のことです。あなたのプロポーザルは、開発プロセスのと
564ても早い段階から紹介されるべきです。そうすれば あなたは自分のやってい
565ることにフィードバックを得られます。これは、コミュニティからみれば、あ
566なたが彼らと一緒にやっているように感じられ、単にあなたの提案する機能の
567ゴミ捨て場として使っているのではない、と感じられるでしょう。
568しかし、一度に 50 もの email をメーリングリストに送りつけるようなことは
569やってはいけません、あなたのパッチ群はいつもどんな時でもそれよりは小さ
570くなければなりません。
571
572パッチを分割する理由は以下です-
573
5741) 小さいパッチはあなたのパッチが適用される見込みを大きくします、カー
575 ネルの人達はパッチが正しいかどうかを確認する時間や労力をかけないか
576 らです。5行のパッチはメンテナがたった1秒見るだけで適用できます。し
577 かし、500行のパッチは、正しいことをレビューするのに数時間かかるかも
578 しれません(時間はパッチのサイズなどにより指数関数に比例してかかりま
579 す)
580 小さいパッチは何かあったときにデバッグもとても簡単になります。パッ
581 チを1個1個取り除くのは、とても大きなパッチを当てた後に(かつ、何かお
582 かしくなった後で)解剖するのに比べればとても簡単です。
583
5842) 小さいパッチを送るだけでなく、送るまえに、書き直して、シンプルにす
585 る(もしくは、単に順番を変えるだけでも)ことも、とても重要です。
586
587以下はカーネル開発者の Al Viro のたとえ話しです:
588
589 "生徒の数学の宿題を採点する先生のことを考えてみてください、先
590 生は生徒が解に到達するまでの試行錯誤をみたいとは思わないでしょ
591 う。先生は簡潔な最高の解をみたいのです。良い生徒はこれを知って
592 おり、そして最終解の前の中間作業を提出することは決してないので
593 す"
594 カーネル開発でもこれは同じです。メンテナー達とレビューア達は、
595 問題を解決する解の背後になる思考プロセスをみたいとは思いません。
596 彼らは単純であざやかな解決方法をみたいのです。
597
598あざやかな解を説明するのと、コミュニティと共に仕事をし、未解決の仕事を
599議論することのバランスをキープするのは難しいかもしれません。
600ですから、開発プロセスの早期段階で改善のためのフィードバックをもらうよ
601うにするのもいいですが、変更点を小さい部分に分割して全体ではまだ完成し
602ていない仕事を(部分的に)取り込んでもらえるようにすることもいいことです。
603
604また、でき上がっていないものや、"将来直す" ようなパッチを、本流に含め
605てもらうように送っても、それは受け付けられないことを理解してください。
606
607あなたの変更を正当化する
608-------------------
609
610あなたのパッチを分割するのと同時に、なぜその変更を追加しなければならな
611いかを Linux コミュニティに知らせることはとても重要です。新機能は必要
612性と有用性で正当化されなければなりません。
613
614あなたの変更の説明
615--------------------
616
617あなたのパッチを送付する場合には、メールの中のテキストで何を言うかにつ
618いて、特別に注意を払ってください。この情報はパッチの ChangeLog に使わ
619れ、いつも皆がみられるように保管されます。これは次のような項目を含め、
620パッチを完全に記述するべきです-
621
622 - なぜ変更が必要か
623 - パッチ全体の設計アプローチ
624 - 実装の詳細
625 - テスト結果
626
627これについて全てがどのようにあるべきかについての詳細は、以下のドキュメ
628ントの ChangeLog セクションをみてください-
629 "The Perfect Patch"
630 http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt
631
632これらのどれもが、時にはとても困難です。これらの慣例を完璧に実施するに
633は数年かかるかもしれません。これは継続的な改善のプロセスであり、そのた
634めには多数の忍耐と決意を必要とするものです。でも、諦めないで、これは可
635能なことです。多数の人がすでにできていますし、彼らも皆最初はあなたと同
636じところからスタートしたのですから。
637
638Paolo Ciarrocchi に感謝、彼は彼の書いた "Development Process"
639(http://linux.tar.bz/articles/2.6-development_process)セクショ
640ンをこのテキストの原型にすることを許可してくれました。
641Rundy Dunlap と Gerrit Huizenga はメーリングリストでやるべきこととやっ
642てはいけないことのリストを提供してくれました。
643以下の人々のレビュー、コメント、貢献に感謝。
644Pat Mochel, Hanna Linder, Randy Dunlap, Kay Sievers,
645Vojtech Pavlik, Jan Kara, Josh Boyer, Kees Cook, Andrew Morton, Andi
646Kleen, Vadim Lobanov, Jesper Juhl, Adrian Bunk, Keri Harris, Frans Pop,
647David A. Wheeler, Junio Hamano, Michael Kerrisk, と Alex Shepard
648彼らの支援なしでは、このドキュメントはできなかったでしょう。
649
650Maintainer: Greg Kroah-Hartman <greg@kroah.com>
diff --git a/Documentation/ja_JP/stable_api_nonsense.txt b/Documentation/ja_JP/stable_api_nonsense.txt
new file mode 100644
index 000000000000..b3f2b27f0881
--- /dev/null
+++ b/Documentation/ja_JP/stable_api_nonsense.txt
@@ -0,0 +1,263 @@
1NOTE:
2This is a Japanese translated version of
3"Documentation/stable_api_nonsense.txt".
4This one is maintained by
5IKEDA, Munehiro <m-ikeda@ds.jp.nec.com>
6and JF Project team <http://www.linux.or.jp/JF/>.
7If you find difference with original file or problem in translation,
8please contact the maintainer of this file or JF project.
9
10Please also note that purpose of this file is easier to read for non
11English natives and not to be intended to fork. So, if you have any
12comments or updates of this file, please try to update
13Original(English) file at first.
14
15==================================
16これは、
17linux-2.6.22-rc4/Documentation/stable_api_nonsense.txt の和訳
18です。
19翻訳団体: JF プロジェクト < http://www.linux.or.jp/JF/ >
20翻訳日 : 2007/06/11
21原著作者: Greg Kroah-Hartman < greg at kroah dot com >
22翻訳者 : 池田 宗広 < m-ikeda at ds dot jp dot nec dot com >
23校正者 : Masanori Kobayashi さん < zap03216 at nifty dot ne dot jp >
24 Seiji Kaneko さん < skaneko at a2 dot mbn dot or dot jp >
25==================================
26
27
28
29Linux カーネルのドライバインターフェース
30(あなたの質問すべてに対する回答とその他諸々)
31
32Greg Kroah-Hartman <greg at kroah dot com>
33
34
35この文書は、なぜ Linux ではバイナリカーネルインターフェースが定義
36されていないのか、またはなぜ不変のカーネルインターフェースを持たな
37いのか、ということを説明するために書かれた。ここでの話題は「カーネ
38ル内部の」インターフェースについてであり、ユーザー空間とのインター
39フェースではないことを理解してほしい。カーネルとユーザー空間とのイ
40ンターフェースとはアプリケーションプログラムが使用するものであり、
41つまりシステムコールのインターフェースがこれに当たる。これは今まで
42長きに渡り、かつ今後も「まさしく」不変である。私は確か 0.9 か何か
43より前のカーネルを使ってビルドした古いプログラムを持っているが、そ
44れは最新の 2.6 カーネルでもきちんと動作する。ユーザー空間とのイン
45ターフェースは、ユーザーとアプリケーションプログラマが不変性を信頼
46してよいものの一つである。
47
48
49要旨
50----
51
52あなたは不変のカーネルインターフェースが必要だと考えているかもしれ
53ないが、実際のところはそうではない。あなたは必要としているものが分
54かっていない。あなたが必要としているものは安定して動作するドライバ
55であり、それはドライバがメインのカーネルツリーに含まれる場合のみ得
56ることができる。ドライバがメインのカーネルツリーに含まれていると、
57他にも多くの良いことがある。それは、Linux をより強固で、安定な、成
58熟したオペレーティングシステムにすることができるということだ。これ
59こそ、そもそもあなたが Linux を使う理由のはずだ。
60
61
62はじめに
63--------
64
65カーネル内部のインターフェース変更を心配しなければならないドライバ
66を書きたいなどというのは、変わり者だけだ。この世界のほとんどの人は、
67そのようなドライバがどんなインターフェースを使っているかなど知らな
68いし、そんなドライバのことなど全く気にもかけていない。
69
70
71まず初めに、クローズソースとか、ソースコードの隠蔽とか、バイナリの
72みが配布される使い物にならない代物[訳注(1)]とか、実体はバイナリ
73コードでそれを読み込むためのラッパー部分のみソースコードが公開され
74ているとか、その他用語は何であれ GPL の下にソースコードがリリース
75されていないカーネルドライバに関する法的な問題について、私は「いか
76なる議論も」行うつもりがない。法的な疑問があるのならば、プログラマ
77である私ではなく、弁護士に相談して欲しい。ここでは単に、技術的な問
78題について述べることにする。(法的な問題を軽視しているわけではない。
79それらは実際に存在するし、あなたはそれをいつも気にかけておく必要が
80ある)
81
82訳注(1)
83「使い物にならない代物」の原文は "blob"
84
85
86さてここでは、バイナリカーネルインターフェースについてと、ソースレ
87ベルでのインターフェースの不変性について、という二つの話題を取り上
88げる。この二つは互いに依存する関係にあるが、まずはバイナリインター
89フェースについて議論を行いやっつけてしまおう。
90
91
92バイナリカーネルインターフェース
93--------------------------------
94
95もしソースレベルでのインターフェースが不変ならば、バイナリインター
96フェースも当然のように不変である、というのは正しいだろうか?正しく
97ない。Linux カーネルに関する以下の事実を考えてみてほしい。
98 - あなたが使用するCコンパイラのバージョンによって、カーネル内部
99 の構造体の配置構造は異なったものになる。また、関数は異なった方
100 法でカーネルに含まれることになるかもしれない(例えばインライン
101 関数として扱われたり、扱われなかったりする)。個々の関数がどの
102 ようにコンパイルされるかはそれほど重要ではないが、構造体のパデ
103 ィングが異なるというのは非常に重要である。
104 - あなたがカーネルのビルドオプションをどのように設定するかによっ
105 て、カーネルには広い範囲で異なった事態が起こり得る。
106 - データ構造は異なるデータフィールドを持つかもしれない
107 - いくつかの関数は全く実装されていない状態になり得る
108 (例:SMP向けではないビルドでは、いくつかのロックは中身が
109 カラにコンパイルされる)
110 - カーネル内のメモリは、異なった方法で配置され得る。これはビ
111 ルドオプションに依存している。
112 - Linux は様々な異なるプロセッサアーキテクチャ上で動作する。
113 あるアーキテクチャ用のバイナリドライバを、他のアーキテクチャで
114 正常に動作させる方法はない。
115
116
117ある特定のカーネル設定を使用し、カーネルをビルドしたのと正確に同じ
118Cコンパイラを使用して単にカーネルモジュールをコンパイルするだけで
119も、あなたはこれらいくつもの問題に直面することになる。ある特定の
120Linux ディストリビューションの、ある特定のリリースバージョン用にモ
121ジュールを提供しようと思っただけでも、これらの問題を引き起こすには
122十分である。にも関わらず Linux ディストリビューションの数と、サ
123ポートするディストリビューションのリリース数を掛け算し、それら一つ
124一つについてビルドを行ったとしたら、今度はリリースごとのビルドオプ
125ションの違いという悪夢にすぐさま悩まされることになる。また、ディス
126トリビューションの各リリースバージョンには、異なるハードウェア(プ
127ロセッサタイプや種々のオプション)に対応するため、何種類かのカーネ
128ルが含まれているということも理解して欲しい。従って、ある一つのリ
129リースバージョンだけのためにモジュールを作成する場合でも、あなたは
130何バージョンものモジュールを用意しなければならない。
131
132
133信じて欲しい。このような方法でサポートを続けようとするなら、あなた
134はいずれ正気を失うだろう。遠い昔、私はそれがいかに困難なことか、身
135をもって学んだのだ・・・
136
137
138不変のカーネルソースレベルインターフェース
139------------------------------------------
140
141メインカーネルツリーに含まれていない Linux カーネルドライバを継続
142してサポートしていこうとしている人たちとの議論においては、これは極
143めて「引火性の高い」話題である。[訳注(2)]
144
145訳注(2)
146「引火性の高い」の原文は "volatile"。
147volatile には「揮発性の」「爆発しやすい」という意味の他、「変わり
148やすい」「移り気な」という意味がある。
149「(この話題は)爆発的に激しい論争を巻き起こしかねない」ということ
150を、「(カーネルのソースレベルインターフェースは)移ろい行くもので
151ある」ということを連想させる "volatile" という単語で表現している。
152
153
154Linux カーネルの開発は継続的に速いペースで行われ、決して歩みを緩め
155ることがない。その中でカーネル開発者達は、現状のインターフェースに
156あるバグを見つけ、より良い方法を考え出す。彼らはやがて、現状のイン
157ターフェースがより正しく動作するように修正を行う。その過程で関数の
158名前は変更されるかもしれず、構造体は大きく、または小さくなるかもし
159れず、関数の引数は検討しなおされるかもしれない。そのような場合、引
160き続き全てが正常に動作するよう、カーネル内でこれらのインターフェー
161スを使用している個所も全て同時に修正される。
162
163
164具体的な例として、カーネル内の USB インターフェースを挙げる。USB
165サブシステムはこれまでに少なくとも3回の書き直しが行われ、その結果
166インターフェースが変更された。これらの書き直しはいくつかの異なった
167問題を修正するために行われた。
168 - 同期的データストリームが非同期に変更された。これにより多数のド
169 ライバを単純化でき、全てのドライバのスループットが向上した。今
170 やほとんど全ての USB デバイスは、考えられる最高の速度で動作し
171 ている。
172 - USB ドライバが USB サブシステムのコアから行う、データパケット
173 用のメモリ確保方法が変更された。これに伴い、いくつもの文書化さ
174 れたデッドロック条件を回避するため、全ての USB ドライバはより
175 多くの情報を USB コアに提供しなければならないようになっている。
176
177
178このできごとは、数多く存在するクローズソースのオペレーティングシス
179テムとは全く対照的だ。それらは長期に渡り古い USB インターフェース
180をメンテナンスしなければならない。古いインターフェースが残ることで、
181新たな開発者が偶然古いインターフェースを使い、正しくない方法で開発
182を行ってしまう可能性が生じる。これによりシステムの安定性は危険にさ
183らされることになる。
184
185
186上に挙げたどちらの例においても、開発者達はその変更が重要かつ必要で
187あることに合意し、比較的楽にそれを実行した。もし Linux がソースレ
188ベルでインターフェースの不変性を保証しなければならないとしたら、新
189しいインターフェースを作ると同時に、古い、問題のある方を今後ともメ
190ンテナンスするという余計な仕事を USB の開発者にさせなければならな
191い。Linux の USB 開発者は、自分の時間を使って仕事をしている。よっ
192て、価値のない余計な仕事を報酬もなしに実行しろと言うことはできない。
193
194
195セキュリティ問題も、Linux にとっては非常に重要である。ひとたびセキ
196ュリティに関する問題が発見されれば、それは極めて短期間のうちに修正
197される。セキュリティ問題の発生を防ぐための修正は、カーネルの内部イ
198ンターフェースの変更を何度も引き起こしてきた。その際同時に、変更さ
199れたインターフェースを使用する全てのドライバもまた変更された。これ
200により問題が解消し、将来偶然に問題が再発してしまわないことが保証さ
201れる。もし内部インターフェースの変更が許されないとしたら、このよう
202にセキュリティ問題を修正し、将来再発しないことを保証することなど不
203可能なのだ。
204
205
206カーネルのインターフェースは時が経つにつれクリーンナップを受ける。
207誰も使っていないインターフェースは削除される。これにより、可能な限
208りカーネルが小さく保たれ、現役の全てのインターフェースが可能な限り
209テストされることを保証しているのだ。(使われていないインターフェー
210スの妥当性をテストすることは不可能と言っていいだろう)
211
212
213
214これから何をすべきか
215-----------------------
216
217では、もしメインのカーネルツリーに含まれない Linux カーネルドライ
218バがあったとして、あなたは、つまり開発者は何をするべきだろうか?全
219てのディストリビューションの全てのカーネルバージョン向けにバイナリ
220のドライバを供給することは悪夢であり、カーネルインターフェースの変
221更を追いかけ続けることもまた過酷な仕事だ。
222
223
224答えは簡単。そのドライバをメインのカーネルツリーに入れてしまえばよ
225い。(ここで言及しているのは、GPL に従って公開されるドライバのこと
226だということに注意してほしい。あなたのコードがそれに該当しないなら
227ば、さよなら。幸運を祈ります。ご自分で何とかしてください。Andrew
228と Linus からのコメント<Andrew と Linus のコメントへのリンクをこ
229こに置く>をどうぞ)ドライバがメインツリーに入れば、カーネルのイン
230ターフェースが変更された場合、変更を行った開発者によってドライバも
231修正されることになるだろう。あなたはほとんど労力を払うことなしに、
232常にビルド可能できちんと動作するドライバを手に入れることができる。
233
234
235ドライバをメインのカーネルツリーに入れると、非常に好ましい以下の効
236果がある。
237 - ドライバの品質が向上する一方で、(元の開発者にとっての)メンテ
238 ナンスコストは下がる。
239 - あなたのドライバに他の開発者が機能を追加してくれる。
240 - 誰かがあなたのドライバにあるバグを見つけ、修正してくれる。
241 - 誰かがあなたのドライバにある改善点を見つけてくれる。
242 - 外部インターフェースが変更されドライバの更新が必要になった場合、
243 誰かがあなたの代わりに更新してくれる。
244 - ドライバを入れてくれとディストロに頼まなくても、そのドライバは
245 全ての Linux ディストリビューションに自動的に含まれてリリース
246 される。
247
248
249Linux では、他のどのオペレーティングシステムよりも数多くのデバイス
250が「そのまま」使用できるようになった。また Linux は、どのオペレー
251ティングシステムよりも数多くのプロセッサアーキテクチャ上でそれらの
252デバイスを使用することができるようにもなった。このように、Linux の
253開発モデルは実証されており、今後も間違いなく正しい方向へと進んでい
254くだろう。:)
255
256
257
258------
259
260この文書の初期の草稿に対し、Randy Dunlap, Andrew Morton, David
261Brownell, Hanna Linder, Robert Love, Nishanth Aravamudan から査読
262と助言を頂きました。感謝申し上げます。
263
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index bb5306e9a5c3..e08ef8759a07 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -501,6 +501,20 @@ more details, with real examples.
501 The third parameter may be a text as in this example, but it may also 501 The third parameter may be a text as in this example, but it may also
502 be an expanded variable or a macro. 502 be an expanded variable or a macro.
503 503
504 cc-fullversion
505 cc-fullversion is useful when the exact version of gcc is needed.
506 One typical use-case is when a specific GCC version is broken.
507 cc-fullversion points out a more specific version than cc-version does.
508
509 Example:
510 #arch/powerpc/Makefile
511 $(Q)if test "$(call cc-fullversion)" = "040200" ; then \
512 echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \
513 false ; \
514 fi
515
516 In this example for a specific GCC version the build will error out explaining
517 to the user why it stops.
504 518
505=== 4 Host Program support 519=== 4 Host Program support
506 520
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 9a541486fb7e..fb80e9ffea68 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1154,6 +1154,8 @@ and is between 256 and 4096 characters. It is defined in the file
1154 1154
1155 nointroute [IA-64] 1155 nointroute [IA-64]
1156 1156
1157 nojitter [IA64] Disables jitter checking for ITC timers.
1158
1157 nolapic [IA-32,APIC] Do not enable or use the local APIC. 1159 nolapic [IA-32,APIC] Do not enable or use the local APIC.
1158 1160
1159 nolapic_timer [IA-32,APIC] Do not use the local APIC timer. 1161 nolapic_timer [IA-32,APIC] Do not use the local APIC timer.
@@ -1880,11 +1882,14 @@ and is between 256 and 4096 characters. It is defined in the file
1880 usbhid.mousepoll= 1882 usbhid.mousepoll=
1881 [USBHID] The interval which mice are to be polled at. 1883 [USBHID] The interval which mice are to be polled at.
1882 1884
1883 vdso= [IA-32,SH] 1885 vdso= [IA-32,SH,x86-64]
1884 vdso=2: enable compat VDSO (default with COMPAT_VDSO) 1886 vdso=2: enable compat VDSO (default with COMPAT_VDSO)
1885 vdso=1: enable VDSO (default) 1887 vdso=1: enable VDSO (default)
1886 vdso=0: disable VDSO mapping 1888 vdso=0: disable VDSO mapping
1887 1889
1890 vector= [IA-64,SMP]
1891 vector=percpu: enable percpu vector domain
1892
1888 video= [FB] Frame buffer configuration 1893 video= [FB] Frame buffer configuration
1889 See Documentation/fb/modedb.txt. 1894 See Documentation/fb/modedb.txt.
1890 1895
diff --git a/Documentation/kprobes.txt b/Documentation/kprobes.txt
index da5404ab7569..cb12ae175aa2 100644
--- a/Documentation/kprobes.txt
+++ b/Documentation/kprobes.txt
@@ -247,12 +247,6 @@ control to Kprobes.) If the probed function is declared asmlinkage,
247fastcall, or anything else that affects how args are passed, the 247fastcall, or anything else that affects how args are passed, the
248handler's declaration must match. 248handler's declaration must match.
249 249
250NOTE: A macro JPROBE_ENTRY is provided to handle architecture-specific
251aliasing of jp->entry. In the interest of portability, it is advised
252to use:
253
254 jp->entry = JPROBE_ENTRY(handler);
255
256register_jprobe() returns 0 on success, or a negative errno otherwise. 250register_jprobe() returns 0 on success, or a negative errno otherwise.
257 251
2584.3 register_kretprobe 2524.3 register_kretprobe
@@ -518,7 +512,7 @@ long jdo_fork(unsigned long clone_flags, unsigned long stack_start,
518} 512}
519 513
520static struct jprobe my_jprobe = { 514static struct jprobe my_jprobe = {
521 .entry = JPROBE_ENTRY(jdo_fork) 515 .entry = jdo_fork
522}; 516};
523 517
524static int __init jprobe_init(void) 518static int __init jprobe_init(void)
diff --git a/Documentation/lguest/Makefile b/Documentation/lguest/Makefile
new file mode 100644
index 000000000000..b9b9427376e9
--- /dev/null
+++ b/Documentation/lguest/Makefile
@@ -0,0 +1,27 @@
1# This creates the demonstration utility "lguest" which runs a Linux guest.
2
3# For those people that have a separate object dir, look there for .config
4KBUILD_OUTPUT := ../..
5ifdef O
6 ifeq ("$(origin O)", "command line")
7 KBUILD_OUTPUT := $(O)
8 endif
9endif
10# We rely on CONFIG_PAGE_OFFSET to know where to put lguest binary.
11include $(KBUILD_OUTPUT)/.config
12LGUEST_GUEST_TOP := ($(CONFIG_PAGE_OFFSET) - 0x08000000)
13
14CFLAGS:=-Wall -Wmissing-declarations -Wmissing-prototypes -O3 \
15 -static -DLGUEST_GUEST_TOP="$(LGUEST_GUEST_TOP)" -Wl,-T,lguest.lds
16LDLIBS:=-lz
17
18all: lguest.lds lguest
19
20# The linker script on x86 is so complex the only way of creating one
21# which will link our binary in the right place is to mangle the
22# default one.
23lguest.lds:
24 $(LD) --verbose | awk '/^==========/ { PRINT=1; next; } /SIZEOF_HEADERS/ { gsub(/0x[0-9A-F]*/, "$(LGUEST_GUEST_TOP)") } { if (PRINT) print $$0; }' > $@
25
26clean:
27 rm -f lguest.lds lguest
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c
new file mode 100644
index 000000000000..1432b502a2d9
--- /dev/null
+++ b/Documentation/lguest/lguest.c
@@ -0,0 +1,1012 @@
1/* Simple program to layout "physical" memory for new lguest guest.
2 * Linked high to avoid likely physical memory. */
3#define _LARGEFILE64_SOURCE
4#define _GNU_SOURCE
5#include <stdio.h>
6#include <string.h>
7#include <unistd.h>
8#include <err.h>
9#include <stdint.h>
10#include <stdlib.h>
11#include <elf.h>
12#include <sys/mman.h>
13#include <sys/types.h>
14#include <sys/stat.h>
15#include <sys/wait.h>
16#include <fcntl.h>
17#include <stdbool.h>
18#include <errno.h>
19#include <ctype.h>
20#include <sys/socket.h>
21#include <sys/ioctl.h>
22#include <sys/time.h>
23#include <time.h>
24#include <netinet/in.h>
25#include <net/if.h>
26#include <linux/sockios.h>
27#include <linux/if_tun.h>
28#include <sys/uio.h>
29#include <termios.h>
30#include <getopt.h>
31#include <zlib.h>
32typedef unsigned long long u64;
33typedef uint32_t u32;
34typedef uint16_t u16;
35typedef uint8_t u8;
36#include "../../include/linux/lguest_launcher.h"
37#include "../../include/asm-i386/e820.h"
38
39#define PAGE_PRESENT 0x7 /* Present, RW, Execute */
40#define NET_PEERNUM 1
41#define BRIDGE_PFX "bridge:"
42#ifndef SIOCBRADDIF
43#define SIOCBRADDIF 0x89a2 /* add interface to bridge */
44#endif
45
46static bool verbose;
47#define verbose(args...) \
48 do { if (verbose) printf(args); } while(0)
49static int waker_fd;
50
51struct device_list
52{
53 fd_set infds;
54 int max_infd;
55
56 struct device *dev;
57 struct device **lastdev;
58};
59
60struct device
61{
62 struct device *next;
63 struct lguest_device_desc *desc;
64 void *mem;
65
66 /* Watch this fd if handle_input non-NULL. */
67 int fd;
68 bool (*handle_input)(int fd, struct device *me);
69
70 /* Watch DMA to this key if handle_input non-NULL. */
71 unsigned long watch_key;
72 u32 (*handle_output)(int fd, const struct iovec *iov,
73 unsigned int num, struct device *me);
74
75 /* Device-specific data. */
76 void *priv;
77};
78
79static int open_or_die(const char *name, int flags)
80{
81 int fd = open(name, flags);
82 if (fd < 0)
83 err(1, "Failed to open %s", name);
84 return fd;
85}
86
87static void *map_zeroed_pages(unsigned long addr, unsigned int num)
88{
89 static int fd = -1;
90
91 if (fd == -1)
92 fd = open_or_die("/dev/zero", O_RDONLY);
93
94 if (mmap((void *)addr, getpagesize() * num,
95 PROT_READ|PROT_WRITE|PROT_EXEC, MAP_FIXED|MAP_PRIVATE, fd, 0)
96 != (void *)addr)
97 err(1, "Mmaping %u pages of /dev/zero @%p", num, (void *)addr);
98 return (void *)addr;
99}
100
101/* Find magic string marking entry point, return entry point. */
102static unsigned long entry_point(void *start, void *end,
103 unsigned long page_offset)
104{
105 void *p;
106
107 for (p = start; p < end; p++)
108 if (memcmp(p, "GenuineLguest", strlen("GenuineLguest")) == 0)
109 return (long)p + strlen("GenuineLguest") + page_offset;
110
111 err(1, "Is this image a genuine lguest?");
112}
113
114/* Returns the entry point */
115static unsigned long map_elf(int elf_fd, const Elf32_Ehdr *ehdr,
116 unsigned long *page_offset)
117{
118 void *addr;
119 Elf32_Phdr phdr[ehdr->e_phnum];
120 unsigned int i;
121 unsigned long start = -1UL, end = 0;
122
123 /* Sanity checks. */
124 if (ehdr->e_type != ET_EXEC
125 || ehdr->e_machine != EM_386
126 || ehdr->e_phentsize != sizeof(Elf32_Phdr)
127 || ehdr->e_phnum < 1 || ehdr->e_phnum > 65536U/sizeof(Elf32_Phdr))
128 errx(1, "Malformed elf header");
129
130 if (lseek(elf_fd, ehdr->e_phoff, SEEK_SET) < 0)
131 err(1, "Seeking to program headers");
132 if (read(elf_fd, phdr, sizeof(phdr)) != sizeof(phdr))
133 err(1, "Reading program headers");
134
135 *page_offset = 0;
136 /* We map the loadable segments at virtual addresses corresponding
137 * to their physical addresses (our virtual == guest physical). */
138 for (i = 0; i < ehdr->e_phnum; i++) {
139 if (phdr[i].p_type != PT_LOAD)
140 continue;
141
142 verbose("Section %i: size %i addr %p\n",
143 i, phdr[i].p_memsz, (void *)phdr[i].p_paddr);
144
145 /* We expect linear address space. */
146 if (!*page_offset)
147 *page_offset = phdr[i].p_vaddr - phdr[i].p_paddr;
148 else if (*page_offset != phdr[i].p_vaddr - phdr[i].p_paddr)
149 errx(1, "Page offset of section %i different", i);
150
151 if (phdr[i].p_paddr < start)
152 start = phdr[i].p_paddr;
153 if (phdr[i].p_paddr + phdr[i].p_filesz > end)
154 end = phdr[i].p_paddr + phdr[i].p_filesz;
155
156 /* We map everything private, writable. */
157 addr = mmap((void *)phdr[i].p_paddr,
158 phdr[i].p_filesz,
159 PROT_READ|PROT_WRITE|PROT_EXEC,
160 MAP_FIXED|MAP_PRIVATE,
161 elf_fd, phdr[i].p_offset);
162 if (addr != (void *)phdr[i].p_paddr)
163 err(1, "Mmaping vmlinux seg %i gave %p not %p",
164 i, addr, (void *)phdr[i].p_paddr);
165 }
166
167 return entry_point((void *)start, (void *)end, *page_offset);
168}
169
170/* This is amazingly reliable. */
171static unsigned long intuit_page_offset(unsigned char *img, unsigned long len)
172{
173 unsigned int i, possibilities[256] = { 0 };
174
175 for (i = 0; i + 4 < len; i++) {
176 /* mov 0xXXXXXXXX,%eax */
177 if (img[i] == 0xA1 && ++possibilities[img[i+4]] > 3)
178 return (unsigned long)img[i+4] << 24;
179 }
180 errx(1, "could not determine page offset");
181}
182
183static unsigned long unpack_bzimage(int fd, unsigned long *page_offset)
184{
185 gzFile f;
186 int ret, len = 0;
187 void *img = (void *)0x100000;
188
189 f = gzdopen(fd, "rb");
190 while ((ret = gzread(f, img + len, 65536)) > 0)
191 len += ret;
192 if (ret < 0)
193 err(1, "reading image from bzImage");
194
195 verbose("Unpacked size %i addr %p\n", len, img);
196 *page_offset = intuit_page_offset(img, len);
197
198 return entry_point(img, img + len, *page_offset);
199}
200
201static unsigned long load_bzimage(int fd, unsigned long *page_offset)
202{
203 unsigned char c;
204 int state = 0;
205
206 /* Ugly brute force search for gzip header. */
207 while (read(fd, &c, 1) == 1) {
208 switch (state) {
209 case 0:
210 if (c == 0x1F)
211 state++;
212 break;
213 case 1:
214 if (c == 0x8B)
215 state++;
216 else
217 state = 0;
218 break;
219 case 2 ... 8:
220 state++;
221 break;
222 case 9:
223 lseek(fd, -10, SEEK_CUR);
224 if (c != 0x03) /* Compressed under UNIX. */
225 state = -1;
226 else
227 return unpack_bzimage(fd, page_offset);
228 }
229 }
230 errx(1, "Could not find kernel in bzImage");
231}
232
233static unsigned long load_kernel(int fd, unsigned long *page_offset)
234{
235 Elf32_Ehdr hdr;
236
237 if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr))
238 err(1, "Reading kernel");
239
240 if (memcmp(hdr.e_ident, ELFMAG, SELFMAG) == 0)
241 return map_elf(fd, &hdr, page_offset);
242
243 return load_bzimage(fd, page_offset);
244}
245
246static inline unsigned long page_align(unsigned long addr)
247{
248 return ((addr + getpagesize()-1) & ~(getpagesize()-1));
249}
250
251/* initrd gets loaded at top of memory: return length. */
252static unsigned long load_initrd(const char *name, unsigned long mem)
253{
254 int ifd;
255 struct stat st;
256 unsigned long len;
257 void *iaddr;
258
259 ifd = open_or_die(name, O_RDONLY);
260 if (fstat(ifd, &st) < 0)
261 err(1, "fstat() on initrd '%s'", name);
262
263 len = page_align(st.st_size);
264 iaddr = mmap((void *)mem - len, st.st_size,
265 PROT_READ|PROT_EXEC|PROT_WRITE,
266 MAP_FIXED|MAP_PRIVATE, ifd, 0);
267 if (iaddr != (void *)mem - len)
268 err(1, "Mmaping initrd '%s' returned %p not %p",
269 name, iaddr, (void *)mem - len);
270 close(ifd);
271 verbose("mapped initrd %s size=%lu @ %p\n", name, st.st_size, iaddr);
272 return len;
273}
274
275static unsigned long setup_pagetables(unsigned long mem,
276 unsigned long initrd_size,
277 unsigned long page_offset)
278{
279 u32 *pgdir, *linear;
280 unsigned int mapped_pages, i, linear_pages;
281 unsigned int ptes_per_page = getpagesize()/sizeof(u32);
282
283 /* If we can map all of memory above page_offset, we do so. */
284 if (mem <= -page_offset)
285 mapped_pages = mem/getpagesize();
286 else
287 mapped_pages = -page_offset/getpagesize();
288
289 /* Each linear PTE page can map ptes_per_page pages. */
290 linear_pages = (mapped_pages + ptes_per_page-1)/ptes_per_page;
291
292 /* We lay out top-level then linear mapping immediately below initrd */
293 pgdir = (void *)mem - initrd_size - getpagesize();
294 linear = (void *)pgdir - linear_pages*getpagesize();
295
296 for (i = 0; i < mapped_pages; i++)
297 linear[i] = ((i * getpagesize()) | PAGE_PRESENT);
298
299 /* Now set up pgd so that this memory is at page_offset */
300 for (i = 0; i < mapped_pages; i += ptes_per_page) {
301 pgdir[(i + page_offset/getpagesize())/ptes_per_page]
302 = (((u32)linear + i*sizeof(u32)) | PAGE_PRESENT);
303 }
304
305 verbose("Linear mapping of %u pages in %u pte pages at %p\n",
306 mapped_pages, linear_pages, linear);
307
308 return (unsigned long)pgdir;
309}
310
311static void concat(char *dst, char *args[])
312{
313 unsigned int i, len = 0;
314
315 for (i = 0; args[i]; i++) {
316 strcpy(dst+len, args[i]);
317 strcat(dst+len, " ");
318 len += strlen(args[i]) + 1;
319 }
320 /* In case it's empty. */
321 dst[len] = '\0';
322}
323
324static int tell_kernel(u32 pgdir, u32 start, u32 page_offset)
325{
326 u32 args[] = { LHREQ_INITIALIZE,
327 LGUEST_GUEST_TOP/getpagesize(), /* Just below us */
328 pgdir, start, page_offset };
329 int fd;
330
331 fd = open_or_die("/dev/lguest", O_RDWR);
332 if (write(fd, args, sizeof(args)) < 0)
333 err(1, "Writing to /dev/lguest");
334 return fd;
335}
336
337static void set_fd(int fd, struct device_list *devices)
338{
339 FD_SET(fd, &devices->infds);
340 if (fd > devices->max_infd)
341 devices->max_infd = fd;
342}
343
344/* When input arrives, we tell the kernel to kick lguest out with -EAGAIN. */
345static void wake_parent(int pipefd, int lguest_fd, struct device_list *devices)
346{
347 set_fd(pipefd, devices);
348
349 for (;;) {
350 fd_set rfds = devices->infds;
351 u32 args[] = { LHREQ_BREAK, 1 };
352
353 select(devices->max_infd+1, &rfds, NULL, NULL, NULL);
354 if (FD_ISSET(pipefd, &rfds)) {
355 int ignorefd;
356 if (read(pipefd, &ignorefd, sizeof(ignorefd)) == 0)
357 exit(0);
358 FD_CLR(ignorefd, &devices->infds);
359 } else
360 write(lguest_fd, args, sizeof(args));
361 }
362}
363
364static int setup_waker(int lguest_fd, struct device_list *device_list)
365{
366 int pipefd[2], child;
367
368 pipe(pipefd);
369 child = fork();
370 if (child == -1)
371 err(1, "forking");
372
373 if (child == 0) {
374 close(pipefd[1]);
375 wake_parent(pipefd[0], lguest_fd, device_list);
376 }
377 close(pipefd[0]);
378
379 return pipefd[1];
380}
381
382static void *_check_pointer(unsigned long addr, unsigned int size,
383 unsigned int line)
384{
385 if (addr >= LGUEST_GUEST_TOP || addr + size >= LGUEST_GUEST_TOP)
386 errx(1, "%s:%i: Invalid address %li", __FILE__, line, addr);
387 return (void *)addr;
388}
389#define check_pointer(addr,size) _check_pointer(addr, size, __LINE__)
390
391/* Returns pointer to dma->used_len */
392static u32 *dma2iov(unsigned long dma, struct iovec iov[], unsigned *num)
393{
394 unsigned int i;
395 struct lguest_dma *udma;
396
397 udma = check_pointer(dma, sizeof(*udma));
398 for (i = 0; i < LGUEST_MAX_DMA_SECTIONS; i++) {
399 if (!udma->len[i])
400 break;
401
402 iov[i].iov_base = check_pointer(udma->addr[i], udma->len[i]);
403 iov[i].iov_len = udma->len[i];
404 }
405 *num = i;
406 return &udma->used_len;
407}
408
409static u32 *get_dma_buffer(int fd, void *key,
410 struct iovec iov[], unsigned int *num, u32 *irq)
411{
412 u32 buf[] = { LHREQ_GETDMA, (u32)key };
413 unsigned long udma;
414 u32 *res;
415
416 udma = write(fd, buf, sizeof(buf));
417 if (udma == (unsigned long)-1)
418 return NULL;
419
420 /* Kernel stashes irq in ->used_len. */
421 res = dma2iov(udma, iov, num);
422 *irq = *res;
423 return res;
424}
425
426static void trigger_irq(int fd, u32 irq)
427{
428 u32 buf[] = { LHREQ_IRQ, irq };
429 if (write(fd, buf, sizeof(buf)) != 0)
430 err(1, "Triggering irq %i", irq);
431}
432
433static void discard_iovec(struct iovec *iov, unsigned int *num)
434{
435 static char discard_buf[1024];
436 *num = 1;
437 iov->iov_base = discard_buf;
438 iov->iov_len = sizeof(discard_buf);
439}
440
441static struct termios orig_term;
442static void restore_term(void)
443{
444 tcsetattr(STDIN_FILENO, TCSANOW, &orig_term);
445}
446
447struct console_abort
448{
449 int count;
450 struct timeval start;
451};
452
453/* We DMA input to buffer bound at start of console page. */
454static bool handle_console_input(int fd, struct device *dev)
455{
456 u32 irq = 0, *lenp;
457 int len;
458 unsigned int num;
459 struct iovec iov[LGUEST_MAX_DMA_SECTIONS];
460 struct console_abort *abort = dev->priv;
461
462 lenp = get_dma_buffer(fd, dev->mem, iov, &num, &irq);
463 if (!lenp) {
464 warn("console: no dma buffer!");
465 discard_iovec(iov, &num);
466 }
467
468 len = readv(dev->fd, iov, num);
469 if (len <= 0) {
470 warnx("Failed to get console input, ignoring console.");
471 len = 0;
472 }
473
474 if (lenp) {
475 *lenp = len;
476 trigger_irq(fd, irq);
477 }
478
479 /* Three ^C within one second? Exit. */
480 if (len == 1 && ((char *)iov[0].iov_base)[0] == 3) {
481 if (!abort->count++)
482 gettimeofday(&abort->start, NULL);
483 else if (abort->count == 3) {
484 struct timeval now;
485 gettimeofday(&now, NULL);
486 if (now.tv_sec <= abort->start.tv_sec+1) {
487 /* Make sure waker is not blocked in BREAK */
488 u32 args[] = { LHREQ_BREAK, 0 };
489 close(waker_fd);
490 write(fd, args, sizeof(args));
491 exit(2);
492 }
493 abort->count = 0;
494 }
495 } else
496 abort->count = 0;
497
498 if (!len) {
499 restore_term();
500 return false;
501 }
502 return true;
503}
504
505static u32 handle_console_output(int fd, const struct iovec *iov,
506 unsigned num, struct device*dev)
507{
508 return writev(STDOUT_FILENO, iov, num);
509}
510
511static u32 handle_tun_output(int fd, const struct iovec *iov,
512 unsigned num, struct device *dev)
513{
514 /* Now we've seen output, we should warn if we can't get buffers. */
515 *(bool *)dev->priv = true;
516 return writev(dev->fd, iov, num);
517}
518
519static unsigned long peer_offset(unsigned int peernum)
520{
521 return 4 * peernum;
522}
523
524static bool handle_tun_input(int fd, struct device *dev)
525{
526 u32 irq = 0, *lenp;
527 int len;
528 unsigned num;
529 struct iovec iov[LGUEST_MAX_DMA_SECTIONS];
530
531 lenp = get_dma_buffer(fd, dev->mem+peer_offset(NET_PEERNUM), iov, &num,
532 &irq);
533 if (!lenp) {
534 if (*(bool *)dev->priv)
535 warn("network: no dma buffer!");
536 discard_iovec(iov, &num);
537 }
538
539 len = readv(dev->fd, iov, num);
540 if (len <= 0)
541 err(1, "reading network");
542 if (lenp) {
543 *lenp = len;
544 trigger_irq(fd, irq);
545 }
546 verbose("tun input packet len %i [%02x %02x] (%s)\n", len,
547 ((u8 *)iov[0].iov_base)[0], ((u8 *)iov[0].iov_base)[1],
548 lenp ? "sent" : "discarded");
549 return true;
550}
551
552static u32 handle_block_output(int fd, const struct iovec *iov,
553 unsigned num, struct device *dev)
554{
555 struct lguest_block_page *p = dev->mem;
556 u32 irq, *lenp;
557 unsigned int len, reply_num;
558 struct iovec reply[LGUEST_MAX_DMA_SECTIONS];
559 off64_t device_len, off = (off64_t)p->sector * 512;
560
561 device_len = *(off64_t *)dev->priv;
562
563 if (off >= device_len)
564 err(1, "Bad offset %llu vs %llu", off, device_len);
565 if (lseek64(dev->fd, off, SEEK_SET) != off)
566 err(1, "Bad seek to sector %i", p->sector);
567
568 verbose("Block: %s at offset %llu\n", p->type ? "WRITE" : "READ", off);
569
570 lenp = get_dma_buffer(fd, dev->mem, reply, &reply_num, &irq);
571 if (!lenp)
572 err(1, "Block request didn't give us a dma buffer");
573
574 if (p->type) {
575 len = writev(dev->fd, iov, num);
576 if (off + len > device_len) {
577 ftruncate(dev->fd, device_len);
578 errx(1, "Write past end %llu+%u", off, len);
579 }
580 *lenp = 0;
581 } else {
582 len = readv(dev->fd, reply, reply_num);
583 *lenp = len;
584 }
585
586 p->result = 1 + (p->bytes != len);
587 trigger_irq(fd, irq);
588 return 0;
589}
590
591static void handle_output(int fd, unsigned long dma, unsigned long key,
592 struct device_list *devices)
593{
594 struct device *i;
595 u32 *lenp;
596 struct iovec iov[LGUEST_MAX_DMA_SECTIONS];
597 unsigned num = 0;
598
599 lenp = dma2iov(dma, iov, &num);
600 for (i = devices->dev; i; i = i->next) {
601 if (i->handle_output && key == i->watch_key) {
602 *lenp = i->handle_output(fd, iov, num, i);
603 return;
604 }
605 }
606 warnx("Pending dma %p, key %p", (void *)dma, (void *)key);
607}
608
609static void handle_input(int fd, struct device_list *devices)
610{
611 struct timeval poll = { .tv_sec = 0, .tv_usec = 0 };
612
613 for (;;) {
614 struct device *i;
615 fd_set fds = devices->infds;
616
617 if (select(devices->max_infd+1, &fds, NULL, NULL, &poll) == 0)
618 break;
619
620 for (i = devices->dev; i; i = i->next) {
621 if (i->handle_input && FD_ISSET(i->fd, &fds)) {
622 if (!i->handle_input(fd, i)) {
623 FD_CLR(i->fd, &devices->infds);
624 /* Tell waker to ignore it too... */
625 write(waker_fd, &i->fd, sizeof(i->fd));
626 }
627 }
628 }
629 }
630}
631
632static struct lguest_device_desc *new_dev_desc(u16 type, u16 features,
633 u16 num_pages)
634{
635 static unsigned long top = LGUEST_GUEST_TOP;
636 struct lguest_device_desc *desc;
637
638 desc = malloc(sizeof(*desc));
639 desc->type = type;
640 desc->num_pages = num_pages;
641 desc->features = features;
642 desc->status = 0;
643 if (num_pages) {
644 top -= num_pages*getpagesize();
645 map_zeroed_pages(top, num_pages);
646 desc->pfn = top / getpagesize();
647 } else
648 desc->pfn = 0;
649 return desc;
650}
651
652static struct device *new_device(struct device_list *devices,
653 u16 type, u16 num_pages, u16 features,
654 int fd,
655 bool (*handle_input)(int, struct device *),
656 unsigned long watch_off,
657 u32 (*handle_output)(int,
658 const struct iovec *,
659 unsigned,
660 struct device *))
661{
662 struct device *dev = malloc(sizeof(*dev));
663
664 /* Append to device list. */
665 *devices->lastdev = dev;
666 dev->next = NULL;
667 devices->lastdev = &dev->next;
668
669 dev->fd = fd;
670 if (handle_input)
671 set_fd(dev->fd, devices);
672 dev->desc = new_dev_desc(type, features, num_pages);
673 dev->mem = (void *)(dev->desc->pfn * getpagesize());
674 dev->handle_input = handle_input;
675 dev->watch_key = (unsigned long)dev->mem + watch_off;
676 dev->handle_output = handle_output;
677 return dev;
678}
679
680static void setup_console(struct device_list *devices)
681{
682 struct device *dev;
683
684 if (tcgetattr(STDIN_FILENO, &orig_term) == 0) {
685 struct termios term = orig_term;
686 term.c_lflag &= ~(ISIG|ICANON|ECHO);
687 tcsetattr(STDIN_FILENO, TCSANOW, &term);
688 atexit(restore_term);
689 }
690
691 /* We don't currently require a page for the console. */
692 dev = new_device(devices, LGUEST_DEVICE_T_CONSOLE, 0, 0,
693 STDIN_FILENO, handle_console_input,
694 LGUEST_CONSOLE_DMA_KEY, handle_console_output);
695 dev->priv = malloc(sizeof(struct console_abort));
696 ((struct console_abort *)dev->priv)->count = 0;
697 verbose("device %p: console\n",
698 (void *)(dev->desc->pfn * getpagesize()));
699}
700
701static void setup_block_file(const char *filename, struct device_list *devices)
702{
703 int fd;
704 struct device *dev;
705 off64_t *device_len;
706 struct lguest_block_page *p;
707
708 fd = open_or_die(filename, O_RDWR|O_LARGEFILE|O_DIRECT);
709 dev = new_device(devices, LGUEST_DEVICE_T_BLOCK, 1,
710 LGUEST_DEVICE_F_RANDOMNESS,
711 fd, NULL, 0, handle_block_output);
712 device_len = dev->priv = malloc(sizeof(*device_len));
713 *device_len = lseek64(fd, 0, SEEK_END);
714 p = dev->mem;
715
716 p->num_sectors = *device_len/512;
717 verbose("device %p: block %i sectors\n",
718 (void *)(dev->desc->pfn * getpagesize()), p->num_sectors);
719}
720
721/* We use fnctl locks to reserve network slots (autocleanup!) */
722static unsigned int find_slot(int netfd, const char *filename)
723{
724 struct flock fl;
725
726 fl.l_type = F_WRLCK;
727 fl.l_whence = SEEK_SET;
728 fl.l_len = 1;
729 for (fl.l_start = 0;
730 fl.l_start < getpagesize()/sizeof(struct lguest_net);
731 fl.l_start++) {
732 if (fcntl(netfd, F_SETLK, &fl) == 0)
733 return fl.l_start;
734 }
735 errx(1, "No free slots in network file %s", filename);
736}
737
738static void setup_net_file(const char *filename,
739 struct device_list *devices)
740{
741 int netfd;
742 struct device *dev;
743
744 netfd = open(filename, O_RDWR, 0);
745 if (netfd < 0) {
746 if (errno == ENOENT) {
747 netfd = open(filename, O_RDWR|O_CREAT, 0600);
748 if (netfd >= 0) {
749 char page[getpagesize()];
750 memset(page, 0, sizeof(page));
751 write(netfd, page, sizeof(page));
752 }
753 }
754 if (netfd < 0)
755 err(1, "cannot open net file '%s'", filename);
756 }
757
758 dev = new_device(devices, LGUEST_DEVICE_T_NET, 1,
759 find_slot(netfd, filename)|LGUEST_NET_F_NOCSUM,
760 -1, NULL, 0, NULL);
761
762 /* We overwrite the /dev/zero mapping with the actual file. */
763 if (mmap(dev->mem, getpagesize(), PROT_READ|PROT_WRITE,
764 MAP_FIXED|MAP_SHARED, netfd, 0) != dev->mem)
765 err(1, "could not mmap '%s'", filename);
766 verbose("device %p: shared net %s, peer %i\n",
767 (void *)(dev->desc->pfn * getpagesize()), filename,
768 dev->desc->features & ~LGUEST_NET_F_NOCSUM);
769}
770
771static u32 str2ip(const char *ipaddr)
772{
773 unsigned int byte[4];
774
775 sscanf(ipaddr, "%u.%u.%u.%u", &byte[0], &byte[1], &byte[2], &byte[3]);
776 return (byte[0] << 24) | (byte[1] << 16) | (byte[2] << 8) | byte[3];
777}
778
779/* adapted from libbridge */
780static void add_to_bridge(int fd, const char *if_name, const char *br_name)
781{
782 int ifidx;
783 struct ifreq ifr;
784
785 if (!*br_name)
786 errx(1, "must specify bridge name");
787
788 ifidx = if_nametoindex(if_name);
789 if (!ifidx)
790 errx(1, "interface %s does not exist!", if_name);
791
792 strncpy(ifr.ifr_name, br_name, IFNAMSIZ);
793 ifr.ifr_ifindex = ifidx;
794 if (ioctl(fd, SIOCBRADDIF, &ifr) < 0)
795 err(1, "can't add %s to bridge %s", if_name, br_name);
796}
797
798static void configure_device(int fd, const char *devname, u32 ipaddr,
799 unsigned char hwaddr[6])
800{
801 struct ifreq ifr;
802 struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr;
803
804 memset(&ifr, 0, sizeof(ifr));
805 strcpy(ifr.ifr_name, devname);
806 sin->sin_family = AF_INET;
807 sin->sin_addr.s_addr = htonl(ipaddr);
808 if (ioctl(fd, SIOCSIFADDR, &ifr) != 0)
809 err(1, "Setting %s interface address", devname);
810 ifr.ifr_flags = IFF_UP;
811 if (ioctl(fd, SIOCSIFFLAGS, &ifr) != 0)
812 err(1, "Bringing interface %s up", devname);
813
814 if (ioctl(fd, SIOCGIFHWADDR, &ifr) != 0)
815 err(1, "getting hw address for %s", devname);
816
817 memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6);
818}
819
820static void setup_tun_net(const char *arg, struct device_list *devices)
821{
822 struct device *dev;
823 struct ifreq ifr;
824 int netfd, ipfd;
825 u32 ip;
826 const char *br_name = NULL;
827
828 netfd = open_or_die("/dev/net/tun", O_RDWR);
829 memset(&ifr, 0, sizeof(ifr));
830 ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
831 strcpy(ifr.ifr_name, "tap%d");
832 if (ioctl(netfd, TUNSETIFF, &ifr) != 0)
833 err(1, "configuring /dev/net/tun");
834 ioctl(netfd, TUNSETNOCSUM, 1);
835
836 /* You will be peer 1: we should create enough jitter to randomize */
837 dev = new_device(devices, LGUEST_DEVICE_T_NET, 1,
838 NET_PEERNUM|LGUEST_DEVICE_F_RANDOMNESS, netfd,
839 handle_tun_input, peer_offset(0), handle_tun_output);
840 dev->priv = malloc(sizeof(bool));
841 *(bool *)dev->priv = false;
842
843 ipfd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
844 if (ipfd < 0)
845 err(1, "opening IP socket");
846
847 if (!strncmp(BRIDGE_PFX, arg, strlen(BRIDGE_PFX))) {
848 ip = INADDR_ANY;
849 br_name = arg + strlen(BRIDGE_PFX);
850 add_to_bridge(ipfd, ifr.ifr_name, br_name);
851 } else
852 ip = str2ip(arg);
853
854 /* We are peer 0, ie. first slot. */
855 configure_device(ipfd, ifr.ifr_name, ip, dev->mem);
856
857 /* Set "promisc" bit: we want every single packet. */
858 *((u8 *)dev->mem) |= 0x1;
859
860 close(ipfd);
861
862 verbose("device %p: tun net %u.%u.%u.%u\n",
863 (void *)(dev->desc->pfn * getpagesize()),
864 (u8)(ip>>24), (u8)(ip>>16), (u8)(ip>>8), (u8)ip);
865 if (br_name)
866 verbose("attached to bridge: %s\n", br_name);
867}
868
869/* Now we know how much memory we have, we copy in device descriptors */
870static void map_device_descriptors(struct device_list *devs, unsigned long mem)
871{
872 struct device *i;
873 unsigned int num;
874 struct lguest_device_desc *descs;
875
876 /* Device descriptor array sits just above top of normal memory */
877 descs = map_zeroed_pages(mem, 1);
878
879 for (i = devs->dev, num = 0; i; i = i->next, num++) {
880 if (num == LGUEST_MAX_DEVICES)
881 errx(1, "too many devices");
882 verbose("Device %i: %s\n", num,
883 i->desc->type == LGUEST_DEVICE_T_NET ? "net"
884 : i->desc->type == LGUEST_DEVICE_T_CONSOLE ? "console"
885 : i->desc->type == LGUEST_DEVICE_T_BLOCK ? "block"
886 : "unknown");
887 descs[num] = *i->desc;
888 free(i->desc);
889 i->desc = &descs[num];
890 }
891}
892
893static void __attribute__((noreturn))
894run_guest(int lguest_fd, struct device_list *device_list)
895{
896 for (;;) {
897 u32 args[] = { LHREQ_BREAK, 0 };
898 unsigned long arr[2];
899 int readval;
900
901 /* We read from the /dev/lguest device to run the Guest. */
902 readval = read(lguest_fd, arr, sizeof(arr));
903
904 if (readval == sizeof(arr)) {
905 handle_output(lguest_fd, arr[0], arr[1], device_list);
906 continue;
907 } else if (errno == ENOENT) {
908 char reason[1024] = { 0 };
909 read(lguest_fd, reason, sizeof(reason)-1);
910 errx(1, "%s", reason);
911 } else if (errno != EAGAIN)
912 err(1, "Running guest failed");
913 handle_input(lguest_fd, device_list);
914 if (write(lguest_fd, args, sizeof(args)) < 0)
915 err(1, "Resetting break");
916 }
917}
918
919static struct option opts[] = {
920 { "verbose", 0, NULL, 'v' },
921 { "sharenet", 1, NULL, 's' },
922 { "tunnet", 1, NULL, 't' },
923 { "block", 1, NULL, 'b' },
924 { "initrd", 1, NULL, 'i' },
925 { NULL },
926};
927static void usage(void)
928{
929 errx(1, "Usage: lguest [--verbose] "
930 "[--sharenet=<filename>|--tunnet=(<ipaddr>|bridge:<bridgename>)\n"
931 "|--block=<filename>|--initrd=<filename>]...\n"
932 "<mem-in-mb> vmlinux [args...]");
933}
934
935int main(int argc, char *argv[])
936{
937 unsigned long mem, pgdir, start, page_offset, initrd_size = 0;
938 int c, lguest_fd;
939 struct device_list device_list;
940 void *boot = (void *)0;
941 const char *initrd_name = NULL;
942
943 device_list.max_infd = -1;
944 device_list.dev = NULL;
945 device_list.lastdev = &device_list.dev;
946 FD_ZERO(&device_list.infds);
947
948 while ((c = getopt_long(argc, argv, "v", opts, NULL)) != EOF) {
949 switch (c) {
950 case 'v':
951 verbose = true;
952 break;
953 case 's':
954 setup_net_file(optarg, &device_list);
955 break;
956 case 't':
957 setup_tun_net(optarg, &device_list);
958 break;
959 case 'b':
960 setup_block_file(optarg, &device_list);
961 break;
962 case 'i':
963 initrd_name = optarg;
964 break;
965 default:
966 warnx("Unknown argument %s", argv[optind]);
967 usage();
968 }
969 }
970 if (optind + 2 > argc)
971 usage();
972
973 /* We need a console device */
974 setup_console(&device_list);
975
976 /* First we map /dev/zero over all of guest-physical memory. */
977 mem = atoi(argv[optind]) * 1024 * 1024;
978 map_zeroed_pages(0, mem / getpagesize());
979
980 /* Now we load the kernel */
981 start = load_kernel(open_or_die(argv[optind+1], O_RDONLY),
982 &page_offset);
983
984 /* Write the device descriptors into memory. */
985 map_device_descriptors(&device_list, mem);
986
987 /* Map the initrd image if requested */
988 if (initrd_name) {
989 initrd_size = load_initrd(initrd_name, mem);
990 *(unsigned long *)(boot+0x218) = mem - initrd_size;
991 *(unsigned long *)(boot+0x21c) = initrd_size;
992 *(unsigned char *)(boot+0x210) = 0xFF;
993 }
994
995 /* Set up the initial linar pagetables. */
996 pgdir = setup_pagetables(mem, initrd_size, page_offset);
997
998 /* E820 memory map: ours is a simple, single region. */
999 *(char*)(boot+E820NR) = 1;
1000 *((struct e820entry *)(boot+E820MAP))
1001 = ((struct e820entry) { 0, mem, E820_RAM });
1002 /* Command line pointer and command line (at 4096) */
1003 *(void **)(boot + 0x228) = boot + 4096;
1004 concat(boot + 4096, argv+optind+2);
1005 /* Paravirt type: 1 == lguest */
1006 *(int *)(boot + 0x23c) = 1;
1007
1008 lguest_fd = tell_kernel(pgdir, start, page_offset);
1009 waker_fd = setup_waker(lguest_fd, &device_list);
1010
1011 run_guest(lguest_fd, &device_list);
1012}
diff --git a/Documentation/lguest/lguest.txt b/Documentation/lguest/lguest.txt
new file mode 100644
index 000000000000..821617bd6c04
--- /dev/null
+++ b/Documentation/lguest/lguest.txt
@@ -0,0 +1,129 @@
1Rusty's Remarkably Unreliable Guide to Lguest
2 - or, A Young Coder's Illustrated Hypervisor
3http://lguest.ozlabs.org
4
5Lguest is designed to be a minimal hypervisor for the Linux kernel, for
6Linux developers and users to experiment with virtualization with the
7minimum of complexity. Nonetheless, it should have sufficient
8features to make it useful for specific tasks, and, of course, you are
9encouraged to fork and enhance it.
10
11Features:
12
13- Kernel module which runs in a normal kernel.
14- Simple I/O model for communication.
15- Simple program to create new guests.
16- Logo contains cute puppies: http://lguest.ozlabs.org
17
18Developer features:
19
20- Fun to hack on.
21- No ABI: being tied to a specific kernel anyway, you can change anything.
22- Many opportunities for improvement or feature implementation.
23
24Running Lguest:
25
26- Lguest runs the same kernel as guest and host. You can configure
27 them differently, but usually it's easiest not to.
28
29 You will need to configure your kernel with the following options:
30
31 CONFIG_HIGHMEM64G=n ("High Memory Support" "64GB")[1]
32 CONFIG_TUN=y/m ("Universal TUN/TAP device driver support")
33 CONFIG_EXPERIMENTAL=y ("Prompt for development and/or incomplete code/drivers")
34 CONFIG_PARAVIRT=y ("Paravirtualization support (EXPERIMENTAL)")
35 CONFIG_LGUEST=y/m ("Linux hypervisor example code")
36
37 and I recommend:
38 CONFIG_HZ=100 ("Timer frequency")[2]
39
40- A tool called "lguest" is available in this directory: type "make"
41 to build it. If you didn't build your kernel in-tree, use "make
42 O=<builddir>".
43
44- Create or find a root disk image. There are several useful ones
45 around, such as the xm-test tiny root image at
46 http://xm-test.xensource.com/ramdisks/initrd-1.1-i386.img
47
48 For more serious work, I usually use a distribution ISO image and
49 install it under qemu, then make multiple copies:
50
51 dd if=/dev/zero of=rootfile bs=1M count=2048
52 qemu -cdrom image.iso -hda rootfile -net user -net nic -boot d
53
54- "modprobe lg" if you built it as a module.
55
56- Run an lguest as root:
57
58 Documentation/lguest/lguest 64m vmlinux --tunnet=192.168.19.1 --block=rootfile root=/dev/lgba
59
60 Explanation:
61 64m: the amount of memory to use.
62
63 vmlinux: the kernel image found in the top of your build directory. You
64 can also use a standard bzImage.
65
66 --tunnet=192.168.19.1: configures a "tap" device for networking with this
67 IP address.
68
69 --block=rootfile: a file or block device which becomes /dev/lgba
70 inside the guest.
71
72 root=/dev/lgba: this (and anything else on the command line) are
73 kernel boot parameters.
74
75- Configuring networking. I usually have the host masquerade, using
76 "iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE" and "echo 1 >
77 /proc/sys/net/ipv4/ip_forward". In this example, I would configure
78 eth0 inside the guest at 192.168.19.2.
79
80 Another method is to bridge the tap device to an external interface
81 using --tunnet=bridge:<bridgename>, and perhaps run dhcp on the guest
82 to obtain an IP address. The bridge needs to be configured first:
83 this option simply adds the tap interface to it.
84
85 A simple example on my system:
86
87 ifconfig eth0 0.0.0.0
88 brctl addbr lg0
89 ifconfig lg0 up
90 brctl addif lg0 eth0
91 dhclient lg0
92
93 Then use --tunnet=bridge:lg0 when launching the guest.
94
95 See http://linux-net.osdl.org/index.php/Bridge for general information
96 on how to get bridging working.
97
98- You can also create an inter-guest network using
99 "--sharenet=<filename>": any two guests using the same file are on
100 the same network. This file is created if it does not exist.
101
102Lguest I/O model:
103
104Lguest uses a simplified DMA model plus shared memory for I/O. Guests
105can communicate with each other if they share underlying memory
106(usually by the lguest program mmaping the same file), but they can
107use any non-shared memory to communicate with the lguest process.
108
109Guests can register DMA buffers at any key (must be a valid physical
110address) using the LHCALL_BIND_DMA(key, dmabufs, num<<8|irq)
111hypercall. "dmabufs" is the physical address of an array of "num"
112"struct lguest_dma": each contains a used_len, and an array of
113physical addresses and lengths. When a transfer occurs, the
114"used_len" field of one of the buffers which has used_len 0 will be
115set to the length transferred and the irq will fire.
116
117Using an irq value of 0 unbinds the dma buffers.
118
119To send DMA, the LHCALL_SEND_DMA(key, dma_physaddr) hypercall is used,
120and the bytes used is written to the used_len field. This can be 0 if
121noone else has bound a DMA buffer to that key or some other error.
122DMA buffers bound by the same guest are ignored.
123
124Cheers!
125Rusty Russell rusty@rustcorp.com.au.
126
127[1] These are on various places on the TODO list, waiting for you to
128 get annoyed enough at the limitation to fix it.
129[2] Lguest is not yet tickless when idle. See [1].
diff --git a/Documentation/power/freezing-of-tasks.txt b/Documentation/power/freezing-of-tasks.txt
index af1a282c71a3..04dc1cf9d215 100644
--- a/Documentation/power/freezing-of-tasks.txt
+++ b/Documentation/power/freezing-of-tasks.txt
@@ -155,6 +155,8 @@ Suppose, however, that the firmware file is located on a filesystem accessible
155only through another device that hasn't been resumed yet. In that case, 155only through another device that hasn't been resumed yet. In that case,
156request_firmware() will fail regardless of whether or not the freezing of tasks 156request_firmware() will fail regardless of whether or not the freezing of tasks
157is used. Consequently, the problem is not really related to the freezing of 157is used. Consequently, the problem is not really related to the freezing of
158tasks, since it generally exists anyway. [The solution to this particular 158tasks, since it generally exists anyway.
159problem is to keep the firmware in memory after it's loaded for the first time 159
160and upload if from memory to the device whenever necessary.] 160A driver must have all firmwares it may need in RAM before suspend() is called.
161If keeping them is not practical, for example due to their size, they must be
162requested early enough using the suspend notifier API described in notifiers.txt.
diff --git a/Documentation/power/notifiers.txt b/Documentation/power/notifiers.txt
new file mode 100644
index 000000000000..9293e4bc857c
--- /dev/null
+++ b/Documentation/power/notifiers.txt
@@ -0,0 +1,50 @@
1Suspend notifiers
2 (C) 2007 Rafael J. Wysocki <rjw@sisk.pl>, GPL
3
4There are some operations that device drivers may want to carry out in their
5.suspend() routines, but shouldn't, because they can cause the hibernation or
6suspend to fail. For example, a driver may want to allocate a substantial amount
7of memory (like 50 MB) in .suspend(), but that shouldn't be done after the
8swsusp's memory shrinker has run.
9
10Also, there may be some operations, that subsystems want to carry out before a
11hibernation/suspend or after a restore/resume, requiring the system to be fully
12functional, so the drivers' .suspend() and .resume() routines are not suitable
13for this purpose. For example, device drivers may want to upload firmware to
14their devices after a restore from a hibernation image, but they cannot do it by
15calling request_firmware() from their .resume() routines (user land processes
16are frozen at this point). The solution may be to load the firmware into
17memory before processes are frozen and upload it from there in the .resume()
18routine. Of course, a hibernation notifier may be used for this purpose.
19
20The subsystems that have such needs can register suspend notifiers that will be
21called upon the following events by the suspend core:
22
23PM_HIBERNATION_PREPARE The system is going to hibernate or suspend, tasks will
24 be frozen immediately.
25
26PM_POST_HIBERNATION The system memory state has been restored from a
27 hibernation image or an error occured during the
28 hibernation. Device drivers' .resume() callbacks have
29 been executed and tasks have been thawed.
30
31PM_SUSPEND_PREPARE The system is preparing for a suspend.
32
33PM_POST_SUSPEND The system has just resumed or an error occured during
34 the suspend. Device drivers' .resume() callbacks have
35 been executed and tasks have been thawed.
36
37It is generally assumed that whatever the notifiers do for
38PM_HIBERNATION_PREPARE, should be undone for PM_POST_HIBERNATION. Analogously,
39operations performed for PM_SUSPEND_PREPARE should be reversed for
40PM_POST_SUSPEND. Additionally, all of the notifiers are called for
41PM_POST_HIBERNATION if one of them fails for PM_HIBERNATION_PREPARE, and
42all of the notifiers are called for PM_POST_SUSPEND if one of them fails for
43PM_SUSPEND_PREPARE.
44
45The hibernation and suspend notifiers are called with pm_mutex held. They are
46defined in the usual way, but their last argument is meaningless (it is always
47NULL). To register and/or unregister a suspend notifier use the functions
48register_pm_notifier() and unregister_pm_notifier(), respectively, defined in
49include/linux/suspend.h . If you don't need to unregister the notifier, you can
50also use the pm_notifier() macro defined in include/linux/suspend.h .
diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
index 0c2434822094..76733a3962f0 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -1250,6 +1250,12 @@ platforms are moved over to use the flattened-device-tree model.
1250 network device. This is used by the bootwrapper to interpret 1250 network device. This is used by the bootwrapper to interpret
1251 MAC addresses passed by the firmware when no information other 1251 MAC addresses passed by the firmware when no information other
1252 than indices is available to associate an address with a device. 1252 than indices is available to associate an address with a device.
1253 - phy-connection-type : a string naming the controller/PHY interface type,
1254 i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id", "sgmii",
1255 "tbi", or "rtbi". This property is only really needed if the connection
1256 is of type "rgmii-id", as all other connection types are detected by
1257 hardware.
1258
1253 1259
1254 Example: 1260 Example:
1255 1261
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index 355ff0a2bb7c..241e26c4ff92 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -467,7 +467,12 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
467 above explicitly. 467 above explicitly.
468 468
469 The power-management is supported. 469 The power-management is supported.
470 470
471 Module snd-cs5530
472 _________________
473
474 Module for Cyrix/NatSemi Geode 5530 chip.
475
471 Module snd-cs5535audio 476 Module snd-cs5535audio
472 ---------------------- 477 ----------------------
473 478
@@ -759,6 +764,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
759 764
760 model - force the model name 765 model - force the model name
761 position_fix - Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size) 766 position_fix - Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size)
767 probe_mask - Bitmask to probe codecs (default = -1, meaning all slots)
762 single_cmd - Use single immediate commands to communicate with 768 single_cmd - Use single immediate commands to communicate with
763 codecs (for debugging only) 769 codecs (for debugging only)
764 enable_msi - Enable Message Signaled Interrupt (MSI) (default = off) 770 enable_msi - Enable Message Signaled Interrupt (MSI) (default = off)
@@ -803,6 +809,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
803 hp-3013 HP machines (3013-variant) 809 hp-3013 HP machines (3013-variant)
804 fujitsu Fujitsu S7020 810 fujitsu Fujitsu S7020
805 acer Acer TravelMate 811 acer Acer TravelMate
812 will Will laptops (PB V7900)
813 replacer Replacer 672V
806 basic fixed pin assignment (old default model) 814 basic fixed pin assignment (old default model)
807 auto auto-config reading BIOS (default) 815 auto auto-config reading BIOS (default)
808 816
@@ -811,16 +819,31 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
811 hp-bpc HP xw4400/6400/8400/9400 laptops 819 hp-bpc HP xw4400/6400/8400/9400 laptops
812 hp-bpc-d7000 HP BPC D7000 820 hp-bpc-d7000 HP BPC D7000
813 benq Benq ED8 821 benq Benq ED8
822 benq-t31 Benq T31
814 hippo Hippo (ATI) with jack detection, Sony UX-90s 823 hippo Hippo (ATI) with jack detection, Sony UX-90s
815 hippo_1 Hippo (Benq) with jack detection 824 hippo_1 Hippo (Benq) with jack detection
825 sony-assamd Sony ASSAMD
816 basic fixed pin assignment w/o SPDIF 826 basic fixed pin assignment w/o SPDIF
817 auto auto-config reading BIOS (default) 827 auto auto-config reading BIOS (default)
818 828
829 ALC268
830 3stack 3-stack model
831 auto auto-config reading BIOS (default)
832
833 ALC662
834 3stack-dig 3-stack (2-channel) with SPDIF
835 3stack-6ch 3-stack (6-channel)
836 3stack-6ch-dig 3-stack (6-channel) with SPDIF
837 6stack-dig 6-stack with SPDIF
838 lenovo-101e Lenovo laptop
839 auto auto-config reading BIOS (default)
840
819 ALC882/885 841 ALC882/885
820 3stack-dig 3-jack with SPDIF I/O 842 3stack-dig 3-jack with SPDIF I/O
821 6stack-dig 6-jack digital with SPDIF I/O 843 6stack-dig 6-jack digital with SPDIF I/O
822 arima Arima W820Di1 844 arima Arima W820Di1
823 macpro MacPro support 845 macpro MacPro support
846 imac24 iMac 24'' with jack detection
824 w2jc ASUS W2JC 847 w2jc ASUS W2JC
825 auto auto-config reading BIOS (default) 848 auto auto-config reading BIOS (default)
826 849
@@ -832,9 +855,15 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
832 6stack-dig-demo 6-jack digital for Intel demo board 855 6stack-dig-demo 6-jack digital for Intel demo board
833 acer Acer laptops (Travelmate 3012WTMi, Aspire 5600, etc) 856 acer Acer laptops (Travelmate 3012WTMi, Aspire 5600, etc)
834 medion Medion Laptops 857 medion Medion Laptops
858 medion-md2 Medion MD2
835 targa-dig Targa/MSI 859 targa-dig Targa/MSI
836 targa-2ch-dig Targs/MSI with 2-channel 860 targa-2ch-dig Targs/MSI with 2-channel
837 laptop-eapd 3-jack with SPDIF I/O and EAPD (Clevo M540JE, M550JE) 861 laptop-eapd 3-jack with SPDIF I/O and EAPD (Clevo M540JE, M550JE)
862 lenovo-101e Lenovo 101E
863 lenovo-nb0763 Lenovo NB0763
864 lenovo-ms7195-dig Lenovo MS7195
865 6stack-hp HP machines with 6stack (Nettle boards)
866 3stack-hp HP machines with 3stack (Lucknow, Samba boards)
838 auto auto-config reading BIOS (default) 867 auto auto-config reading BIOS (default)
839 868
840 ALC861/660 869 ALC861/660
@@ -853,7 +882,9 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
853 3stack-dig 3-jack with SPDIF OUT 882 3stack-dig 3-jack with SPDIF OUT
854 6stack-dig 6-jack with SPDIF OUT 883 6stack-dig 6-jack with SPDIF OUT
855 3stack-660 3-jack (for ALC660VD) 884 3stack-660 3-jack (for ALC660VD)
885 3stack-660-digout 3-jack with SPDIF OUT (for ALC660VD)
856 lenovo Lenovo 3000 C200 886 lenovo Lenovo 3000 C200
887 dallas Dallas laptops
857 auto auto-config reading BIOS (default) 888 auto auto-config reading BIOS (default)
858 889
859 CMI9880 890 CMI9880
@@ -864,12 +895,26 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
864 allout 5-jack in back, 2-jack in front, SPDIF out 895 allout 5-jack in back, 2-jack in front, SPDIF out
865 auto auto-config reading BIOS (default) 896 auto auto-config reading BIOS (default)
866 897
898 AD1882
899 3stack 3-stack mode (default)
900 6stack 6-stack mode
901
902 AD1884
903 N/A
904
867 AD1981 905 AD1981
868 basic 3-jack (default) 906 basic 3-jack (default)
869 hp HP nx6320 907 hp HP nx6320
870 thinkpad Lenovo Thinkpad T60/X60/Z60 908 thinkpad Lenovo Thinkpad T60/X60/Z60
871 toshiba Toshiba U205 909 toshiba Toshiba U205
872 910
911 AD1983
912 N/A
913
914 AD1984
915 basic default configuration
916 thinkpad Lenovo Thinkpad T61/X61
917
873 AD1986A 918 AD1986A
874 6stack 6-jack, separate surrounds (default) 919 6stack 6-jack, separate surrounds (default)
875 3stack 3-stack, shared surrounds 920 3stack 3-stack, shared surrounds
@@ -907,11 +952,18 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
907 ref Reference board 952 ref Reference board
908 3stack D945 3stack 953 3stack D945 3stack
909 5stack D945 5stack + SPDIF 954 5stack D945 5stack + SPDIF
910 macmini Intel Mac Mini 955 dell Dell XPS M1210
911 macbook Intel Mac Book 956 intel-mac-v1 Intel Mac Type 1
912 macbook-pro-v1 Intel Mac Book Pro 1st generation 957 intel-mac-v2 Intel Mac Type 2
913 macbook-pro Intel Mac Book Pro 2nd generation 958 intel-mac-v3 Intel Mac Type 3
914 imac-intel Intel iMac 959 intel-mac-v4 Intel Mac Type 4
960 intel-mac-v5 Intel Mac Type 5
961 macmini Intel Mac Mini (equivalent with type 3)
962 macbook Intel Mac Book (eq. type 5)
963 macbook-pro-v1 Intel Mac Book Pro 1st generation (eq. type 3)
964 macbook-pro Intel Mac Book Pro 2nd generation (eq. type 3)
965 imac-intel Intel iMac (eq. type 2)
966 imac-intel-20 Intel iMac (newer version) (eq. type 3)
915 967
916 STAC9202/9250/9251 968 STAC9202/9250/9251
917 ref Reference board, base config 969 ref Reference board, base config
@@ -956,6 +1008,17 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
956 from the irq. Remember this is a last resort, and should be 1008 from the irq. Remember this is a last resort, and should be
957 avoided as much as possible... 1009 avoided as much as possible...
958 1010
1011 MORE NOTES ON "azx_get_response timeout" PROBLEMS:
1012 On some hardwares, you may need to add a proper probe_mask option
1013 to avoid the "azx_get_response timeout" problem above, instead.
1014 This occurs when the access to non-existing or non-working codec slot
1015 (likely a modem one) causes a stall of the communication via HD-audio
1016 bus. You can see which codec slots are probed by enabling
1017 CONFIG_SND_DEBUG_DETECT, or simply from the file name of the codec
1018 proc files. Then limit the slots to probe by probe_mask option.
1019 For example, probe_mask=1 means to probe only the first slot, and
1020 probe_mask=4 means only the third slot.
1021
959 The power-management is supported. 1022 The power-management is supported.
960 1023
961 Module snd-hdsp 1024 Module snd-hdsp
diff --git a/Documentation/sound/alsa/Audiophile-Usb.txt b/Documentation/sound/alsa/Audiophile-Usb.txt
index e40cce83327c..2ad5e6306c44 100644
--- a/Documentation/sound/alsa/Audiophile-Usb.txt
+++ b/Documentation/sound/alsa/Audiophile-Usb.txt
@@ -1,4 +1,4 @@
1 Guide to using M-Audio Audiophile USB with ALSA and Jack v1.3 1 Guide to using M-Audio Audiophile USB with ALSA and Jack v1.5
2 ======================================================== 2 ========================================================
3 3
4 Thibault Le Meur <Thibault.LeMeur@supelec.fr> 4 Thibault Le Meur <Thibault.LeMeur@supelec.fr>
@@ -6,8 +6,19 @@
6This document is a guide to using the M-Audio Audiophile USB (tm) device with 6This document is a guide to using the M-Audio Audiophile USB (tm) device with
7ALSA and JACK. 7ALSA and JACK.
8 8
9History
10=======
11* v1.4 - Thibault Le Meur (2007-07-11)
12 - Added Low Endianness nature of 16bits-modes
13 found by Hakan Lennestal <Hakan.Lennestal@brfsodrahamn.se>
14 - Modifying document structure
15* v1.5 - Thibault Le Meur (2007-07-12)
16 - Added AC3/DTS passthru info
17
18
91 - Audiophile USB Specs and correct usage 191 - Audiophile USB Specs and correct usage
10========================================== 20==========================================
21
11This part is a reminder of important facts about the functions and limitations 22This part is a reminder of important facts about the functions and limitations
12of the device. 23of the device.
13 24
@@ -25,18 +36,18 @@ The device has 4 audio interfaces, and 2 MIDI ports:
25The internal DAC/ADC has the following characteristics: 36The internal DAC/ADC has the following characteristics:
26* sample depth of 16 or 24 bits 37* sample depth of 16 or 24 bits
27* sample rate from 8kHz to 96kHz 38* sample rate from 8kHz to 96kHz
28* Two ports can't use different sample depths at the same time. Moreover, the 39* Two interfaces can't use different sample depths at the same time.
29Audiophile USB documentation gives the following Warning: "Please exit any 40Moreover, the Audiophile USB documentation gives the following Warning:
30audio application running before switching between bit depths" 41"Please exit any audio application running before switching between bit depths"
31 42
32Due to the USB 1.1 bandwidth limitation, a limited number of interfaces can be 43Due to the USB 1.1 bandwidth limitation, a limited number of interfaces can be
33activated at the same time depending on the audio mode selected: 44activated at the same time depending on the audio mode selected:
34 * 16-bit/48kHz ==> 4 channels in/4 channels out 45 * 16-bit/48kHz ==> 4 channels in + 4 channels out
35 - Ai+Ao+Di+Do 46 - Ai+Ao+Di+Do
36 * 24-bit/48kHz ==> 4 channels in/2 channels out, 47 * 24-bit/48kHz ==> 4 channels in + 2 channels out,
37 or 2 channels in/4 channels out 48 or 2 channels in + 4 channels out
38 - Ai+Ao+Do or Ai+Di+Ao or Ai+Di+Do or Di+Ao+Do 49 - Ai+Ao+Do or Ai+Di+Ao or Ai+Di+Do or Di+Ao+Do
39 * 24-bit/96kHz ==> 2 channels in, or 2 channels out (half duplex only) 50 * 24-bit/96kHz ==> 2 channels in _or_ 2 channels out (half duplex only)
40 - Ai or Ao or Di or Do 51 - Ai or Ao or Di or Do
41 52
42Important facts about the Digital interface: 53Important facts about the Digital interface:
@@ -52,44 +63,56 @@ source is connected
52synchronization error (for instance sound played at an odd sample rate) 63synchronization error (for instance sound played at an odd sample rate)
53 64
54 65
552 - Audiophile USB support in ALSA 662 - Audiophile USB MIDI support in ALSA
56================================== 67=======================================
57 68
582.1 - MIDI ports 69The Audiophile USB MIDI ports will be automatically supported once the
59----------------
60The Audiophile USB MIDI ports will be automatically supported once the
61following modules have been loaded: 70following modules have been loaded:
62 * snd-usb-audio 71 * snd-usb-audio
63 * snd-seq-midi 72 * snd-seq-midi
64 73
65No additional setting is required. 74No additional setting is required.
66 75
672.2 - Audio ports 76
68----------------- 773 - Audiophile USB Audio support in ALSA
78========================================
69 79
70Audio functions of the Audiophile USB device are handled by the snd-usb-audio 80Audio functions of the Audiophile USB device are handled by the snd-usb-audio
71module. This module can work in a default mode (without any device-specific 81module. This module can work in a default mode (without any device-specific
72parameter), or in an "advanced" mode with the device-specific parameter called 82parameter), or in an "advanced" mode with the device-specific parameter called
73"device_setup". 83"device_setup".
74 84
752.2.1 - Default Alsa driver mode 853.1 - Default Alsa driver mode
76 86------------------------------
77The default behavior of the snd-usb-audio driver is to parse the device 87
78capabilities at startup and enable all functions inside the device (including 88The default behavior of the snd-usb-audio driver is to list the device
79all ports at any supported sample rates and sample depths). This approach 89capabilities at startup and activate the required mode when required
80has the advantage to let the driver easily switch from sample rates/depths 90by the applications: for instance if the user is recording in a
81automatically according to the need of the application claiming the device. 9124bit-depth-mode and immediately after wants to switch to a 16bit-depth mode,
82 92the snd-usb-audio module will reconfigure the device on the fly.
83In this case the Audiophile ports are mapped to alsa pcm devices in the 93
84following way (I suppose the device's index is 1): 94This approach has the advantage to let the driver automatically switch from sample
95rates/depths automatically according to the user's needs. However, those who
96are using the device under windows know that this is not how the device is meant to
97work: under windows applications must be closed before using the m-audio control
98panel to switch the device working mode. Thus as we'll see in next section, this
99Default Alsa driver mode can lead to device misconfigurations.
100
101Let's get back to the Default Alsa driver mode for now. In this case the
102Audiophile interfaces are mapped to alsa pcm devices in the following
103way (I suppose the device's index is 1):
85 * hw:1,0 is Ao in playback and Di in capture 104 * hw:1,0 is Ao in playback and Di in capture
86 * hw:1,1 is Do in playback and Ai in capture 105 * hw:1,1 is Do in playback and Ai in capture
87 * hw:1,2 is Do in AC3/DTS passthrough mode 106 * hw:1,2 is Do in AC3/DTS passthrough mode
88 107
89You must note as well that the device uses Big Endian byte encoding so that 108In this mode, the device uses Big Endian byte-encoding so that
90supported audio format are S16_BE for 16-bit depth modes and S24_3BE for 109supported audio format are S16_BE for 16-bit depth modes and S24_3BE for
9124-bits depth mode. One exception is the hw:1,2 port which is Little Endian 11024-bits depth mode.
92compliant and thus uses S16_LE. 111
112One exception is the hw:1,2 port which was reported to be Little Endian
113compliant (supposedly supporting S16_LE) but processes in fact only S16_BE streams.
114This has been fixed in kernel 2.6.23 and above and now the hw:1,2 interface
115is reported to be big endian in this default driver mode.
93 116
94Examples: 117Examples:
95 * playing a S24_3BE encoded raw file to the Ao port 118 * playing a S24_3BE encoded raw file to the Ao port
@@ -98,22 +121,26 @@ Examples:
98 % arecord -D hw:1,1 -c2 -t raw -r48000 -fS24_3BE test.raw 121 % arecord -D hw:1,1 -c2 -t raw -r48000 -fS24_3BE test.raw
99 * playing a S16_BE encoded raw file to the Do port 122 * playing a S16_BE encoded raw file to the Do port
100 % aplay -D hw:1,1 -c2 -t raw -r48000 -fS16_BE test.raw 123 % aplay -D hw:1,1 -c2 -t raw -r48000 -fS16_BE test.raw
124 * playing an ac3 sample file to the Do port
125 % aplay -D hw:1,2 --channels=6 ac3_S16_BE_encoded_file.raw
101 126
102If you're happy with the default Alsa driver setup and don't experience any 127If you're happy with the default Alsa driver mode and don't experience any
103issue with this mode, then you can skip the following chapter. 128issue with this mode, then you can skip the following chapter.
104 129
1052.2.2 - Advanced module setup 1303.2 - Advanced module setup
131---------------------------
106 132
107Due to the hardware constraints described above, the device initialization made 133Due to the hardware constraints described above, the device initialization made
108by the Alsa driver in default mode may result in a corrupted state of the 134by the Alsa driver in default mode may result in a corrupted state of the
109device. For instance, a particularly annoying issue is that the sound captured 135device. For instance, a particularly annoying issue is that the sound captured
110from the Ai port sounds distorted (as if boosted with an excessive high volume 136from the Ai interface sounds distorted (as if boosted with an excessive high
111gain). 137volume gain).
112 138
113For people having this problem, the snd-usb-audio module has a new module 139For people having this problem, the snd-usb-audio module has a new module
114parameter called "device_setup". 140parameter called "device_setup" (this parameter was introduced in kernel
141release 2.6.17)
115 142
1162.2.2.1 - Initializing the working mode of the Audiophile USB 1433.2.1 - Initializing the working mode of the Audiophile USB
117 144
118As far as the Audiophile USB device is concerned, this value let the user 145As far as the Audiophile USB device is concerned, this value let the user
119specify: 146specify:
@@ -121,33 +148,57 @@ specify:
121 * the sample rate 148 * the sample rate
122 * whether the Di port is used or not 149 * whether the Di port is used or not
123 150
124Here is a list of supported device_setup values for this device: 151When initialized with "device_setup=0x00", the snd-usb-audio module has
125 * device_setup=0x00 (or omitted) 152the same behaviour as when the parameter is omitted (see paragraph "Default
126 - Alsa driver default mode 153Alsa driver mode" above)
127 - maintains backward compatibility with setups that do not use this 154
128 parameter by not introducing any change 155Others modes are described in the following subsections.
129 - results sometimes in corrupted sound as described earlier 156
1573.2.1.1 - 16-bit modes
158
159The two supported modes are:
160
130 * device_setup=0x01 161 * device_setup=0x01
131 - 16bits 48kHz mode with Di disabled 162 - 16bits 48kHz mode with Di disabled
132 - Ai,Ao,Do can be used at the same time 163 - Ai,Ao,Do can be used at the same time
133 - hw:1,0 is not available in capture mode 164 - hw:1,0 is not available in capture mode
134 - hw:1,2 is not available 165 - hw:1,2 is not available
166
135 * device_setup=0x11 167 * device_setup=0x11
136 - 16bits 48kHz mode with Di enabled 168 - 16bits 48kHz mode with Di enabled
137 - Ai,Ao,Di,Do can be used at the same time 169 - Ai,Ao,Di,Do can be used at the same time
138 - hw:1,0 is available in capture mode 170 - hw:1,0 is available in capture mode
139 - hw:1,2 is not available 171 - hw:1,2 is not available
172
173In this modes the device operates only at 16bits-modes. Before kernel 2.6.23,
174the devices where reported to be Big-Endian when in fact they were Little-Endian
175so that playing a file was a matter of using:
176 % aplay -D hw:1,1 -c2 -t raw -r48000 -fS16_BE test_S16_LE.raw
177where "test_S16_LE.raw" was in fact a little-endian sample file.
178
179Thanks to Hakan Lennestal (who discovered the Little-Endiannes of the device in
180these modes) a fix has been committed (expected in kernel 2.6.23) and
181Alsa now reports Little-Endian interfaces. Thus playing a file now is as simple as
182using:
183 % aplay -D hw:1,1 -c2 -t raw -r48000 -fS16_LE test_S16_LE.raw
184
1853.2.1.2 - 24-bit modes
186
187The three supported modes are:
188
140 * device_setup=0x09 189 * device_setup=0x09
141 - 24bits 48kHz mode with Di disabled 190 - 24bits 48kHz mode with Di disabled
142 - Ai,Ao,Do can be used at the same time 191 - Ai,Ao,Do can be used at the same time
143 - hw:1,0 is not available in capture mode 192 - hw:1,0 is not available in capture mode
144 - hw:1,2 is not available 193 - hw:1,2 is not available
194
145 * device_setup=0x19 195 * device_setup=0x19
146 - 24bits 48kHz mode with Di enabled 196 - 24bits 48kHz mode with Di enabled
147 - 3 ports from {Ai,Ao,Di,Do} can be used at the same time 197 - 3 ports from {Ai,Ao,Di,Do} can be used at the same time
148 - hw:1,0 is available in capture mode and an active digital source must be 198 - hw:1,0 is available in capture mode and an active digital source must be
149 connected to Di 199 connected to Di
150 - hw:1,2 is not available 200 - hw:1,2 is not available
201
151 * device_setup=0x0D or 0x10 202 * device_setup=0x0D or 0x10
152 - 24bits 96kHz mode 203 - 24bits 96kHz mode
153 - Di is enabled by default for this mode but does not need to be connected 204 - Di is enabled by default for this mode but does not need to be connected
@@ -155,34 +206,64 @@ Here is a list of supported device_setup values for this device:
155 - Only 1 port from {Ai,Ao,Di,Do} can be used at the same time 206 - Only 1 port from {Ai,Ao,Di,Do} can be used at the same time
156 - hw:1,0 is available in captured mode 207 - hw:1,0 is available in captured mode
157 - hw:1,2 is not available 208 - hw:1,2 is not available
209
210In these modes the device is only Big-Endian compliant (see "Default Alsa driver
211mode" above for an aplay command example)
212
2133.2.1.3 - AC3 w/ DTS passthru mode
214
215Thanks to Hakan Lennestal, I now have a report saying that this mode works.
216
158 * device_setup=0x03 217 * device_setup=0x03
159 - 16bits 48kHz mode with only the Do port enabled 218 - 16bits 48kHz mode with only the Do port enabled
160 - AC3 with DTS passthru (not tested) 219 - AC3 with DTS passthru
161 - Caution with this setup the Do port is mapped to the pcm device hw:1,0 220 - Caution with this setup the Do port is mapped to the pcm device hw:1,0
162 221
1632.2.2.2 - Setting and switching configurations with the device_setup parameter 222The command line used to playback the AC3/DTS encoded .wav-files in this mode:
223 % aplay -D hw:1,0 --channels=6 ac3_S16_LE_encoded_file.raw
224
2253.2.2 - How to use the device_setup parameter
226----------------------------------------------
164 227
165The parameter can be given: 228The parameter can be given:
229
166 * By manually probing the device (as root): 230 * By manually probing the device (as root):
167 # modprobe -r snd-usb-audio 231 # modprobe -r snd-usb-audio
168 # modprobe snd-usb-audio index=1 device_setup=0x09 232 # modprobe snd-usb-audio index=1 device_setup=0x09
233
169 * Or while configuring the modules options in your modules configuration file 234 * Or while configuring the modules options in your modules configuration file
170 - For Fedora distributions, edit the /etc/modprobe.conf file: 235 - For Fedora distributions, edit the /etc/modprobe.conf file:
171 alias snd-card-1 snd-usb-audio 236 alias snd-card-1 snd-usb-audio
172 options snd-usb-audio index=1 device_setup=0x09 237 options snd-usb-audio index=1 device_setup=0x09
173 238
174IMPORTANT NOTE WHEN SWITCHING CONFIGURATION: 239CAUTION when initializaing the device
175------------------------------------------- 240-------------------------------------
176 * You may need to _first_ initialize the module with the correct device_setup 241
177 parameter and _only_after_ turn on the Audiophile USB device 242 * Correct initialization on the device requires that device_setup is given to
178 * This is especially true when switching the sample depth: 243 the module BEFORE the device is turned on. So, if you use the "manual probing"
244 method described above, take care to power-on the device AFTER this initialization.
245
246 * Failing to respect this will lead in a misconfiguration of the device. In this case
247 turn off the device, unproble the snd-usb-audio module, then probe it again with
248 correct device_setup parameter and then (and only then) turn on the device again.
249
250 * If you've correctly initialized the device in a valid mode and then want to switch
251 to another mode (possibly with another sample-depth), please use also the following
252 procedure:
179 - first turn off the device 253 - first turn off the device
180 - de-register the snd-usb-audio module (modprobe -r) 254 - de-register the snd-usb-audio module (modprobe -r)
181 - change the device_setup parameter by changing the device_setup 255 - change the device_setup parameter by changing the device_setup
182 option in /etc/modprobe.conf 256 option in /etc/modprobe.conf
183 - turn on the device 257 - turn on the device
258 * A workaround for this last issue has been applied to kernel 2.6.23, but it may not
259 be enough to ensure the 'stability' of the device initialization.
184 260
1852.2.2.3 - Audiophile USB's device_setup structure 2613.2.3 - Technical details for hackers
262-------------------------------------
263This section is for hackers, wanting to understand details about the device
264internals and how Alsa supports it.
265
2663.2.3.1 - Audiophile USB's device_setup structure
186 267
187If you want to understand the device_setup magic numbers for the Audiophile 268If you want to understand the device_setup magic numbers for the Audiophile
188USB, you need some very basic understanding of binary computation. However, 269USB, you need some very basic understanding of binary computation. However,
@@ -228,12 +309,12 @@ Caution:
228 - choosing b2 will prepare all interfaces for 24bits/96kHz but you'll 309 - choosing b2 will prepare all interfaces for 24bits/96kHz but you'll
229 only be able to use one at the same time 310 only be able to use one at the same time
230 311
2312.2.3 - USB implementation details for this device 3123.2.3.2 - USB implementation details for this device
232 313
233You may safely skip this section if you're not interested in driver 314You may safely skip this section if you're not interested in driver
234development. 315hacking.
235 316
236This section describes some internal aspects of the device and summarize the 317This section describes some internal aspects of the device and summarizes the
237data I got by usb-snooping the windows and Linux drivers. 318data I got by usb-snooping the windows and Linux drivers.
238 319
239The M-Audio Audiophile USB has 7 USB Interfaces: 320The M-Audio Audiophile USB has 7 USB Interfaces:
@@ -293,43 +374,45 @@ parse_audio_endpoints function uses a quirk called
293"audiophile_skip_setting_quirk" in order to prevent AltSettings not 374"audiophile_skip_setting_quirk" in order to prevent AltSettings not
294corresponding to device_setup from being registered in the driver. 375corresponding to device_setup from being registered in the driver.
295 376
2963 - Audiophile USB and Jack support 3774 - Audiophile USB and Jack support
297=================================== 378===================================
298 379
299This section deals with support of the Audiophile USB device in Jack. 380This section deals with support of the Audiophile USB device in Jack.
300The main issue regarding this support is that the device is Big Endian
301compliant.
302 381
3033.1 - Using the plug alsa plugin 382There are 2 main potential issues when using Jackd with the device:
304-------------------------------- 383* support for Big-Endian devices in 24-bit modes
384* support for 4-in / 4-out channels
385
3864.1 - Direct support in Jackd
387-----------------------------
305 388
306Jack doesn't directly support big endian devices. Thus, one way to have support 389Jack supports big endian devices only in recent versions (thanks to
307for this device with Alsa is to use the Alsa "plug" converter. 390Andreas Steinmetz for his first big-endian patch). I can't remember
391extacly when this support was released into jackd, let's just say that
392with jackd version 0.103.0 it's almost ok (just a small bug is affecting
39316bits Big-Endian devices, but since you've read carefully the above
394paragraphs, you're now using kernel >= 2.6.23 and your 16bits devices
395are now Little Endians ;-) ).
396
397You can run jackd with the following command for playback with Ao and
398record with Ai:
399 % jackd -R -dalsa -Phw:1,0 -r48000 -p128 -n2 -D -Chw:1,1
400
4014.2 - Using Alsa plughw
402-----------------------
403If you don't have a recent Jackd installed, you can downgrade to using
404the Alsa "plug" converter.
308 405
309For instance here is one way to run Jack with 2 playback channels on Ao and 2 406For instance here is one way to run Jack with 2 playback channels on Ao and 2
310capture channels from Ai: 407capture channels from Ai:
311 % jackd -R -dalsa -dplughw:1 -r48000 -p256 -n2 -D -Cplughw:1,1 408 % jackd -R -dalsa -dplughw:1 -r48000 -p256 -n2 -D -Cplughw:1,1
312 409
313
314However you may see the following warning message: 410However you may see the following warning message:
315"You appear to be using the ALSA software "plug" layer, probably a result of 411"You appear to be using the ALSA software "plug" layer, probably a result of
316using the "default" ALSA device. This is less efficient than it could be. 412using the "default" ALSA device. This is less efficient than it could be.
317Consider using a hardware device instead rather than using the plug layer." 413Consider using a hardware device instead rather than using the plug layer."
318 414
3193.2 - Patching alsa to use direct pcm device 4154.3 - Getting 2 input and/or output interfaces in Jack
320--------------------------------------------
321A patch for Jack by Andreas Steinmetz adds support for Big Endian devices.
322However it has not been included in the CVS tree.
323
324You can find it at the following URL:
325http://sourceforge.net/tracker/index.php?func=detail&aid=1289682&group_id=39687&
326atid=425939
327
328After having applied the patch you can run jackd with the following command
329line:
330 % jackd -R -dalsa -Phw:1,0 -r48000 -p128 -n2 -D -Chw:1,1
331
3323.2 - Getting 2 input and/or output interfaces in Jack
333------------------------------------------------------ 416------------------------------------------------------
334 417
335As you can see, starting the Jack server this way will only enable 1 stereo 418As you can see, starting the Jack server this way will only enable 1 stereo
@@ -339,6 +422,7 @@ This is due to the following restrictions:
339* Jack can only open one capture device and one playback device at a time 422* Jack can only open one capture device and one playback device at a time
340* The Audiophile USB is seen as 2 (or three) Alsa devices: hw:1,0, hw:1,1 423* The Audiophile USB is seen as 2 (or three) Alsa devices: hw:1,0, hw:1,1
341 (and optionally hw:1,2) 424 (and optionally hw:1,2)
425
342If you want to get Ai+Di and/or Ao+Do support with Jack, you would need to 426If you want to get Ai+Di and/or Ao+Do support with Jack, you would need to
343combine the Alsa devices into one logical "complex" device. 427combine the Alsa devices into one logical "complex" device.
344 428
@@ -348,13 +432,11 @@ It is related to another device (ice1712) but can be adapted to suit
348the Audiophile USB. 432the Audiophile USB.
349 433
350Enabling multiple Audiophile USB interfaces for Jackd will certainly require: 434Enabling multiple Audiophile USB interfaces for Jackd will certainly require:
351* patching Jack with the previously mentioned "Big Endian" patch 435* Making sure your Jackd version has the MMAP_COMPLEX patch (see the ice1712 page)
352* patching Jackd with the MMAP_COMPLEX patch (see the ice1712 page) 436* (maybe) patching the alsa-lib/src/pcm/pcm_multi.c file (see the ice1712 page)
353* patching the alsa-lib/src/pcm/pcm_multi.c file (see the ice1712 page)
354* define a multi device (combination of hw:1,0 and hw:1,1) in your .asoundrc 437* define a multi device (combination of hw:1,0 and hw:1,1) in your .asoundrc
355 file 438 file
356* start jackd with this device 439* start jackd with this device
357 440
358I had no success in testing this for now, but this may be due to my OS 441I had no success in testing this for now, if you have any success with this kind
359configuration. If you have any success with this kind of setup, please 442of setup, please drop me an email.
360drop me an email.
diff --git a/Documentation/sound/alsa/OSS-Emulation.txt b/Documentation/sound/alsa/OSS-Emulation.txt
index ec2a02541d5b..bfa0c9aacb4b 100644
--- a/Documentation/sound/alsa/OSS-Emulation.txt
+++ b/Documentation/sound/alsa/OSS-Emulation.txt
@@ -278,6 +278,21 @@ current mixer configuration by reading and writing the whole file
278image. 278image.
279 279
280 280
281Duplex Streams
282==============
283
284Note that when attempting to use a single device file for playback and
285capture, the OSS API provides no way to set the format, sample rate or
286number of channels different in each direction. Thus
287 io_handle = open("device", O_RDWR)
288will only function correctly if the values are the same in each direction.
289
290To use different values in the two directions, use both
291 input_handle = open("device", O_RDONLY)
292 output_handle = open("device", O_WRONLY)
293and set the values for the corresponding handle.
294
295
281Unsupported Features 296Unsupported Features
282==================== 297====================
283 298
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index 9e6b94face4b..6711fbcf4080 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -1,11 +1,11 @@
1 ThinkPad ACPI Extras Driver 1 ThinkPad ACPI Extras Driver
2 2
3 Version 0.14 3 Version 0.15
4 April 21st, 2007 4 July 1st, 2007
5 5
6 Borislav Deianov <borislav@users.sf.net> 6 Borislav Deianov <borislav@users.sf.net>
7 Henrique de Moraes Holschuh <hmh@hmh.eng.br> 7 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
8 http://ibm-acpi.sf.net/ 8 http://ibm-acpi.sf.net/
9 9
10 10
11This is a Linux driver for the IBM and Lenovo ThinkPad laptops. It 11This is a Linux driver for the IBM and Lenovo ThinkPad laptops. It
@@ -134,54 +134,68 @@ end of this document. Changes to the sysfs interface done by the kernel
134subsystems are not documented here, nor are they tracked by this 134subsystems are not documented here, nor are they tracked by this
135attribute. 135attribute.
136 136
137Changes to the thinkpad-acpi sysfs interface are only considered
138non-experimental when they are submitted to Linux mainline, at which
139point the changes in this interface are documented and interface_version
140may be updated. If you are using any thinkpad-acpi features not yet
141sent to mainline for merging, you do so on your own risk: these features
142may disappear, or be implemented in a different and incompatible way by
143the time they are merged in Linux mainline.
144
145Changes that are backwards-compatible by nature (e.g. the addition of
146attributes that do not change the way the other attributes work) do not
147always warrant an update of interface_version. Therefore, one must
148expect that an attribute might not be there, and deal with it properly
149(an attribute not being there *is* a valid way to make it clear that a
150feature is not available in sysfs).
151
137Hot keys 152Hot keys
138-------- 153--------
139 154
140procfs: /proc/acpi/ibm/hotkey 155procfs: /proc/acpi/ibm/hotkey
141sysfs device attribute: hotkey_* 156sysfs device attribute: hotkey_*
142 157
143Without this driver, only the Fn-F4 key (sleep button) generates an 158In a ThinkPad, the ACPI HKEY handler is responsible for comunicating
144ACPI event. With the driver loaded, the hotkey feature enabled and the 159some important events and also keyboard hot key presses to the operating
145mask set (see below), the various hot keys generate ACPI events in the 160system. Enabling the hotkey functionality of thinkpad-acpi signals the
161firmware that such a driver is present, and modifies how the ThinkPad
162firmware will behave in many situations.
163
164When the hotkey feature is enabled and the hot key mask is set (see
165below), the various hot keys either generate ACPI events in the
146following format: 166following format:
147 167
148 ibm/hotkey HKEY 00000080 0000xxxx 168 ibm/hotkey HKEY 00000080 0000xxxx
149 169
150The last four digits vary depending on the key combination pressed. 170or events over the input layer. The input layer support accepts the
151All labeled Fn-Fx key combinations generate distinct events. In 171standard IOCTLs to remap the keycodes assigned to each hotkey.
152addition, the lid microswitch and some docking station buttons may 172
153also generate such events. 173When the input device is open, the driver will suppress any ACPI hot key
154 174events that get translated into a meaningful input layer event, in order
155The bit mask allows some control over which hot keys generate ACPI 175to avoid sending duplicate events to userspace. Hot keys that are
156events. Not all bits in the mask can be modified. Not all bits that 176mapped to KEY_RESERVED in the keymap are not translated, and will always
157can be modified do anything. Not all hot keys can be individually 177generate an ACPI ibm/hotkey HKEY event, and no input layer events.
158controlled by the mask. Most recent ThinkPad models honor the 178
159following bits (assuming the hot keys feature has been enabled): 179The hot key bit mask allows some control over which hot keys generate
160 180events. If a key is "masked" (bit set to 0 in the mask), the firmware
161 key bit behavior when set behavior when unset 181will handle it. If it is "unmasked", it signals the firmware that
162 182thinkpad-acpi would prefer to handle it, if the firmware would be so
163 Fn-F3 always generates ACPI event 183kind to allow it (and it often doesn't!).
164 Fn-F4 always generates ACPI event 184
165 Fn-F5 0010 generate ACPI event enable/disable Bluetooth 185Not all bits in the mask can be modified. Not all bits that can be
166 Fn-F7 0040 generate ACPI event switch LCD and external display 186modified do anything. Not all hot keys can be individually controlled
167 Fn-F8 0080 generate ACPI event expand screen or none 187by the mask. Some models do not support the mask at all, and in those
168 Fn-F9 0100 generate ACPI event none 188models, hot keys cannot be controlled individually. The behaviour of
169 Fn-F12 always generates ACPI event 189the mask is, therefore, higly dependent on the ThinkPad model.
170 190
171Some models do not support all of the above. For example, the T30 does 191Note that unmasking some keys prevents their default behavior. For
172not support Fn-F5 and Fn-F9. Other models do not support the mask at 192example, if Fn+F5 is unmasked, that key will no longer enable/disable
173all. On those models, hot keys cannot be controlled individually. 193Bluetooth by itself.
174 194
175Note that enabling ACPI events for some keys prevents their default 195Note also that not all Fn key combinations are supported through ACPI.
176behavior. For example, if events for Fn-F5 are enabled, that key will 196For example, on the X40, the brightness, volume and "Access IBM" buttons
177no longer enable/disable Bluetooth by itself. This can still be done 197do not generate ACPI events even with this driver. They *can* be used
178from an acpid handler for the ibm/hotkey event. 198through the "ThinkPad Buttons" utility, see http://www.nongnu.org/tpb/
179
180Note also that not all Fn key combinations are supported through
181ACPI. For example, on the X40, the brightness, volume and "Access IBM"
182buttons do not generate ACPI events even with this driver. They *can*
183be used through the "ThinkPad Buttons" utility, see
184http://www.nongnu.org/tpb/
185 199
186procfs notes: 200procfs notes:
187 201
@@ -189,9 +203,9 @@ The following commands can be written to the /proc/acpi/ibm/hotkey file:
189 203
190 echo enable > /proc/acpi/ibm/hotkey -- enable the hot keys feature 204 echo enable > /proc/acpi/ibm/hotkey -- enable the hot keys feature
191 echo disable > /proc/acpi/ibm/hotkey -- disable the hot keys feature 205 echo disable > /proc/acpi/ibm/hotkey -- disable the hot keys feature
192 echo 0xffff > /proc/acpi/ibm/hotkey -- enable all possible hot keys 206 echo 0xffffffff > /proc/acpi/ibm/hotkey -- enable all hot keys
193 echo 0x0000 > /proc/acpi/ibm/hotkey -- disable all possible hot keys 207 echo 0 > /proc/acpi/ibm/hotkey -- disable all possible hot keys
194 ... any other 4-hex-digit mask ... 208 ... any other 8-hex-digit mask ...
195 echo reset > /proc/acpi/ibm/hotkey -- restore the original mask 209 echo reset > /proc/acpi/ibm/hotkey -- restore the original mask
196 210
197sysfs notes: 211sysfs notes:
@@ -202,7 +216,7 @@ sysfs notes:
202 key feature status will be restored to this value. 216 key feature status will be restored to this value.
203 217
204 0: hot keys were disabled 218 0: hot keys were disabled
205 1: hot keys were enabled 219 1: hot keys were enabled (unusual)
206 220
207 hotkey_bios_mask: 221 hotkey_bios_mask:
208 Returns the hot keys mask when thinkpad-acpi was loaded. 222 Returns the hot keys mask when thinkpad-acpi was loaded.
@@ -217,9 +231,182 @@ sysfs notes:
217 1: enables the hot keys feature / feature enabled 231 1: enables the hot keys feature / feature enabled
218 232
219 hotkey_mask: 233 hotkey_mask:
220 bit mask to enable ACPI event generation for each hot 234 bit mask to enable driver-handling and ACPI event
221 key (see above). Returns the current status of the hot 235 generation for each hot key (see above). Returns the
222 keys mask, and allows one to modify it. 236 current status of the hot keys mask, and allows one to
237 modify it.
238
239 hotkey_all_mask:
240 bit mask that should enable event reporting for all
241 supported hot keys, when echoed to hotkey_mask above.
242 Unless you know which events need to be handled
243 passively (because the firmware *will* handle them
244 anyway), do *not* use hotkey_all_mask. Use
245 hotkey_recommended_mask, instead. You have been warned.
246
247 hotkey_recommended_mask:
248 bit mask that should enable event reporting for all
249 supported hot keys, except those which are always
250 handled by the firmware anyway. Echo it to
251 hotkey_mask above, to use.
252
253 hotkey_radio_sw:
254 if the ThinkPad has a hardware radio switch, this
255 attribute will read 0 if the switch is in the "radios
256 disabled" postition, and 1 if the switch is in the
257 "radios enabled" position.
258
259input layer notes:
260
261A Hot key is mapped to a single input layer EV_KEY event, possibly
262followed by an EV_MSC MSC_SCAN event that shall contain that key's scan
263code. An EV_SYN event will always be generated to mark the end of the
264event block.
265
266Do not use the EV_MSC MSC_SCAN events to process keys. They are to be
267used as a helper to remap keys, only. They are particularly useful when
268remapping KEY_UNKNOWN keys.
269
270The events are available in an input device, with the following id:
271
272 Bus: BUS_HOST
273 vendor: 0x1014 (PCI_VENDOR_ID_IBM) or
274 0x17aa (PCI_VENDOR_ID_LENOVO)
275 product: 0x5054 ("TP")
276 version: 0x4101
277
278The version will have its LSB incremented if the keymap changes in a
279backwards-compatible way. The MSB shall always be 0x41 for this input
280device. If the MSB is not 0x41, do not use the device as described in
281this section, as it is either something else (e.g. another input device
282exported by a thinkpad driver, such as HDAPS) or its functionality has
283been changed in a non-backwards compatible way.
284
285Adding other event types for other functionalities shall be considered a
286backwards-compatible change for this input device.
287
288Thinkpad-acpi Hot Key event map (version 0x4101):
289
290ACPI Scan
291event code Key Notes
292
2930x1001 0x00 FN+F1 -
2940x1002 0x01 FN+F2 IBM: battery (rare)
295 Lenovo: Screen lock
296
2970x1003 0x02 FN+F3 Many IBM models always report
298 this hot key, even with hot keys
299 disabled or with Fn+F3 masked
300 off
301 IBM: screen lock
302 Lenovo: battery
303
3040x1004 0x03 FN+F4 Sleep button (ACPI sleep button
305 semanthics, i.e. sleep-to-RAM).
306 It is always generate some kind
307 of event, either the hot key
308 event or a ACPI sleep button
309 event. The firmware may
310 refuse to generate further FN+F4
311 key presses until a S3 or S4 ACPI
312 sleep cycle is performed or some
313 time passes.
314
3150x1005 0x04 FN+F5 Radio. Enables/disables
316 the internal BlueTooth hardware
317 and W-WAN card if left in control
318 of the firmware. Does not affect
319 the WLAN card.
320 Should be used to turn on/off all
321 radios (bluetooth+W-WAN+WLAN),
322 really.
323
3240x1006 0x05 FN+F6 -
325
3260x1007 0x06 FN+F7 Video output cycle.
327 Do you feel lucky today?
328
3290x1008 0x07 FN+F8 IBM: toggle screen expand
330 Lenovo: configure ultranav
331
3320x1009 0x08 FN+F9 -
333 .. .. ..
3340x100B 0x0A FN+F11 -
335
3360x100C 0x0B FN+F12 Sleep to disk. You are always
337 supposed to handle it yourself,
338 either through the ACPI event,
339 or through a hotkey event.
340 The firmware may refuse to
341 generate further FN+F4 key
342 press events until a S3 or S4
343 ACPI sleep cycle is performed,
344 or some time passes.
345
3460x100D 0x0C FN+BACKSPACE -
3470x100E 0x0D FN+INSERT -
3480x100F 0x0E FN+DELETE -
349
3500x1010 0x0F FN+HOME Brightness up. This key is
351 always handled by the firmware
352 in IBM ThinkPads, even when
353 unmasked. Just leave it alone.
354 For Lenovo ThinkPads with a new
355 BIOS, it has to be handled either
356 by the ACPI OSI, or by userspace.
3570x1011 0x10 FN+END Brightness down. See brightness
358 up for details.
359
3600x1012 0x11 FN+PGUP Thinklight toggle. This key is
361 always handled by the firmware,
362 even when unmasked.
363
3640x1013 0x12 FN+PGDOWN -
365
3660x1014 0x13 FN+SPACE Zoom key
367
3680x1015 0x14 VOLUME UP Internal mixer volume up. This
369 key is always handled by the
370 firmware, even when unmasked.
371 NOTE: Lenovo seems to be changing
372 this.
3730x1016 0x15 VOLUME DOWN Internal mixer volume up. This
374 key is always handled by the
375 firmware, even when unmasked.
376 NOTE: Lenovo seems to be changing
377 this.
3780x1017 0x16 MUTE Mute internal mixer. This
379 key is always handled by the
380 firmware, even when unmasked.
381
3820x1018 0x17 THINKPAD Thinkpad/Access IBM/Lenovo key
383
3840x1019 0x18 unknown
385.. .. ..
3860x1020 0x1F unknown
387
388The ThinkPad firmware does not allow one to differentiate when most hot
389keys are pressed or released (either that, or we don't know how to, yet).
390For these keys, the driver generates a set of events for a key press and
391immediately issues the same set of events for a key release. It is
392unknown by the driver if the ThinkPad firmware triggered these events on
393hot key press or release, but the firmware will do it for either one, not
394both.
395
396If a key is mapped to KEY_RESERVED, it generates no input events at all,
397and it may generate a legacy thinkpad-acpi ACPI hotkey event.
398
399If a key is mapped to KEY_UNKNOWN, it generates an input event that
400includes an scan code, and it may also generate a legacy thinkpad-acpi
401ACPI hotkey event.
402
403If a key is mapped to anything else, it will only generate legacy
404thinkpad-acpi ACPI hotkey events if nobody has opened the input device.
405
406Non hot-key ACPI HKEY event map:
4070x5001 Lid closed
4080x5002 Lid opened
4090x7000 Radio Switch may have changed state
223 410
224 411
225Bluetooth 412Bluetooth
@@ -437,27 +624,34 @@ CMOS control
437procfs: /proc/acpi/ibm/cmos 624procfs: /proc/acpi/ibm/cmos
438sysfs device attribute: cmos_command 625sysfs device attribute: cmos_command
439 626
440This feature is used internally by the ACPI firmware to control the 627This feature is mostly used internally by the ACPI firmware to keep the legacy
441ThinkLight on most newer ThinkPad models. It may also control LCD 628CMOS NVRAM bits in sync with the current machine state, and to record this
442brightness, sounds volume and more, but only on some models. 629state so that the ThinkPad will retain such settings across reboots.
630
631Some of these commands actually perform actions in some ThinkPad models, but
632this is expected to disappear more and more in newer models. As an example, in
633a T43 and in a X40, commands 12 and 13 still control the ThinkLight state for
634real, but commands 0 to 2 don't control the mixer anymore (they have been
635phased out) and just update the NVRAM.
443 636
444The range of valid cmos command numbers is 0 to 21, but not all have an 637The range of valid cmos command numbers is 0 to 21, but not all have an
445effect and the behavior varies from model to model. Here is the behavior 638effect and the behavior varies from model to model. Here is the behavior
446on the X40 (tpb is the ThinkPad Buttons utility): 639on the X40 (tpb is the ThinkPad Buttons utility):
447 640
448 0 - no effect but tpb reports "Volume down" 641 0 - Related to "Volume down" key press
449 1 - no effect but tpb reports "Volume up" 642 1 - Related to "Volume up" key press
450 2 - no effect but tpb reports "Mute on" 643 2 - Related to "Mute on" key press
451 3 - simulate pressing the "Access IBM" button 644 3 - Related to "Access IBM" key press
452 4 - LCD brightness up 645 4 - Related to "LCD brightness up" key pess
453 5 - LCD brightness down 646 5 - Related to "LCD brightness down" key press
454 11 - toggle screen expansion 647 11 - Related to "toggle screen expansion" key press/function
455 12 - ThinkLight on 648 12 - Related to "ThinkLight on"
456 13 - ThinkLight off 649 13 - Related to "ThinkLight off"
457 14 - no effect but tpb reports ThinkLight status change 650 14 - Related to "ThinkLight" key press (toggle thinklight)
458 651
459The cmos command interface is prone to firmware split-brain problems, as 652The cmos command interface is prone to firmware split-brain problems, as
460in newer ThinkPads it is just a compatibility layer. 653in newer ThinkPads it is just a compatibility layer. Do not use it, it is
654exported just as a debug tool.
461 655
462LED control -- /proc/acpi/ibm/led 656LED control -- /proc/acpi/ibm/led
463--------------------------------- 657---------------------------------
@@ -516,23 +710,15 @@ Temperature sensors
516procfs: /proc/acpi/ibm/thermal 710procfs: /proc/acpi/ibm/thermal
517sysfs device attributes: (hwmon) temp*_input 711sysfs device attributes: (hwmon) temp*_input
518 712
519Most ThinkPads include six or more separate temperature sensors but 713Most ThinkPads include six or more separate temperature sensors but only
520only expose the CPU temperature through the standard ACPI methods. 714expose the CPU temperature through the standard ACPI methods. This
521This feature shows readings from up to eight different sensors on older 715feature shows readings from up to eight different sensors on older
522ThinkPads, and it has experimental support for up to sixteen different 716ThinkPads, and up to sixteen different sensors on newer ThinkPads.
523sensors on newer ThinkPads.
524
525EXPERIMENTAL: The 16-sensors feature is marked EXPERIMENTAL because the
526implementation directly accesses hardware registers and may not work as
527expected. USE WITH CAUTION! To use this feature, you need to supply the
528experimental=1 parameter when loading the module. When EXPERIMENTAL
529mode is enabled, reading the first 8 sensors on newer ThinkPads will
530also use an new experimental thermal sensor access mode.
531 717
532For example, on the X40, a typical output may be: 718For example, on the X40, a typical output may be:
533temperatures: 42 42 45 41 36 -128 33 -128 719temperatures: 42 42 45 41 36 -128 33 -128
534 720
535EXPERIMENTAL: On the T43/p, a typical output may be: 721On the T43/p, a typical output may be:
536temperatures: 48 48 36 52 38 -128 31 -128 48 52 48 -128 -128 -128 -128 -128 722temperatures: 48 48 36 52 38 -128 31 -128 48 52 48 -128 -128 -128 -128 -128
537 723
538The mapping of thermal sensors to physical locations varies depending on 724The mapping of thermal sensors to physical locations varies depending on
@@ -562,7 +748,8 @@ http://thinkwiki.org/wiki/Thermal_Sensors#ThinkPad_T43.2C_T43p
5622: System board, left side (near PCMCIA slot), reported as HDAPS temp 7482: System board, left side (near PCMCIA slot), reported as HDAPS temp
5633: PCMCIA slot 7493: PCMCIA slot
5649: MCH (northbridge) to DRAM Bus 7509: MCH (northbridge) to DRAM Bus
56510: ICH (southbridge), under Mini-PCI card, under touchpad 75110: Clock-generator, mini-pci card and ICH (southbridge), under Mini-PCI
752 card, under touchpad
56611: Power regulator, underside of system board, below F2 key 75311: Power regulator, underside of system board, below F2 key
567 754
568The A31 has a very atypical layout for the thermal sensors 755The A31 has a very atypical layout for the thermal sensors
@@ -681,6 +868,12 @@ cannot be controlled.
681The backlight control has eight levels, ranging from 0 to 7. Some of the 868The backlight control has eight levels, ranging from 0 to 7. Some of the
682levels may not be distinct. 869levels may not be distinct.
683 870
871There are two interfaces to the firmware for brightness control, EC and CMOS.
872To select which one should be used, use the brightness_mode module parameter:
873brightness_mode=1 selects EC mode, brightness_mode=2 selects CMOS mode,
874brightness_mode=3 selects both EC and CMOS. The driver tries to autodetect
875which interface to use.
876
684Procfs notes: 877Procfs notes:
685 878
686 The available commands are: 879 The available commands are:
@@ -976,3 +1169,9 @@ Sysfs interface changelog:
976 1169
9770x000100: Initial sysfs support, as a single platform driver and 11700x000100: Initial sysfs support, as a single platform driver and
978 device. 1171 device.
11720x000200: Hot key support for 32 hot keys, and radio slider switch
1173 support.
11740x010000: Hot keys are now handled by default over the input
1175 layer, the radio switch generates input event EV_RADIO,
1176 and the driver enables hot key handling by default in
1177 the firmware.
diff --git a/Documentation/time_interpolators.txt b/Documentation/time_interpolators.txt
deleted file mode 100644
index e3b60854fbc2..000000000000
--- a/Documentation/time_interpolators.txt
+++ /dev/null
@@ -1,41 +0,0 @@
1Time Interpolators
2------------------
3
4Time interpolators are a base of time calculation between timer ticks and
5allow an accurate determination of time down to the accuracy of the time
6source in nanoseconds.
7
8The architecture specific code typically provides gettimeofday and
9settimeofday under Linux. The time interpolator provides both if an arch
10defines CONFIG_TIME_INTERPOLATION. The arch still must set up timer tick
11operations and call the necessary functions to advance the clock.
12
13With the time interpolator a standardized interface exists for time
14interpolation between ticks. The provided logic is highly scalable
15and has been tested in SMP situations of up to 512 CPUs.
16
17If CONFIG_TIME_INTERPOLATION is defined then the architecture specific code
18(or the device drivers - like HPET) may register time interpolators.
19These are typically defined in the following way:
20
21static struct time_interpolator my_interpolator {
22 .frequency = MY_FREQUENCY,
23 .source = TIME_SOURCE_MMIO32,
24 .shift = 8, /* scaling for higher accuracy */
25 .drift = -1, /* Unknown drift */
26 .jitter = 0 /* time source is stable */
27};
28
29void time_init(void)
30{
31 ....
32 /* Initialization of the timer *.
33 my_interpolator.address = &my_timer;
34 register_time_interpolator(&my_interpolator);
35 ....
36}
37
38For more details see include/linux/timex.h and kernel/timer.c.
39
40Christoph Lameter <christoph@lameter.com>, October 31, 2004
41
diff --git a/Documentation/video4linux/CARDLIST.bttv b/Documentation/video4linux/CARDLIST.bttv
index b60639130a51..177159c5f4c4 100644
--- a/Documentation/video4linux/CARDLIST.bttv
+++ b/Documentation/video4linux/CARDLIST.bttv
@@ -66,7 +66,7 @@
66 65 -> Lifeview FlyVideo 2000S LR90 66 65 -> Lifeview FlyVideo 2000S LR90
67 66 -> Terratec TValueRadio [153b:1135,153b:ff3b] 67 66 -> Terratec TValueRadio [153b:1135,153b:ff3b]
68 67 -> IODATA GV-BCTV4/PCI [10fc:4050] 68 67 -> IODATA GV-BCTV4/PCI [10fc:4050]
69 68 -> 3Dfx VoodooTV FM (Euro), VoodooTV 200 (USA) [121a:3000,10b4:2637] 69 68 -> 3Dfx VoodooTV FM (Euro) [10b4:2637]
70 69 -> Active Imaging AIMMS 70 69 -> Active Imaging AIMMS
71 70 -> Prolink Pixelview PV-BT878P+ (Rev.4C,8E) 71 70 -> Prolink Pixelview PV-BT878P+ (Rev.4C,8E)
72 71 -> Lifeview FlyVideo 98EZ (capture only) LR51 [1851:1851] 72 71 -> Lifeview FlyVideo 98EZ (capture only) LR51 [1851:1851]
@@ -145,3 +145,5 @@
145144 -> MagicTV 145144 -> MagicTV
146145 -> SSAI Security Video Interface [4149:5353] 146145 -> SSAI Security Video Interface [4149:5353]
147146 -> SSAI Ultrasound Video Interface [414a:5353] 147146 -> SSAI Ultrasound Video Interface [414a:5353]
148147 -> VoodooTV 200 (USA) [121a:3000]
149148 -> DViCO FusionHDTV 2 [dbc0:d200]
diff --git a/Documentation/video4linux/CARDLIST.cx88 b/Documentation/video4linux/CARDLIST.cx88
index 60f838beb9c8..82ac8250e978 100644
--- a/Documentation/video4linux/CARDLIST.cx88
+++ b/Documentation/video4linux/CARDLIST.cx88
@@ -55,3 +55,4 @@
55 54 -> Norwood Micro TV Tuner 55 54 -> Norwood Micro TV Tuner
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]
diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134
index 712e8c8333cc..3f8aeab50a10 100644
--- a/Documentation/video4linux/CARDLIST.saa7134
+++ b/Documentation/video4linux/CARDLIST.saa7134
@@ -114,3 +114,4 @@
114113 -> Elitegroup ECS TVP3XP FM1246 Tuner Card (PAL,FM) [1019:4cb6] 114113 -> Elitegroup ECS TVP3XP FM1246 Tuner Card (PAL,FM) [1019:4cb6]
115114 -> KWorld DVB-T 210 [17de:7250] 115114 -> KWorld DVB-T 210 [17de:7250]
116115 -> Sabrent PCMCIA TV-PCB05 [0919:2003] 116115 -> Sabrent PCMCIA TV-PCB05 [0919:2003]
117116 -> 10MOONS TM300 TV Card [1131:2304]
diff --git a/Documentation/video4linux/CARDLIST.tuner b/Documentation/video4linux/CARDLIST.tuner
index 44134f04b82a..a88c02d23805 100644
--- a/Documentation/video4linux/CARDLIST.tuner
+++ b/Documentation/video4linux/CARDLIST.tuner
@@ -40,7 +40,7 @@ tuner=38 - Philips PAL/SECAM multi (FM1216ME MK3)
40tuner=39 - LG NTSC (newer TAPC series) 40tuner=39 - LG NTSC (newer TAPC series)
41tuner=40 - HITACHI V7-J180AT 41tuner=40 - HITACHI V7-J180AT
42tuner=41 - Philips PAL_MK (FI1216 MK) 42tuner=41 - Philips PAL_MK (FI1216 MK)
43tuner=42 - Philips 1236D ATSC/NTSC dual in 43tuner=42 - Philips FCV1236D ATSC/NTSC dual in
44tuner=43 - Philips NTSC MK3 (FM1236MK3 or FM1236/F) 44tuner=43 - Philips NTSC MK3 (FM1236MK3 or FM1236/F)
45tuner=44 - Philips 4 in 1 (ATI TV Wonder Pro/Conexant) 45tuner=44 - Philips 4 in 1 (ATI TV Wonder Pro/Conexant)
46tuner=45 - Microtune 4049 FM5 46tuner=45 - Microtune 4049 FM5
@@ -72,3 +72,4 @@ tuner=70 - Samsung TCPN 2121P30A
72tuner=71 - Xceive xc3028 72tuner=71 - Xceive xc3028
73tuner=72 - Thomson FE6600 73tuner=72 - Thomson FE6600
74tuner=73 - Samsung TCPG 6121P30A 74tuner=73 - Samsung TCPG 6121P30A
75tuner=75 - Philips TEA5761 FM Radio
diff --git a/Documentation/video4linux/sn9c102.txt b/Documentation/video4linux/sn9c102.txt
index 279717c96f63..1ffad19ce891 100644
--- a/Documentation/video4linux/sn9c102.txt
+++ b/Documentation/video4linux/sn9c102.txt
@@ -436,7 +436,7 @@ HV7131D Hynix Semiconductor | Yes No No No
436HV7131R Hynix Semiconductor | No Yes Yes Yes 436HV7131R Hynix Semiconductor | No Yes Yes Yes
437MI-0343 Micron Technology | Yes No No No 437MI-0343 Micron Technology | Yes No No No
438MI-0360 Micron Technology | No Yes Yes Yes 438MI-0360 Micron Technology | No Yes Yes Yes
439OV7630 OmniVision Technologies | Yes Yes No No 439OV7630 OmniVision Technologies | Yes Yes Yes Yes
440OV7660 OmniVision Technologies | No No Yes Yes 440OV7660 OmniVision Technologies | No No Yes Yes
441PAS106B PixArt Imaging | Yes No No No 441PAS106B PixArt Imaging | Yes No No No
442PAS202B PixArt Imaging | Yes Yes No No 442PAS202B PixArt Imaging | Yes Yes No No
@@ -583,6 +583,7 @@ order):
583- Bertrik Sikken, who reverse-engineered and documented the Huffman compression 583- Bertrik Sikken, who reverse-engineered and documented the Huffman compression
584 algorithm used in the SN9C101, SN9C102 and SN9C103 controllers and 584 algorithm used in the SN9C101, SN9C102 and SN9C103 controllers and
585 implemented the first decoder; 585 implemented the first decoder;
586- Ronny Standke for the donation of a webcam;
586- Mizuno Takafumi for the donation of a webcam; 587- Mizuno Takafumi for the donation of a webcam;
587- an "anonymous" donator (who didn't want his name to be revealed) for the 588- an "anonymous" donator (who didn't want his name to be revealed) for the
588 donation of a webcam. 589 donation of a webcam.
diff --git a/Documentation/video4linux/zr364xx.txt b/Documentation/video4linux/zr364xx.txt
index c76992d0ff4d..4d9a0c33f2fd 100644
--- a/Documentation/video4linux/zr364xx.txt
+++ b/Documentation/video4linux/zr364xx.txt
@@ -62,4 +62,4 @@ Vendor Product Distributor Model
620x0784 0x0040 Traveler Slimline X5 620x0784 0x0040 Traveler Slimline X5
630x06d6 0x0034 Trust Powerc@m 750 630x06d6 0x0034 Trust Powerc@m 750
640x0a17 0x0062 Pentax Optio 50L 640x0a17 0x0062 Pentax Optio 50L
65 650x06d6 0x003b Trust Powerc@m 970Z
diff --git a/Documentation/x86_64/boot-options.txt b/Documentation/x86_64/boot-options.txt
index 6177d881983f..945311840a10 100644
--- a/Documentation/x86_64/boot-options.txt
+++ b/Documentation/x86_64/boot-options.txt
@@ -14,9 +14,11 @@ Machine check
14 mce=nobootlog 14 mce=nobootlog
15 Disable boot machine check logging. 15 Disable boot machine check logging.
16 mce=tolerancelevel (number) 16 mce=tolerancelevel (number)
17 0: always panic, 1: panic if deadlock possible, 17 0: always panic on uncorrected errors, log corrected errors
18 2: try to avoid panic, 3: never panic or exit (for testing) 18 1: panic or SIGBUS on uncorrected errors, log corrected errors
19 default is 1 19 2: SIGBUS or log uncorrected errors, log corrected errors
20 3: never panic or SIGBUS, log all errors (for testing only)
21 Default is 1
20 Can be also set using sysfs which is preferable. 22 Can be also set using sysfs which is preferable.
21 23
22 nomce (for compatibility with i386): same as mce=off 24 nomce (for compatibility with i386): same as mce=off
@@ -134,12 +136,6 @@ Non Executable Mappings
134 136
135SMP 137SMP
136 138
137 nosmp Only use a single CPU
138
139 maxcpus=NUMBER only use upto NUMBER CPUs
140
141 cpumask=MASK only use cpus with bits set in mask
142
143 additional_cpus=NUM Allow NUM more CPUs for hotplug 139 additional_cpus=NUM Allow NUM more CPUs for hotplug
144 (defaults are specified by the BIOS, see Documentation/x86_64/cpu-hotplug-spec) 140 (defaults are specified by the BIOS, see Documentation/x86_64/cpu-hotplug-spec)
145 141
diff --git a/Documentation/x86_64/machinecheck b/Documentation/x86_64/machinecheck
index feaeaf6f6e4d..a05e58e7b159 100644
--- a/Documentation/x86_64/machinecheck
+++ b/Documentation/x86_64/machinecheck
@@ -49,12 +49,14 @@ tolerant
49 Since machine check exceptions can happen any time it is sometimes 49 Since machine check exceptions can happen any time it is sometimes
50 risky for the kernel to kill a process because it defies 50 risky for the kernel to kill a process because it defies
51 normal kernel locking rules. The tolerance level configures 51 normal kernel locking rules. The tolerance level configures
52 how hard the kernel tries to recover even at some risk of deadlock. 52 how hard the kernel tries to recover even at some risk of
53 53 deadlock. Higher tolerant values trade potentially better uptime
54 0: always panic, 54 with the risk of a crash or even corruption (for tolerant >= 3).
55 1: panic if deadlock possible, 55
56 2: try to avoid panic, 56 0: always panic on uncorrected errors, log corrected errors
57 3: never panic or exit (for testing only) 57 1: panic or SIGBUS on uncorrected errors, log corrected errors
58 2: SIGBUS or log uncorrected errors, log corrected errors
59 3: never panic or SIGBUS, log all errors (for testing only)
58 60
59 Default: 1 61 Default: 1
60 62
diff --git a/Documentation/zh_CN/HOWTO b/Documentation/zh_CN/HOWTO
new file mode 100644
index 000000000000..48fc67bfbe3d
--- /dev/null
+++ b/Documentation/zh_CN/HOWTO
@@ -0,0 +1,536 @@
1Chinese translated version of Documentation/HOWTO
2
3If you have any comment or update to the content, please contact the
4original document maintainer directly. However, if you have problem
5communicating in English you can also ask the Chinese maintainer for
6help. Contact the Chinese maintainer, if this translation is outdated
7or there is problem with translation.
8
9Maintainer: Greg Kroah-Hartman <greg@kroah.com>
10Chinese maintainer: Li Yang <leoli@freescale.com>
11---------------------------------------------------------------------
12Documentation/HOWTO 的中文翻译
13
14如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
15交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
16译存在问题,请联系中文版维护者。
17
18英文版维护者: Greg Kroah-Hartman <greg@kroah.com>
19中文版维护者: 李阳 Li Yang <leoli@freescale.com>
20中文版翻译者: 李阳 Li Yang <leoli@freescale.com>
21中文版校译者: 钟宇 TripleX Chung <xxx.phy@gmail.com>
22 陈琦 Maggie Chen <chenqi@beyondsoft.com>
23 王聪 Wang Cong <xiyou.wangcong@gmail.com>
24
25以下为正文
26---------------------------------------------------------------------
27
28如何参与Linux内核开发
29---------------------
30
31这是一篇将如何参与Linux内核开发的相关问题一网打尽的终极秘笈。它将指导你
32成为一名Linux内核开发者,并且学会如何同Linux内核开发社区合作。它尽可能不
33包括任何关于内核编程的技术细节,但会给你指引一条获得这些知识的正确途径。
34
35如果这篇文章中的任何内容不再适用,请给文末列出的文件维护者发送补丁。
36
37
38入门
39----
40
41你想了解如何成为一名Linux内核开发者?或者老板吩咐你“给这个设备写个Linux
42驱动程序”?这篇文章的目的就是教会你达成这些目标的全部诀窍,它将描述你需
43要经过的流程以及给出如何同内核社区合作的一些提示。它还将试图解释内核社区
44为何这样运作。
45
46Linux内核大部分是由C语言写成的,一些体系结构相关的代码用到了汇编语言。要
47参与内核开发,你必须精通C语言。除非你想为某个架构开发底层代码,否则你并
48不需要了解(任何体系结构的)汇编语言。下面列举的书籍虽然不能替代扎实的C
49语言教育和多年的开发经验,但如果需要的话,做为参考还是不错的:
50 - "The C Programming Language" by Kernighan and Ritchie [Prentice Hall]
51 《C程序设计语言(第2版·新版)》(徐宝文 李志 译)[机械工业出版社]
52 - "Practical C Programming" by Steve Oualline [O'Reilly]
53 《实用C语言编程(第三版)》(郭大海 译)[中国电力出版社]
54 - "C: A Reference Manual" by Harbison and Steele [Prentice Hall]
55 《C语言参考手册(原书第5版)》(邱仲潘 等译)[机械工业出版社]
56
57Linux内核使用GNU C和GNU工具链开发。虽然它遵循ISO C89标准,但也用到了一些
58标准中没有定义的扩展。内核是自给自足的C环境,不依赖于标准C库的支持,所以
59并不支持C标准中的部分定义。比如long long类型的大数除法和浮点运算就不允许
60使用。有时候确实很难弄清楚内核对工具链的要求和它所使用的扩展,不幸的是目
61前还没有明确的参考资料可以解释它们。请查阅gcc信息页(使用“info gcc”命令
62显示)获得一些这方面信息。
63
64请记住你是在学习怎么和已经存在的开发社区打交道。它由一群形形色色的人组成,
65他们对代码、风格和过程有着很高的标准。这些标准是在长期实践中总结出来的,
66适应于地理上分散的大型开发团队。它们已经被很好得整理成档,建议你在开发
67之前尽可能多的学习这些标准,而不要期望别人来适应你或者你公司的行为方式。
68
69
70法律问题
71--------
72
73Linux内核源代码都是在GPL(通用公共许可证)的保护下发布的。要了解这种许可
74的细节请查看源代码主目录下的COPYING文件。如果你对它还有更深入问题请联系
75律师,而不要在Linux内核邮件组上提问。因为邮件组里的人并不是律师,不要期
76望他们的话有法律效力。
77
78对于GPL的常见问题和解答,请访问以下链接:
79 http://www.gnu.org/licenses/gpl-faq.html
80
81
82文档
83----
84
85Linux内核代码中包含有大量的文档。这些文档对于学习如何与内核社区互动有着
86不可估量的价值。当一个新的功能被加入内核,最好把解释如何使用这个功能的文
87档也放进内核。当内核的改动导致面向用户空间的接口发生变化时,最好将相关信
88息或手册页(manpages)的补丁发到mtk-manpages@gmx.net,以向手册页(manpages)
89的维护者解释这些变化。
90
91以下是内核代码中需要阅读的文档:
92 README
93 文件简要介绍了Linux内核的背景,并且描述了如何配置和编译内核。内核的
94 新用户应该从这里开始。
95
96 Documentation/Changes
97 文件给出了用来编译和使用内核所需要的最小软件包列表。
98
99 Documentation/CodingStyle
100 描述Linux内核的代码风格和理由。所有新代码需要遵守这篇文档中定义的规
101 范。大多数维护者只会接收符合规定的补丁,很多人也只会帮忙检查符合风格
102 的代码。
103
104 Documentation/SubmittingPatches
105 Documentation/SubmittingDrivers
106 这两份文档明确描述如何创建和发送补丁,其中包括(但不仅限于):
107 - 邮件内容
108 - 邮件格式
109 - 选择收件人
110 遵守这些规定并不能保证提交成功(因为所有补丁需要通过严格的内容和风格
111 审查),但是忽视他们几乎就意味着失败。
112
113 其他关于如何正确地生成补丁的优秀文档包括:
114 "The Perfect Patch"
115 http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt
116 "Linux kernel patch submission format"
117 http://linux.yyz.us/patch-format.html
118
119 Documentation/stable_api_nonsense.txt
120 论证内核为什么特意不包括稳定的内核内部API,也就是说不包括像这样的特
121 性:
122 - 子系统中间层(为了兼容性?)
123 - 在不同操作系统间易于移植的驱动程序
124 - 减缓(甚至阻止)内核代码的快速变化
125 这篇文档对于理解Linux的开发哲学至关重要。对于将开发平台从其他操作系
126 统转移到Linux的人来说也很重要。
127
128 Documentation/SecurityBugs
129 如果你认为自己发现了Linux内核的安全性问题,请根据这篇文档中的步骤来
130 提醒其他内核开发者并帮助解决这个问题。
131
132 Documentation/ManagementStyle
133 描述内核维护者的工作方法及其共有特点。这对于刚刚接触内核开发(或者对
134 它感到好奇)的人来说很重要,因为它解释了很多对于内核维护者独特行为的
135 普遍误解与迷惑。
136
137 Documentation/stable_kernel_rules.txt
138 解释了稳定版内核发布的规则,以及如何将改动放入这些版本的步骤。
139
140 Documentation/kernel-docs.txt
141 有助于内核开发的外部文档列表。如果你在内核自带的文档中没有找到你想找
142 的内容,可以查看这些文档。
143
144 Documentation/applying-patches.txt
145 关于补丁是什么以及如何将它打在不同内核开发分支上的好介绍
146
147内核还拥有大量从代码自动生成的文档。它包含内核内部API的全面介绍以及如何
148妥善处理加锁的规则。生成的文档会放在 Documentation/DocBook/目录下。在内
149核源码的主目录中使用以下不同命令将会分别生成PDF、Postscript、HTML和手册
150页等不同格式的文档:
151 make pdfdocs
152 make psdocs
153 make htmldocs
154 make mandocs
155
156
157如何成为内核开发者
158------------------
159如果你对Linux内核开发一无所知,你应该访问“Linux内核新手”计划:
160 http://kernelnewbies.org
161它拥有一个可以问各种最基本的内核开发问题的邮件列表(在提问之前一定要记得
162查找已往的邮件,确认是否有人已经回答过相同的问题)。它还拥有一个可以获得
163实时反馈的IRC聊天频道,以及大量对于学习Linux内核开发相当有帮助的文档。
164
165网站简要介绍了源代码组织结构、子系统划分以及目前正在进行的项目(包括内核
166中的和单独维护的)。它还提供了一些基本的帮助信息,比如如何编译内核和打补
167丁。
168
169如果你想加入内核开发社区并协助完成一些任务,却找不到从哪里开始,可以访问
170“Linux内核房管员”计划:
171 http://janitor.kernelnewbies.org/
172这是极佳的起点。它提供一个相对简单的任务列表,列出内核代码中需要被重新
173整理或者改正的地方。通过和负责这个计划的开发者们一同工作,你会学到将补丁
174集成进内核的基本原理。如果还没有决定下一步要做什么的话,你还可能会得到方
175向性的指点。
176
177如果你已经有一些现成的代码想要放到内核中,但是需要一些帮助来使它们拥有正
178确的格式。请访问“内核导师”计划。这个计划就是用来帮助你完成这个目标的。它
179是一个邮件列表,地址如下:
180 http://selenic.com/mailman/listinfo/kernel-mentors
181
182在真正动手修改内核代码之前,理解要修改的代码如何运作是必需的。要达到这个
183目的,没什么办法比直接读代码更有效了(大多数花招都会有相应的注释),而且
184一些特制的工具还可以提供帮助。例如,“Linux代码交叉引用”项目就是一个值得
185特别推荐的帮助工具,它将源代码显示在有编目和索引的网页上。其中一个更新及
186时的内核源码库,可以通过以下地址访问:
187 http://sosdg.org/~coywolf/lxr/
188
189
190开发流程
191--------
192
193目前Linux内核开发流程包括几个“主内核分支”和很多子系统相关的内核分支。这
194些分支包括:
195 - 2.6.x主内核源码树
196 - 2.6.x.y -stable内核源码树
197 - 2.6.x -git内核补丁集
198 - 2.6.x -mm内核补丁集
199 - 子系统相关的内核源码树和补丁集
200
201
2022.6.x内核主源码树
203-----------------
2042.6.x内核是由Linus Torvalds(Linux的创造者)亲自维护的。你可以在
205kernel.org网站的pub/linux/kernel/v2.6/目录下找到它。它的开发遵循以下步
206骤:
207 - 每当一个新版本的内核被发布,为期两周的集成窗口将被打开。在这段时间里
208 维护者可以向Linus提交大段的修改,通常这些修改已经被放到-mm内核中几个
209 星期了。提交大量修改的首选方式是使用git工具(内核的代码版本管理工具
210 ,更多的信息可以在http://git.or.cz/获取),不过使用普通补丁也是可以
211 的。
212 - 两个星期以后-rc1版本内核发布。之后只有不包含可能影响整个内核稳定性的
213 新功能的补丁才可能被接受。请注意一个全新的驱动程序(或者文件系统)有
214 可能在-rc1后被接受是因为这样的修改完全独立,不会影响其他的代码,所以
215 没有造成内核退步的风险。在-rc1以后也可以用git向Linus提交补丁,不过所
216 有的补丁需要同时被发送到相应的公众邮件列表以征询意见。
217 - 当Linus认为当前的git源码树已经达到一个合理健全的状态足以发布供人测试
218 时,一个新的-rc版本就会被发布。计划是每周都发布新的-rc版本。
219 - 这个过程一直持续下去直到内核被认为达到足够稳定的状态,持续时间大概是
220 6个星期。
221
222关于内核发布,值得一提的是Andrew Morton在linux-kernel邮件列表中如是说:
223 “没有人知道新内核何时会被发布,因为发布是根据已知bug的情况来决定
224 的,而不是根据一个事先制定好的时间表。”
225
226
2272.6.x.y -stable(稳定版)内核源码树
228-----------------------------------
229由4个数字组成的内核版本号说明此内核是-stable版本。它们包含基于2.6.x版本
230内核的相对较小且至关重要的修补,这些修补针对安全性问题或者严重的内核退步。
231
232这种版本的内核适用于那些期望获得最新的稳定版内核并且不想参与测试开发版或
233者实验版的用户。
234
235如果没有2.6.x.y版本内核存在,那么最新的2.6.x版本内核就相当于是当前的稳定
236版内核。
237
2382.6.x.y版本由“稳定版”小组(邮件地址<stable@kernel.org>)维护,一般隔周发
239布新版本。
240
241内核源码中的Documentation/stable_kernel_rules.txt文件具体描述了可被稳定
242版内核接受的修改类型以及发布的流程。
243
244
2452.6.x -git补丁集
246----------------
247Linus的内核源码树的每日快照,这个源码树是由git工具管理的(由此得名)。这
248些补丁通常每天更新以反映Linus的源码树的最新状态。它们比-rc版本的内核源码
249树更具试验性质,因为这个补丁集是全自动生成的,没有任何人来确认其是否真正
250健全。
251
252
2532.6.x -mm补丁集
254---------------
255这是由Andrew Morton维护的试验性内核补丁集。Andrew将所有子系统的内核源码
256和补丁拼凑到一起,并且加入了大量从linux-kernel邮件列表中采集的补丁。这个
257源码树是新功能和补丁的试炼场。当补丁在-mm补丁集里证明了其价值以后Andrew
258或者相应子系统的维护者会将补丁发给Linus以便集成进主内核源码树。
259
260在将所有新补丁发给Linus以集成到主内核源码树之前,我们非常鼓励先把这些补
261丁放在-mm版内核源码树中进行测试。
262
263这些内核版本不适合在需要稳定运行的系统上运行,因为运行它们比运行任何其他
264内核分支都更具有风险。
265
266如果你想为内核开发进程提供帮助,请尝试并使用这些内核版本,并在
267linux-kernel邮件列表中提供反馈,告诉大家你遇到了问题还是一切正常。
268
269通常-mm版补丁集不光包括这些额外的试验性补丁,还包括发布时-git版主源码树
270中的改动。
271
272-mm版内核没有固定的发布周期,但是通常在每两个-rc版内核发布之间都会有若干
273个-mm版内核发布(一般是1至3个)。
274
275
276子系统相关内核源码树和补丁集
277----------------------------
278相当一部分内核子系统开发者会公开他们自己的开发源码树,以便其他人能了解内
279核的不同领域正在发生的事情。如上所述,这些源码树会被集成到-mm版本内核中。
280
281下面是目前可用的一些内核源码树的列表:
282 通过git管理的源码树:
283 - Kbuild开发源码树, Sam Ravnborg <sam@ravnborg.org>
284 git.kernel.org:/pub/scm/linux/kernel/git/sam/kbuild.git
285
286 - ACPI开发源码树, Len Brown <len.brown@intel.com>
287 git.kernel.org:/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6.git
288
289 - 块设备开发源码树, Jens Axboe <axboe@suse.de>
290 git.kernel.org:/pub/scm/linux/kernel/git/axboe/linux-2.6-block.git
291
292 - DRM开发源码树, Dave Airlie <airlied@linux.ie>
293 git.kernel.org:/pub/scm/linux/kernel/git/airlied/drm-2.6.git
294
295 - ia64开发源码树, Tony Luck <tony.luck@intel.com>
296 git.kernel.org:/pub/scm/linux/kernel/git/aegl/linux-2.6.git
297
298 - ieee1394开发源码树, Jody McIntyre <scjody@modernduck.com>
299 git.kernel.org:/pub/scm/linux/kernel/git/scjody/ieee1394.git
300
301 - infiniband开发源码树, Roland Dreier <rolandd@cisco.com>
302 git.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git
303
304 - libata开发源码树, Jeff Garzik <jgarzik@pobox.com>
305 git.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git
306
307 - 网络驱动程序开发源码树, Jeff Garzik <jgarzik@pobox.com>
308 git.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6.git
309
310 - pcmcia开发源码树, Dominik Brodowski <linux@dominikbrodowski.net>
311 git.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6.git
312
313 - SCSI开发源码树, James Bottomley <James.Bottomley@SteelEye.com>
314 git.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git
315
316 使用quilt管理的补丁集:
317 - USB, PCI, 驱动程序核心和I2C, Greg Kroah-Hartman <gregkh@suse.de>
318 kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/
319 - x86-64, 部分i386, Andi Kleen <ak@suse.de>
320 ftp.firstfloor.org:/pub/ak/x86_64/quilt/
321
322 其他内核源码树可以在http://git.kernel.org的列表中和MAINTAINERS文件里
323 找到。
324
325报告bug
326-------
327
328bugzilla.kernel.org是Linux内核开发者们用来跟踪内核Bug的网站。我们鼓励用
329户在这个工具中报告找到的所有bug。如何使用内核bugzilla的细节请访问:
330 http://test.kernel.org/bugzilla/faq.html
331
332内核源码主目录中的REPORTING-BUGS文件里有一个很好的模板。它指导用户如何报
333告可能的内核bug以及需要提供哪些信息来帮助内核开发者们找到问题的根源。
334
335
336利用bug报告
337-----------
338
339练习内核开发技能的最好办法就是修改其他人报告的bug。你不光可以帮助内核变
340得更加稳定,还可以学会如何解决实际问题从而提高自己的技能,并且让其他开发
341者感受到你的存在。修改bug是赢得其他开发者赞誉的最好办法,因为并不是很多
342人都喜欢浪费时间去修改别人报告的bug。
343
344要尝试修改已知的bug,请访问http://bugzilla.kernel.org网址。如果你想获得
345最新bug的通知,可以订阅bugme-new邮件列表(只有新的bug报告会被寄到这里)
346或者订阅bugme-janitor邮件列表(所有bugzilla的变动都会被寄到这里)。
347
348 http://lists.osdl.org/mailman/listinfo/bugme-new
349 http://lists.osdl.org/mailman/listinfo/bugme-janitors
350
351
352邮件列表
353--------
354
355正如上面的文档所描述,大多数的骨干内核开发者都加入了Linux Kernel邮件列
356表。如何订阅和退订列表的细节可以在这里找到:
357 http://vger.kernel.org/vger-lists.html#linux-kernel
358网上很多地方都有这个邮件列表的存档(archive)。可以使用搜索引擎来找到这些
359存档。比如:
360 http://dir.gmane.org/gmane.linux.kernel
361在发信之前,我们强烈建议你先在存档中搜索你想要讨论的问题。很多已经被详细
362讨论过的问题只在邮件列表的存档中可以找到。
363
364大多数内核子系统也有自己独立的邮件列表来协调各自的开发工作。从
365MAINTAINERS文件中可以找到不同话题对应的邮件列表。
366
367很多邮件列表架设在kernel.org服务器上。这些列表的信息可以在这里找到:
368 http://vger.kernel.org/vger-lists.html
369
370在使用这些邮件列表时,请记住保持良好的行为习惯。下面的链接提供了与这些列
371表(或任何其它邮件列表)交流的一些简单规则,虽然内容有点滥竽充数。
372 http://www.albion.com/netiquette/
373
374当有很多人回复你的邮件时,邮件的抄送列表会变得很长。请不要将任何人从抄送
375列表中删除,除非你有足够的理由这么做。也不要只回复到邮件列表。请习惯于同
376一封邮件接收两次(一封来自发送者一封来自邮件列表),而不要试图通过添加一
377些奇特的邮件头来解决这个问题,人们不会喜欢的。
378
379记住保留你所回复内容的上下文和源头。在你回复邮件的顶部保留“某某某说到……”
380这几行。将你的评论加在被引用的段落之间而不要放在邮件的顶部。
381
382如果你在邮件中附带补丁,请确认它们是可以直接阅读的纯文本(如
383Documentation/SubmittingPatches文档中所述)。内核开发者们不希望遇到附件
384或者被压缩了的补丁。只有这样才能保证他们可以直接评论你的每行代码。请确保
385你使用的邮件发送程序不会修改空格和制表符。一个防范性的测试方法是先将邮件
386发送给自己,然后自己尝试是否可以顺利地打上收到的补丁。如果测试不成功,请
387调整或者更换你的邮件发送程序直到它正确工作为止。
388
389总而言之,请尊重其他的邮件列表订阅者。
390
391
392同内核社区合作
393----------------
394
395内核社区的目标就是提供尽善尽美的内核。所以当你提交补丁期望被接受进内核的
396时候,它的技术价值以及其他方面都将被评审。那么你可能会得到什么呢?
397 - 批评
398 - 评论
399 - 要求修改
400 - 要求证明修改的必要性
401 - 沉默
402
403要记住,这些是把补丁放进内核的正常情况。你必须学会听取对补丁的批评和评论,
404从技术层面评估它们,然后要么重写你的补丁要么简明扼要地论证修改是不必要
405的。如果你发的邮件没有得到任何回应,请过几天后再试一次,因为有时信件会湮
406没在茫茫信海中。
407
408你不应该做的事情:
409 - 期望自己的补丁不受任何质疑就直接被接受
410 - 翻脸
411 - 忽略别人的评论
412 - 没有按照别人的要求做任何修改就重新提交
413
414在一个努力追寻最好技术方案的社区里,对于一个补丁有多少好处总会有不同的见
415解。你必须要抱着合作的态度,愿意改变自己的观点来适应内核的风格。或者至少
416愿意去证明你的想法是有价值的。记住,犯错误是允许的,只要你愿意朝着正确的
417方案去努力。
418
419如果你的第一个补丁换来的是一堆修改建议,这是很正常的。这并不代表你的补丁
420不会被接受,也不意味着有人和你作对。你只需要改正所有提出的问题然后重新发
421送你的补丁。
422
423内核社区和公司文化的差异
424------------------------
425
426内核社区的工作模式同大多数传统公司开发队伍的工作模式并不相同。下面这些例
427子,可以帮助你避免某些可能发生问题:
428 用这些话介绍你的修改提案会有好处:
429 - 它同时解决了多个问题
430 - 它删除了2000行代码
431 - 这是补丁,它已经解释了我想要说明的
432 - 我在5种不同的体系结构上测试过它……
433 - 这是一系列小补丁用来……
434 - 这个修改提高了普通机器的性能……
435
436 应该避免如下的说法:
437 - 我们在AIX/ptx/Solaris就是这么做的,所以这么做肯定是好的……
438 - 我做这行已经20年了,所以……
439 - 为了我们公司赚钱考虑必须这么做
440 - 这是我们的企业产品线所需要的
441 - 这里是描述我观点的1000页设计文档
442 - 这是一个5000行的补丁用来……
443 - 我重写了现在乱七八糟的代码,这就是……
444 - 我被规定了最后期限,所以这个补丁需要立刻被接受
445
446另外一个内核社区与大部分传统公司的软件开发队伍不同的地方是无法面对面地交
447流。使用电子邮件和IRC聊天工具做为主要沟通工具的一个好处是性别和种族歧视
448将会更少。Linux内核的工作环境更能接受妇女和少数族群,因为每个人在别人眼
449里只是一个邮件地址。国际化也帮助了公平的实现,因为你无法通过姓名来判断人
450的性别。男人有可能叫李丽,女人也有可能叫王刚。大多数在Linux内核上工作过
451并表达过看法的女性对在linux上工作的经历都给出了正面的评价。
452
453对于一些不习惯使用英语的人来说,语言可能是一个引起问题的障碍。在邮件列表
454中要正确地表达想法必需良好地掌握语言,所以建议你在发送邮件之前最好检查一
455下英文写得是否正确。
456
457
458拆分修改
459--------
460
461Linux内核社区并不喜欢一下接收大段的代码。修改需要被恰当地介绍、讨论并且
462拆分成独立的小段。这几乎完全和公司中的习惯背道而驰。你的想法应该在开发最
463开始的阶段就让大家知道,这样你就可以及时获得对你正在进行的开发的反馈。这
464样也会让社区觉得你是在和他们协作,而不是仅仅把他们当作倾销新功能的对象。
465无论如何,你不要一次性地向邮件列表发送50封信,你的补丁序列应该永远用不到
466这么多。
467
468将补丁拆开的原因如下:
469
4701) 小的补丁更有可能被接受,因为它们不需要太多的时间和精力去验证其正确性。
471 一个5行的补丁,可能在维护者看了一眼以后就会被接受。而500行的补丁则
472 需要数个小时来审查其正确性(所需时间随补丁大小增加大约呈指数级增长)。
473
474 当出了问题的时候,小的补丁也会让调试变得非常容易。一个一个补丁地回溯
475 将会比仔细剖析一个被打上的大补丁(这个补丁破坏了其他东西)容易得多。
476
4772)不光发送小的补丁很重要,在提交之前重新编排、化简(或者仅仅重新排列)
478 补丁也是很重要的。
479
480这里有内核开发者Al Viro打的一个比方:
481 “想象一个老师正在给学生批改数学作业。老师并不希望看到学生为了得
482 到正确解法所进行的尝试和产生的错误。他希望看到的是最干净最优雅的
483 解答。好学生了解这点,绝不会把最终解决之前的中间方案提交上去。”
484
485 内核开发也是这样。维护者和评审者不希望看到一个人在解决问题时的思
486 考过程。他们只希望看到简单和优雅的解决方案。
487
488直接给出一流的解决方案,和社区一起协作讨论尚未完成的工作,这两者之间似乎
489很难找到一个平衡点。所以最好尽早开始收集有利于你进行改进的反馈;同时也要
490保证修改分成很多小块,这样在整个项目都准备好被包含进内核之前,其中的一部
491分可能会先被接收。
492
493必须了解这样做是不可接受的:试图将未完成的工作提交进内核,然后再找时间修
494复。
495
496
497证明修改的必要性
498----------------
499除了将补丁拆成小块,很重要的一点是让Linux社区了解他们为什么需要这样修改。
500你必须证明新功能是有人需要的并且是有用的。
501
502
503记录修改
504--------
505
506当你发送补丁的时候,需要特别留意邮件正文的内容。因为这里的信息将会做为补
507丁的修改记录(ChangeLog),会被一直保留以备大家查阅。它需要完全地描述补丁,
508包括:
509 - 为什么需要这个修改
510 - 补丁的总体设计
511 - 实现细节
512 - 测试结果
513
514想了解它具体应该看起来像什么,请查阅以下文档中的“ChangeLog”章节:
515 “The Perfect Patch”
516 http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt
517
518
519这些事情有时候做起来很难。要在任何方面都做到完美可能需要好几年时间。这是
520一个持续提高的过程,它需要大量的耐心和决心。只要不放弃,你一定可以做到。
521很多人已经做到了,而他们都曾经和现在的你站在同样的起点上。
522
523
524---------------
525感谢Paolo Ciarrocchi允许“开发流程”部分基于他所写的文章
526(http://linux.tar.bz/articles/2.6-development_process),感谢Randy
527Dunlap和Gerrit Huizenga完善了应该说和不该说的列表。感谢Pat Mochel, Hanna
528Linder, Randy Dunlap, Kay Sievers, Vojtech Pavlik, Jan Kara, Josh Boyer,
529Kees Cook, Andrew Morton, Andi Kleen, Vadim Lobanov, Jesper Juhl, Adrian
530Bunk, Keri Harris, Frans Pop, David A. Wheeler, Junio Hamano, Michael
531Kerrisk和Alex Shepard的评审、建议和贡献。没有他们的帮助,这篇文档是不可
532能完成的。
533
534
535
536英文版维护者: Greg Kroah-Hartman <greg@kroah.com>
diff --git a/Documentation/zh_CN/stable_api_nonsense.txt b/Documentation/zh_CN/stable_api_nonsense.txt
new file mode 100644
index 000000000000..c26a27d1ee7d
--- /dev/null
+++ b/Documentation/zh_CN/stable_api_nonsense.txt
@@ -0,0 +1,157 @@
1Chinese translated version of Documentation/stable_api_nonsense.txt
2
3If you have any comment or update to the content, please contact the
4original document maintainer directly. However, if you have problem
5communicating in English you can also ask the Chinese maintainer for help.
6Contact the Chinese maintainer, if this translation is outdated or there
7is problem with translation.
8
9Maintainer: Greg Kroah-Hartman <greg@kroah.com>
10Chinese maintainer: TripleX Chung <zhongyu@18mail.cn>
11---------------------------------------------------------------------
12Documentation/stable_api_nonsense.txt 的中文翻译
13
14如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
15交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
16译存在问题,请联系中文版维护者。
17
18英文版维护者: Greg Kroah-Hartman <greg@kroah.com>
19中文版维护者: 钟宇 TripleX Chung <zhongyu@18mail.cn>
20中文版翻译者: 钟宇 TripleX Chung <zhongyu@18mail.cn>
21中文版校译者: 李阳 Li Yang <leoli@freescale.com>
22以下为正文
23---------------------------------------------------------------------
24
25写作本文档的目的,是为了解释为什么Linux既没有二进制内核接口,也没有稳定
26的内核接口。这里所说的内核接口,是指内核里的接口,而不是内核和用户空间
27的接口。内核到用户空间的接口,是提供给应用程序使用的系统调用,系统调用
28在历史上几乎没有过变化,将来也不会有变化。我有一些老应用程序是在0.9版本
29或者更早版本的内核上编译的,在使用2.6版本内核的Linux发布上依然用得很好
30。用户和应用程序作者可以将这个接口看成是稳定的。
31
32
33执行纲要
34--------
35
36你也许以为自己想要稳定的内核接口,但是你不清楚你要的实际上不是它。你需
37要的其实是稳定的驱动程序,而你只有将驱动程序放到公版内核的源代码树里,
38才有可能达到这个目的。而且这样做还有很多其它好处,正是因为这些好处使得
39Linux能成为强壮,稳定,成熟的操作系统,这也是你最开始选择Linux的原因。
40
41
42入门
43-----
44
45只有那些写驱动程序的“怪人”才会担心内核接口的改变,对广大用户来说,既
46看不到内核接口,也不需要去关心它。
47
48首先,我不打算讨论关于任何非GPL许可的内核驱动的法律问题,这些非GPL许可
49的驱动程序包括不公开源代码,隐藏源代码,二进制或者是用源代码包装,或者
50是其它任何形式的不能以GPL许可公开源代码的驱动程序。如果有法律问题,请咨
51询律师,我只是一个程序员,所以我只打算探讨技术问题(不是小看法律问题,
52法律问题很实际,并且需要一直关注)。
53
54既然只谈技术问题,我们就有了下面两个主题:二进制内核接口和稳定的内核源
55代码接口。这两个问题是互相关联的,让我们先解决掉二进制接口的问题。
56
57
58二进制内核接口
59--------------
60假如我们有一个稳定的内核源代码接口,那么自然而然的,我们就拥有了稳定的
61二进制接口,是这样的吗?错。让我们看看关于Linux内核的几点事实:
62 - 取决于所用的C编译器的版本,不同的内核数据结构里的结构体的对齐方
63式会有差别,代码中不同函数的表现形式也不一样(函数是不是被inline编译取
64决于编译器行为)。不同的函数的表现形式并不重要,但是数据结构内部的对齐
65方式很关键。
66 - 取决于内核的配置选项,不同的选项会让内核的很多东西发生改变:
67 - 同一个结构体可能包含不同的成员变量
68 - 有的函数可能根本不会被实现(比如编译的时候没有选择SMP支持
69,一些锁函数就会被定义成空函数)。
70 - 内核使用的内存会以不同的方式对齐,这取决于不同的内核配置选
71项。
72 - Linux可以在很多的不同体系结构的处理器上运行。在某个体系结构上编
73译好的二进制驱动程序,不可能在另外一个体系结构上正确的运行。
74
75对于一个特定的内核,满足这些条件并不难,使用同一个C编译器和同样的内核配
76置选项来编译驱动程序模块就可以了。这对于给一个特定Linux发布的特定版本提
77供驱动程序,是完全可以满足需求的。但是如果你要给不同发布的不同版本都发
78布一个驱动程序,就需要在每个发布上用不同的内核设置参数都编译一次内核,
79这简直跟噩梦一样。而且还要注意到,每个Linux发布还提供不同的Linux内核,
80这些内核都针对不同的硬件类型进行了优化(有很多种不同的处理器,还有不同
81的内核设置选项)。所以每发布一次驱动程序,都需要提供很多不同版本的内核
82模块。
83
84相信我,如果你真的要采取这种发布方式,一定会慢慢疯掉,我很久以前就有过
85深刻的教训...
86
87
88稳定的内核源代码接口
89--------------------
90
91如果有人不将他的内核驱动程序,放入公版内核的源代码树,而又想让驱动程序
92一直保持在最新的内核中可用,那么这个话题将会变得没完没了。
93 内核开发是持续而且快节奏的,从来都不会慢下来。内核开发人员在当前接口中
94找到bug,或者找到更好的实现方式。一旦发现这些,他们就很快会去修改当前的
95接口。修改接口意味着,函数名可能会改变,结构体可能被扩充或者删减,函数
96的参数也可能发生改变。一旦接口被修改,内核中使用这些接口的地方需要同时
97修正,这样才能保证所有的东西继续工作。
98
99举一个例子,内核的USB驱动程序接口在USB子系统的整个生命周期中,至少经历
100了三次重写。这些重写解决以下问题:
101 - 把数据流从同步模式改成非同步模式,这个改动减少了一些驱动程序的
102复杂度,提高了所有USB驱动程序的吞吐率,这样几乎所有的USB设备都能以最大
103速率工作了。
104 - 修改了USB核心代码中为USB驱动分配数据包内存的方式,所有的驱动都
105需要提供更多的参数给USB核心,以修正了很多已经被记录在案的死锁。
106
107这和一些封闭源代码的操作系统形成鲜明的对比,在那些操作系统上,不得不额
108外的维护旧的USB接口。这导致了一个可能性,新的开发者依然会不小心使用旧的
109接口,以不恰当的方式编写代码,进而影响到操作系统的稳定性。
110 在上面的例子中,所有的开发者都同意这些重要的改动,在这样的情况下修改代
111价很低。如果Linux保持一个稳定的内核源代码接口,那么就得创建一个新的接口
112;旧的,有问题的接口必须一直维护,给Linux USB开发者带来额外的工作。既然
113所有的Linux USB驱动的作者都是利用自己的时间工作,那么要求他们去做毫无意
114义的免费额外工作,是不可能的。
115 安全问题对Linux来说十分重要。一个安全问题被发现,就会在短时间内得到修
116正。在很多情况下,这将导致Linux内核中的一些接口被重写,以从根本上避免安
117全问题。一旦接口被重写,所有使用这些接口的驱动程序,必须同时得到修正,
118以确定安全问题已经得到修复并且不可能在未来还有同样的安全问题。如果内核
119内部接口不允许改变,那么就不可能修复这样的安全问题,也不可能确认这样的
120安全问题以后不会发生。
121开发者一直在清理内核接口。如果一个接口没有人在使用了,它就会被删除。这
122样可以确保内核尽可能的小,而且所有潜在的接口都会得到尽可能完整的测试
123(没有人使用的接口是不可能得到良好的测试的)。
124
125
126要做什么
127-------
128
129如果你写了一个Linux内核驱动,但是它还不在Linux源代码树里,作为一个开发
130者,你应该怎么做?为每个发布的每个版本提供一个二进制驱动,那简直是一个
131噩梦,要跟上永远处于变化之中的内核接口,也是一件辛苦活。
132很简单,让你的驱动进入内核源代码树(要记得我们在谈论的是以GPL许可发行
133的驱动,如果你的代码不符合GPL,那么祝你好运,你只能自己解决这个问题了,
134你这个吸血鬼<把Andrew和Linus对吸血鬼的定义链接到这里>)。当你的代码加入
135公版内核源代码树之后,如果一个内核接口改变,你的驱动会直接被修改接口的
136那个人修改。保证你的驱动永远都可以编译通过,并且一直工作,你几乎不需要
137做什么事情。
138
139把驱动放到内核源代码树里会有很多的好处:
140 - 驱动的质量会提升,而维护成本(对原始作者来说)会下降。
141 - 其他人会给驱动添加新特性。
142 - 其他人会找到驱动中的bug并修复。
143 - 其他人会在驱动中找到性能优化的机会。
144 - 当外部的接口的改变需要修改驱动程序的时候,其他人会修改驱动程序
145
146 - 不需要联系任何发行商,这个驱动会自动的随着所有的Linux发布一起发
147布。
148
149和别的操作系统相比,Linux为更多不同的设备提供现成的驱动,而且能在更多不
150同体系结构的处理器上支持这些设备。这个经过考验的开发模式,必然是错不了
151的 :)
152
153-------------
154感谢 Randy Dunlap, Andrew Morton, David Brownell, Hanna Linder,
155Robert Love, and Nishanth Aravamudan 对于本文档早期版本的评审和建议。
156
157英文版维护者: Greg Kroah-Hartman <greg@kroah.com>