Skip to content

Commit dce4046

Browse files
committed
nixos/nvidia: use kernel suspend notifier if available
1 parent af0ee7c commit dce4046

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

nixos/modules/hardware/video/nvidia.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ let
2020
busIDType = lib.types.strMatching "([[:print:]]+:[0-9]{1,3}(@[0-9]{1,10})?:[0-9]{1,2}:[0-9])?";
2121
ibtSupport = useOpenModules || (nvidia_x11.ibtSupport or false);
2222
settingsFormat = pkgs.formats.keyValue { };
23+
kernelSuspendNotifier = useOpenModules && lib.versionAtLeast nvidia_x11.version "595";
2324
in
2425
{
2526
options = {
@@ -620,7 +621,7 @@ in
620621
};
621622
in
622623
lib.mkMerge [
623-
(lib.mkIf cfg.powerManagement.enable {
624+
(lib.mkIf (cfg.powerManagement.enable && !kernelSuspendNotifier) {
624625
nvidia-suspend = nvidiaService "suspend";
625626
nvidia-hibernate = nvidiaService "hibernate";
626627
nvidia-resume = (nvidiaService "resume") // {
@@ -687,6 +688,9 @@ in
687688
// lib.optionalAttrs (
688689
(offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545"
689690
) { nvidia-drm.fbdev = 1; }
691+
// lib.optionalAttrs (cfg.powerManagement.enable && kernelSuspendNotifier) {
692+
nvidia.NVreg_UseKernelSuspendNotifiers = 1;
693+
}
690694
// lib.optionalAttrs cfg.powerManagement.enable { nvidia.NVreg_PreserveVideoMemoryAllocations = 1; }
691695
// lib.optionalAttrs useOpenModules { nvidia.NVreg_OpenRmEnableUnsupportedGpus = 1; }
692696
// lib.optionalAttrs cfg.powerManagement.finegrained {

0 commit comments

Comments
 (0)