25

This is related to the issue discussed in Wireless mouse temporarily freezes (sleeps) on battery power.

Summary: the mouse freezes when operating on battery since it is autosuspended after a certain time and needs more time to wake up.

Disabling USB autosuspend for the mouse's receiver in PowerTOP is a temporary solution, but it does not survive a reboot.

How can I permanently disable the USB autosuspend for only one specific device?

A solution that does not involve installing additional packages is preferred (after all, I want to disable something), but it is not required. Removing PowerTOP (which seems to be a solution for some) is not what I want - I like PowerTOP...

And installing laptop-mode-tools to disable USB autosuspend altogether is not what I want, either, thus the new question.

Also: Will this affect the battery of my notebook? The Logitech unifying receiver for the mouse stays connected all the time, so if that prevents the autosuspend from happening for all devices that would probably be bad.

6 Answers 6

29

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).

6
  • Actually my mouse got lost/stolen shortly after, so I cannot test this. But judging from the .conf file this is exactly the kind of thing I was hoping for :) Nov 3, 2013 at 11:36
  • Looks like it's AUTOSUSPEND_RUNTIME_DEVID_BLACKLIST now (Ubuntu 17.04) Oct 1, 2017 at 1:46
  • 2
    Dell's Ubuntu laptops with Ubuntu 16.04 LTS have tlp installed rather than laptop-mode-tools, so if you want to blacklist USB devices from being put into autosuspend mode on these laptops, set the USB_BLACKLIST setting in the file /etc/default/tlp - the changes take place immediately Jan 1, 2018 at 23:51
  • HIDs are already blacklisting from tlp: /etc/default/tlp # Note: input devices (usbhid) are excluded automatically (see below) #USB_BLACKLIST="045e:07a5"
    – Tom
    Jun 21, 2018 at 16:31
  • The TLP documentation mentions that it’s a power management for laptops (more specifically ThinkPad). Does it work for desktop PCs? Feb 21, 2019 at 9:39
13

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
1
  • 2
    This answer helped me stop USB autosuspend causing my Logitech webcam to make me sound like a chipmunk on Skype. This was on a desktop where installing laptop-mode-tools was inappropriate. I was not able, however, to get udev to write to power/control on boot, but was able to accomplish the same thing by setting the autosuspend delay to -1: SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="0809", TEST=="power/autosuspend", ATTR{power/autosuspend}:="-1"
    – ven42
    Apr 8, 2020 at 4:02
6

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
5

The power options for a USB device are in /sys/bus/usb/devices/n-n/power. Unfortunately, what n-n is for a given device takes some sleuthing to find out, so I think this will prove a stumbling block when it comes to having a script that automatically does

echo -1 > /sys/bus/usb/devices/3-2/power/autosuspend

to turn off autosuspend on that device. The magic n-n does actually appear in the output of

udevadm info --export-db

so I think udev will be your friend here; some kind of udev script keyed on a parameter that identifies your mouse, then runs a script that echos -1 into the relevant file.

3
  • 4
    Will this survive a reboot? echoing into /sys seems to be non-permanent, isn't it? Sep 16, 2012 at 18:53
  • 2
    Put the command in your /etc/rc.local before the 'exit 0' line
    – Bryce
    Sep 18, 2014 at 23:51
  • I have written this gist as an automation for getting the magic number n-n given the device vendor:product id
    – weshouman
    Oct 20, 2022 at 18:10
4

I created my own udev rule:

ACTION=="add", ATTR{idVendor}=="0cf3", ATTR{idProduct}=="3004", RUN="/bin/sh -c 'echo 0 >/sys/\$devpath/authorized'"
2

In Ubuntu 16.04 LTS (Xenial Xerus), I found a solution in /etc/laptop-mode/conf.d/runtime-pm.conf:

# Auto-Suspend timeout in seconds
# Number of seconds after which the USB devices should suspend
AUTOSUSPEND_TIMEOUT=1800

It was originally set for 2 for me. 30 minutes is far more reasonable.

After the change, do:

sudo service laptop-mode restart

I am still not sure how to fully disable it, but this is fine for me now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .