How can I disable USB autosuspend for a specific device?

Ubuntu 16.04 (Xenial Xerus)

sudo apt install tlp
sudo lsusb

Find the USB device's input id - it should look like 1234:5678.

Edit the file sudo vi /etc/default/tlp and add your device's input ID to USB_BLACKLIST by adding the following line with your device's input id like so:

USB_BLACKLIST="1234:5678"

Ubuntu 14.04 (Trusty Tahr)

As mentioned here at hecticgeek.com, the trick consists of two parts:

Using lsusb to ascertain the device IDs of the USB devices you wish to disable autosuspend for.

And then adding them to AUTOSUSPEND_USBID_BLACKLIST in the /etc/laptop-mode/conf.d/runtime-pm.conf (usb-autosuspend.conf until Ubuntu 14.04) configuration file (details are well documented in there as well).


I had a similar problem with PCs on an Avocent KVM, where laptop-mode-tools was not installed (and didn't want to solve it that way in any case). In my case, autosuspending the KVM made the keyboard and mouse behave erratically (after a few seconds idle, they'd suspend and lose input data for a while until enough clicks and shakes woke them up).

When I ran PowerTOP and toggled USB autosuspend off for the Avocent, PowerTOP told me the command to disable it from the command line was:

echo 'on' > '/sys/bus/usb/devices/3-10/power/control'

The '3-10' bit will be different on different systems. I'm not sure how to determine that other than running PowerTOP, but there's probably some way.

Instead, I used a udev rule to match the product id of my device:

trent+14.04:/etc/udev/rules.d$ cat 10-usb-avocent-kvm-pm.rules

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0624", ATTR{idProduct}=="0013", ATTR{product}=="SC Secure KVM", TEST=="power/control", ATTR{power/control}:="on"

To get the proper udev information I ran:

udevadm info -a --path /sys/bus/usb/devices/N-N

In /etc/laptop-mode/conf.d/usb-autosuspend.conf you will find:

# Enable USB autosuspend feature?
# Set to 0 to disable
CONTROL_USB_AUTOSUSPEND="auto"

You should change it to CONTROL_USB_AUTOSUSPEND="0".

This will automatically make any USB device have the value "on" in /sys/bus/usb/devices/"DEVICE ID"/power/control. This will make the value of the autosuspend files inactive:

$ cat /sys/bus/usb/devices/"DEVICE ID"/power/autosuspend
2
$ cat /sys/bus/usb/devices/"DEVICE ID"/power/autosuspend_delay_ms
2000