On 7/4/22 20:58, Brad Campbell via Dng wrote:
> G'day,
> 
> I could use a bit of advice if anyone has the relevant experience.
> 
> My laptop is running Devuan Beowulf currently, but this suspend config goes 
> back at least 10 years.
> It suspends / hibernates using pm-utils with the uswsusp back-end onto a 
> dmycrypted swap partition. The kernel is vanilla with a cut-down config and 
> locally compiled.
> 
> This works flawlessly and has done since I set it up. The GUI is xfce4 and 
> when I hit the power button xfce4-power-manager does all the right things 
> (which is hit up pm-utils and get out of its way).
> 
> Last night I upgraded to Chimaera. This installed elogind and tries to use 
> that to pull the relevant kernel levers to suspend. Unfortunately on my 
> system, while it suspends most times, it comes back about 1 in 10 and then 
> usually the nvme is broken and it dies in a ball of flames. I spent the best 
> part of a day experimenting with the in-kernel suspend mechanisms and I can't 
> seem to make it work, while the trusty old uswsusp userspace suspend/resume 
> works first time every time.
> 
> So, I'm asking for either :
> - Experience in making the in-kernel mechanisms work; or preferably
> - How to remove elogind from an xfce4 Chimaera install and make 
> xfce4-power-manager use pm-utils like it used to.
> 
> Does anyone have any ideas?
> 

Just to follow this up, it appears to be related to power management. When 
unplugged pm-utils pulls a pile of levers in the kernel to reduce power 
consumption. This does reduce on-battery consumption significantly, but it also 
breaks resume on a number of pcie devices. In the past I had issues with both 
brcmfmac and the xhci driver, so I was unloading those pre-suspend and 
re-loading on resume. I also had to serialize the device suspend as async 
seemed to lock up.

By inserting some magic into the suspend hook to undo all the power management 
magic, it would appear I no longer need to unload any modules and suspend, 
hibernate and hybrid suspend all work and resume as-was.

I don't want to speak too soon, but so far I have 24 hybrid cycles on the 
machine and it's still resuming ok.

To be specific, pre-suspend I'm using :

        echo 0 > /sys/power/pm_async
        echo default > /sys/module/pcie_aspm/parameters/policy 
        /usr/lib/pm-utils/power.d/pci_devices false

Async device freeze off and then undo all the power saving modes.

Once I'm convinced it's reliable, I'll start peeling these commands back one by 
one to see which one(s) cause the issues, but at the moment it's looking happy.

Now, why this all works on Beowulf and doesn't on Chimaera is entirely a 
mystery give the pm-utils, uswsusp and kernel config is identical is beyond me, 
but I figure as both pm-utils and uswsusp are effectively dead I'm going to 
have to use the in-kernel stuff at some point.

My current hook script in /lib/elogind/system-sleep/Hooks.sh :

#!/bin/bash
do_wakeup () {
        for i in LID0 XHC1 ; do
                if [ -z "`cat /proc/acpi/wakeup | grep $i | grep disabled`" ] ; 
then
                        echo $i > /proc/acpi/wakeup
                fi;
        done;
}

do_suspend() {
        echo N > /sys/module/printk/parameters/console_suspend
        echo 0 > /sys/power/image_size
        echo 0 > /sys/power/pm_async
        echo default > /sys/module/pcie_aspm/parameters/policy 
        /usr/lib/pm-utils/power.d/pci_devices false
        do_wakeup
        /etc/init.d/openvpn stop
        xscreensaver-command -lock
        sync
}

do_resume() {
        for i in gpe66 gpe4E ; do
                echo disable > /sys/firmware/acpi/interrupts/$i 2>/dev/null
        done;
        do_wakeup
        rfkill block bluetooth
        echo 120 > /sys/class/leds/smc::kbd_backlight/brightness
        xscreensaver-command -deactivate
        if [ "`cat /sys/class/power_supply/ADP1/online`" -eq 1 ] ; then
               pm-powersave false
        else
               pm-powersave true
        fi             

}
PID=`pgrep xfce4-session`
USER=`ps -p $PID -o ruser=`
export DISPLAY=:0.0
export XAUTHORITY=/home/$USER/.Xauthority

case $1/$2 in
        pre/*)
        do_suspend
        ;;
        post/*)
        do_resume
        ;;
esac


Regards,
Brad
_______________________________________________
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Reply via email to