diff options
Diffstat (limited to 'Documentation/usb')
-rw-r--r-- | Documentation/usb/error-codes.txt | 6 | ||||
-rw-r--r-- | Documentation/usb/power-management.txt | 301 |
2 files changed, 125 insertions, 182 deletions
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 ad642615ad4c..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 | October 5, 2007 | 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? |
@@ -71,12 +71,10 @@ being accessed through sysfs, then it definitely is idle. | |||
71 | Forms of dynamic PM | 71 | Forms of dynamic PM |
72 | ------------------- | 72 | ------------------- |
73 | 73 | ||
74 | Dynamic suspends can occur in two ways: manual and automatic. | 74 | Dynamic suspends occur when the kernel decides to suspend an idle |
75 | "Manual" means that the user has told the kernel to suspend a device, | 75 | device. This is called "autosuspend" for short. In general, a device |
76 | whereas "automatic" means that the kernel has decided all by itself to | 76 | won't be autosuspended unless it has been idle for some minimum period |
77 | suspend a device. Automatic suspend is called "autosuspend" for | 77 | of time, the so-called idle-delay time. |
78 | short. In general, a device won't be autosuspended unless it has been | ||
79 | idle for some minimum period of time, the so-called idle-delay time. | ||
80 | 78 | ||
81 | Of course, nothing the kernel does on its own initiative should | 79 | Of course, nothing the kernel does on its own initiative should |
82 | prevent the computer or its devices from working properly. If a | 80 | prevent the computer or its devices from working properly. If a |
@@ -96,10 +94,11 @@ idle. | |||
96 | We can categorize power management events in two broad classes: | 94 | We can categorize power management events in two broad classes: |
97 | external and internal. External events are those triggered by some | 95 | external and internal. External events are those triggered by some |
98 | agent outside the USB stack: system suspend/resume (triggered by | 96 | agent outside the USB stack: system suspend/resume (triggered by |
99 | userspace), manual dynamic suspend/resume (also triggered by | 97 | userspace), manual dynamic resume (also triggered by userspace), and |
100 | userspace), and remote wakeup (triggered by the device). Internal | 98 | remote wakeup (triggered by the device). Internal events are those |
101 | events are those triggered within the USB stack: autosuspend and | 99 | triggered within the USB stack: autosuspend and autoresume. Note that |
102 | autoresume. | 100 | all dynamic suspend events are internal; external agents are not |
101 | allowed to issue dynamic suspends. | ||
103 | 102 | ||
104 | 103 | ||
105 | The user interface for dynamic PM | 104 | The user interface for dynamic PM |
@@ -123,9 +122,9 @@ relevant attribute files are: wakeup, level, and autosuspend. | |||
123 | 122 | ||
124 | power/level | 123 | power/level |
125 | 124 | ||
126 | This file contains one of three words: "on", "auto", | 125 | This file contains one of two words: "on" or "auto". |
127 | or "suspend". You can write those words to the file | 126 | You can write those words to the file to change the |
128 | to change the device's setting. | 127 | device's setting. |
129 | 128 | ||
130 | "on" means that the device should be resumed and | 129 | "on" means that the device should be resumed and |
131 | autosuspend is not allowed. (Of course, system | 130 | autosuspend is not allowed. (Of course, system |
@@ -134,10 +133,10 @@ relevant attribute files are: wakeup, level, and autosuspend. | |||
134 | "auto" is the normal state in which the kernel is | 133 | "auto" is the normal state in which the kernel is |
135 | allowed to autosuspend and autoresume the device. | 134 | allowed to autosuspend and autoresume the device. |
136 | 135 | ||
137 | "suspend" means that the device should remain | 136 | (In kernels up to 2.6.32, you could also specify |
138 | suspended, and autoresume is not allowed. (But remote | 137 | "suspend", meaning that the device should remain |
139 | wakeup may still be allowed, since it is controlled | 138 | suspended and autoresume was not allowed. This |
140 | separately by the power/wakeup attribute.) | 139 | setting is no longer supported.) |
141 | 140 | ||
142 | power/autosuspend | 141 | power/autosuspend |
143 | 142 | ||
@@ -145,9 +144,9 @@ relevant attribute files are: wakeup, level, and autosuspend. | |||
145 | number of seconds the device should remain idle before | 144 | number of seconds the device should remain idle before |
146 | the kernel will autosuspend it (the idle-delay time). | 145 | the kernel will autosuspend it (the idle-delay time). |
147 | The default is 2. 0 means to autosuspend as soon as | 146 | The default is 2. 0 means to autosuspend as soon as |
148 | the device becomes idle, and -1 means never to | 147 | the device becomes idle, and negative values mean |
149 | autosuspend. You can write a number to the file to | 148 | never to autosuspend. You can write a number to the |
150 | change the autosuspend idle-delay time. | 149 | file to change the autosuspend idle-delay time. |
151 | 150 | ||
152 | Writing "-1" to power/autosuspend and writing "on" to power/level do | 151 | Writing "-1" to power/autosuspend and writing "on" to power/level do |
153 | essentially the same thing -- they both prevent the device from being | 152 | essentially the same thing -- they both prevent the device from being |
@@ -230,6 +229,11 @@ necessary operations by hand or add them to a udev script. You can | |||
230 | 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 |
231 | every device. | 230 | every device. |
232 | 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 | |||
233 | 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 |
234 | autosuspend there are still problems. For example, there are | 238 | autosuspend there are still problems. For example, there are |
235 | experimental patches adding autosuspend support to the usbhid driver, | 239 | experimental patches adding autosuspend support to the usbhid driver, |
@@ -313,82 +317,90 @@ three of the methods listed above. In addition, a driver indicates | |||
313 | that it supports autosuspend by setting the .supports_autosuspend flag | 317 | that it supports autosuspend by setting the .supports_autosuspend flag |
314 | in its usb_driver structure. It is then responsible for informing the | 318 | in its usb_driver structure. It is then responsible for informing the |
315 | USB core whenever one of its interfaces becomes busy or idle. The | 319 | USB core whenever one of its interfaces becomes busy or idle. The |
316 | driver does so by calling these five functions: | 320 | driver does so by calling these six functions: |
317 | 321 | ||
318 | int usb_autopm_get_interface(struct usb_interface *intf); | 322 | int usb_autopm_get_interface(struct usb_interface *intf); |
319 | void usb_autopm_put_interface(struct usb_interface *intf); | 323 | void usb_autopm_put_interface(struct usb_interface *intf); |
320 | int usb_autopm_set_interface(struct usb_interface *intf); | ||
321 | int usb_autopm_get_interface_async(struct usb_interface *intf); | 324 | int usb_autopm_get_interface_async(struct usb_interface *intf); |
322 | void usb_autopm_put_interface_async(struct usb_interface *intf); | 325 | void usb_autopm_put_interface_async(struct usb_interface *intf); |
326 | void usb_autopm_get_interface_no_resume(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 | The driver owns intf->pm_usage_count; it can modify the value however | 340 | Drivers need not be concerned about balancing changes to the usage |
335 | and whenever it likes. A nice aspect of the non-async usb_autopm_* | 341 | counter; the USB core will undo any remaining "get"s when a driver |
336 | routines is that the changes they make are protected by the usb_device | 342 | is unbound from its interface. As a corollary, drivers must not call |
337 | structure's PM mutex (udev->pm_mutex); however drivers may change | 343 | any of the usb_autopm_* functions after their diconnect() routine has |
338 | pm_usage_count without holding the mutex. Drivers using the async | 344 | returned. |
339 | routines are responsible for their own synchronization and mutual | ||
340 | exclusion. | ||
341 | 345 | ||
342 | usb_autopm_get_interface() increments pm_usage_count and | 346 | Drivers using the async routines are responsible for their own |
343 | attempts an autoresume if the new value is > 0 and the | 347 | synchronization and mutual exclusion. |
344 | device is suspended. | ||
345 | 348 | ||
346 | usb_autopm_put_interface() decrements pm_usage_count and | 349 | usb_autopm_get_interface() increments the usage counter and |
347 | attempts an autosuspend if the new value is <= 0 and the | 350 | does an autoresume if the device is suspended. If the |
348 | device isn't suspended. | 351 | autoresume fails, the counter is decremented back. |
349 | 352 | ||
350 | usb_autopm_set_interface() leaves pm_usage_count alone. | 353 | usb_autopm_put_interface() decrements the usage counter and |
351 | It attempts an autoresume if the value is > 0 and the device | 354 | attempts an autosuspend if the new value is = 0. |
352 | is suspended, and it attempts an autosuspend if the value is | ||
353 | <= 0 and the device isn't suspended. | ||
354 | 355 | ||
355 | usb_autopm_get_interface_async() and | 356 | usb_autopm_get_interface_async() and |
356 | usb_autopm_put_interface_async() do almost the same things as | 357 | usb_autopm_put_interface_async() do almost the same things as |
357 | their non-async counterparts. The differences are: they do | 358 | their non-async counterparts. The big difference is that they |
358 | 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 |
359 | 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, |
360 | 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 |
361 | device will not generally not yet be in the desired state. | 362 | device will generally not yet be in the desired state. |
362 | |||
363 | There also are a couple of utility routines drivers can use: | ||
364 | |||
365 | usb_autopm_enable() sets pm_usage_cnt to 0 and then calls | ||
366 | usb_autopm_set_interface(), which will attempt an autosuspend. | ||
367 | 363 | ||
368 | usb_autopm_disable() sets pm_usage_cnt to 1 and then calls | 364 | usb_autopm_get_interface_no_resume() and |
369 | usb_autopm_set_interface(), which will attempt an autoresume. | 365 | usb_autopm_put_interface_no_suspend() merely increment or |
366 | decrement the usage counter; they do not attempt to carry out | ||
367 | an autoresume or an autosuspend. Hence they can be called in | ||
368 | an atomic context. | ||
370 | 369 | ||
371 | The conventional usage pattern is that a driver calls | 370 | The simplest usage pattern is that a driver calls |
372 | usb_autopm_get_interface() in its open routine and | 371 | usb_autopm_get_interface() in its open routine and |
373 | usb_autopm_put_interface() in its close or release routine. But | 372 | usb_autopm_put_interface() in its close or release routine. But other |
374 | other patterns are possible. | 373 | patterns are possible. |
375 | 374 | ||
376 | The autosuspend attempts mentioned above will often fail for one | 375 | The autosuspend attempts mentioned above will often fail for one |
377 | reason or another. For example, the power/level attribute might be | 376 | reason or another. For example, the power/level attribute might be |
378 | 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 |
379 | 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 |
380 | 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 |
381 | routine is automatically set up to carry out the operation when the | 380 | carry out the operation automatically when the autosuspend idle-delay |
382 | autosuspend idle-delay has expired. | 381 | has expired. |
383 | 382 | ||
384 | Autoresume attempts also can fail. This will happen if power/level is | 383 | Autoresume attempts also can fail, although failure would mean that |
385 | set to "suspend" or if the device doesn't manage to resume properly. | 384 | the device is no longer present or operating properly. Unlike |
386 | Unlike autosuspend, there's no delay for an autoresume. | 385 | autosuspend, there's no idle-delay for an autoresume. |
387 | 386 | ||
388 | 387 | ||
389 | Other parts of the driver interface | 388 | Other parts of the driver interface |
390 | ----------------------------------- | 389 | ----------------------------------- |
391 | 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 | |||
392 | 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 |
393 | during autosuspend. For example, there's not much point | 405 | during autosuspend. For example, there's not much point |
394 | 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 |
@@ -400,101 +412,51 @@ though, setting this flag won't cause the kernel to autoresume it. | |||
400 | 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 |
401 | time the device is guaranteed not to be autosuspended.) | 413 | time the device is guaranteed not to be autosuspended.) |
402 | 414 | ||
403 | The usb_autopm_* routines have to run in a sleepable process context; | 415 | If a driver does its I/O asynchronously in interrupt context, it |
404 | they must not be called from an interrupt handler or while holding a | 416 | should call usb_autopm_get_interface_async() before starting output and |
405 | spinlock. In fact, the entire autosuspend mechanism is not well geared | 417 | usb_autopm_put_interface_async() when the output queue drains. When |
406 | toward interrupt-driven operation. However there is one thing a | 418 | it receives an input event, it should call |
407 | driver can do in an interrupt handler: | ||
408 | 419 | ||
409 | usb_mark_last_busy(struct usb_device *udev); | 420 | usb_mark_last_busy(struct usb_device *udev); |
410 | 421 | ||
411 | 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. |
412 | field used for idle-delay calculations; updating it will cause any | 423 | udev->last_busy is the field used for idle-delay calculations; |
413 | pending autosuspend to be moved back. The usb_autopm_* routines will | 424 | updating it will cause any pending autosuspend to be moved back. Most |
414 | 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 |
415 | 426 | current time. | |
416 | Calling urb_mark_last_busy() from within an URB completion handler is | 427 | |
417 | subject to races: The kernel may have just finished deciding the | 428 | Asynchronous operation is always subject to races. For example, a |
418 | 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 |
419 | 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 |
420 | responsible for synchronizing its suspend method with its URB | 431 | idle for long enough but not yet gotten around to calling the driver's |
421 | completion handler and causing the autosuspend to fail with -EBUSY if | 432 | suspend method. The suspend method must be responsible for |
422 | 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. | ||
423 | 436 | ||
424 | 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, |
425 | only autosuspend calls. The driver can tell them apart by checking | 438 | only autosuspend calls. The driver can tell them apart by checking |
426 | udev->auto_pm; this flag will be set to 1 for internal PM events | 439 | the PM_EVENT_AUTO bit in the message.event argument to the suspend |
427 | (autosuspend or autoresume) and 0 for external PM events. | 440 | method; this bit will be set for internal PM events (autosuspend) and |
428 | 441 | clear for external PM events. | |
429 | Many of the ingredients in the autosuspend framework are oriented | ||
430 | towards interfaces: The usb_interface structure contains the | ||
431 | pm_usage_cnt field, and the usb_autopm_* routines take an interface | ||
432 | pointer as their argument. But somewhat confusingly, a few of the | ||
433 | pieces (usb_mark_last_busy() and udev->auto_pm) use the usb_device | ||
434 | structure instead. Drivers need to keep this straight; they can call | ||
435 | interface_to_usbdev() to find the device structure for a given | ||
436 | interface. | ||
437 | |||
438 | |||
439 | Locking requirements | ||
440 | -------------------- | ||
441 | |||
442 | All three suspend/resume methods are always called while holding the | ||
443 | usb_device's PM mutex. For external events -- but not necessarily for | ||
444 | autosuspend or autoresume -- the device semaphore (udev->dev.sem) will | ||
445 | also be held. This implies that external suspend/resume events are | ||
446 | mutually exclusive with calls to probe, disconnect, pre_reset, and | ||
447 | post_reset; the USB core guarantees that this is true of internal | ||
448 | suspend/resume events as well. | ||
449 | |||
450 | If a driver wants to block all suspend/resume calls during some | ||
451 | critical section, it can simply acquire udev->pm_mutex. Note that | ||
452 | calls to resume may be triggered indirectly. Block IO due to memory | ||
453 | allocations can make the vm subsystem resume a device. Thus while | ||
454 | holding this lock you must not allocate memory with GFP_KERNEL or | ||
455 | GFP_NOFS. | ||
456 | |||
457 | Alternatively, if the critical section might call some of the | ||
458 | usb_autopm_* routines, the driver can avoid deadlock by doing: | ||
459 | |||
460 | down(&udev->dev.sem); | ||
461 | rc = usb_autopm_get_interface(intf); | ||
462 | |||
463 | and at the end of the critical section: | ||
464 | |||
465 | if (!rc) | ||
466 | usb_autopm_put_interface(intf); | ||
467 | up(&udev->dev.sem); | ||
468 | 442 | ||
469 | Holding the device semaphore will block all external PM calls, and the | ||
470 | usb_autopm_get_interface() will prevent any internal PM calls, even if | ||
471 | it fails. (Exercise: Why?) | ||
472 | 443 | ||
473 | The rules for locking order are: | 444 | Mutual exclusion |
445 | ---------------- | ||
474 | 446 | ||
475 | Never acquire any device semaphore while holding any PM mutex. | 447 | For external events -- but not necessarily for autosuspend or |
448 | autoresume -- the device semaphore (udev->dev.sem) will be held when a | ||
449 | suspend or resume method is called. This implies that external | ||
450 | suspend/resume events are mutually exclusive with calls to probe, | ||
451 | disconnect, pre_reset, and post_reset; the USB core guarantees that | ||
452 | this is true of autosuspend/autoresume events as well. | ||
476 | 453 | ||
477 | Never acquire udev->pm_mutex while holding the PM mutex for | 454 | If a driver wants to block all suspend/resume calls during some |
478 | a device that isn't a descendant of udev. | 455 | critical section, the best way is to lock the device and call |
479 | 456 | usb_autopm_get_interface() (and do the reverse at the end of the | |
480 | In other words, PM mutexes should only be acquired going up the device | 457 | critical section). Holding the device semaphore will block all |
481 | tree, and they should be acquired only after locking all the device | 458 | external PM calls, and the usb_autopm_get_interface() will prevent any |
482 | semaphores you need to hold. These rules don't matter to drivers very | 459 | internal PM calls, even if it fails. (Exercise: Why?) |
483 | much; they usually affect just the USB core. | ||
484 | |||
485 | Still, drivers do need to be careful. For example, many drivers use a | ||
486 | private mutex to synchronize their normal I/O activities with their | ||
487 | disconnect method. Now if the driver supports autosuspend then it | ||
488 | must call usb_autopm_put_interface() from somewhere -- maybe from its | ||
489 | close method. It should make the call while holding the private mutex, | ||
490 | since a driver shouldn't call any of the usb_autopm_* functions for an | ||
491 | interface from which it has been unbound. | ||
492 | |||
493 | But the usb_autpm_* routines always acquire the device's PM mutex, and | ||
494 | consequently the locking order has to be: private mutex first, PM | ||
495 | mutex second. Since the suspend method is always called with the PM | ||
496 | mutex held, it mustn't try to acquire the private mutex. It has to | ||
497 | synchronize with the driver's I/O activities in some other way. | ||
498 | 460 | ||
499 | 461 | ||
500 | Interaction between dynamic PM and system PM | 462 | Interaction between dynamic PM and system PM |
@@ -503,22 +465,11 @@ synchronize with the driver's I/O activities in some other way. | |||
503 | Dynamic power management and system power management can interact in | 465 | Dynamic power management and system power management can interact in |
504 | a couple of ways. | 466 | a couple of ways. |
505 | 467 | ||
506 | Firstly, a device may already be manually suspended or autosuspended | 468 | Firstly, a device may already be autosuspended when a system suspend |
507 | when a system suspend occurs. Since system suspends are supposed to | 469 | occurs. Since system suspends are supposed to be as transparent as |
508 | be as transparent as possible, the device should remain suspended | 470 | possible, the device should remain suspended following the system |
509 | 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 |
510 | for manually suspended devices but not for autosuspended devices; they | 472 | the kernel's behavior in this regard has changed. |
511 | do get resumed when the system wakes up. (Presumably they will be | ||
512 | autosuspended again after their idle-delay time expires.) In later | ||
513 | kernels this behavior will be fixed. | ||
514 | |||
515 | (There is an exception. If a device would undergo a reset-resume | ||
516 | instead of a normal resume, and the device is enabled for remote | ||
517 | wakeup, then the reset-resume takes place even if the device was | ||
518 | already suspended when the system suspend began. The justification is | ||
519 | that a reset-resume is a kind of remote-wakeup event. Or to put it | ||
520 | another way, a device which needs a reset won't be able to generate | ||
521 | normal remote-wakeup signals, so it ought to be resumed immediately.) | ||
522 | 473 | ||
523 | Secondly, a dynamic power-management event may occur as a system | 474 | Secondly, a dynamic power-management event may occur as a system |
524 | suspend is underway. The window for this is short, since system | 475 | suspend is underway. The window for this is short, since system |
@@ -530,13 +481,3 @@ succeed, it may still remain active and thus cause the system to | |||
530 | resume as soon as the system suspend is complete. Or the remote | 481 | resume as soon as the system suspend is complete. Or the remote |
531 | wakeup may fail and get lost. Which outcome occurs depends on timing | 482 | wakeup may fail and get lost. Which outcome occurs depends on timing |
532 | and on the hardware and firmware design. | 483 | and on the hardware and firmware design. |
533 | |||
534 | More interestingly, a device might undergo a manual resume or | ||
535 | autoresume during system suspend. With current kernels this shouldn't | ||
536 | happen, because manual resumes must be initiated by userspace and | ||
537 | autoresumes happen in response to I/O requests, but all user processes | ||
538 | and I/O should be quiescent during a system suspend -- thanks to the | ||
539 | freezer. However there are plans to do away with the freezer, which | ||
540 | would mean these things would become possible. If and when this comes | ||
541 | about, the USB core will carefully arrange matters so that either type | ||
542 | of resume will block until the entire system has resumed. | ||