Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Suspend to RAM immediately wake-up
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
costis
n00b
n00b


Joined: 14 Oct 2014
Posts: 14

PostPosted: Wed Oct 09, 2019 3:33 pm    Post subject: Suspend to RAM immediately wake-up Reply with quote

This isn't really a call for help, unless you know how I could enable waking up from my keyboard. :D
I just post a concise solution to my problem for future reference.

So my problem was that when I was trying to suspend to RAM following our wiki the system seemed to go into sleep for say half a second and then immediately wake up. dmesg was throwing a "port does not support device sleep" error. Trying different USB ports for my devices didn't help. Various online posts, the Arch wiki and the magnificent usbwakup.sh script by danomac from this how-to led me to the solution.

The solution is to disable waking up from my keyboard and enable it from my mouse:
Code:
echo disabled > /sys/devices/pci0000:00/0000:00:01.3/0000:03:00.0/power/wakeup
echo enabled > /sys/devices/pci0000:00/0000:00:07.1/0000:27:00.3/usb3/3-2/power/wakeup


With systemd, the above are run automatically putting them in a shell script, creating a systemd unit file and enabling/starting the corresponding service as in:
Code:
# /etc/systemd/system/properSuspend.service
[Unit]
Description=Prope Suspend service
[Service]
ExecStart=/etc/systemd/system/properSuspend.sh # script location
[Install]
WantedBy=multi-user.target


PS.: echo PTXH > /proc/acpi/wakeup prevents the immediate wake up, too. It changes the last line from enabled to disabled. When I suspend to RAM, the system properly suspends without waking up. Nevertheless, the keyboard lights/LEDs are turned on, but I cannot resume from keyboard. To have the keyboard lights turned off, I need echo disabled > /sys/devices/pci0000:00/0000:00:01.3/0000:03:00.0/usb1/1-8/power/wakeup.
Code:
# cat /proc/acpi/wakeup
Device  S-state   Status   Sysfs node
GPP0      S4    *disabled
GPP1      S4    *disabled
GPP3      S4    *disabled
GPP4      S4    *disabled
GPP5      S4    *disabled
GPP6      S4    *disabled
GPP7      S4    *disabled
GPP8      S4    *enabled   pci:0000:00:03.1
GPP9      S4    *disabled
GPPA      S4    *disabled
GPPB      S4    *disabled
GPPC      S4    *disabled
GPPD      S4    *disabled
GPPE      S4    *disabled
GPPF      S4    *disabled
GP17      S4    *enabled   pci:0000:00:07.1
XHC0      S4    *enabled   pci:0000:27:00.3
GP18      S4    *enabled   pci:0000:00:08.1
GPP2      S4    *enabled   pci:0000:00:01.3
PT21      S4    *enabled   pci:0000:20:01.0
PTXH      S4    *disabled  pci:0000:03:00.0


Relevant entries from lshw:
Code:
           *-usb
                description: USB controller
                product: 400 Series Chipset USB 3.1 XHCI Controller
                vendor: Advanced Micro Devices, Inc. [AMD]
                physical id: 0
                bus info: pci@0000:03:00.0
                version: 01
                width: 64 bits
                clock: 33MHz
                capabilities: msi msix pm pciexpress xhci bus_master cap_list
                configuration: driver=xhci_hcd latency=0
                resources: irq:29 memory:fcda0000-fcda7fff
              *-usbhost:0
                   product: xHCI Host Controller
                   vendor: Linux 5.3.5-gentoo-x86_64 xhci-hcd
                   physical id: 0
                   bus info: usb@1
                   logical name: usb1
                   version: 5.03
                   capabilities: usb-2.00
                   configuration: driver=hub slots=10 speed=480Mbit/s
                 *-usb:0
                      description: Keyboard
                      product: USB-HID Keyboard
                      vendor: Holtek Semiconductor, Inc.
                      physical id: 8
                      bus info: usb@1:8
                      version: 11.02
                      capabilities: usb-1.10
                      configuration: driver=usbhid maxpower=100mA speed=12Mbit/s


