Device and Bus Power Management
USB selective suspend
This is a project in progress for the USB subsystem. USB selective suspend allows you to suspend a USB device on demand. If one device doesn't support selective suspend, then the entire bus must remain active. This not only consumes USB bus power unnecessarily, but also prevents the CPU from entering lower power states.A white paper describing USB selective suspend can be found here.
Autosuspend on Linux
For a device to be autosuspended in Linux, it must have in-kernel driver support. Currently there are several types of USB devices that have autosuspend support:
- printers
- hubs
- some USB Ethernet devices
- USB LCDs
Although kernel drivers may support autosuspend, some USB devices may not properly implement autosuspend. These devices may behave in unexpected ways, or simply not work after the kernel attempts to suspend them. Often a physical disconnection from the bus will fix the problem, but only until the kernel attempts to suspend the device again.
If you see these types of problems, please send mail to linux-usb-users@lists.sourceforge.net. Include output from `lsusb -v`, dmesg output with CONFIG_USB_DEBUG turned on, and a description of the symptoms. We would also appreciate a note that your USB device actually works with autosuspend.
Enabling Autosuspend
To enable autosuspend, you must recompile your kernel with CONFIG_USB_SUSPEND. (As of 2.6.23-rc6, this feature is marked "experimental".) You may also want to enable CONFIG_USB_DEBUG so you can see suspend and resume messages via dmesg.
Autosuspending USB devices
To attempt to autosuspend your USB device, first use lsusb as root to find out the bus number and device number of your usb device:# lsusb Bus 005 Device 014: ID 04b3:4485 IBM Corp. Bus 005 Device 001: ID 0000:0000 Bus 004 Device 009: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader Bus 004 Device 001: ID 0000:0000 Bus 002 Device 001: ID 0000:0000 Bus 003 Device 001: ID 0000:0000 Bus 001 Device 008: ID 04b3:310c IBM Corp. Bus 001 Device 007: ID 050d:0121 Belkin Components F5D5050 100Mbps Ethernet Bus 001 Device 001: ID 0000:0000Then find your device's directory in /sys/bus/usb/devices/. Look in directories that are named with two numbers separated with a dash:
/sys/bus/usb/devices# ls 1-0:1.0 1-1 1-1:1.0 1-2 1-2:1.0 2-0:1.0 3-0:1.0 4-0:1.0 4-2 4-2:1.0 5-0:1.0 5-6 5-6:1.0 usb1 usb2 usb3 usb4 usb5 /sys/bus/usb/devices# cat 1-1/busnum 1 /sys/bus/usb/devices# cat 1-1/devnum 8 /sys/bus/usb/devices# cat 1-2/busnum 1 /sys/bus/usb/devices# cat 1-2/devnum 7We know the USB to ethernet device's directory is 1-2 because the device and bus numbers match the lsusb output. Now we can tell the kernel that it should suspend this device automatically if it is not being used. First we set the idle timeout to 2 seconds:
/sys/bus/usb/devices# echo 2 > 1-2/power/autosuspendThe timeout can be set to any integer number of seconds. If set to -1, the device will not autosuspend. Then we make sure the kernel will automatically suspend the device, and resume the device if data needs to be transferred:
/sys/bus/usb/devices# echo auto > 1-2/power/level
Other options to echo to this file are "on" and "suspend":
- "on" will force the device to be on all the time.
- "suspend" will permanently suspend the device until the user echoes "on" or "auto" to this file.
(Note that this is a simplification, since the value of the power/wakeup file may allow the device to signal a remote wakeup.)
For a more complete description of USB power management, see the file Documentation/usb/power-management.txt, which is in kernel sources 2.6.24-rc2 and later.