rizitis/nvidia-sleep-hook
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
nvidia-sleep-hook based on: https://download.nvidia.com/XFree86/Linux-x86_64/435.17/README/powermanagement.html https://www.linuxquestions.org/questions/slackware-14/how-to-get-wayland-working-on-a-nvidia-pascal-video-card-4175765650/ NOTE for the fix with nvidia-dbus.conf / nvidia-powerd: That is a separate feature (Dynamic Boost: CPU<->GPU power budget shifting on supported laptops) and plays no role in suspend or resume; sleep works without it, as verified during testing. It is therefore intentionally not shipped here. If you want Dynamic Boost, set it up independently per the NVIDIA driver README. ================= An elogind system-sleep hook that makes suspend and hibernate work properly with the NVIDIA proprietary driver on Slackware. Without it, systems running the NVIDIA driver commonly fail to suspend, wake up instantly, or resume with corrupted graphics, because the driver's default (kernel callback) power management path can only preserve a small amount of video memory. The hook drives the /proc/driver/nvidia/suspend interface at the right moments of the sleep cycle, telling the driver to save all video memory allocations to disk before sleeping and to restore them on resume. This is the same mechanism the NVIDIA-provided systemd units use, adapted to elogind. The hook is a silent no-op on systems without the NVIDIA driver (nouveau, legacy drivers without the /proc interface, or no NVIDIA hardware at all), so it is safe to install anywhere. Requirements ------------ * Slackware 15.0 or -current with elogind. * NVIDIA proprietary driver new enough to provide /proc/driver/nvidia/suspend (470 series and later). * The following kernel module options MUST be set. This package ships them in /etc/modprobe.d/nvidia-pm.conf (installed as .new, never clobbering an existing copy): options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_TemporaryFilePath=/var/tmp If you already set these options in your own modprobe file (e.g. /etc/modprobe.d/nvidia.conf), keep only one copy. Notes on NVreg_TemporaryFilePath: - It must point to a filesystem that is NOT tmpfs and supports unnamed temporary files (O_TMPFILE); any normal ext4/xfs/btrfs location is fine. /var/tmp is a good default on Slackware. - /var/tmp may be a separate mount on some systems; always check the actual filesystem behind it with: df -h /var/tmp - It must have at least as much free space as the video memory allocated at suspend time. Check your card's capacity with: nvidia-smi -q -d MEMORY | grep -A2 'FB Memory' - You will never see the temporary files in a directory listing; they are unnamed and exist only for the duration of the sleep cycle. A reboot (or full module unload/reload) is required for the options to take effect. Verify with: grep PreserveVideoMemoryAllocations /proc/driver/nvidia/params which must report: PreserveVideoMemoryAllocations: 1 Installation ------------ Via the SlackBuild, or manually: install -m 0755 nvidia-sleep.sh /etc/elogind/system-sleep/nvidia-sleep.sh Then configure the module options as described above and reboot. Usage ----- Nothing to do: elogind runs every executable in /etc/elogind/system-sleep/ automatically around each sleep cycle. Suspend as usual (lid close, loginctl suspend, desktop menu). Hybrid sleep and suspend-then-hibernate are handled with a hibernate-grade video memory image, since both may end up resuming from disk. X11 note: when a running Xorg server is detected, the hook switches to a spare virtual terminal before sleeping and back afterwards, as required by the NVIDIA X driver. Wayland sessions need no VT dance and none is performed. Not tested in XLibre. Troubleshooting --------------- The hook logs every action via syslog with the tag "nvidia-sleep": grep nvidia-sleep /var/log/messages * "suspend: FAILED (driver refused, see dmesg)" -- the driver could not save its state. Check dmesg; the usual causes are missing NVreg_PreserveVideoMemoryAllocations=1 (check /proc/driver/nvidia/params) or insufficient free space at NVreg_TemporaryFilePath. * System still wakes up instantly even though the hook logs "suspend: ok" -- the problem is not the NVIDIA driver state but a spurious wakeup source (typically PCIe PME from the GPU root port, or a USB controller). Inspect dmesg after the failed cycle and /proc/acpi/wakeup, and disable the offending wakeup source. * No log lines at all -- the hook exited early because /proc/driver/nvidia/suspend does not exist or is not writable; the NVIDIA driver is not loaded or is too old. Author ------ Ioannis Anagnostakis (rizitis)