danomac's usbwakeup.sh -l:
Code:
Listing USB hubs/devices and their wakeup status... (hitting any key

USB ID    :: Device* :: Status :: Device Description
----------------------------------------------------
062a:4101 :: 1-9 :: enabled :: 2.4G Keyboard Mouse
1d6b:0002 :: usb1 :: disabled :: xHCI Host Controller
04d9:0203 :: 1-8 :: enabled :: USB-HID Keyboard
1d6b:0003 :: usb2 :: disabled :: xHCI Host Controller
1d6b:0002 :: usb3 :: disabled :: xHCI Host Controller
1532:0067 :: 3-2 :: enabled :: Razer Naga Trinity
1d6b:0003 :: usb4 :: disabled :: xHCI Host Controller

*Use the Device column to identify hubs/devices to be toggled.

7 USB hubs/devices listed.


I have tried enabling/disabling different devices but still can't wake up from keyboard.
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1741
Location: United Kingdom

PostPosted: Thu Oct 10, 2019 11:45 am    Post subject: Reply with quote

I had a similar problem in 2016 with my laptop using OpenRC+ConsoleKit+pm-utils, viz. my laptop waking up immediately after Suspend to RAM, as discussed in my 2016 blog post Stopping my laptop spontaneously resuming immediately after Suspend to RAM.

I first used the command 'acpitool -w' (lowercase w) to find out which wakeup-capable USB devices were currently enabled, then the command 'acpitool -W <device number>' (uppercase W) to find out which of them needed to be disabled in order for my laptop to remain suspended when I suspended it. In this particular laptop these two devices are two internal USB root hubs.

In those days I was using OpenRC+ConsoleKit+pm-utils, so my solution was to create a hook script /etc/pm/sleep.d/01-toggle-usb-hubs containing:

Code:
#!/bin/sh
#
username=fitzcarraldo
userhome=/home/$username
export XAUTHORITY="$userhome/.Xauthority"
export DISPLAY=":0"
#
case "$1" in
    suspend|hibernate)
        # Unbind ehci-pci for the device 0000:00:1a.0
        echo -n "0000:00:1a.0" | tee /sys/bus/pci/drivers/ehci-pci/unbind
        # Unbind ehci-pci for the device 0000:00:1d.0
        echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci-pci/unbind
    ;;
    resume|thaw)
        # Bind ehci-pci for the device 0000:00:1a.0
        echo -n "0000:00:1a.0" | tee /sys/bus/pci/drivers/ehci-pci/bind
        # Bind ehci-pci for the device 0000:00:1d.0
        echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci-pci/bind
    ;;
    *)
        exit $NA
    ;;
esac


After I switched to OpenRC+elogind I had to change the script to /lib64/elogind/system-sleep/01-toggle-usb-hubs containing the following:

Code:
#!/bin/sh

username=fitzcarraldo
userhome=/home/$username
export XAUTHORITY="$userhome/.Xauthority"
export DISPLAY=":0"

case $1/$2 in
     pre/*)
          # Unbind ehci-pci for first device 0000:00:1a.0
          echo -n "0000:00:1a.0" | tee /sys/bus/pci/drivers/ehci-pci/unbind
          # Unbind ehci-pci for second device 0000:00:1d.0
          echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci-pci/unbind
     ;;
     post/*)
          # Bind ehci-pci for first device 0000:00:1a.0
          echo -n "0000:00:1a.0" | tee /sys/bus/pci/drivers/ehci-pci/bind
          # Bind ehci-pci for second device 0000:00:1d.0
          echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci-pci/bind
     ;;
     *)
          exit $NA
     ;;
esac


Given that elogind is a fork of systemd-logind, my understanding is that the above script would also have worked if my laptop were using systemd instead of OpenRC+elogind, albeit the script would be in the directory /lib/systemd/system-sleep/ rather than /lib64/elogind/system-sleep/.

In my case I can wake my laptop from sleep by pressing a key on an external USB keyboard, and also by pressing the Wakeup key on my laptop's keyboard (Fn+F4 on the Clevo W230SS laptop).
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum