From 9408ef97db4005ac3b093b98d4e26ffa653bb3e8 Mon Sep 17 00:00:00 2001 From: r-vdp Date: Mon, 17 Aug 2026 10:48:17 +0200 Subject: [PATCH] common/gpu/amd: add hardware.amdgpu.dcDebugMask options This allows to combine several such options to get the right hex value without any repeated kernel params. Before this, the framework AI 300 got both 0x10 and 0x410 on the cmdline with the order depending on the module system eval order. This also allows users to re-enable PSR on framework machines. --- common/gpu/amd/dc-debug-mask.nix | 36 +++++++++++++++++++ common/gpu/amd/default.nix | 2 ++ framework/13-inch/common/amd.nix | 24 ++++++------- .../16-inch/amd-ai-300-series/default.nix | 3 +- framework/16-inch/common/amd.nix | 24 ++++++------- 5 files changed, 64 insertions(+), 25 deletions(-) create mode 100644 common/gpu/amd/dc-debug-mask.nix diff --git a/common/gpu/amd/dc-debug-mask.nix b/common/gpu/amd/dc-debug-mask.nix new file mode 100644 index 00000000..5c73dfc7 --- /dev/null +++ b/common/gpu/amd/dc-debug-mask.nix @@ -0,0 +1,36 @@ +# Flag values from drivers/gpu/drm/amd/include/amd_shared.h +{ config, lib, ... }: +let + flags = { + disablePipeSplit = 1; + disableStutter = 2; + disableDsc = 4; + disableClockGating = 8; + disablePsr = 16; + disableMpo = 64; + disablePsrSu = 512; + disableReplay = 1024; + disableIps = 2048; + }; + + cfg = config.hardware.amdgpu.dcDebugMask; + + mask = lib.foldlAttrs ( + acc: name: bit: + if cfg.${name} then lib.bitOr acc bit else acc + ) 0 flags; +in +{ + options.hardware.amdgpu.dcDebugMask = lib.mapAttrs ( + _name: bit: + lib.mkOption { + type = lib.types.bool; + default = false; + description = "Set flag 0x${lib.toHexString bit} in amdgpu.dcdebugmask."; + } + ) flags; + + config = lib.mkIf (mask != 0) { + boot.kernelParams = [ "amdgpu.dcdebugmask=0x${lib.toHexString mask}" ]; + }; +} diff --git a/common/gpu/amd/default.nix b/common/gpu/amd/default.nix index f6903d9e..5bb4546e 100644 --- a/common/gpu/amd/default.nix +++ b/common/gpu/amd/default.nix @@ -1,6 +1,8 @@ { lib, ... }: { + imports = [ ./dc-debug-mask.nix ]; + config = { services.xserver.videoDrivers = lib.mkDefault [ "modesetting" ]; diff --git a/framework/13-inch/common/amd.nix b/framework/13-inch/common/amd.nix index 4a89f8da..fc34d3dc 100644 --- a/framework/13-inch/common/amd.nix +++ b/framework/13-inch/common/amd.nix @@ -6,18 +6,18 @@ ../../../common/gpu/amd ]; - boot.kernelParams = [ - # There seems to be an issue with panel self-refresh (PSR) that - # causes hangs for users. - # - # https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459 - # https://gitlab.freedesktop.org/drm/amd/-/issues/3647 - "amdgpu.dcdebugmask=0x10" - ] - # Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/ - ++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [ - "rtc_cmos.use_acpi_alarm=1" - ]; + # There seems to be an issue with panel self-refresh (PSR) that + # causes hangs for users. + # + # https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459 + # https://gitlab.freedesktop.org/drm/amd/-/issues/3647 + hardware.amdgpu.dcDebugMask.disablePsr = lib.mkDefault true; + + boot.kernelParams = + # Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/ + lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [ + "rtc_cmos.use_acpi_alarm=1" + ]; # AMD has better battery life with PPD over TLP: # https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13 diff --git a/framework/16-inch/amd-ai-300-series/default.nix b/framework/16-inch/amd-ai-300-series/default.nix index 1e42fff1..c4d4e911 100644 --- a/framework/16-inch/amd-ai-300-series/default.nix +++ b/framework/16-inch/amd-ai-300-series/default.nix @@ -21,8 +21,9 @@ # The following mitigations fix various graphics issues # See https://gist.github.com/lbrame/f9034b1a9fe4fc2d2835c5542acb170a#user-content-quick-version-apply-the-mitigations-i-am-personally-using + hardware.amdgpu.dcDebugMask.disableReplay = lib.mkDefault true; + boot.kernelParams = [ - "amdgpu.dcdebugmask=0x410" "amdgpu.sg_display=0" "amdgpu.abmlevel=0" ]; diff --git a/framework/16-inch/common/amd.nix b/framework/16-inch/common/amd.nix index 4a89f8da..fc34d3dc 100644 --- a/framework/16-inch/common/amd.nix +++ b/framework/16-inch/common/amd.nix @@ -6,18 +6,18 @@ ../../../common/gpu/amd ]; - boot.kernelParams = [ - # There seems to be an issue with panel self-refresh (PSR) that - # causes hangs for users. - # - # https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459 - # https://gitlab.freedesktop.org/drm/amd/-/issues/3647 - "amdgpu.dcdebugmask=0x10" - ] - # Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/ - ++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [ - "rtc_cmos.use_acpi_alarm=1" - ]; + # There seems to be an issue with panel self-refresh (PSR) that + # causes hangs for users. + # + # https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459 + # https://gitlab.freedesktop.org/drm/amd/-/issues/3647 + hardware.amdgpu.dcDebugMask.disablePsr = lib.mkDefault true; + + boot.kernelParams = + # Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/ + lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [ + "rtc_cmos.use_acpi_alarm=1" + ]; # AMD has better battery life with PPD over TLP: # https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13