0

I could find similar topics but could not find an answer.

In my system (Xubuntu 20.04) grep . /sys/bus/usb/devices/*/power/wakeup only delivers this

/sys/bus/usb/devices/1-1/power/wakeup:disabled
/sys/bus/usb/devices/2-1/power/wakeup:disabled
/sys/bus/usb/devices/3-13/power/wakeup:disabled
/sys/bus/usb/devices/3-14/power/wakeup:disabled
/sys/bus/usb/devices/3-5/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
/sys/bus/usb/devices/usb4/power/wakeup:disabled

Full list of files in the /sys/bus/usb/devices/3-5/power/

active_duration  
async  
autosuspend  
autosuspend_delay_ms  
connected_duration  
control  
level  
persist  
runtime_active_kids  
runtime_active_time  
runtime_enabled  
runtime_status  
runtime_suspended_time  
runtime_usage  
wakeup  
wakeup_abort_count  
wakeup_active  
wakeup_active_count
wakeup_count
wakeup_expire_count
wakeup_last_time_ms
wakeup_max_time_ms
wakeup_total_time_ms

Yet the wireless mouse (+ 2.4GHz USB dongle) wake the system up from suspend. Is there any way to get that specific USB port/device disabled?

The lshw gives me

          *-usbhost:0      
                product: xHCI Host Controller
                vendor: Linux 5.4.0-70-generic xhci-hcd
                physical id: 0
                bus info: usb@3
                logical name: usb3
                version: 5.04
                capabilities: usb-2.00
                configuration: driver=hub slots=15 speed=480Mbit/s
              *-usb:0
                   description: Mouse
                   product: Wireless Mouse
                   vendor: Genius
                   physical id: 5
                   bus info: usb@3:5
                   version: 10.01
                   capabilities: usb-1.10
                   configuration: driver=usbhid maxpower=100mA speed=12Mbit/s

And the lsusb -t says

    /:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
    /:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/15p, 480M
        |__ Port 5: Dev 8, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 10: Dev 2, If 2, Class=Audio, Driver=snd-usb-audio, 480M
        |__ Port 10: Dev 2, If 0, Class=Video, Driver=uvcvideo, 480M
        |__ Port 10: Dev 2, If 3, Class=Audio, Driver=snd-usb-audio, 480M
        |__ Port 10: Dev 2, If 1, Class=Video, Driver=uvcvideo, 480M
        |__ Port 12: Dev 3, If 0, Class=Vendor Specific Class, Driver=mt7601u, 480M
        |__ Port 13: Dev 4, If 0, Class=Wireless, Driver=btusb, 12M
        |__ Port 13: Dev 4, If 1, Class=Wireless, Driver=btusb, 12M
        |__ Port 14: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
    /:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
        |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
    /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
        |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M

But since no /sys/bus/usb/devices seems to be relevant I'm not sure what to configure and how.

13
  • I had a similar problem. I've got a couple of scripts to do it, but it looks like they won't work for you because USB 3-5 already shows as disabled.
    – heynnema
    Apr 2 at 19:19
  • @heynnema that's exactly what confuses me. because i did research the issue and ppls were suggesting finding the 'enabled' device and simply replace it w/'disabled' in the /sys/bus/usb/devices/*/power/wakeup. But my config shows it's 'disabled' (which i feel actually relates to a different device). Looks like the 'wireless dongle' part is what messes stuff a bit. I just got that wireless mouse and it started waking up my box from the 'sleep/standby' mode even on move... Maybe a better way would be to simply power down the USB port on 'sleep'? Apr 2 at 22:54
  • You could try to plug/unplug the mouse dongle and confirm which device appear/disappears in lsusb and /sys/bus/usb/devices. Maybe you've already done that.
    – heynnema
    Apr 2 at 23:10
  • Yes, I did that. It's that same 'USB 3-5' device. Every time the same. Apr 3 at 2:25
  • Review the other parameters in /sys/bus/usb/devices/3-5/power/ to see if there's anything else that sounds like it has to do with resume/sleep.
    – heynnema
    Apr 3 at 2:43
1

Writing a value disabled instead of enabled into the file /sys/bus/usb/devices/3-5/power/wakeup is working correctly: when the value is disabled, a corresponding mouse or keyboard doesn't wake up the computer, but if the value is enabled - they wake up it. This helper script do it for a device with particular vendorId and productId:

#!/bin/bash
### Put it here: /usr/bin/usb-resume-control

while getopts v:p:s: flag
do
    case "${flag}" in
      v) vendor=${OPTARG};;
      p) product=${OPTARG};;
      s) state=${OPTARG};;
    esac
done
if [ -z "$vendor" -o -z "$product" ]; then
        echo -en "Usage: $0 -v vendorId -p productId -s state\nin any order, where vendorId and productId are both from [lsusb] and state can be enable or disable\n"
        exit 1;
fi
if [ -z $state ]; then
        stateTo="disabled"
fi
DEVICES=/sys/bus/usb/devices

for a in `ls $DEVICES`; do
  if [ -f "$DEVICES/$a/idVendor" -a -f "$DEVICES/$a/idProduct" ]; then
    idVendor=`cat "$DEVICES/$a/idVendor"`
    idProduct=`cat "$DEVICES/$a/idProduct"`
    if [ -f "$DEVICES/$a/product" ]; then 
      productName=`cat "$DEVICES/$a/product"`
    fi
    WAKEUPFILE="$DEVICES/$a/power/wakeup"
    if [ $idVendor = $vendor -a $idProduct = $product -a -f "$WAKEUPFILE" ]; then
      oldState=`cat "$WAKEUPFILE"`
      echo "$state" > "$WAKEUPFILE"
      newState=`cat "$WAKEUPFILE"`
      echo Bus-port:$a vendor=$idVendor product=$idProduct name=$productName WakeUp: old=$oldState new=$newState
    fi
  fi
done

To automate process create a systemd unit file /etc/systemd/system/control-usb-wakeup-mouse.service with the following content:

[Unit]
Description=Control wakeup of USB device before sleep so they will or not resume the computer
Before=sleep.target

[Service]
Type=oneshot
ExecStart=/usr/bin/usb-resume-control -v 045e -p 0745 -s disabled
StandardOutput=journal

[Install]
WantedBy=sleep.target

Update vendorId and productId to your USB device (see output of lsusb). After that run those commands against a unit:

chmod 755 /etc/systemd/system/control-usb-wakeup-mouse.service
systemctl daemon-reload
systemctl enable control-usb-wakeup-mouse.service

Now the device mentioned cannot wake up the computer after sleep.

0

Sometimes there are BIOS settings for USB ports to enable/disable power during suspend and/or enable/disable wakeup.

But you may also need to disable wakeup for the relevant USB controllers/hubs. Try this:

cat /proc/acpi/wakeup

I actually don't know how to confirm the device names here is the device you want as the names listed here are different to what you see elsewhere but in my case my USB devices are EHC1, EHC2 and XHC

You can toggle between enabled and disabled by doing for example:

sudo -s
echo XHC > /proc/acpi/wakeup
exit

But I am not sure it's a permanent change. I am not sure on the best way to make it permanent, I just made an executable script to echo the commands I needed and added it to roots crontab like:

@reboot /etc/my_script

1
  • The problem with the /proc/acpi/wakeup is it will disable the whole controller. So that no other USB device will wake up the box (like my USB keyboard). I was looking for a way to disable precise device. I checked my BIOS setting today. There's no such setting. Apr 2 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.