aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/usb/power-management.txt113
1 files changed, 58 insertions, 55 deletions
diff --git a/Documentation/usb/power-management.txt b/Documentation/usb/power-management.txt
index b29d8e56cf28..c9ffa9ced7ee 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 December 11, 2009 5 October 28, 2010
6 6
7 7
8 8
@@ -107,9 +107,14 @@ allowed to issue dynamic suspends.
107The user interface for controlling dynamic PM is located in the power/ 107The user interface for controlling dynamic PM is located in the power/
108subdirectory of each USB device's sysfs directory, that is, in 108subdirectory of each USB device's sysfs directory, that is, in
109/sys/bus/usb/devices/.../power/ where "..." is the device's ID. The 109/sys/bus/usb/devices/.../power/ where "..." is the device's ID. The
110relevant attribute files are: wakeup, control, and autosuspend. 110relevant attribute files are: wakeup, control, and
111(There may also be a file named "level"; this file was deprecated 111autosuspend_delay_ms. (There may also be a file named "level"; this
112as of the 2.6.35 kernel and replaced by the "control" file.) 112file was deprecated as of the 2.6.35 kernel and replaced by the
113"control" file. In 2.6.38 the "autosuspend" file will be deprecated
114and replaced by the "autosuspend_delay_ms" file. The only difference
115is that the newer file expresses the delay in milliseconds whereas the
116older file uses seconds. Confusingly, both files are present in 2.6.37
117but only "autosuspend" works.)
113 118
114 power/wakeup 119 power/wakeup
115 120
@@ -140,33 +145,36 @@ as of the 2.6.35 kernel and replaced by the "control" file.)
140 suspended and autoresume was not allowed. This 145 suspended and autoresume was not allowed. This
141 setting is no longer supported.) 146 setting is no longer supported.)
142 147
143 power/autosuspend 148 power/autosuspend_delay_ms
144 149
145 This file contains an integer value, which is the 150 This file contains an integer value, which is the
146 number of seconds the device should remain idle before 151 number of milliseconds the device should remain idle
147 the kernel will autosuspend it (the idle-delay time). 152 before the kernel will autosuspend it (the idle-delay
148 The default is 2. 0 means to autosuspend as soon as 153 time). The default is 2000. 0 means to autosuspend
149 the device becomes idle, and negative values mean 154 as soon as the device becomes idle, and negative
150 never to autosuspend. You can write a number to the 155 values mean never to autosuspend. You can write a
151 file to change the autosuspend idle-delay time. 156 number to the file to change the autosuspend
152 157 idle-delay time.
153Writing "-1" to power/autosuspend and writing "on" to power/control do 158
154essentially the same thing -- they both prevent the device from being 159Writing "-1" to power/autosuspend_delay_ms and writing "on" to
155autosuspended. Yes, this is a redundancy in the API. 160power/control do essentially the same thing -- they both prevent the
161device from being autosuspended. Yes, this is a redundancy in the
162API.
156 163
157(In 2.6.21 writing "0" to power/autosuspend would prevent the device 164(In 2.6.21 writing "0" to power/autosuspend would prevent the device
158from being autosuspended; the behavior was changed in 2.6.22. The 165from being autosuspended; the behavior was changed in 2.6.22. The
159power/autosuspend attribute did not exist prior to 2.6.21, and the 166power/autosuspend attribute did not exist prior to 2.6.21, and the
160power/level attribute did not exist prior to 2.6.22. power/control 167power/level attribute did not exist prior to 2.6.22. power/control
161was added in 2.6.34.) 168was added in 2.6.34, and power/autosuspend_delay_ms was added in
1692.6.37 but did not become functional until 2.6.38.)
162 170
163 171
164 Changing the default idle-delay time 172 Changing the default idle-delay time
165 ------------------------------------ 173 ------------------------------------
166 174
167The default autosuspend idle-delay time is controlled by a module 175The default autosuspend idle-delay time (in seconds) is controlled by
168parameter in usbcore. You can specify the value when usbcore is 176a module parameter in usbcore. You can specify the value when usbcore
169loaded. For example, to set it to 5 seconds instead of 2 you would 177is loaded. For example, to set it to 5 seconds instead of 2 you would
170do: 178do:
171 179
172 modprobe usbcore autosuspend=5 180 modprobe usbcore autosuspend=5
@@ -234,25 +242,23 @@ every device.
234 242
235If a driver knows that its device has proper suspend/resume support, 243If a driver knows that its device has proper suspend/resume support,
236it can enable autosuspend all by itself. For example, the video 244it can enable autosuspend all by itself. For example, the video
237driver for a laptop's webcam might do this, since these devices are 245driver for a laptop's webcam might do this (in recent kernels they
238rarely used and so should normally be autosuspended. 246do), since these devices are rarely used and so should normally be
247autosuspended.
239 248
240Sometimes it turns out that even when a device does work okay with 249Sometimes it turns out that even when a device does work okay with
241autosuspend there are still problems. For example, there are 250autosuspend there are still problems. For example, the usbhid driver,
242experimental patches adding autosuspend support to the usbhid driver, 251which manages keyboards and mice, has autosuspend support. Tests with
243which manages keyboards and mice, among other things. Tests with a 252a number of keyboards show that typing on a suspended keyboard, while
244number of keyboards showed that typing on a suspended keyboard, while 253causing the keyboard to do a remote wakeup all right, will nonetheless
245causing the keyboard to do a remote wakeup all right, would 254frequently result in lost keystrokes. Tests with mice show that some
246nonetheless frequently result in lost keystrokes. Tests with mice 255of them will issue a remote-wakeup request in response to button
247showed that some of them would issue a remote-wakeup request in 256presses but not to motion, and some in response to neither.
248response to button presses but not to motion, and some in response to
249neither.
250 257
251The kernel will not prevent you from enabling autosuspend on devices 258The kernel will not prevent you from enabling autosuspend on devices
252that can't handle it. It is even possible in theory to damage a 259that can't handle it. It is even possible in theory to damage a
253device by suspending it at the wrong time -- for example, suspending a 260device by suspending it at the wrong time. (Highly unlikely, but
254USB hard disk might cause it to spin down without parking the heads. 261possible.) Take care.
255(Highly unlikely, but possible.) Take care.
256 262
257 263
258 The driver interface for Power Management 264 The driver interface for Power Management
@@ -336,10 +342,6 @@ autosuspend the interface's device. When the usage counter is = 0
336then the interface is considered to be idle, and the kernel may 342then the interface is considered to be idle, and the kernel may
337autosuspend the device. 343autosuspend the device.
338 344
339(There is a similar usage counter field in struct usb_device,
340associated with the device itself rather than any of its interfaces.
341This counter is used only by the USB core.)
342
343Drivers need not be concerned about balancing changes to the usage 345Drivers need not be concerned about balancing changes to the usage
344counter; the USB core will undo any remaining "get"s when a driver 346counter; the USB core will undo any remaining "get"s when a driver
345is unbound from its interface. As a corollary, drivers must not call 347is unbound from its interface. As a corollary, drivers must not call
@@ -409,11 +411,11 @@ during autosuspend. For example, there's not much point
409autosuspending a keyboard if the user can't cause the keyboard to do a 411autosuspending a keyboard if the user can't cause the keyboard to do a
410remote wakeup by typing on it. If the driver sets 412remote wakeup by typing on it. If the driver sets
411intf->needs_remote_wakeup to 1, the kernel won't autosuspend the 413intf->needs_remote_wakeup to 1, the kernel won't autosuspend the
412device if remote wakeup isn't available or has been disabled through 414device if remote wakeup isn't available. (If the device is already
413the power/wakeup attribute. (If the device is already autosuspended, 415autosuspended, though, setting this flag won't cause the kernel to
414though, setting this flag won't cause the kernel to autoresume it. 416autoresume it. Normally a driver would set this flag in its probe
415Normally a driver would set this flag in its probe method, at which 417method, at which time the device is guaranteed not to be
416time the device is guaranteed not to be autosuspended.) 418autosuspended.)
417 419
418If a driver does its I/O asynchronously in interrupt context, it 420If a driver does its I/O asynchronously in interrupt context, it
419should call usb_autopm_get_interface_async() before starting output and 421should call usb_autopm_get_interface_async() before starting output and
@@ -422,20 +424,19 @@ it receives an input event, it should call
422 424
423 usb_mark_last_busy(struct usb_device *udev); 425 usb_mark_last_busy(struct usb_device *udev);
424 426
425in the event handler. This sets udev->last_busy to the current time. 427in the event handler. This tells the PM core that the device was just
426udev->last_busy is the field used for idle-delay calculations; 428busy and therefore the next autosuspend idle-delay expiration should
427updating it will cause any pending autosuspend to be moved back. Most 429be pushed back. Many of the usb_autopm_* routines also make this call,
428of the usb_autopm_* routines will also set the last_busy field to the 430so drivers need to worry only when interrupt-driven input arrives.
429current time.
430 431
431Asynchronous operation is always subject to races. For example, a 432Asynchronous operation is always subject to races. For example, a
432driver may call one of the usb_autopm_*_interface_async() routines at 433driver may call the usb_autopm_get_interface_async() routine at a time
433a time when the core has just finished deciding the device has been 434when the core has just finished deciding the device has been idle for
434idle for long enough but not yet gotten around to calling the driver's 435long enough but not yet gotten around to calling the driver's suspend
435suspend method. The suspend method must be responsible for 436method. The suspend method must be responsible for synchronizing with
436synchronizing with the output request routine and the URB completion 437the I/O request routine and the URB completion handler; it should
437handler; it should cause autosuspends to fail with -EBUSY if the 438cause autosuspends to fail with -EBUSY if the driver needs to use the
438driver needs to use the device. 439device.
439 440
440External suspend calls should never be allowed to fail in this way, 441External suspend calls should never be allowed to fail in this way,
441only autosuspend calls. The driver can tell them apart by checking 442only autosuspend calls. The driver can tell them apart by checking
@@ -472,7 +473,9 @@ Firstly, a device may already be autosuspended when a system suspend
472occurs. Since system suspends are supposed to be as transparent as 473occurs. Since system suspends are supposed to be as transparent as
473possible, the device should remain suspended following the system 474possible, the device should remain suspended following the system
474resume. But this theory may not work out well in practice; over time 475resume. But this theory may not work out well in practice; over time
475the kernel's behavior in this regard has changed. 476the kernel's behavior in this regard has changed. As of 2.6.37 the
477policy is to resume all devices during a system resume and let them
478handle their own runtime suspends afterward.
476 479
477Secondly, a dynamic power-management event may occur as a system 480Secondly, a dynamic power-management event may occur as a system
478suspend is underway. The window for this is short, since system 481suspend is underway. The window for this is short, since system