This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

machines.xerxes: add suspend-then-hibernate with VRAM eviction workaround

- Disable spurious PCIe wakeup sources via udev rule
- Add 64GB swapfile and resume config for hibernation
- Enable suspend-then-hibernate (15min s2idle, then hibernate)
- Load amdgpu in initrd for reliable resume
- Add amdgpu.gpu_recovery=1 kernel param
- Pre-evict VRAM before sleep via systemd service

+53 -1
+53 -1
machines/xerxes/physical.nix
··· 11 11 boot.kernelPackages = pkgs.linuxPackages_latest; 12 12 hardware.graphics.enable = true; 13 13 14 + # Load amdgpu early in initrd for reliable suspend/hibernate resume 15 + hardware.amdgpu.initrd.enable = true; 16 + 14 17 # Disable Bluetooth USB autosuspend to prevent hardware errors/disconnects 15 18 # Disable VPE (Video Processing Engine) to fix black screen after suspend/resume 16 19 # on AMD Strix APUs. VPE fails to reset properly causing IB test timeouts. ··· 20 23 options amdgpu ip_block_mask=0xfffff7ff 21 24 ''; 22 25 23 - services.logind.powerKey = "suspend"; 26 + # Disable spurious wakeup sources (PCIe ports triggering immediate wake from s2idle) 27 + services.udev.extraRules = '' 28 + ACTION=="add", SUBSYSTEM=="pci", DRIVER=="pcieport", ATTR{power/wakeup}="disabled" 29 + ''; 30 + 31 + # Swapfile for hibernation (suspend-then-hibernate needs somewhere to dump RAM) 32 + swapDevices = [ 33 + { 34 + device = "/swapfile"; 35 + size = 65536; # 64GB to cover full RAM 36 + } 37 + ]; 38 + 39 + # Resume from swapfile on the root partition 40 + boot.resumeDevice = "/dev/disk/by-uuid/e2e38fb5-0cea-4a97-ae56-c2858ae0e07b"; 41 + boot.kernelParams = [ 42 + "resume_offset=156473344" 43 + "amdgpu.gpu_recovery=1" # attempt GPU reset on failure instead of black screen 44 + ]; 45 + 46 + # Pre-evict VRAM before sleep to prevent amdgpu resume black screen 47 + # https://nyanpasu64.gitlab.io/blog/amdgpu-sleep-wake-hang/ 48 + systemd.services.amdgpu-sleep = { 49 + description = "Evict VRAM before sleep"; 50 + before = [ 51 + "sleep.target" 52 + "suspend.target" 53 + "hibernate.target" 54 + "suspend-then-hibernate.target" 55 + ]; 56 + wantedBy = [ 57 + "sleep.target" 58 + "suspend.target" 59 + "hibernate.target" 60 + "suspend-then-hibernate.target" 61 + ]; 62 + unitConfig.StopWhenUnneeded = true; 63 + serviceConfig = { 64 + Type = "oneshot"; 65 + RemainAfterExit = true; 66 + ExecStart = "${pkgs.bash}/bin/bash -c 'for f in /sys/kernel/debug/dri/*/amdgpu_evict_vram; do cat \"$f\"; done'"; 67 + }; 68 + }; 69 + 70 + # s2idle for 15 minutes, then hibernate to save power 71 + services.logind.powerKey = "suspend-then-hibernate"; 72 + services.logind.lidSwitch = "suspend-then-hibernate"; 73 + systemd.sleep.extraConfig = '' 74 + HibernateDelaySec=15min 75 + ''; 24 76 }