57

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?

2
  • Does tail /sys/bus/usb/devices/<BUS>-<DEVPATH>/power/persist give you 1? Does grep CONFIG_PM_RUNTIME /boot/config-$(uname -r) give you y? power-management.txt
    – Runium
    Oct 8, 2013 at 4:24
  • 1
    power/persist gives 1 and I don't have any config file in /boot. CONFIG_PM_RUNTIME=y is configured in the kernel's .config file.
    – Peter
    Oct 9, 2013 at 14:05

3 Answers 3

63

For Ubuntu and Debian, usbcore is compiled into 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.
6
  • 1
    This seems to be true for Debian as well. Mar 17, 2015 at 20:03
  • 2
    Rael, thanks very much for this. The same is true for the most recent version of Kali. I added the above and my USB IRToy (v2) is now working properly.
    – joatd
    May 5, 2015 at 22:41
  • 1
    I have a USB card in one of the mPCIE slots and just did not want the truth. Running Debian Jessie. This has solved my issue solving a huge headache, THANK YOU!
    – xebo
    Dec 18, 2015 at 0:17
  • 1
    I tried this in Ubuntu 15.10 but the value is not applied (the value is 2). Is there anything else I can try? Jan 22, 2016 at 12:43
  • I'm still on 14.04. But afaik, in the latest kernel versions, the param to change is autosuspend_delay_ms. Jan 25, 2016 at 9:52
23

According to the kernel tree documentation, the autosuspend idle-delay time is controlled by the autosuspend module parameter in usbcore. Setting the initial default idle-delay to -1 will prevent the autosuspend of any USB device. You should still be able to to enable autosuspend for selected devices.

The usbcore.autosuspend kernel parameter can be set when the module is loaded manually:

$ modprobe usbcore autosuspend=-1

or by adding the following line to a configuration file in /etc/modprobe.d:

options usbcore autosuspend=-1

If usbcore is compiled into the kernel, parameter can be adjusted by adding the following to the kernel command line:

usbcore.autosuspend=-1

Lastly, the option may be adjusted at runtime by doing:

echo -1 >/sys/module/usbcore/parameters/autosuspend

The change will affect all new USB devices. Already existing devices will not be affected.

5
  • 2
    I have usbcore compiled into the kernel, but using the modprobe.d option doesn't seem to work. Despite modprobe -c usbcore | grep autosuspend displays it as -1, doing cat /sys/module/usbcore/parameters/autosuspend I get 2
    – Peter
    Oct 9, 2013 at 14:08
  • 1
    @Peter: autosuspend is deprecated. The new file is autosuspend_delay_ms which takes ms instead of seconds. ref. But power/control set to on should have same effect.
    – Runium
    Oct 9, 2013 at 18:21
  • @Sukminder, what should I configure then to keep autosuspend disabled forever? I've tried using autosuspend=-1 in both modprobe.d and kernel parameter, but the HDD still suspends and doesn't wake up nicely.
    – Peter
    Oct 10, 2013 at 8:12
  • 1
    @Peter: If I knew I'll tell you :). I'm only quoting what doc. says. Your pt. 1 in your post should have done it as far as I can tell, I have no idea why it does not. Have you tried to set autosuspend_delay_ms to -1? (In /sys/bus/usb/devices/<device>/power/autosuspend_delay_ms)
    – Runium
    Oct 10, 2013 at 8:51
  • 1
    I'm on kernel 4.4 and autosuspend_delay_ms is not there. But autosuspend IS. Apr 6, 2018 at 20:25
4

I have a similar issue with a Microsoft Wheel Mouse Optical USB and PS/2 Compatible since upgrading a Linux Mint Debian Edition system to kernel 3.10-2-amd64. An inappropriate autosuspend by the kernel's USB power management was suspected. In Debian, this is compiled as the usbcore module into the kernel.

You can change this permanently by issuing at the command line:

sudo echo "options usbcore autosuspend=-1" | sudo tee /etc/modprobe.d/disable-usb-autosuspend.conf > /dev/null

Some kernels might require autosuspend=0, though.

If your system uses initrd (most probably does), then rebuild the initrd for your kernel.

For example:

uname -r
sudo dpkg-reconfigure linux-image-3.10-2-amd64

Reboot and check with:

cat /sys/module/usbcore/parameters/autosuspend

which should yield -1 now.

1
  • I don't use initrd and the actions described here don't work in this case, as they we're answered before.
    – Peter
    Oct 22, 2013 at 12:48

You must log in to answer this question.

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