You are not logged in.

#1 2015-10-21 10:26:47

Aliverix
Member
Registered: 2014-11-05
Posts: 12

USB 3.0 device always triggers wakeup

Hi everyone,

On my notebook, an Asus N550JV, suspension works correctly most of the times but, when I plug a USB 3.0 device in the USB port on the right side, my computer is no longer able to suspend. In that case, the suspension process is executed correctly but, once completed, the notebook wakes up immediately, even if the lid is closed.

My notebook has three USB 3.0 ports, two on the left side and one on the right side. If I use the ports on the left side everything works normally, the problem is only present with the right side port. I've tried also with USB 2.0 devices but in that case everything works fine. I want to remark that, when I connect, and than disconnect, the device to, and from, that port, the notebook is not able to suspend until the next reboot of the system, even if there isn't a USB device attached during the suspension process.

After triggering the problem, with a connection and a disconnection of a USB 3.0 device on the right port, I managed to make my notebook suspend correctly again changing the wakeup triggers in /proc/acpi/wakeup; in particular I disabled EHC1, EHC2 and XHC triggers. Obviously this change does not survive a reboot. (You have to disable all three of them at the same time, otherwise the problem is still present)

I suspect that the problem is related with the xhci_hcd module, so I posted in the kernel section.

I don't know for how long the problem has been there, it is something quite difficult to isolate and notice. Now I'm using the "linux" package, thus kernel "4.2.3-1", but the problem is still present with the "linux-lts" package, thus kernel "4.1.10-2".

Offline

#2 2015-10-29 14:42:09

9233
Member
Registered: 2015-02-01
Posts: 36

Re: USB 3.0 device always triggers wakeup

This exact issue has been bugging me me for months!
It only happens with my WD external hard drive on one specific USB 3.0 port though.
I managed to reproduce it while running "dmesg -w" and this is what I got:

[   14.804088] fuse init (API version 7.23)
[   36.445636] usb 4-2: new SuperSpeed USB device number 2 using xhci_hcd
[   36.987416] usb-storage 4-2:1.0: USB Mass Storage device detected
[   36.987580] scsi host5: usb-storage 4-2:1.0
[   36.987923] usbcore: registered new interface driver usb-storage
[   36.989021] usbcore: registered new interface driver uas
[   37.991551] scsi 5:0:0:0: Direct-Access     WD       Elements 10A8    1042 PQ: 0 ANSI: 6
[   37.992623] sd 5:0:0:0: [sdb] Spinning up disk...
[   38.995093] .....ready
[   43.204826] sd 5:0:0:0: [sdb] 1953458176 512-byte logical blocks: (1.00 TB/931 GiB)
[   43.205078] sd 5:0:0:0: [sdb] Write Protect is off
[   43.205081] sd 5:0:0:0: [sdb] Mode Sense: 53 00 10 08
[   43.205268] sd 5:0:0:0: [sdb] No Caching mode page found
[   43.205270] sd 5:0:0:0: [sdb] Assuming drive cache: write through
[   43.216284]  sdb: sdb1 sdb2 sdb3
[   43.217150] sd 5:0:0:0: [sdb] Attached SCSI disk
[   51.650998] usb 4-2: USB disconnect, device number 2
[   59.622661] PM: Syncing filesystems ... done.
[   59.634500] PM: Preparing system for sleep (mem)
[   59.634826] Freezing user space processes ... (elapsed 0.001 seconds) done.
[   59.636149] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[   59.637257] PM: Suspending system (mem)
[   59.637276] Suspending console(s) (use no_console_suspend to debug)
[   59.637533] sd 4:0:0:0: [sda] Synchronizing SCSI cache
[   59.639892] sd 4:0:0:0: [sda] Stopping disk
[   60.665566] PM: suspend of devices complete after 1027.034 msecs
[   60.682192] PM: late suspend of devices complete after 16.604 msecs
[   60.682875] ehci-pci 0000:00:1d.0: System wakeup enabled by ACPI
[   60.683258] ehci-pci 0000:00:1a.0: System wakeup enabled by ACPI
[   60.683272] xhci_hcd 0000:00:14.0: System wakeup enabled by ACPI
[   60.695595] PM: noirq suspend of devices complete after 13.386 msecs
[   60.695872] ACPI: Preparing to enter system sleep state S3
[   60.702337] ACPI : EC: EC stopped
[   60.702337] PM: Saving platform NVS memory
[   60.702342] Disabling non-boot CPUs ...
[   60.703584] smpboot: CPU 1 is now offline
[   60.705075] smpboot: CPU 2 is now offline
[   60.706560] smpboot: CPU 3 is now offline
[   60.708024] smpboot: CPU 4 is now offline
[   60.709473] smpboot: CPU 5 is now offline
[   60.710854] smpboot: CPU 6 is now offline
[   60.712288] smpboot: CPU 7 is now offline
[   60.713688] ACPI: Low-level resume complete
[   60.713726] ACPI : EC: EC started
[   60.713726] PM: Restoring platform NVS memory
[   60.715999] microcode: CPU0 microcode updated early to revision 0x1c, date = 2014-07-03
[   60.716087] Enabling non-boot CPUs ...
[   60.716130] x86: Booting SMP configuration:
[   60.716131] smpboot: Booting Node 0 Processor 1 APIC 0x1
[   60.720386]  cache: parent cpu1 should not be sleeping
[   60.720501] CPU1 is up
[   60.720522] smpboot: Booting Node 0 Processor 2 APIC 0x2
[   60.722637] microcode: CPU2 microcode updated early to revision 0x1c, date = 2014-07-03
[   60.725871]  cache: parent cpu2 should not be sleeping
[   60.725984] CPU2 is up
[   60.726008] smpboot: Booting Node 0 Processor 3 APIC 0x3
[   60.730274]  cache: parent cpu3 should not be sleeping
[   60.730390] CPU3 is up
[   60.730410] smpboot: Booting Node 0 Processor 4 APIC 0x4
[   60.732524] microcode: CPU4 microcode updated early to revision 0x1c, date = 2014-07-03
[   60.735773]  cache: parent cpu4 should not be sleeping
[   60.735885] CPU4 is up
[   60.735907] smpboot: Booting Node 0 Processor 5 APIC 0x5
[   60.740189]  cache: parent cpu5 should not be sleeping
[   60.740306] CPU5 is up
[   60.740331] smpboot: Booting Node 0 Processor 6 APIC 0x6
[   60.742451] microcode: CPU6 microcode updated early to revision 0x1c, date = 2014-07-03
[   60.745713]  cache: parent cpu6 should not be sleeping
[   60.745836] CPU6 is up
[   60.745862] smpboot: Booting Node 0 Processor 7 APIC 0x7
[   60.750172]  cache: parent cpu7 should not be sleeping
[   60.750294] CPU7 is up
[   60.757464] ACPI: Waking up from system sleep state S3
[   60.759225] ehci-pci 0000:00:1d.0: System wakeup disabled by ACPI
[   60.759237] xhci_hcd 0000:00:14.0: System wakeup disabled by ACPI
[   60.759307] ehci-pci 0000:00:1a.0: System wakeup disabled by ACPI
[   60.770213] PM: noirq resume of devices complete after 12.191 msecs
[   60.770521] PM: early resume of devices complete after 0.291 msecs
[   60.770762] r8169 0000:03:00.0: System wakeup disabled by ACPI
[   60.774760] sd 4:0:0:0: [sda] Starting disk
[   60.781468] r8169 0000:03:00.0 enp3s0: link down
[   60.877115] rtc_cmos 00:02: System wakeup disabled by ACPI
[   61.036277] usb 3-6: reset high-speed USB device number 2 using xhci_hcd
[   61.092817] ata5: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[   61.110601] ata5.00: configured for UDMA/133
[   61.197138] psmouse serio1: synaptics: queried max coordinates: x [..5664], y [..4678]
[   61.226421] psmouse serio1: synaptics: queried min coordinates: x [1278..], y [1228..]
[   61.273553] PM: resume of devices complete after 502.477 msecs
[   61.273694] PM: Finishing wakeup.
[   61.273695] Restarting tasks ... done.

