From 2ef417b6b14be7ceffd26ad10f2e0f9634e1f28f Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 13 Nov 2024 12:09:17 +0000 Subject: [PATCH] Update NVIDIA configuration and add cpupower package - Enable nvidiaPersistenced and add udev rules for NVIDIA devices in citadel/default.nix - Add boot.extraModprobeConfig for NVreg_DynamicPowerManagement and NVreg_EnableGpuFirmware - Include the cpupower package in common/core/default.nix --- hosts/citadel/default.nix | 28 +++++++++++++++++++++++++++- hosts/common/core/default.nix | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/hosts/citadel/default.nix b/hosts/citadel/default.nix index 60d850d..5c6a896 100644 --- a/hosts/citadel/default.nix +++ b/hosts/citadel/default.nix @@ -135,7 +135,7 @@ in { enable = true; }; - services.xserver.videoDrivers = ["nvidia"]; + services.xserver.videoDrivers = [ "nvidia" ]; hardware.nvidia = { prime = { @@ -146,6 +146,7 @@ in { intelBusId = "PCI:0:2:0"; nvidiaBusId = "PCI:1:0:0"; }; + nvidiaPersistenced = true; modesetting.enable = true; powerManagement.enable = false; powerManagement.finegrained = false; @@ -164,6 +165,31 @@ in { persistencedSha256 = "sha256-a1D7ZZmcKFWfPjjH1REqPM5j/YLWKnbkP9qfRyIyxAw="; }; }; + # https://bbs.archlinux.org/viewtopic.php?id=297276 for NVreg_EnableGpuFirmware fix + # https://discourse.nixos.org/t/how-to-use-nvidia-prime-offload-to-run-the-x-server-on-the-integrated-board/9091/15 + # for udev rules to disable dGPU when not in use + boot.extraModprobeConfig = '' + options nvidia NVreg_DynamicPowerManagement=0x02 + options nvidia NVreg_EnableGpuFirmware=0 + ''; + services.udev.extraRules = '' + # Remove NVIDIA USB xHCI Host Controller devices, if present + ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1" + + # Remove NVIDIA USB Type-C UCSI devices, if present + ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1" + + # Remove NVIDIA Audio devices, if present + ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1" + + # Enable runtime PM for NVIDIA VGA/3D controller devices on driver bind + ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="auto" + ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="auto" + + # Disable runtime PM for NVIDIA VGA/3D controller devices on driver unbind + ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="on" + ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="on" + ''; networking = { hostName = "citadel"; diff --git a/hosts/common/core/default.nix b/hosts/common/core/default.nix index 0074988..036c0d6 100644 --- a/hosts/common/core/default.nix +++ b/hosts/common/core/default.nix @@ -49,6 +49,7 @@ in pkgs.just pkgs.git pkgs.vim + pkgs.linuxKernel.packages.linux_zen.cpupower ]; system.stateVersion = "24.05";