|
88 | 88 | the NVIDIA docs, on Chapter 21. Configuring Power Management Support |
89 | 89 | ''; |
90 | 90 |
|
91 | | - powerManagement.finegrained = lib.mkEnableOption '' |
92 | | - experimental power management of PRIME offload. For more information, see |
93 | | - the NVIDIA docs, on Chapter 22. PCI-Express Runtime D3 (RTD3) Power Management |
94 | | - ''; |
| 91 | + powerManagement.kernelSuspendNotifier = |
| 92 | + lib.mkEnableOption '' |
| 93 | + NVIDIA driver support for kernel suspend notifiers, which allows the driver |
| 94 | + to be notified of suspend and resume events by the kernel, rather than |
| 95 | + relying on systemd services. |
| 96 | + Requires NVIDIA driver version 595 or newer, and the open source kernel modules. |
| 97 | + '' |
| 98 | + // { |
| 99 | + default = useOpenModules && lib.versionAtLeast nvidia_x11.version "595"; |
| 100 | + defaultText = lib.literalExpression '' |
| 101 | + config.hardware.nvidia.open == true && lib.versionAtLeast config.hardware.nvidia.package.version "595" |
| 102 | + ''; |
| 103 | + }; |
95 | 104 |
|
96 | 105 | dynamicBoost.enable = lib.mkEnableOption '' |
97 | 106 | dynamic Boost balances power between the CPU and the GPU for improved |
|
465 | 474 | assertion = cfg.dynamicBoost.enable -> lib.versionAtLeast nvidia_x11.version "510.39.01"; |
466 | 475 | message = "NVIDIA's Dynamic Boost feature only exists on versions >= 510.39.01"; |
467 | 476 | } |
| 477 | + |
| 478 | + { |
| 479 | + assertion = |
| 480 | + cfg.powerManagement.kernelSuspendNotifier |
| 481 | + -> (useOpenModules && lib.versionAtLeast nvidia_x11.version "595"); |
| 482 | + message = "NVIDIA driver support for kernel suspend notifiers requires NVIDIA driver version 595 or newer, and the open source kernel modules."; |
| 483 | + } |
468 | 484 | ]; |
469 | 485 |
|
470 | 486 | # If Optimus/PRIME is enabled, we: |
|
576 | 592 | '' |
577 | 593 | ); |
578 | 594 |
|
579 | | - systemd.packages = lib.optional cfg.powerManagement.enable nvidia_x11.out; |
| 595 | + systemd.packages = lib.optional ( |
| 596 | + cfg.powerManagement.enable && !cfg.powerManagement.kernelSuspendNotifier |
| 597 | + ) nvidia_x11.out; |
580 | 598 |
|
581 | 599 | systemd.services = |
582 | 600 | let |
|
592 | 610 | }; |
593 | 611 | in |
594 | 612 | lib.mkMerge [ |
595 | | - (lib.mkIf cfg.powerManagement.enable { |
| 613 | + (lib.mkIf (cfg.powerManagement.enable && !cfg.powerManagement.kernelSuspendNotifier) { |
596 | 614 | nvidia-suspend = nvidiaService "suspend"; |
597 | 615 | nvidia-hibernate = nvidiaService "hibernate"; |
598 | 616 | nvidia-resume = (nvidiaService "resume") // { |
|
669 | 687 | ++ lib.optional ( |
670 | 688 | (offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545" |
671 | 689 | ) "nvidia-drm.fbdev=1" |
| 690 | + ++ lib.optional ( |
| 691 | + cfg.powerManagement.enable && cfg.powerManagement.kernelSuspendNotifier |
| 692 | + ) "nvidia.NVreg_UseKernelSuspendNotifiers=1" |
672 | 693 | ++ lib.optional cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1" |
673 | 694 | ++ lib.optional useOpenModules "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1" |
674 | 695 | ++ lib.optional (config.boot.kernelPackages.kernel.kernelAtLeast "6.2" && !ibtSupport) "ibt=off"; |
|
0 commit comments