6

Since updating from 19.04 to 19.10, I find that moving the mouse wakes the computer from sleep. I'm using a Logitech mouse along with its Unifying receiver into a USB 3.0 port (USB 2.0 port behaves the same). This behavior is different from 19.04.

I found something similar in an old post from 2017 at Mouse movement wakes computer from suspend, can't disable it, and the output of grep --color -E '|enabled' /sys/bus/usb/devices/*/power/wakeup shows:

/sys/bus/usb/devices/1-1.3.1/power/wakeup:disabled
/sys/bus/usb/devices/1-1.3/power/wakeup:disabled
/sys/bus/usb/devices/1-1/power/wakeup:disabled
/sys/bus/usb/devices/2-1.4/power/wakeup:disabled
/sys/bus/usb/devices/2-1/power/wakeup:disabled
/sys/bus/usb/devices/2-2/power/wakeup:enabled
/sys/bus/usb/devices/3-1.4/power/wakeup:disabled
/sys/bus/usb/devices/3-1/power/wakeup:disabled
/sys/bus/usb/devices/usb1/power/wakeup:disabled
/sys/bus/usb/devices/usb2/power/wakeup:disabled
/sys/bus/usb/devices/usb3/power/wakeup:disabled

As you can see, USB device 2-2 is enabled.

and lsusb -t shows:

/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M
        |__ Port 4: Dev 3, If 0, Class=Hub, Driver=hub/4p, 5000M
            |__ Port 4: Dev 4, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/9p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 4: Dev 4, If 0, Class=Hub, Driver=hub/4p, 480M
    |__ Port 2: Dev 3, If 2, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 2: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 2: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
        |__ Port 3: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 1: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
            |__ Port 4: Dev 6, If 2, Class=Human Interface Device, Driver=usbhid, 12M
            |__ Port 4: Dev 6, If 0, Class=Audio, Driver=snd-usb-audio, 12M
            |__ Port 4: Dev 6, If 1, Class=Audio, Driver=snd-usb-audio, 12M
        |__ Port 8: Dev 4, If 0, Class=Video, Driver=uvcvideo, 480M
        |__ Port 8: Dev 4, If 1, Class=Video, Driver=uvcvideo, 480M

Should I disable it with something like this in /etc/rc.local?

# Disable
for f in /sys/bus/usb/devices/*/power/wakeup
do
   echo "disabled" > $f
done

Why this different behavior, and what is the best way to disable this "new" feature in 19.10?

Update #1:

Also see...

How do I prevent mouse movement from waking up a suspended computer?

http://www.das-werkstatt.com/forum/werkstatt/viewtopic.php?f=7&t=1985

grep -i enable /proc/acpi/wakeup

EHC1      S3    *enabled   pci:0000:00:1d.0
XHC       S3    *enabled   pci:0000:00:14.0
PWRB      S4    *enabled   platform:PNP0C0C:00
LID0      S4    *enabled   platform:PNP0C0D:00

shows EHC1 and XHC USB hubs (and lid and power button) enabled.

Suggested...

Add the following lines to /etc/rc.local...

echo "EHC1" > /proc/acpi/wakeup
echo "XHC" > /proc/acpi/wakeup
heynnema
  • 73,649

3 Answers3

4

I found something similar in an old post from 2017 at Mouse movement wakes computer from suspend, can't disable it, and the output of

grep --color -E '|enabled' /sys/bus/usb/devices/*/power/wakeup

shows:

/sys/bus/usb/devices/1-1.3.1/power/wakeup:disabled
/sys/bus/usb/devices/1-1.3/power/wakeup:disabled
/sys/bus/usb/devices/1-1/power/wakeup:disabled
/sys/bus/usb/devices/2-1.4/power/wakeup:disabled
/sys/bus/usb/devices/2-1/power/wakeup:disabled
/sys/bus/usb/devices/2-2/power/wakeup:enabled
/sys/bus/usb/devices/3-1.4/power/wakeup:disabled
/sys/bus/usb/devices/3-1/power/wakeup:disabled
/sys/bus/usb/devices/usb1/power/wakeup:disabled
/sys/bus/usb/devices/usb2/power/wakeup:disabled
/sys/bus/usb/devices/usb3/power/wakeup:disabled

As you can see, USB device 2-2 is enabled. If I unplug the Logitech Unifying receiver, and plug it back in, and repeat the grep command, it now shows as disabled. This means that enabled status is only determined at boot time.

My current fix is to edit /etc/rc.local and add...

# Disable wake computer from mouse movement
for f in /sys/bus/usb/devices/*/power/wakeup
do
   echo "disabled" > $f
done

just BEFORE the exit 0 found at the end of the file. This forces all USB devices to show as disabled.

Sleep still works. And the mouse movement no longer wakes from sleep.

heynnema
  • 73,649
2

Power off USB devices when suspending

My suspend/resume broke about a year ago. The solution for me was powering off the USB devices before going to sleep and powering them on with resume.

In the directory /lib/systemd/system-sleep create this script:

#!/bin/bash

# Original script was using /bin/sh but shellcheck reporting warnings.

# NAME: custom-xhci_hcd
# PATH: /lib/systemd/system-sleep
# CALL: Called from SystemD automatically
# DESC: Suspend broken for USB3.0 as of Oct 25/2018 various kernels all at once

# DATE: Oct 28 2018.

# NOTE: From comment #61 at: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/522998

TMPLIST=/tmp/xhci-dev-list

# Original script was: case "${1}" in hibernate|suspend)

case $1/$2 in
  pre/*)
    echo "$0: Going to $2..."
    echo -n '' > $TMPLIST
          for i in `ls /sys/bus/pci/drivers/xhci_hcd/ | egrep '[0-9a-z]+\:[0-9a-z]+\:.*$'`; do
              # Unbind xhci_hcd for first device XXXX:XX:XX.X:
               echo -n "$i" | tee /sys/bus/pci/drivers/xhci_hcd/unbind
           echo "$i" >> $TMPLIST
          done
        ;;
  post/*)
    echo "$0: Waking up from $2..."
    for i in `cat $TMPLIST`; do
              # Bind xhci_hcd for first device XXXX:XX:XX.X:
              echo -n "$i" | tee /sys/bus/pci/drivers/xhci_hcd/bind
    done
    rm $TMPLIST
        ;;
esac

Mark the script executable with chmod a+x /lib/systemd/system-sleep/custom-xhci_hcd

Reboot.

Confirm script is working with journalctl -b-0 | grep custom-xhci_hcd:

Nov 12 14:06:27 alien systemd-sleep[20174]: /lib/systemd/system-sleep/custom-xhci_hcd: Going to suspend...
Nov 12 17:22:19 alien systemd-sleep[20174]: /lib/systemd/system-sleep/custom-xhci_hcd: Waking up from suspend...
  (... SNIP ...)
Nov 22 22:28:06 alien systemd-sleep[24432]: /lib/systemd/system-sleep/custom-xhci_hcd: Going to suspend...
Nov 23 08:16:15 alien systemd-sleep[24432]: /lib/systemd/system-sleep/custom-xhci_hcd: Waking up from suspend...
0

I can report above solution of putting this into /etc/rc.local:

# Disable wake computer from mouse movement
for f in /sys/bus/usb/devices/*/power/wakeup
do
   echo "disabled" > $f
done

...also works on KDE Neon (based on Ubuntu 20.04) for disabling wakeing up by the Logitech Unifying Receiver. Thank you very much!

Note: Disabling devices in /proc/acpi/wakeup didn't work for me.