Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions nixos/modules/hardware/video/nvidia.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ in
the NVIDIA docs, on Chapter 22. PCI-Express Runtime D3 (RTD3) Power Management
'';

powerManagement.kernelSuspendNotifier =
lib.mkEnableOption ''
NVIDIA driver support for kernel suspend notifiers, which allows the driver
to be notified of suspend and resume events by the kernel, rather than
relying on systemd services.
Requires NVIDIA driver version 595 or newer, and the open source kernel modules.
''
// {
default = useOpenModules && lib.versionAtLeast nvidia_x11.version "595";
defaultText = lib.literalExpression ''
config.hardware.nvidia.open == true && lib.versionAtLeast config.hardware.nvidia.package.version "595"
'';
};

dynamicBoost.enable = lib.mkEnableOption ''
dynamic Boost balances power between the CPU and the GPU for improved
performance on supported laptops using the nvidia-powerd daemon. For more
Expand Down Expand Up @@ -465,6 +479,13 @@ in
assertion = cfg.dynamicBoost.enable -> lib.versionAtLeast nvidia_x11.version "510.39.01";
message = "NVIDIA's Dynamic Boost feature only exists on versions >= 510.39.01";
}

{
assertion =
cfg.powerManagement.kernelSuspendNotifier
-> (useOpenModules && lib.versionAtLeast nvidia_x11.version "595");
message = "NVIDIA driver support for kernel suspend notifiers requires NVIDIA driver version 595 or newer, and the open source kernel modules.";
}
];

# If Optimus/PRIME is enabled, we:
Expand Down Expand Up @@ -576,7 +597,9 @@ in
''
);

systemd.packages = lib.optional cfg.powerManagement.enable nvidia_x11.out;
systemd.packages = lib.optional (
cfg.powerManagement.enable && !cfg.powerManagement.kernelSuspendNotifier
) nvidia_x11.out;

systemd.services =
let
Expand All @@ -592,7 +615,7 @@ in
};
in
lib.mkMerge [
(lib.mkIf cfg.powerManagement.enable {
(lib.mkIf (cfg.powerManagement.enable && !cfg.powerManagement.kernelSuspendNotifier) {
nvidia-suspend = nvidiaService "suspend";
nvidia-hibernate = nvidiaService "hibernate";
nvidia-resume = (nvidiaService "resume") // {
Expand Down Expand Up @@ -669,6 +692,9 @@ in
++ lib.optional (
(offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545"
) "nvidia-drm.fbdev=1"
++ lib.optional (
cfg.powerManagement.enable && cfg.powerManagement.kernelSuspendNotifier
) "nvidia.NVreg_UseKernelSuspendNotifiers=1"
++ lib.optional cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
++ lib.optional useOpenModules "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1"
++ lib.optional (config.boot.kernelPackages.kernel.kernelAtLeast "6.2" && !ibtSupport) "ibt=off";
Expand Down
Loading