Jump to content

Power Management: Difference between revisions

Add workaround for systems that immediatly wakeup after beign suspended
imported>Samueldr
(Created page with "{{expansion}} == Suspend == === Suspend hooks === NixOS provides the {{nixos:option|powerManagement.resumeCommands}} option which defines commands that are added to a globa...")
 
imported>Lelgenio
(Add workaround for systems that immediatly wakeup after beign suspended)
Line 28: Line 28:
</syntaxhighlight>
</syntaxhighlight>


=== Troubleshooting ===
==== System Immediately wakes up from suspend ====
Particularly in some gigabyte motherboards with NVMe drives, the system may immediately wake up from being suspended.
This can be worked around by disabling the wakeup triggers for the offending components:
===== Solution 1: Disabling wakeup triggers for all PCIe devices =====
If you don't need your system to wakeup via PCIe components you can simply disable it for all without needing to search for what component is causing problems.
<syntaxhighlight lang="nix">
services.udev.extraRules = ''
  ACTION=="add", SUBSYSTEM=="pci", DRIVER=="pcieport", ATTR{power/wakeup}="disabled"
'';
</syntaxhighlight>
===== Solution 2: Disabling a common NVMe interface =====
Specifically on Gigabyte motherboards you can try targetting only the NVMe ports.
<syntaxhighlight lang="nix">
services.udev.extraRules = ''
  ACTION=="add" SUBSYSTEM=="pci" ATTR{vendor}=="0x1022" ATTR{device}=="0x1483" ATTR{power/wakeup}="disabled"
'';
</syntaxhighlight>
===== Solution 3: Disabling a single device's wakeup triggers =====
If you wish to be more granular in what components should no longer be able to wakeup your system you can manually search what component is causing the wakeup events.
First, list all components and their current wakeup status:
<syntaxhighlight lang="sh">
$ cat /proc/acpi/wakeup
Device S-state   Status  Sysfs node
GP12   S4 *enabled  pci:0000:00:07.1
GP13   S4 *disabled  pci:0000:00:08.1
XHC0   S4 *enabled  pci:0000:0a:00.3
GP30   S4 *disabled
....
PT27   S4 *disabled
PT28   S4 *disabled
PT29   S4 *disabled  pci:0000:03:09.0
</syntaxhighlight>
You can temporarily toggle a device by sending it's "Device" collumn back into `/proc/acpi/wakeup`
<syntaxhighlight lang="sh">
echo GPP0 | sudo tee /proc/acpi/wakeup
</syntaxhighlight>
After finding out which component is causing unwanted wakeups you can use the sysfs id to find out the "vendor" and "device" fields:
<syntaxhighlight lang="sh">
$ cat /sys/class/pci_bus/0000:04/device/0000:04:00.0/vendor
0x1987
$ cat /sys/class/pci_bus/0000:04/device/0000:04:00.0/device
0x5013
</syntaxhighlight>
And finally use those values in a udev rule:
<syntaxhighlight lang="nix">
services.udev.extraRules = ''
  ACTION=="add" SUBSYSTEM=="pci" ATTR{vendor}=="0x1987" ATTR{device}=="0x5013" ATTR{power/wakeup}="disabled"
'';
</syntaxhighlight>


== External resources ==
== External resources ==


* {{manual:nixos|sec=#sec-rebooting|chapter=Chapter 23. Rebooting and Shutting Down}}
* {{manual:nixos|sec=#sec-rebooting|chapter=Chapter 23. Rebooting and Shutting Down}}
Anonymous user