|
93 | 93 | the NVIDIA docs, on Chapter 22. PCI-Express Runtime D3 (RTD3) Power Management |
94 | 94 | ''; |
95 | 95 |
|
| 96 | + powerManagement.kernelSuspendNotifier = |
| 97 | + lib.mkEnableOption '' |
| 98 | + NVIDIA driver support for kernel suspend notifiers, which allows the driver |
| 99 | + to be notified of suspend and resume events by the kernel, rather than |
| 100 | + relying on systemd services. |
| 101 | + Requires NVIDIA driver version 595 or newer, and the open source kernel modules. |
| 102 | + '' |
| 103 | + // { |
| 104 | + default = useOpenModules && lib.versionAtLeast nvidia_x11.version "595"; |
| 105 | + defaultText = lib.literalExpression '' |
| 106 | + config.hardware.nvidia.open == true && lib.versionAtLeast config.hardware.nvidia.package.version "595" |
| 107 | + ''; |
| 108 | + }; |
| 109 | + |
96 | 110 | dynamicBoost.enable = lib.mkEnableOption '' |
97 | 111 | dynamic Boost balances power between the CPU and the GPU for improved |
98 | 112 | performance on supported laptops using the nvidia-powerd daemon. For more |
|
465 | 479 | assertion = cfg.dynamicBoost.enable -> lib.versionAtLeast nvidia_x11.version "510.39.01"; |
466 | 480 | message = "NVIDIA's Dynamic Boost feature only exists on versions >= 510.39.01"; |
467 | 481 | } |
| 482 | + |
| 483 | + { |
| 484 | + assertion = |
| 485 | + cfg.powerManagement.kernelSuspendNotifier |
| 486 | + -> (useOpenModules && lib.versionAtLeast nvidia_x11.version "595"); |
| 487 | + message = "NVIDIA driver support for kernel suspend notifiers requires NVIDIA driver version 595 or newer, and the open source kernel modules."; |
| 488 | + } |
468 | 489 | ]; |
469 | 490 |
|
470 | 491 | # If Optimus/PRIME is enabled, we: |
|
576 | 597 | '' |
577 | 598 | ); |
578 | 599 |
|
579 | | - systemd.packages = lib.optional cfg.powerManagement.enable nvidia_x11.out; |
| 600 | + systemd.packages = lib.optional ( |
| 601 | + cfg.powerManagement.enable && !cfg.powerManagement.kernelSuspendNotifier |
| 602 | + ) nvidia_x11.out; |
580 | 603 |
|
581 | 604 | systemd.services = |
582 | 605 | let |
|
592 | 615 | }; |
593 | 616 | in |
594 | 617 | lib.mkMerge [ |
595 | | - (lib.mkIf cfg.powerManagement.enable { |
| 618 | + (lib.mkIf (cfg.powerManagement.enable && !cfg.powerManagement.kernelSuspendNotifier) { |
596 | 619 | nvidia-suspend = nvidiaService "suspend"; |
597 | 620 | nvidia-hibernate = nvidiaService "hibernate"; |
598 | 621 | nvidia-resume = (nvidiaService "resume") // { |
|
669 | 692 | ++ lib.optional ( |
670 | 693 | (offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545" |
671 | 694 | ) "nvidia-drm.fbdev=1" |
| 695 | + ++ lib.optional ( |
| 696 | + cfg.powerManagement.enable && cfg.powerManagement.kernelSuspendNotifier |
| 697 | + ) "nvidia.NVreg_UseKernelSuspendNotifiers=1" |
672 | 698 | ++ lib.optional cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1" |
673 | 699 | ++ lib.optional useOpenModules "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1" |
674 | 700 | ++ lib.optional (config.boot.kernelPackages.kernel.kernelAtLeast "6.2" && !ibtSupport) "ibt=off"; |
|
0 commit comments