3

I have Dell Venue transformer with LUbuntu 18.04 with the kernel 5.1.0-6.4-liquorix-amd64 #1 ZEN SMP PREEMPT liquorix 5.1-4ubuntu1~bionic (2019-06-03) x86_64 x86_64 x86_64 GNU/Linux. I disabled wakeup by all devices except PBTN. In BIOS USB PowerShare is switched off.

Nevertheless, after suspending the laptop remains warm. Only three devices do not change the power state:

$ cat /proc/acpi/wakeup
...
EHC1      S0    *disabled
EHC2      S0    *disabled
XHC   S0    *disabled  pci:0000:00:14.0
...
journalctl -xe > JOURNAL.TXT

...
Jun 15 10:29:14 <Sys_Name> systemd-sleep[11312]: Suspending system...
-- Subject: System sleep state suspend entered
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The system has now entered the suspend sleep state.
Jun 15 10:29:14 <Sys_Name> kernel: PM: suspend entry (s2idle)
Jun 15 10:29:14 <Sys_Name> kernel: PM: Syncing filesystems ... done.
Jun 15 10:29:31 <Sys_Name> kernel: Freezing user space processes ... (elapsed 0.008 seconds) done.
Jun 15 10:29:31 <Sys_Name> kernel: OOM killer disabled.
Jun 15 10:29:31 <Sys_Name> kernel: Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
Jun 15 10:29:31 <Sys_Name> kernel: printk: Suspending console(s) (use no_console_suspend to debug)
Jun 15 10:29:31 <Sys_Name> kernel: sd 0:0:0:0: [sda] Synchronizing SCSI cache
Jun 15 10:29:31 <Sys_Name> kernel: sd 0:0:0:0: [sda] Stopping disk
Jun 15 10:29:31 <Sys_Name> kernel: Removing pn544
Jun 15 10:29:31 <Sys_Name> kernel: sd 0:0:0:0: [sda] Starting disk
Jun 15 10:29:31 <Sys_Name> kernel: mei_me 0000:00:16.0: NFC MEI VERSION: IVN 0x1 Vendor ID 0x1 Type 0x1
Jun 15 10:29:31 <Sys_Name> kernel: ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
Jun 15 10:29:31 <Sys_Name> kernel: ata1.00: ACPI cmd ef/**:**:**:**:**:** (SET FEATURES) succeeded
Jun 15 10:29:31 <Sys_Name> kernel: ata1.00: ACPI cmd ef/**:**:**:**:**:** (SET FEATURES) succeeded
Jun 15 10:29:31 <Sys_Name> kernel: ata1.00: configured for UDMA/133
Jun 15 10:29:31 <Sys_Name> kernel: usb 2-2: Disable of device-initiated U1 failed.
Jun 15 10:29:31 <Sys_Name> kernel: usb 2-2: Disable of device-initiated U2 failed.
Jun 15 10:29:31 <Sys_Name> kernel: usb 2-2: reset SuperSpeed Gen 1 USB device number 2 using xhci_hcd
Jun 15 10:29:31 <Sys_Name> kernel: usb 2-2.4: Disable of device-initiated U1 failed.
Jun 15 10:29:31 <Sys_Name> kernel: usb 2-2.4: Disable of device-initiated U2 failed.
Jun 15 10:29:31 <Sys_Name> kernel: usb 2-2.4: reset SuperSpeed Gen 1 USB device number 3 using xhci_hcd
Jun 15 10:29:31 <Sys_Name> kernel: OOM killer enabled.
Jun 15 10:29:31 <Sys_Name> kernel: Restarting tasks ... done.
Jun 15 10:29:31 <Sys_Name> kernel: Probing NFC pn544
Jun 15 10:29:31 <Sys_Name> kernel: pci_bus 0000:01: Allocating resources
Jun 15 10:29:31 <Sys_Name> kernel: pci_bus 0000:02: Allocating resources
...

Testing by non-controlled USB LED toys shows that they are remain on during suspend. Installing laptop-mode-tools is not helpful (possibly, some additional settings are necessary).

How to set the devices to S3 or S4 state?

v_mil
  • 491
  • 1
  • 7
  • 14

1 Answers1

2

I had a similar problem recently when all of a sudden suspend stopped working due to USB. I wrote this script to fix it:

#!/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

Place the script in /lib/systemd/system-sleep/custom-xhci_hcd and mark it executable with:

chmod a+x /lib/systemd/system-sleep/custom-xhci_hcd

On next reboot script is activated.


Suspend message log

Use journalctl -xe and press Page Up numerous times to see the suspend messages:

Jun 14 17:30:51 alien systemd-sleep[16326]: /lib/systemd/system-sleep/custom-xhci_hcd: Going
Jun 14 17:30:51 alien kernel: xhci_hcd 0000:00:14.0: remove, state 4
Jun 14 17:30:51 alien kernel: usb usb2: USB disconnect, device number 1
Jun 14 17:30:51 alien kernel: usb 2-1: USB disconnect, device number 2
Jun 14 17:30:51 alien kernel: usb 2-1.4: USB disconnect, device number 3
Jun 14 17:30:51 alien kernel: xhci_hcd 0000:00:14.0: USB bus 2 deregistered
Jun 14 17:30:51 alien kernel: xhci_hcd 0000:00:14.0: remove, state 1
Jun 14 17:30:51 alien kernel: usb usb1: USB disconnect, device number 1
Jun 14 17:30:51 alien kernel: usb 1-1: USB disconnect, device number 2
Jun 14 17:30:51 alien kernel: usb 1-1.1: USB disconnect, device number 4
Jun 14 17:30:51 alien kernel: usblp1: removed
Jun 14 17:30:51 alien kernel: usb 1-1.2: USB disconnect, device number 6

Then press Page Down numerous times to see the resume messages:

Jun 14 17:31:07 alien systemd-sleep[16326]: /lib/systemd/system-sleep/custom-xhci_hcd: Wakin
Jun 14 17:31:07 alien systemd-sleep[16326]: Selected interface 'p2p-dev-wlp60s0'
Jun 14 17:31:07 alien systemd-sleep[16326]: OK
Jun 14 17:31:07 alien systemd-sleep[16326]: /lib/systemd/system-sleep/lag-suspend.sh: Waking
Jun 14 17:31:07 alien kernel: PM: suspend exit
Jun 14 17:31:07 alien kernel: xhci_hcd 0000:00:14.0: xHCI Host Controller
Jun 14 17:31:07 alien kernel: xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus nu
Jun 14 17:31:07 alien kernel: xhci_hcd 0000:00:14.0: hcc params 0x200077c1 hci version 0x100
Jun 14 17:31:07 alien kernel: xhci_hcd 0000:00:14.0: cache line size of 128 is not supported
Jun 14 17:31:07 alien kernel: usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
Jun 14 17:31:07 alien kernel: usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumb
Jun 14 17:31:07 alien kernel: usb usb1: Product: xHCI Host Controller
Jun 14 17:31:07 alien kernel: usb usb1: Manufacturer: Linux 4.14.114-0414114-generic xhci-hc
Jun 14 17:31:07 alien kernel: usb usb1: SerialNumber: 0000:00:14.0
Jun 14 17:31:07 alien kernel: hub 1-0:1.0: USB hub found
Jun 14 17:31:07 alien kernel: hub 1-0:1.0: 16 ports detected
Jun 14 17:31:07 alien kernel: xhci_hcd 0000:00:14.0: xHCI Host Controller
Jun 14 17:31:07 alien kernel: xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus nu
Jun 14 17:31:07 alien kernel: xhci_hcd 0000:00:14.0: Host supports USB 3.0  SuperSpeed
Jun 14 17:31:07 alien kernel: usb usb2: New USB device found, idVendor=1d6b, idProduct=0003
Jun 14 17:31:07 alien kernel: usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumb
Jun 14 17:31:07 alien kernel: usb usb2: Product: xHCI Host Controller
Jun 14 17:31:07 alien kernel: usb usb2: Manufacturer: Linux 4.14.114-0414114-generic xhci-hc
Jun 14 17:31:07 alien kernel: usb usb2: SerialNumber: 0000:00:14.0
Jun 14 17:31:07 alien kernel: hub 2-0:1.0: USB hub found
Jun 14 17:31:07 alien kernel: hub 2-0:1.0: 8 ports detected
Jun 14 17:31:07 alien eyesome[16633]: Wakeup: Called from suspend.
WinEunuuchs2Unix
  • 99,709
  • 34
  • 237
  • 401
  • The folder "system-sleep" has been created in "/etc/systemd/". The script has been copied and marked as executable. After restart the power state remains S0. – v_mil Jun 13 '19 at 19:12
  • Sorry typo. Folder already exists as `/lib/systemd/system-sleep`. Copy the script there to make it work. – WinEunuuchs2Unix Jun 13 '19 at 19:32
  • I moved the script to the correct folder and restarted. The power state remained S0. When the lid was closed, all USB peripherals (Ethernet, wired mouse) remained on (the mouse LED did not switch off, the "Data" LED on the Ethernet controller continued blinking). After waking up, all peripherals switched off and on. The mouse stoped responding until manual re-plug. I moved the script outside the target folder and restarted. After closing the lid, the peripherals now operate normally except S0 state of the host controllers. – v_mil Jun 14 '19 at 15:39
  • Something may have changed in kernel after October 2018. I will check system logs for errors. Thanks. – WinEunuuchs2Unix Jun 14 '19 at 17:07
  • Also what does `/etc/systemd/logind.conf` contain for two `LidSwitch` entries? – WinEunuuchs2Unix Jun 14 '19 at 17:14
  • I looked through system log files and script is still working on my kernel version 4.14.114 which is fairly recent. I've included the relevant log messages in my answer. Sorry if it's not working for you it does work for others but you are not the first to report it doesn't work for them. I'm not sure why. Perhaps you can look at your system messages too? – WinEunuuchs2Unix Jun 14 '19 at 23:40
  • I tested on the kernel 4.15.0-51-generic. The power state is the same. Possibly, the problem is related to the controller. On other laptop (Lenovo Ideapad Z580) all equipment is at S3/S4 state. Maybe, the developer alows charging external devices in suspend mode independently on BIOS settings. Or it is the driver bug. How to find the model of the USB 3.0 controller? – v_mil Jun 17 '19 at 08:35
  • On 4.15.0-52-generic the state indicated is S0 but in the suspend mode the system stay cool and non-controlled devices are switched off. Thus, the problem is belong to the linux kernel 5.1.0-6.4-liquorix-amd64 #1 ZEN SMP PREEMPT. – v_mil Jun 24 '19 at 15:57
  • It works after upgrading to LUbuntu 20.04 LTS. It solves the problems with power leakage and with rapid resume. Only one minus - resuming needs approx. 4-5 s. for re-initializing USB. I have embedded USB cardreader with SD card, which contains my e-book library and some materials. Is it possible to break the filesystem on it by unbinding on-the-fly. – v_mil Jun 30 '20 at 18:04
  • @v_mil From what I understand it is important to save the addresses when unbinding and reuse the same addresses when binding upon resume. I'm not sure what *"unbinding on-the-fly"* will do. – WinEunuuchs2Unix Jun 30 '20 at 18:10
  • When you run `journalctl` are you running it as root? Because when I run it with my user, I don't see any kernel messages (also I can't run it as root as I don't have privileges on my machine). – Alex Spurling Aug 05 '20 at 22:14
  • 1
    @AlexSpurling I seldomly invoke `journalctl` with `sudo` powers and in this instance `sudo` definitely wasn't used. – WinEunuuchs2Unix Aug 06 '20 at 03:00
  • The problem appears if some power settings was applied during boot process, for example, https://wiki.ubuntu.com/DebuggingTouchpadDetection. After rebinding the settings will not be restored. To avoid the problem, at the end of the script above run another script that is used at boot time. For rc.local, add the following line at the end: /etc/rc.local – v_mil Sep 20 '20 at 20:00