olm3ca / Galaxy-Chromebook

Mac OS, Linux and other systems on the Samsung Galaxy Chromebook
65 stars 4 forks source link

Working fix for "wakes up from suspend when lid is closed" [Manjaro 6.3] #12

Open jdc-cunningham opened 1 year ago

jdc-cunningham commented 1 year ago

I looked at journalct logs and came across this line: ACPI: PM: Low-level resume complete after some searching around I came across the fix here:

https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Instantaneous_wakeups_from_suspend

Specifically disabling the one thing that came up from ls /sys/bus/i2c/devices/*/power/wakeup

I'm currently testing if the lid-close suspend is working based on what is set by Energy Saving -> Button events handling

Also regarding mem_sleep mine was [s2idle] set that to deep but I also had to edit grub eg. GRUB_CMDLINE_LINUX_DEFAULT

Audio issues

This is a tangent but I did have problems getting audio to work at first. I had a conflict with pulseaudio and pipewire... In the end I removed pulseaudio or at least it's not a "server option" when you do inxi -Fazy

I also added swap, I'm not sure if it was needed, I put 3GB on there (not for hibernation).

jdc-cunningham commented 1 year ago

One other note, keyboard backlight was interesting.

If I use the start/taskbar sleep, when waking up the keyboard backlight is set to 100%.

I was writing it manually to the /sys/class/leds/chromeos::kbd_backlight/brightness

This seems to not happen now when using lid close suspend

Had to use the echo <val> | sudo tee --append /path... pattern to modify files

JoshuaToenyes commented 2 months ago

For me, I fixed this problem by disabling an ACPI wake up device.

I'm running Fedora 40 and kernel 6.10.9 (I know this issue is for Manjaro... but maybe it'll work for that distro, too).

Below is the current state of /proc/acpi/wakeup:

$ cat /proc/acpi/wakeup
Device  S-state  Status   Sysfs node
LID0     S4 *enabled   platform:PNP0C0D:00
CREC     S5 *disabled  platform:GOOG0004:00
        *disabled  gpio:gpiochip1
H020     S3 *disabled  i2c:i2c-SYNA0000:00
CRFP     S3 *enabled   spi:spi-PRP0001:02
        *disabled  gpio:gpiochip2
XHCI     S4 *enabled   pci:0000:00:14.0
GLAN     S4 *disabled
CNVW     S3 *disabled  pci:0000:00:14.3

The one causing me problems was the H020 device (which shows now as disabled, which fixes the problem). (I'm unsure which device that is exactly... I'm fairly certain it's the touch screen or touchpad.)

You can test to see if that will correct the problem for you by temporarily disabling the device (or go one-by-one on devices until you find the offender).

$ sudo su root
$ echo H020 > /proc/acpi/wakeup

Note: I had to switch to root as show above. A simple sudo won't work.

For me, that corrected the problem. To keep this configuration persistent between boots, I setup a systemd service to run that line each time the system boots.

First, I created the directory, script, and service files that will be used. There's nothing magical about the location; this is just where I decided to store them.

$ sudo mkdir -p /usr/local/share/disable-acpi-devices \
  && cd /usr/local/share/disable-acpi-devices \
  && sudo touch disable-acpi-devices.{service,sh} \
  && sudo chmod +x disable-acpi-devices.sh

That edited the two files. The script which disables the device and the service file we'll use to run it on each boot. The contents of the files are below:

disable-acpi-devices.sh

#!/bin/bash

declare -a devices=(H020) # Allow for disabling more than one device
for device in "${devices[@]}"; do
    if grep -qw ^$device.*enabled /proc/acpi/wakeup; then
        sudo su -c "echo $device > /proc/acpi/wakeup"
    fi
done

disable-acpi-devices.service

[Unit]
Description=Disable devices for ACPI wakeup

[Service]
ExecStart=/bin/bash /usr/local/share/disable-acpi-devices/disable-acpi-devices.sh
Type=oneshot

[Install]
WantedBy=multi-user.target

And finally, I enabled the service:

$ sudo ln -s /usr/local/share/disable-acpi-devices/disable-acpi-devices.service \ 
    /etc/systemd/system/disable-acpi-devices.service \
  && sudo systemctl enable disable-acpi-devices 

This was non-trivial for me :) I hope this helps someone!

olm3ca commented 2 months ago

Great solution, @JoshuaToenyes! Thanks.