My exact steps on a freshly booted system were:

  1. Plug in the drive, waiting until it spins up

  2. Disconnect the drive

  3. try to suspend (it wakes up immediately

Would be great if someone knows how to fix this.

Offline

#3 2015-11-02 19:11:57

9233
Member
Registered: 2015-02-01
Posts: 36

Re: USB 3.0 device always triggers wakeup

I found a pretty simple solution for this.
As Aliverix described, changing the wakeup triggers  in /proc/acpi/wakeup works.
However this settings are only temporary so I wrote a systemd unit file to make these settings at startup:

/etc/systemd/system/disable-USB-wakeup.service

[Unit]
Description=Disable USB wakeup triggers in /proc/acpi/wakeup

[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo EHC1 > /proc/acpi/wakeup; echo EHC2 > /proc/acpi/wakeup; echo XHC > /proc/acpi/wakeup"
ExecStop=/bin/sh -c "echo EHC1 > /proc/acpi/wakeup; echo EHC2 > /proc/acpi/wakeup; echo XHC > /proc/acpi/wakeup"
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Then simply enable and start it:

sudo systemctl enable disable-USB-wakeup.service
sudo systemctl start disable-USB-wakeup.service

Since changes to /proc/acpi/wakeup are toggled and afaik can not be explicitly set, I made shure to run the same command on "ExecStop" so that restarting the service doesn't result in the wakeup triggers being enabled again.

Offline

#4 2016-05-06 12:05:39

Bernie99
Member
Registered: 2016-05-06
Posts: 1

Re: USB 3.0 device always triggers wakeup

Of course, the triggers can be explicitly enabled or disabled by first checking the current status.
An example script to do this would be e.g.:

---- disable_acpi_wakeup.sh

#! /usr/bin/sh
# Add your candidates below but make sure that no pattern matches more than one device in /proc/acpi/wakeup
CANDIDATES="EHC1 EHC2 XHC"
for ACPIDEV in $CANDIDATES; do
ACTIVE=$(grep enabled /proc/acpi/wakeup | cut -f 1 | grep "$ACPIDEV")
  if [ -n "$ACTIVE" ]; then 
    echo "$ACTIVE" > /proc/acpi/wakeup
    echo "DEBUG: disabled -$ACTIVE-" >&2
  else
    echo "DEBUG: no active -$ACPIDEV- found." >&2
  fi
done

I have similar issues with a Lenovo ThinkPad Yoga S1, on which only the XHC trigger exists, and causes wakeup issues. I have no EHC1/2.

I know UNIX but am a newbie to Arch (actually the Manjaro spinoff; I hope the forum tolerates).
Therefore I am not sure where the script above would be best placed to run with each startup.

Any idea?

Offline

#5 2016-06-16 02:07:38

Nikus
Member
Registered: 2012-12-10
Posts: 11

Re: USB 3.0 device always triggers wakeup

@Bernie99, scripts for systemd may be placed in /usr/lib/systemd/scripts

Offline

#6 2019-07-07 13:19:28

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: USB 3.0 device always triggers wakeup

Please be warned that I was not aware trying to write this, and s fell asleep a good 7-10 sentences midsentence!  Please go easy on me!


Nikus wrote:

@Bernie99, scripts for systemd may be placed in /usr/lib/systemd/systemd-scripts/scrptnames.sh,

But overall, it is probably better to create then in /etc/systemd/system/*,conf since that is where unit files stand are where sane dependency resoluion can be impleneed.  Not to mention, asking flks to write scripts in /usr/lib/sysemd/system-sleep is inherently problematic. Writing to /usr/lib seems a shitty hack in general, despite a sy-bash-4.2 ~$ cat /etc/system/system-sleep/xhci-hackey.sleep

                                      [Begin sysemd-sleep back]
---------------------------------------------------------------------------------------------------------------

#!/usr/bin/env bash

[ "$(id -u)" != 0 ]; then
    echo -ne "WHAT ARE YOI DOING?!?!"...
    echo -ne "Get tjos running as theroot uesr to maybebe less lost!)
    exit 2
elif [ "$(id -u)" != 1 ]; then
    echo -ne "Keep this up and we can beat truemp. Hopefully in the general election, but also so we can hope helll be jailed upon being forced out of office."
fistem-sleeps script ultimately being functional.
fi 

One can have any check he'she wnats, but this seems the best omprpmse beteen securtiy and can really part their separate ways!

#So I get where you are coming from, but the continual far right attacks... often totally unprovoked. But sincerely maga beliefs have to be apparently, so? But the hypocritical personal attacks that they tend to whine about being unfair are where i'm most annoyed.   Sero introspetion, yet they think thingselves the final workd.

In my /usr/lib/systems/system-sleep/xhci-hackery.sleep sript.  I unload the xdhci modules, which works, and the unload of xhci_* via systemd-sleep does wonders!


-bash-4.2 ~$ cat /etc/system/system-sleep/xhci-hackey.sleep
c!#/usr/bin/env bash

[ "$(id -u)" != 0 ]; then
    echo -ne "WHAT ARE YOI DOING?!?!"...
    echo -ne "Get tjos running as theroot uesr to maybebe less lost!)
    exit 2
elif [ "$(id -u)" != 1 ]; then
    echo -ne "Keep this up and we can beat truemp. Hopefully in the general election, but also so we can hope helll be jailed upon being forced out of office."
fi

case $i in 
          pre)
                  /usr/bin/modprove -r xhci_pci xhci-hcd
                  ;;
          post) 
                 /usr/lib/modprona xhci)pci xhcd-hde
                 ;;
          *) 
esac`

                                     
                                   

The think is that sincerely help beliefs are not always the way to do.  Th Rise an Tea we have is the extent of our heritege, and i still hae it d vrey ewony (I ha a picky earer back them!```So these forks hasve ponaised t portinteallyup to $20as a PB semployee.

But kid came of p a cleaner solution I think...

$ cat $SMRT_ROOT/userdata/confgi

Afternatively, I've neen told tath this works just as well.  Setup the actiong you wish your computer t l make tose things..



Edit: Maybe I shoulndm't hae written that, as nothing in my head is making sense right now!  Going to bed!!!


Edit2:  Thi is ultimatey what I ended up using....

[Unit]
Description=Script upon suspend/resume
Before=sleep.target
StopWhenUnneeded=no

[Service]
Type=oneshot
ExecStart=/usr/bin/modprobe -r xhci_pci xhci_hcd
ExecStart=/usr/bin/modprobe  xhci_pci xhci_hcd

[Install]
WantedBy=sleep.target

Last edited by WonderWoofy (2019-07-07 13:25:55)

Offline

#7 2019-07-07 13:25:56

2ManyDogs
Forum Moderator
Registered: 2012-01-15
Posts: 4,642

Re: USB 3.0 device always triggers wakeup

Thanks for the contribution WonderWoofy (and welcome back) but this thread is very old.

Closing.


How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.

Offline

Board footer

Powered by FluxBB