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.

  • 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 02 '21 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'?

    – Somehow Buddy Apr 02 '21 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 02 '21 at 23:10
  • Yes, I did that. It's that same 'USB 3-5' device. Every time the same. – Somehow Buddy Apr 03 '21 at 02: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 03 '21 at 02:43
  • @heynnema i dunno (sorry, i'm not an experienced Linux admin). Just added the content of the folder to the question text (could not fit into the comment). – Somehow Buddy Apr 04 '21 at 17:33
  • Just for fun, try a wired mouse, or one that doesn't use 2.4Ghz, and see if the same problem occurs. You'll have to recheck the /sys/bus/usb/devices/*/power/wakeup settings to make sure it's not enabled. – heynnema Apr 04 '21 at 17:39
  • @heynnema the whole reason i'm asking this question is I have always used a wired USB mouse. :)
    And I never had such problems. Also, I use a USB keyboard via PS/2 adapter exactly because USB keyboard does not wake up the system from sleep/suspend. Now I decided to give a wireless mouse a try and got this unwanted 'wakeup' effect.
    – Somehow Buddy Apr 04 '21 at 20:48
  • I understand. However, I don't know how to fix your specific problem. My wireless Logitech mouse/dongle had the same problem, and I could see the "enabled" flag, so I could fix it. Must have something to do with your 2.4Ghz wireless dongle/mouse. – heynnema Apr 04 '21 at 21:03
  • Right, potentially it's the way the 'dongle' is programmed to behave (it's showing as Genius, may be those do behave different from Logitech) – Somehow Buddy Apr 05 '21 at 01:13
  • @heynnema And it looks like potentially there's something wrong with my OS/motherboard/whatever... Or it's an inherent problem of desktops vs laptops...

    Because I just plugged it into a Dell Laptop w/Xubuntu (don't remember immediately, 18.04 or 20.04) and it worked as expected (almost) - didn't wake up the laptop on mouse move/click.

    It still had to have a button clicked after laptop wakeup, but that's bearable to a degree...

    – Somehow Buddy Apr 05 '21 at 15:28
  • Unless there's a BIOS setting that needs tweaking, I don't think it's a problem with your motherboard. Just use a wired mouse, or get yourself a Logitech wireless mouse :-) – heynnema Apr 05 '21 at 15:37
  • @heynnema no, i couldn't find anything relevant in BIOS. well... I was going to try to re-install the system (since I messed up some other [irrelevant here] settings which I would like to set up from scratch) and see if it changes anything... – Somehow Buddy Apr 05 '21 at 21:41

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
  • 2
  • 1
    Thanks for your answer! I was inspired by your solution to write a little tool to make this process easier for daily use and multiple devices: https://github.com/bvobart/usb-wakeup-control – Bart van Oort Feb 23 '24 at 23:11
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
  • 2,506
  • 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.

    – Somehow Buddy Apr 02 '21 at 18:00
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
  • 90,100
  • 91
  • 213
  • 324
Brad
  • 1