diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-03 11:48:58 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-03 11:48:58 -0500 |
commit | 7f5b09c15ab989ed5ce4adda0be42c1302df70b7 (patch) | |
tree | 9695b00983d1bd077ff91c463abcb136330cf344 /Documentation | |
parent | 94468080220162f74dc6ce5c3e95e5fec8022902 (diff) | |
parent | cedf8a78421943441b9011ce7bcdab55f07d2ea6 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (220 commits)
USB: backlight, appledisplay: fix incomplete registration failure handling
USB: pl2303: remove unnecessary reset of usb_device in urbs
USB: ftdi_sio: remove obsolete check in unthrottle
USB: ftdi_sio: remove unused tx_bytes counter
USB: qcaux: driver for auxiliary serial ports on Qualcomm devices
USB: pl2303: initial TIOCGSERIAL support
USB: option: add Longcheer/Longsung vendor ID
USB: fix I2C API usage in ohci-pnx4008.
USB: usbmon: mask seconds properly in text API
USB: sisusbvga: no unnecessary GFP_ATOMIC
USB: storage: onetouch: unnecessary GFP_ATOMIC
USB: serial: ftdi: add CONTEC vendor and product id
USB: remove references to port->port.count from the serial drivers
USB: tty: Prune uses of tty_request_room in the USB layer
USB: tty: Add a function to insert a string of characters with the same flag
USB: don't read past config->interface[] if usb_control_msg() fails in usb_reset_configuration()
USB: tty: kill request_room for USB ACM class
USB: tty: sort out the request_room handling for whiteheat
USB: storage: fix misplaced parenthesis
USB: vstusb.c: removal of driver for Vernier Software & Technology, Inc., devices and spectrometers
...
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/ABI/testing/sysfs-bus-usb | 11 | ||||
-rw-r--r-- | Documentation/ioctl/ioctl-number.txt | 1 | ||||
-rw-r--r-- | Documentation/networking/00-INDEX | 2 | ||||
-rw-r--r-- | Documentation/networking/cxacru-cf.py | 48 | ||||
-rw-r--r-- | Documentation/networking/cxacru.txt | 16 | ||||
-rw-r--r-- | Documentation/usb/error-codes.txt | 6 | ||||
-rw-r--r-- | Documentation/usb/power-management.txt | 235 |
7 files changed, 176 insertions, 143 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb index a07c0f366f91..a986e9bbba3d 100644 --- a/Documentation/ABI/testing/sysfs-bus-usb +++ b/Documentation/ABI/testing/sysfs-bus-usb | |||
@@ -159,3 +159,14 @@ Description: | |||
159 | device. This is useful to ensure auto probing won't | 159 | device. This is useful to ensure auto probing won't |
160 | match the driver to the device. For example: | 160 | match the driver to the device. For example: |
161 | # echo "046d c315" > /sys/bus/usb/drivers/foo/remove_id | 161 | # echo "046d c315" > /sys/bus/usb/drivers/foo/remove_id |
162 | |||
163 | What: /sys/bus/usb/device/.../avoid_reset | ||
164 | Date: December 2009 | ||
165 | Contact: Oliver Neukum <oliver@neukum.org> | ||
166 | Description: | ||
167 | Writing 1 to this file tells the kernel that this | ||
168 | device will morph into another mode when it is reset. | ||
169 | Drivers will not use reset for error handling for | ||
170 | such devices. | ||
171 | Users: | ||
172 | usb_modeswitch | ||
diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt index 35cf64d4436d..35c9b51d20ea 100644 --- a/Documentation/ioctl/ioctl-number.txt +++ b/Documentation/ioctl/ioctl-number.txt | |||
@@ -139,7 +139,6 @@ Code Seq#(hex) Include File Comments | |||
139 | 'K' all linux/kd.h | 139 | 'K' all linux/kd.h |
140 | 'L' 00-1F linux/loop.h conflict! | 140 | 'L' 00-1F linux/loop.h conflict! |
141 | 'L' 10-1F drivers/scsi/mpt2sas/mpt2sas_ctl.h conflict! | 141 | 'L' 10-1F drivers/scsi/mpt2sas/mpt2sas_ctl.h conflict! |
142 | 'L' 20-2F linux/usb/vstusb.h | ||
143 | 'L' E0-FF linux/ppdd.h encrypted disk device driver | 142 | 'L' E0-FF linux/ppdd.h encrypted disk device driver |
144 | <http://linux01.gwdg.de/~alatham/ppdd.html> | 143 | <http://linux01.gwdg.de/~alatham/ppdd.html> |
145 | 'M' all linux/soundcard.h conflict! | 144 | 'M' all linux/soundcard.h conflict! |
diff --git a/Documentation/networking/00-INDEX b/Documentation/networking/00-INDEX index 50189bf07d53..fe5c099b8fc8 100644 --- a/Documentation/networking/00-INDEX +++ b/Documentation/networking/00-INDEX | |||
@@ -32,6 +32,8 @@ cs89x0.txt | |||
32 | - the Crystal LAN (CS8900/20-based) Ethernet ISA adapter driver | 32 | - the Crystal LAN (CS8900/20-based) Ethernet ISA adapter driver |
33 | cxacru.txt | 33 | cxacru.txt |
34 | - Conexant AccessRunner USB ADSL Modem | 34 | - Conexant AccessRunner USB ADSL Modem |
35 | cxacru-cf.py | ||
36 | - Conexant AccessRunner USB ADSL Modem configuration file parser | ||
35 | de4x5.txt | 37 | de4x5.txt |
36 | - the Digital EtherWORKS DE4?? and DE5?? PCI Ethernet driver | 38 | - the Digital EtherWORKS DE4?? and DE5?? PCI Ethernet driver |
37 | decnet.txt | 39 | decnet.txt |
diff --git a/Documentation/networking/cxacru-cf.py b/Documentation/networking/cxacru-cf.py new file mode 100644 index 000000000000..b41d298398c8 --- /dev/null +++ b/Documentation/networking/cxacru-cf.py | |||
@@ -0,0 +1,48 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # Copyright 2009 Simon Arlott | ||
3 | # | ||
4 | # This program is free software; you can redistribute it and/or modify it | ||
5 | # under the terms of the GNU General Public License as published by the Free | ||
6 | # Software Foundation; either version 2 of the License, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # This program is distributed in the hope that it will be useful, but WITHOUT | ||
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | # more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License along with | ||
15 | # this program; if not, write to the Free Software Foundation, Inc., 59 | ||
16 | # Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | # | ||
18 | # Usage: cxacru-cf.py < cxacru-cf.bin | ||
19 | # Output: values string suitable for the sysfs adsl_config attribute | ||
20 | # | ||
21 | # Warning: cxacru-cf.bin with MD5 hash cdbac2689969d5ed5d4850f117702110 | ||
22 | # contains mis-aligned values which will stop the modem from being able | ||
23 | # to make a connection. If the first and last two bytes are removed then | ||
24 | # the values become valid, but the modulation will be forced to ANSI | ||
25 | # T1.413 only which may not be appropriate. | ||
26 | # | ||
27 | # The original binary format is a packed list of le32 values. | ||
28 | |||
29 | import sys | ||
30 | import struct | ||
31 | |||
32 | i = 0 | ||
33 | while True: | ||
34 | buf = sys.stdin.read(4) | ||
35 | |||
36 | if len(buf) == 0: | ||
37 | break | ||
38 | elif len(buf) != 4: | ||
39 | sys.stdout.write("\n") | ||
40 | sys.stderr.write("Error: read {0} not 4 bytes\n".format(len(buf))) | ||
41 | sys.exit(1) | ||
42 | |||
43 | if i > 0: | ||
44 | sys.stdout.write(" ") | ||
45 | sys.stdout.write("{0:x}={1}".format(i, struct.unpack("<I", buf)[0])) | ||
46 | i += 1 | ||
47 | |||
48 | sys.stdout.write("\n") | ||
diff --git a/Documentation/networking/cxacru.txt b/Documentation/networking/cxacru.txt index b074681a963e..2cce04457b4d 100644 --- a/Documentation/networking/cxacru.txt +++ b/Documentation/networking/cxacru.txt | |||
@@ -4,6 +4,12 @@ While it is capable of managing/maintaining the ADSL connection without the | |||
4 | module loaded, the device will sometimes stop responding after unloading the | 4 | module loaded, the device will sometimes stop responding after unloading the |
5 | driver and it is necessary to unplug/remove power to the device to fix this. | 5 | driver and it is necessary to unplug/remove power to the device to fix this. |
6 | 6 | ||
7 | Note: support for cxacru-cf.bin has been removed. It was not loaded correctly | ||
8 | so it had no effect on the device configuration. Fixing it could have stopped | ||
9 | existing devices working when an invalid configuration is supplied. | ||
10 | |||
11 | There is a script cxacru-cf.py to convert an existing file to the sysfs form. | ||
12 | |||
7 | Detected devices will appear as ATM devices named "cxacru". In /sys/class/atm/ | 13 | Detected devices will appear as ATM devices named "cxacru". In /sys/class/atm/ |
8 | these are directories named cxacruN where N is the device number. A symlink | 14 | these are directories named cxacruN where N is the device number. A symlink |
9 | named device points to the USB interface device's directory which contains | 15 | named device points to the USB interface device's directory which contains |
@@ -15,6 +21,15 @@ several sysfs attribute files for retrieving device statistics: | |||
15 | * adsl_headend_environment | 21 | * adsl_headend_environment |
16 | Information about the remote headend. | 22 | Information about the remote headend. |
17 | 23 | ||
24 | * adsl_config | ||
25 | Configuration writing interface. | ||
26 | Write parameters in hexadecimal format <index>=<value>, | ||
27 | separated by whitespace, e.g.: | ||
28 | "1=0 a=5" | ||
29 | Up to 7 parameters at a time will be sent and the modem will restart | ||
30 | the ADSL connection when any value is set. These are logged for future | ||
31 | reference. | ||
32 | |||
18 | * downstream_attenuation (dB) | 33 | * downstream_attenuation (dB) |
19 | * downstream_bits_per_frame | 34 | * downstream_bits_per_frame |
20 | * downstream_rate (kbps) | 35 | * downstream_rate (kbps) |
@@ -61,6 +76,7 @@ several sysfs attribute files for retrieving device statistics: | |||
61 | * mac_address | 76 | * mac_address |
62 | 77 | ||
63 | * modulation | 78 | * modulation |
79 | "" (when not connected) | ||
64 | "ANSI T1.413" | 80 | "ANSI T1.413" |
65 | "ITU-T G.992.1 (G.DMT)" | 81 | "ITU-T G.992.1 (G.DMT)" |
66 | "ITU-T G.992.2 (G.LITE)" | 82 | "ITU-T G.992.2 (G.LITE)" |
diff --git a/Documentation/usb/error-codes.txt b/Documentation/usb/error-codes.txt index 9cf83e8c27b8..d83703ea74b2 100644 --- a/Documentation/usb/error-codes.txt +++ b/Documentation/usb/error-codes.txt | |||
@@ -41,8 +41,8 @@ USB-specific: | |||
41 | 41 | ||
42 | -EFBIG Host controller driver can't schedule that many ISO frames. | 42 | -EFBIG Host controller driver can't schedule that many ISO frames. |
43 | 43 | ||
44 | -EPIPE Specified endpoint is stalled. For non-control endpoints, | 44 | -EPIPE The pipe type specified in the URB doesn't match the |
45 | reset this status with usb_clear_halt(). | 45 | endpoint's actual type. |
46 | 46 | ||
47 | -EMSGSIZE (a) endpoint maxpacket size is zero; it is not usable | 47 | -EMSGSIZE (a) endpoint maxpacket size is zero; it is not usable |
48 | in the current interface altsetting. | 48 | in the current interface altsetting. |
@@ -60,6 +60,8 @@ USB-specific: | |||
60 | 60 | ||
61 | -EHOSTUNREACH URB was rejected because the device is suspended. | 61 | -EHOSTUNREACH URB was rejected because the device is suspended. |
62 | 62 | ||
63 | -ENOEXEC A control URB doesn't contain a Setup packet. | ||
64 | |||
63 | 65 | ||
64 | ************************************************************************** | 66 | ************************************************************************** |
65 | * Error codes returned by in urb->status * | 67 | * Error codes returned by in urb->status * |
diff --git a/Documentation/usb/power-management.txt b/Documentation/usb/power-management.txt index 3bf6818c8cf5..2790ad48cfc2 100644 --- a/Documentation/usb/power-management.txt +++ b/Documentation/usb/power-management.txt | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | Alan Stern <stern@rowland.harvard.edu> | 3 | Alan Stern <stern@rowland.harvard.edu> |
4 | 4 | ||
5 | November 10, 2009 | 5 | December 11, 2009 |
6 | 6 | ||
7 | 7 | ||
8 | 8 | ||
@@ -29,9 +29,9 @@ covered to some extent (see Documentation/power/*.txt for more | |||
29 | information about system PM). | 29 | information about system PM). |
30 | 30 | ||
31 | Note: Dynamic PM support for USB is present only if the kernel was | 31 | Note: Dynamic PM support for USB is present only if the kernel was |
32 | built with CONFIG_USB_SUSPEND enabled. System PM support is present | 32 | built with CONFIG_USB_SUSPEND enabled (which depends on |
33 | only if the kernel was built with CONFIG_SUSPEND or CONFIG_HIBERNATION | 33 | CONFIG_PM_RUNTIME). System PM support is present only if the kernel |
34 | enabled. | 34 | was built with CONFIG_SUSPEND or CONFIG_HIBERNATION enabled. |
35 | 35 | ||
36 | 36 | ||
37 | What is Remote Wakeup? | 37 | What is Remote Wakeup? |
@@ -229,6 +229,11 @@ necessary operations by hand or add them to a udev script. You can | |||
229 | also change the idle-delay time; 2 seconds is not the best choice for | 229 | also change the idle-delay time; 2 seconds is not the best choice for |
230 | every device. | 230 | every device. |
231 | 231 | ||
232 | If a driver knows that its device has proper suspend/resume support, | ||
233 | it can enable autosuspend all by itself. For example, the video | ||
234 | driver for a laptop's webcam might do this, since these devices are | ||
235 | rarely used and so should normally be autosuspended. | ||
236 | |||
232 | Sometimes it turns out that even when a device does work okay with | 237 | Sometimes it turns out that even when a device does work okay with |
233 | autosuspend there are still problems. For example, there are | 238 | autosuspend there are still problems. For example, there are |
234 | experimental patches adding autosuspend support to the usbhid driver, | 239 | experimental patches adding autosuspend support to the usbhid driver, |
@@ -321,69 +326,81 @@ driver does so by calling these six functions: | |||
321 | void usb_autopm_get_interface_no_resume(struct usb_interface *intf); | 326 | void usb_autopm_get_interface_no_resume(struct usb_interface *intf); |
322 | void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); | 327 | void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); |
323 | 328 | ||
324 | The functions work by maintaining a counter in the usb_interface | 329 | The functions work by maintaining a usage counter in the |
325 | structure. When intf->pm_usage_count is > 0 then the interface is | 330 | usb_interface's embedded device structure. When the counter is > 0 |
326 | deemed to be busy, and the kernel will not autosuspend the interface's | 331 | then the interface is deemed to be busy, and the kernel will not |
327 | device. When intf->pm_usage_count is <= 0 then the interface is | 332 | autosuspend the interface's device. When the usage counter is = 0 |
328 | considered to be idle, and the kernel may autosuspend the device. | 333 | then the interface is considered to be idle, and the kernel may |
334 | autosuspend the device. | ||
329 | 335 | ||
330 | (There is a similar pm_usage_count field in struct usb_device, | 336 | (There is a similar usage counter field in struct usb_device, |
331 | associated with the device itself rather than any of its interfaces. | 337 | associated with the device itself rather than any of its interfaces. |
332 | This field is used only by the USB core.) | 338 | This counter is used only by the USB core.) |
333 | 339 | ||
334 | Drivers must not modify intf->pm_usage_count directly; its value | 340 | Drivers need not be concerned about balancing changes to the usage |
335 | should be changed only be using the functions listed above. Drivers | 341 | counter; the USB core will undo any remaining "get"s when a driver |
336 | are responsible for insuring that the overall change to pm_usage_count | 342 | is unbound from its interface. As a corollary, drivers must not call |
337 | during their lifetime balances out to 0 (it may be necessary for the | 343 | any of the usb_autopm_* functions after their diconnect() routine has |
338 | disconnect method to call usb_autopm_put_interface() one or more times | 344 | returned. |
339 | to fulfill this requirement). The first two routines use the PM mutex | 345 | |
340 | in struct usb_device for mutual exclusion; drivers using the async | 346 | Drivers using the async routines are responsible for their own |
341 | routines are responsible for their own synchronization and mutual | 347 | synchronization and mutual exclusion. |
342 | exclusion. | 348 | |
343 | 349 | usb_autopm_get_interface() increments the usage counter and | |
344 | usb_autopm_get_interface() increments pm_usage_count and | 350 | does an autoresume if the device is suspended. If the |
345 | attempts an autoresume if the new value is > 0 and the | 351 | autoresume fails, the counter is decremented back. |
346 | device is suspended. | 352 | |
347 | 353 | usb_autopm_put_interface() decrements the usage counter and | |
348 | usb_autopm_put_interface() decrements pm_usage_count and | 354 | attempts an autosuspend if the new value is = 0. |
349 | attempts an autosuspend if the new value is <= 0 and the | ||
350 | device isn't suspended. | ||
351 | 355 | ||
352 | usb_autopm_get_interface_async() and | 356 | usb_autopm_get_interface_async() and |
353 | usb_autopm_put_interface_async() do almost the same things as | 357 | usb_autopm_put_interface_async() do almost the same things as |
354 | their non-async counterparts. The differences are: they do | 358 | their non-async counterparts. The big difference is that they |
355 | not acquire the PM mutex, and they use a workqueue to do their | 359 | use a workqueue to do the resume or suspend part of their |
356 | jobs. As a result they can be called in an atomic context, | 360 | jobs. As a result they can be called in an atomic context, |
357 | such as an URB's completion handler, but when they return the | 361 | such as an URB's completion handler, but when they return the |
358 | device will not generally not yet be in the desired state. | 362 | device will generally not yet be in the desired state. |
359 | 363 | ||
360 | usb_autopm_get_interface_no_resume() and | 364 | usb_autopm_get_interface_no_resume() and |
361 | usb_autopm_put_interface_no_suspend() merely increment or | 365 | usb_autopm_put_interface_no_suspend() merely increment or |
362 | decrement the pm_usage_count value; they do not attempt to | 366 | decrement the usage counter; they do not attempt to carry out |
363 | carry out an autoresume or an autosuspend. Hence they can be | 367 | an autoresume or an autosuspend. Hence they can be called in |
364 | called in an atomic context. | 368 | an atomic context. |
365 | 369 | ||
366 | The conventional usage pattern is that a driver calls | 370 | The simplest usage pattern is that a driver calls |
367 | usb_autopm_get_interface() in its open routine and | 371 | usb_autopm_get_interface() in its open routine and |
368 | usb_autopm_put_interface() in its close or release routine. But | 372 | usb_autopm_put_interface() in its close or release routine. But other |
369 | other patterns are possible. | 373 | patterns are possible. |
370 | 374 | ||
371 | The autosuspend attempts mentioned above will often fail for one | 375 | The autosuspend attempts mentioned above will often fail for one |
372 | reason or another. For example, the power/level attribute might be | 376 | reason or another. For example, the power/level attribute might be |
373 | set to "on", or another interface in the same device might not be | 377 | set to "on", or another interface in the same device might not be |
374 | idle. This is perfectly normal. If the reason for failure was that | 378 | idle. This is perfectly normal. If the reason for failure was that |
375 | the device hasn't been idle for long enough, a delayed workqueue | 379 | the device hasn't been idle for long enough, a timer is scheduled to |
376 | routine is automatically set up to carry out the operation when the | 380 | carry out the operation automatically when the autosuspend idle-delay |
377 | autosuspend idle-delay has expired. | 381 | has expired. |
378 | 382 | ||
379 | Autoresume attempts also can fail, although failure would mean that | 383 | Autoresume attempts also can fail, although failure would mean that |
380 | the device is no longer present or operating properly. Unlike | 384 | the device is no longer present or operating properly. Unlike |
381 | autosuspend, there's no delay for an autoresume. | 385 | autosuspend, there's no idle-delay for an autoresume. |
382 | 386 | ||
383 | 387 | ||
384 | Other parts of the driver interface | 388 | Other parts of the driver interface |
385 | ----------------------------------- | 389 | ----------------------------------- |
386 | 390 | ||
391 | Drivers can enable autosuspend for their devices by calling | ||
392 | |||
393 | usb_enable_autosuspend(struct usb_device *udev); | ||
394 | |||
395 | in their probe() routine, if they know that the device is capable of | ||
396 | suspending and resuming correctly. This is exactly equivalent to | ||
397 | writing "auto" to the device's power/level attribute. Likewise, | ||
398 | drivers can disable autosuspend by calling | ||
399 | |||
400 | usb_disable_autosuspend(struct usb_device *udev); | ||
401 | |||
402 | This is exactly the same as writing "on" to the power/level attribute. | ||
403 | |||
387 | Sometimes a driver needs to make sure that remote wakeup is enabled | 404 | Sometimes a driver needs to make sure that remote wakeup is enabled |
388 | during autosuspend. For example, there's not much point | 405 | during autosuspend. For example, there's not much point |
389 | autosuspending a keyboard if the user can't cause the keyboard to do a | 406 | autosuspending a keyboard if the user can't cause the keyboard to do a |
@@ -395,26 +412,27 @@ though, setting this flag won't cause the kernel to autoresume it. | |||
395 | Normally a driver would set this flag in its probe method, at which | 412 | Normally a driver would set this flag in its probe method, at which |
396 | time the device is guaranteed not to be autosuspended.) | 413 | time the device is guaranteed not to be autosuspended.) |
397 | 414 | ||
398 | The synchronous usb_autopm_* routines have to run in a sleepable | 415 | If a driver does its I/O asynchronously in interrupt context, it |
399 | process context; they must not be called from an interrupt handler or | 416 | should call usb_autopm_get_interface_async() before starting output and |
400 | while holding a spinlock. In fact, the entire autosuspend mechanism | 417 | usb_autopm_put_interface_async() when the output queue drains. When |
401 | is not well geared toward interrupt-driven operation. However there | 418 | it receives an input event, it should call |
402 | is one thing a driver can do in an interrupt handler: | ||
403 | 419 | ||
404 | usb_mark_last_busy(struct usb_device *udev); | 420 | usb_mark_last_busy(struct usb_device *udev); |
405 | 421 | ||
406 | This sets udev->last_busy to the current time. udev->last_busy is the | 422 | in the event handler. This sets udev->last_busy to the current time. |
407 | field used for idle-delay calculations; updating it will cause any | 423 | udev->last_busy is the field used for idle-delay calculations; |
408 | pending autosuspend to be moved back. The usb_autopm_* routines will | 424 | updating it will cause any pending autosuspend to be moved back. Most |
409 | also set the last_busy field to the current time. | 425 | of the usb_autopm_* routines will also set the last_busy field to the |
410 | 426 | current time. | |
411 | Calling urb_mark_last_busy() from within an URB completion handler is | 427 | |
412 | subject to races: The kernel may have just finished deciding the | 428 | Asynchronous operation is always subject to races. For example, a |
413 | device has been idle for long enough but not yet gotten around to | 429 | driver may call one of the usb_autopm_*_interface_async() routines at |
414 | calling the driver's suspend method. The driver would have to be | 430 | a time when the core has just finished deciding the device has been |
415 | responsible for synchronizing its suspend method with its URB | 431 | idle for long enough but not yet gotten around to calling the driver's |
416 | completion handler and causing the autosuspend to fail with -EBUSY if | 432 | suspend method. The suspend method must be responsible for |
417 | an URB had completed too recently. | 433 | synchronizing with the output request routine and the URB completion |
434 | handler; it should cause autosuspends to fail with -EBUSY if the | ||
435 | driver needs to use the device. | ||
418 | 436 | ||
419 | External suspend calls should never be allowed to fail in this way, | 437 | External suspend calls should never be allowed to fail in this way, |
420 | only autosuspend calls. The driver can tell them apart by checking | 438 | only autosuspend calls. The driver can tell them apart by checking |
@@ -422,75 +440,23 @@ the PM_EVENT_AUTO bit in the message.event argument to the suspend | |||
422 | method; this bit will be set for internal PM events (autosuspend) and | 440 | method; this bit will be set for internal PM events (autosuspend) and |
423 | clear for external PM events. | 441 | clear for external PM events. |
424 | 442 | ||
425 | Many of the ingredients in the autosuspend framework are oriented | ||
426 | towards interfaces: The usb_interface structure contains the | ||
427 | pm_usage_cnt field, and the usb_autopm_* routines take an interface | ||
428 | pointer as their argument. But somewhat confusingly, a few of the | ||
429 | pieces (i.e., usb_mark_last_busy()) use the usb_device structure | ||
430 | instead. Drivers need to keep this straight; they can call | ||
431 | interface_to_usbdev() to find the device structure for a given | ||
432 | interface. | ||
433 | |||
434 | 443 | ||
435 | Locking requirements | 444 | Mutual exclusion |
436 | -------------------- | 445 | ---------------- |
437 | 446 | ||
438 | All three suspend/resume methods are always called while holding the | 447 | For external events -- but not necessarily for autosuspend or |
439 | usb_device's PM mutex. For external events -- but not necessarily for | 448 | autoresume -- the device semaphore (udev->dev.sem) will be held when a |
440 | autosuspend or autoresume -- the device semaphore (udev->dev.sem) will | 449 | suspend or resume method is called. This implies that external |
441 | also be held. This implies that external suspend/resume events are | 450 | suspend/resume events are mutually exclusive with calls to probe, |
442 | mutually exclusive with calls to probe, disconnect, pre_reset, and | 451 | disconnect, pre_reset, and post_reset; the USB core guarantees that |
443 | post_reset; the USB core guarantees that this is true of internal | 452 | this is true of autosuspend/autoresume events as well. |
444 | suspend/resume events as well. | ||
445 | 453 | ||
446 | If a driver wants to block all suspend/resume calls during some | 454 | If a driver wants to block all suspend/resume calls during some |
447 | critical section, it can simply acquire udev->pm_mutex. Note that | 455 | critical section, the best way is to lock the device and call |
448 | calls to resume may be triggered indirectly. Block IO due to memory | 456 | usb_autopm_get_interface() (and do the reverse at the end of the |
449 | allocations can make the vm subsystem resume a device. Thus while | 457 | critical section). Holding the device semaphore will block all |
450 | holding this lock you must not allocate memory with GFP_KERNEL or | 458 | external PM calls, and the usb_autopm_get_interface() will prevent any |
451 | GFP_NOFS. | 459 | internal PM calls, even if it fails. (Exercise: Why?) |
452 | |||
453 | Alternatively, if the critical section might call some of the | ||
454 | usb_autopm_* routines, the driver can avoid deadlock by doing: | ||
455 | |||
456 | down(&udev->dev.sem); | ||
457 | rc = usb_autopm_get_interface(intf); | ||
458 | |||
459 | and at the end of the critical section: | ||
460 | |||
461 | if (!rc) | ||
462 | usb_autopm_put_interface(intf); | ||
463 | up(&udev->dev.sem); | ||
464 | |||
465 | Holding the device semaphore will block all external PM calls, and the | ||
466 | usb_autopm_get_interface() will prevent any internal PM calls, even if | ||
467 | it fails. (Exercise: Why?) | ||
468 | |||
469 | The rules for locking order are: | ||
470 | |||
471 | Never acquire any device semaphore while holding any PM mutex. | ||
472 | |||
473 | Never acquire udev->pm_mutex while holding the PM mutex for | ||
474 | a device that isn't a descendant of udev. | ||
475 | |||
476 | In other words, PM mutexes should only be acquired going up the device | ||
477 | tree, and they should be acquired only after locking all the device | ||
478 | semaphores you need to hold. These rules don't matter to drivers very | ||
479 | much; they usually affect just the USB core. | ||
480 | |||
481 | Still, drivers do need to be careful. For example, many drivers use a | ||
482 | private mutex to synchronize their normal I/O activities with their | ||
483 | disconnect method. Now if the driver supports autosuspend then it | ||
484 | must call usb_autopm_put_interface() from somewhere -- maybe from its | ||
485 | close method. It should make the call while holding the private mutex, | ||
486 | since a driver shouldn't call any of the usb_autopm_* functions for an | ||
487 | interface from which it has been unbound. | ||
488 | |||
489 | But the usb_autpm_* routines always acquire the device's PM mutex, and | ||
490 | consequently the locking order has to be: private mutex first, PM | ||
491 | mutex second. Since the suspend method is always called with the PM | ||
492 | mutex held, it mustn't try to acquire the private mutex. It has to | ||
493 | synchronize with the driver's I/O activities in some other way. | ||
494 | 460 | ||
495 | 461 | ||
496 | Interaction between dynamic PM and system PM | 462 | Interaction between dynamic PM and system PM |
@@ -499,22 +465,11 @@ synchronize with the driver's I/O activities in some other way. | |||
499 | Dynamic power management and system power management can interact in | 465 | Dynamic power management and system power management can interact in |
500 | a couple of ways. | 466 | a couple of ways. |
501 | 467 | ||
502 | Firstly, a device may already be manually suspended or autosuspended | 468 | Firstly, a device may already be autosuspended when a system suspend |
503 | when a system suspend occurs. Since system suspends are supposed to | 469 | occurs. Since system suspends are supposed to be as transparent as |
504 | be as transparent as possible, the device should remain suspended | 470 | possible, the device should remain suspended following the system |
505 | following the system resume. The 2.6.23 kernel obeys this principle | 471 | resume. But this theory may not work out well in practice; over time |
506 | for manually suspended devices but not for autosuspended devices; they | 472 | the kernel's behavior in this regard has changed. |
507 | do get resumed when the system wakes up. (Presumably they will be | ||
508 | autosuspended again after their idle-delay time expires.) In later | ||
509 | kernels this behavior will be fixed. | ||
510 | |||
511 | (There is an exception. If a device would undergo a reset-resume | ||
512 | instead of a normal resume, and the device is enabled for remote | ||
513 | wakeup, then the reset-resume takes place even if the device was | ||
514 | already suspended when the system suspend began. The justification is | ||
515 | that a reset-resume is a kind of remote-wakeup event. Or to put it | ||
516 | another way, a device which needs a reset won't be able to generate | ||
517 | normal remote-wakeup signals, so it ought to be resumed immediately.) | ||
518 | 473 | ||
519 | Secondly, a dynamic power-management event may occur as a system | 474 | Secondly, a dynamic power-management event may occur as a system |
520 | suspend is underway. The window for this is short, since system | 475 | suspend is underway. The window for this is short, since system |