[SOLVED] Keyboard and mouse losing power when idle

It seems like one of the steps in the Linux battery life tuning has worked a little too aggressively on my USB devices, causing my keyboard and mouse to lose power after being idle for a few seconds. I have managed to temporarily fix this by disabling power saving on these devices in powertop, but this doesn’t seem to last between reboots. Does anyone know how to permanently keep them on? (Fedora 36)

1 Like

If you followed all the steps on the tuning page, then it’s likely TLP that is setting the USB autosuspend on boot. Look in /etc/tlp.conf and search for USB_AUTOSUSPEND and USB_DENYLIST and season to taste.

Thanks for the reply
Unfortunately, it seems that powertop is completely ignoring this configuration file
I have set both USB_AUTOSUSPEND = 0 and added the devices to USB_DENYLIST but it still turns on autosuspend for both of them after restarting
I’ve also noticed that a lot of tunables that get set to ‘Good’ after running $ sudo powertop --auto-tune get set back to ‘Bad’ after a restart. ← This only happens when the laptop is plugged in and the settings go back to power saving once the laptop is unplugged, so it is probably intended behaviour

Do you have any idea of what could be causing this?

A quick search gave me two possible solutions: How can I disable USB autosuspend on Ubuntu 18.04? - Ask Ubuntu

  • disable autosuspend completely by setting usbcore.autosuspend=-1 (you can add this in a file in /etc/modprobe.d)
  • add some udev rules for your specific USB devices. This one should work for all input devices: Linux USB powersave: Stop dropping keypresses!

If you do end up needing to go the udev route, this is a nicely detailed writeup: Fixing USB Autosuspend

Here's what I tried without success

I’ve disabled USB autosuspend in TLP:

$ sudo tlp usb
Error: USB autosuspend is disabled. Set USB_AUTOSUSPEND=1 in /etc/tlp.conf.

I’ve added a file to /etc/modprobe.d:

$ cat /etc/modprobe.d/usb-autosuspend

I’ve added udev rules, first all input devices then my specific devices:

$ cat /etc/udev/rules.d/92-usb-input-no-powersave.rules
# all input devices (doesn't work?)
ACTION=="add", SUBSYSTEM=="input", TEST=="power/control", ATTR{power/control}="on"

# Trust keyboard
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="145f", ATTR{idProduct}=="024b", TEST=="power/control", ATTR{power/control}="on"

# Trust mouse
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="30fa", ATTR{idProduct}=="0400", TEST=="power/control", ATTR{power/control}="on"

But still, after every restart my input devices still end up having auto suspend enabled

$ cat /sys/bus/usb/devices/3-3/power/control
$ cat /sys/bus/usb/devices/3-4/power/control

I’ve found the solution! From the Linux battery life tuning thread, I’d followed this step:

This caused powertop --auto-tune to run on startup, completely overriding any other power settings
This can be undone by running
$ sudo systemctl disable powertop

Now all of my earlier attempts can work together to triple make sure that my mouse and keyboard stay on.