Skip to content

Commit 84339e5

Browse files
committed
nixos/nvidia: use kernel suspend notifier if available
1 parent 15d0cfe commit 84339e5

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 = {
@@ -614,7 +615,7 @@ in
614615
};
615616
in
616617
lib.mkMerge [
617-
(lib.mkIf cfg.powerManagement.enable {
618+
(lib.mkIf (cfg.powerManagement.enable && !kernelSuspendNotifier) {
618619
nvidia-suspend = nvidiaService "suspend";
619620
nvidia-hibernate = nvidiaService "hibernate";
620621
nvidia-resume = (nvidiaService "resume") // {
@@ -681,6 +682,9 @@ in
681682
// lib.optionalAttrs (
682683
(offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545"
683684
) { nvidia-drm.fbdev = 1; }
685+
// lib.optionalAttrs (cfg.powerManagement.enable && kernelSuspendNotifier) {
686+
nvidia.NVreg_UseKernelSuspendNotifiers = 1;
687+
}
684688
// lib.optionalAttrs cfg.powerManagement.enable { nvidia.NVreg_PreserveVideoMemoryAllocations = 1; }
685689
// lib.optionalAttrs useOpenModules { nvidia.NVreg_OpenRmEnableUnsupportedGpus = 1; }
686690
// lib.optionalAttrs cfg.powerManagement.finegrained {

0 commit comments

Comments
 (0)