Everytime I was using my wireless USB keyboard with my laptop while the power cable was not connected, the keyboard behaviour was lousy, and keystrokes tend to be delayed by several seconds. The kernel logs said something like
[23302.802096] uhci_hcd 0000:00:1a.0: setting latency timer to 64 [23302.842177] uhci_hcd 0000:00:1a.1: PCI INT B -> GSI 21 (level, low) -> IRQ 21 [23302.842190] uhci_hcd 0000:00:1a.1: setting latency timer to 64 [23302.882145] uhci_hcd 0000:00:1a.2: PCI INT C -> GSI 19 (level, low) -> IRQ 19 [23302.882158] uhci_hcd 0000:00:1a.2: setting latency timer to 64 [23302.929065] uhci_hcd 0000:00:1d.1: PCI INT B -> GSI 19 (level, low) -> IRQ 19 [23302.929079] uhci_hcd 0000:00:1d.1: setting latency timer to 64
Searching on Google, I found a forum post which suggested to
disable USB auto-suspend in the laptop-mode configuration files.
The relevant file on my Ubuntu 12.04 is
/etc/laptop-mode/conf.d/usb-autosuspend.conf, which is fairly well
documented, and has an option
allowed me to blacklist my USB keyboard, so the device was no longer put
in auto-suspend mode. (The USB ID needed for
AUTOSUSPEND_USBID_BLACKLIST can be found in the output of lsusb)
After editing that file, I had to restart the laptop-mode daemon (
/etc/init.d/laptop-mode restart), and keystrokes from my wireless
keyboard arrived again without any delay.