Power Management: Difference between revisions

m change lang=sh to shell session to fix syntax highlighting error
Added a section to troubleshoot userspace suspend issues.
Line 155: Line 155:
'';
'';
</syntaxhighlight>
</syntaxhighlight>
=== Suspend blocked by <code>pre-sleep.service</code> ===
Sometimes, the system appears to suspend (Wi-Fi turns off, screen locks), but the hardware does not actually suspend, and all subsequent <code>systemctl suspend</code> or <code>systemctl reboot</code> commands are met with:
<syntaxhighlight lang="console">
# systemctl suspend
Call to Suspend failed: Action suspend already in progress, refusing requested suspend operation.
# systemctl reboot
Call to Reboot failed: Action suspend already in progress, refusing requested reboot operation.
</syntaxhighlight>
If directly telling the kernel to suspend as root works:
<syntaxhighlight lang="console">
# echo mem > /sys/power/state
</syntaxhighlight>
Then a long-running <code>pre-sleep.service</code> might be hanging the sleep. This can be verified with <code>systemctl list-jobs</code>:
<syntaxhighlight lang="console">
# systemctl list-jobs
JOB  UNIT                    TYPE  STATE 
12144 suspend.target          start waiting
12149 pre-sleep.service      start running
12145 systemd-suspend.service start waiting
12268 post-resume.target      start waiting
12148 sleep.target            start waiting
12269 post-resume.service    start waiting
</syntaxhighlight>
Here, the <code>pre-sleep.service</code> is blocking and halting suspend. To see why, we can use <code>systemctl cat pre-sleep.service</code>:
<syntaxhighlight lang="systemd">
# systemctl cat pre-sleep.service
# /etc/systemd/system/pre-sleep.service
[Unit]
Before=sleep.target
Description=Pre-Sleep Actions
[Service]
# <... Omitted Environment directives PATH, LOCALE_ARCHIVE, TZDIR ...>
ExecStart=/nix/store/yzf7cpiqzq49san2frijxsh160zjy6fp-unit-script-pre-sleep-start/bin/pre-sleep-start
Type=oneshot
[Install]
WantedBy=sleep.target
</syntaxhighlight>
The <code>pre-sleep-start</code> script referenced by <code>ExecStart</code> contained directives installed by the [[Displaylink]] package, that contained a flush operation which hung the suspend action. Starting <code>dlm.service</code> or running <code>sudo DisplayLinkManager</code> unblocks the script and made suspend work normally.
An existing suspend operation that is hung may be interrupted using <code>'''systemctl cancel'''</code> in case reboots or internet access is needed.


== See also ==
== See also ==