如何为处于暂停状态的设备设置 S3/S4 状态

如何为处于暂停状态的设备设置 S3/S4 状态

我有 Dell Venue transformer,配有 LUbuntu 18.04,内核为 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。我禁用了除 PBTN 之外的所有设备的唤醒功能。在 BIOS 中,USB PowerShare 已关闭。

尽管如此,挂起后笔记本电脑仍然很热。只有三个设备不会改变电源状态:

$ 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
...

通过非受控 USB LED 玩具测试,它们在挂起期间保持亮起状态。安装 laptop-mode-tools 没用(可能需要一些额外设置)。

如何将设备设置为S3或S4状态?

答案1

我最近遇到了类似的问题,当时由于 USB 的原因,暂停功能突然停止工作。我写了这个脚本来修复它:

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

放入脚本/lib/systemd/system-sleep/custom-xhci_hcd并将其标记为可执行:

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

下次重启时脚本将被激活。


暂停消息日志

多次使用journalctl -xe并按下可查看暂停消息:Page Up

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

然后Page Down多次按下即可查看恢复消息:

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.

相关内容