15

Recently i installed Ubuntu 18.04 and started to face a strange issue. while i went to sleep/hibernate mode two of my three USB ports stopped working.

If i restart Ubuntu the USB ports goes back to normal mode.

1
  • 2
    What is the output of lsusb before and after the sleep
    – Amith KK
    Jul 15, 2018 at 19:18

4 Answers 4

9

This answer from Unix & Linux Stack Exchange (slightly enhanced here) has a solution.

  1. Edit /etc/default/grub and find the line containing LINUX_DEFAULT. Change the line from:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
    

    to:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.autosuspend=-1"
    
  2. Save the file, run sudo update-grub, and reboot.

  3. After using this, you will find:

    $ cat /sys/module/usbcore/parameters/autosuspend
    -1
    

    The default value is 2. The kernel parameter changes this value.

Setting the kernel parameter helped me. Now my mouse works again when resuming from suspend.

Suggestion: When USB devices don't work after suspend, you can also reload the driver using the following commands as root:

modprobe -r uhci_hcd
modprobe uhci_hcd

and/or:

modprobe -r ehci_hcd
modprobe ehci_hcd
1
  • This seems to have worked on 18.04.2.
    – Natetronn
    Mar 3, 2019 at 21:46
6

The accepted answer did not work for me and I also don't want to keep up with kernel parameters whenever I reinstall or update grub or boot from another os or whatever. There is a file called usbreset that installs along with usbutils. Run that, find the name of the device you want to restart upon wake and put a file into /lib/systemd/system-sleep I call mine reset-mouse so my file is /lib/systemd/system-sleep/reset-mouse.

If you have that folder, just look at another entry for the format. Mine is:

#!/bin/sh

case $1 in
  post)
    usbreset "Wireless Device"
    ;;
esac

I got the name "Wireless Device" by running usbreset from terminal which will also list your devices and tell their name, so whatever device you have a problem with.

sudo chmod +x /lib/systemd/system-sleep/reset-mouse

Then next time my machine went to sleep, and every time after that, it wakes up immediately with no USB issue.

1

Had the same issue and found a solution similar to the answer by @Rasheed.

First, find the devices IDs with lsusb:

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 04f2:b539 Chicony Electronics Co., Ltd USB2.0 Hub
Bus 001 Device 004: ID 1ea7:0064 SHARKOON Technologies GmbH 2.4GHz Wireless rechargeable vertical mouse [More&Better]
Bus 001 Device 003: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 002: ID 2a7a:9a18 CASUE CASUE USB Keyboard
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In my case, devices 002 and 004. Then create a file inside /lib/systemd/system-sleep/ and make it executable.
Mine has this content:

#!/bin/bash
case "$1" in
    post)
    echo  "2a7a:9a18" > /sys/bus/pci/drivers/ohci-pci/unbind
    echo  "2a7a:9a18" > /sys/bus/pci/drivers/ohci-pci/bind
    echo  "1ea7:0064" > /sys/bus/pci/drivers/ohci-pci/unbind
    echo  "1ea7:0064" > /sys/bus/pci/drivers/ohci-pci/bind
    ;;
esac

Now, mouse and keyboard work again after waking.

1
  • 1
    Works perfectly fine on a Dell Precision Apr 12 at 10:57
1

I've recently came across the same problem. What my solution is with

echo "1" > /sys/bus/pci/devices/0000:05:00.0/reset

echo "1" > /sys/bus/pci/devices/0000:05:00.0/remove

echo 1 >/sys/bus/pci/rescan

You can go into /sys/bus/pci/devices to get the list of the devices

use lspci -s to get which code for which device

for my example, my code ` lspci -s 05:00.0 ' give me the result " USB controller: ASMedia Technology Inc. ASM1042 SuperSpeed USB Host Controller"

So I know this is the usb device I need to reset, after reset, I can reconnect my usb device without rebooting.

1
  • Thank you very very much!!! I've tried everything without success. The command "echo 1 >/sys/bus/pci/rescan" worked. Apr 2 at 16:54

You must log in to answer this question.

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