1

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.

3 Answers3

3

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.

uglic
  • 31
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

codlord
  • 3,153
0

I know this is a bit old but I had issues with this too and other solutions did not work. I have found a much simpler solution to this problem and hope it helps.

What uglic says about writing the value disabled instead of enabled into the file /sys/bus/usb/devices/3-5/power/wakeup works correctly is true. Though just to be clear this only works up until you reboot, at that point it is enabled again.

A quick and dirty way to set disabled "permanently" is to simply echo disabled into the **/*/power/wakeup file from the /etc/rc.local file.

echo disabled > /sys/bus/usb/devices/3-5/power/wakeup

Something like that before the last line in the /etc/rc.local file should do the trick.

Pilot6
  • 92,041
Brad
  • 1