From c2ece764dabb299a73c29555b46d24db7174da6c Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Sat, 27 May 2023 17:47:39 +0200 Subject: [PATCH] [Hardware/AMD] Automatically use amd_pstate=active|guided on kernels supporting it --- hardware/amd/cpu.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hardware/amd/cpu.nix b/hardware/amd/cpu.nix index 8c858a8..29d9a2a 100644 --- a/hardware/amd/cpu.nix +++ b/hardware/amd/cpu.nix @@ -3,6 +3,7 @@ with lib; let generalCfg = config.aviallon.general; cpuIsZen = ! isNull (builtins.match "znver[0-9]" generalCfg.cpu.arch); + kernelVersion = getVersion config.boot.kernelPackages.kernel; in { config = mkIf (generalCfg.cpu.vendor == "amd") { boot.kernel.sysctl = { @@ -13,7 +14,14 @@ in { }; aviallon.boot.cmdline = { - "amd_pstate" = "passive"; + "amd_pstate" = + if versionAtLeast kernelVersion "6.4" then + "guided" + else if versionAtLeast kernelVersion "6.3" then + "active" + else + "passive" + ; } // optionalAttrs (generalCfg.cpu.arch == "znver2") { # Required for Zen 2 "amd_pstate.shared_memory" = 1;