How to disable USB autosuspend on kernel 3.7.10 or above

kernelpower-managementsuspendusb

I've updated my HTPC from kernel 3.7.10 to 3.10.7 and it seems CONFIG_USB_SUSPEND is now gone from the kernel options and included in PM.

The main problem I'm facing is that I have an external HDD and when suspending and waking up the HTPC, it isn't available to the system. The HDD wakes up (you can hear it spin up again), but when you try to access the mount point you get the following error:

ZOTAC ~ # ls /media
ls: reading directory /media: Input/output error

And on dmesg:

[  253.278260] EXT4-fs warning (device sdb1): __ext4_read_dirblock:908: error reading   directory block (ino 2, block 0)

In previous kernels, setting CONFIG_USB_SUSPEND=N would solve the problem, as the HDD would handle its hibernation by itself and the mount point was always accesible. When the HDD was on sleep and the HTPC needed something from the HDD's mount point, the HDD itself would wake up and operate without issues.

Right now I've tried the following without success:

  1. Manually change /sys/bus/usb/devices/usb*/power/control to "on" instead of "auto".
  2. Manually change /sys/bus/usb/devices/usb*/power/autosuspend to "-1" instead of "0".

But when waking up again the HTPC, the mount point is again inaccesible. As workarround I can unmount and remount the mount point and it works again without problems, but I'm sure there should be a way to avoid having the OS handle the usb autosuspend.

Any idea how to disable usb autosuspend on kernel 3.7.10 or above?

Best Answer

For Ubuntu and Debian, usbcore is compiled in to the kernel, so creating entries in /etc/modprobe.d will NOT work. Instead, we need to change the kernel boot parameters.

Edit the /etc/default/grub file and change the GRUB_CMDLINE_LINUX_DEFAULT line to add the usbcore.autosuspend=-1 option:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.autosuspend=-1"

Note that quiet splash were already present options. So keep other options you have too.

After save the file, update grub:

sudo update-grub

And reboot.

Now check autosuspend value:

cat /sys/module/usbcore/parameters/autosuspend

And it should display -1.

Additional Info

In the kernel documentation is stated that someday in the future this param will change to autosuspend_delay_ms (instead of autosuspend), but so far, still the same name.

The documentation for the value -1 can be found in the kernel source file drivers/usb/core/hub.c:

1808:    * - If user has indicated to prevent autosuspend by passing
1809:    *   usbcore.autosuspend = -1 then keep autosuspend disabled.
Related Question