USB ports not working after resume from sleep on Ubuntu 18.04

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.


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