diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2007-05-30 15:39:33 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-12 19:34:30 -0400 |
commit | b41a60eca833d76593d4dac8a59f5c38714194ee (patch) | |
tree | a7c5cf721d9978503c3c8c88183747cf954b8733 /Documentation | |
parent | 54515fe528d8c6f9bfaf7d0b9fffb908deecad78 (diff) |
USB: add power/persist device attribute
This patch (as920) adds an extra level of protection to the
USB-Persist facility. Now it will apply by default only to hubs; for
all other devices the user must enable it explicitly by setting the
power/persist device attribute.
The disconnect_all_children() routine in hub.c has been removed and
its code placed inline. This is the way it was originally as part of
hub_pre_reset(); the revised usage in hub_reset_resume() is
sufficiently different that the code can no longer be shared.
Likewise, mark_children_for_reset() is now inline as part of
hub_reset_resume(). The end result looks much cleaner than before.
The sysfs interface is updated to add the new attribute file, and
there are corresponding documentation updates.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/ABI/testing/sysfs-bus-usb | 13 | ||||
-rw-r--r-- | Documentation/usb/persist.txt | 38 |
2 files changed, 38 insertions, 13 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb index f9937add033d..9734577d1711 100644 --- a/Documentation/ABI/testing/sysfs-bus-usb +++ b/Documentation/ABI/testing/sysfs-bus-usb | |||
@@ -39,3 +39,16 @@ Description: | |||
39 | If you want to suspend a device immediately but leave it | 39 | If you want to suspend a device immediately but leave it |
40 | free to wake up in response to I/O requests, you should | 40 | free to wake up in response to I/O requests, you should |
41 | write "0" to power/autosuspend. | 41 | write "0" to power/autosuspend. |
42 | |||
43 | What: /sys/bus/usb/devices/.../power/persist | ||
44 | Date: May 2007 | ||
45 | KernelVersion: 2.6.23 | ||
46 | Contact: Alan Stern <stern@rowland.harvard.edu> | ||
47 | Description: | ||
48 | If CONFIG_USB_PERSIST is set, then each USB device directory | ||
49 | will contain a file named power/persist. The file holds a | ||
50 | boolean value (0 or 1) indicating whether or not the | ||
51 | "USB-Persist" facility is enabled for the device. Since the | ||
52 | facility is inherently dangerous, it is disabled by default | ||
53 | for all devices except hubs. For more information, see | ||
54 | Documentation/usb/persist.txt. | ||
diff --git a/Documentation/usb/persist.txt b/Documentation/usb/persist.txt index 6dcd5f884795..df54d645cbb5 100644 --- a/Documentation/usb/persist.txt +++ b/Documentation/usb/persist.txt | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | Alan Stern <stern@rowland.harvard.edu> | 3 | Alan Stern <stern@rowland.harvard.edu> |
4 | 4 | ||
5 | September 2, 2006 (Updated March 27, 2007) | 5 | September 2, 2006 (Updated May 29, 2007) |
6 | 6 | ||
7 | 7 | ||
8 | What is the problem? | 8 | What is the problem? |
@@ -52,9 +52,9 @@ you can convince the BIOS supplier to fix the problem (lots of luck!). | |||
52 | 52 | ||
53 | On many systems the USB host controllers will get reset after a | 53 | On many systems the USB host controllers will get reset after a |
54 | suspend-to-RAM. On almost all systems, no suspend current is | 54 | suspend-to-RAM. On almost all systems, no suspend current is |
55 | available during suspend-to-disk (also known as swsusp). You can | 55 | available during hibernation (also known as swsusp or suspend-to-disk). |
56 | check the kernel log after resuming to see if either of these has | 56 | You can check the kernel log after resuming to see if either of these |
57 | happened; look for lines saying "root hub lost power or was reset". | 57 | has happened; look for lines saying "root hub lost power or was reset". |
58 | 58 | ||
59 | In practice, people are forced to unmount any filesystems on a USB | 59 | In practice, people are forced to unmount any filesystems on a USB |
60 | device before suspending. If the root filesystem is on a USB device, | 60 | device before suspending. If the root filesystem is on a USB device, |
@@ -71,15 +71,16 @@ structures are allowed to persist across a power-session disruption. | |||
71 | It works like this. If the kernel sees that a USB host controller is | 71 | It works like this. If the kernel sees that a USB host controller is |
72 | not in the expected state during resume (i.e., if the controller was | 72 | not in the expected state during resume (i.e., if the controller was |
73 | reset or otherwise had lost power) then it applies a persistence check | 73 | reset or otherwise had lost power) then it applies a persistence check |
74 | to each of the USB devices below that controller. It doesn't try to | 74 | to each of the USB devices below that controller for which the |
75 | resume the device; that can't work once the power session is gone. | 75 | "persist" attribute is set. It doesn't try to resume the device; that |
76 | Instead it issues a USB port reset and then re-enumerates the device. | 76 | can't work once the power session is gone. Instead it issues a USB |
77 | (This is exactly the same thing that happens whenever a USB device is | 77 | port reset and then re-enumerates the device. (This is exactly the |
78 | reset.) If the re-enumeration shows that the device now attached to | 78 | same thing that happens whenever a USB device is reset.) If the |
79 | that port has the same descriptors as before, including the Vendor and | 79 | re-enumeration shows that the device now attached to that port has the |
80 | Product IDs, then the kernel continues to use the same device | 80 | same descriptors as before, including the Vendor and Product IDs, then |
81 | structure. In effect, the kernel treats the device as though it had | 81 | the kernel continues to use the same device structure. In effect, the |
82 | merely been reset instead of unplugged. | 82 | kernel treats the device as though it had merely been reset instead of |
83 | unplugged. | ||
83 | 84 | ||
84 | If no device is now attached to the port, or if the descriptors are | 85 | If no device is now attached to the port, or if the descriptors are |
85 | different from what the kernel remembers, then the treatment is what | 86 | different from what the kernel remembers, then the treatment is what |
@@ -91,6 +92,17 @@ The end result is that the USB device remains available and usable. | |||
91 | Filesystem mounts and memory mappings are unaffected, and the world is | 92 | Filesystem mounts and memory mappings are unaffected, and the world is |
92 | now a good and happy place. | 93 | now a good and happy place. |
93 | 94 | ||
95 | Note that even when CONFIG_USB_PERSIST is set, the "persist" feature | ||
96 | will be applied only to those devices for which it is enabled. You | ||
97 | can enable the feature by doing (as root): | ||
98 | |||
99 | echo 1 >/sys/bus/usb/devices/.../power/persist | ||
100 | |||
101 | where the "..." should be filled in the with the device's ID. Disable | ||
102 | the feature by writing 0 instead of 1. For hubs the feature is | ||
103 | automatically and permanently enabled, so you only have to worry about | ||
104 | setting it for devices where it really matters. | ||
105 | |||
94 | 106 | ||
95 | Is this the best solution? | 107 | Is this the best solution? |
96 | 108 | ||