nixos/amdgpu: add overdrive and ppfeaturemask option (#411155)

- `programs.corectrl.gpuOverclock.enable` -> `hardware.amdgpu.overdrive.enable`
- `programs.corectrl.gpuOverclock.ppfeaturemask` -> `hardware.amdgpu.overdrive.ppfeaturemask`
- `programs.tuxclocker.enableAMD` -> `hardware.amdgpu.overdrive.enable`
This commit is contained in:
Masum Reza 2025-05-27 19:45:13 +05:30 committed by GitHub
parent 84937b29d6
commit c9f192da92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 50 additions and 39 deletions

View file

@ -27,3 +27,6 @@
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
- `services.clamsmtp` is unmaintained and was removed from Nixpkgs.
- `amdgpu` kernel driver overdrive mode can now be enabled by setting [hardware.amdgpu.overdrive.enable](#opt-hardware.amdgpu.overdrive.enable) and customized through [hardware.amdgpu.overdrive.ppfeaturemask](#opt-hardware.amdgpu.overdrive.ppfeaturemask).
This allows for fine-grained control over the GPU's performance and maybe required by overclocking softwares like Corectrl and Lact. These new options replace old options such as {option}`programs.corectrl.gpuOverclock.enable` and {option}`programs.tuxclocker.enableAMD`.

View file

@ -8,13 +8,23 @@ let
inherit (lib)
mkEnableOption
mkIf
mkOption
mkPackageOption
;
cfg = config.programs.corectrl;
in
{
imports = [
(lib.mkRenamedOptionModule
[ "programs" "corectrl" "gpuOverclock" "enable" ]
[ "hardware" "amdgpu" "overdrive" "enable" ]
)
(lib.mkRenamedOptionModule
[ "programs" "corectrl" "gpuOverclock" "ppfeaturemask" ]
[ "hardware" "amdgpu" "overdrive" "ppfeaturemask" ]
)
];
options.programs.corectrl = {
enable = mkEnableOption ''
CoreCtrl, a tool to overclock amd graphics cards and processors.
@ -24,23 +34,6 @@ in
package = mkPackageOption pkgs "corectrl" {
extraDescription = "Useful for overriding the configuration options used for the package.";
};
gpuOverclock = {
enable = mkEnableOption ''
GPU overclocking
'';
ppfeaturemask = mkOption {
type = lib.types.str;
default = "0xfffd7fff";
example = "0xffffffff";
description = ''
Sets the `amdgpu.ppfeaturemask` kernel option.
In particular, it is used here to set the overdrive bit.
Default is `0xfffd7fff` as it is less likely to cause flicker issues.
Setting it to `0xffffffff` enables all features.
'';
};
};
};
config = mkIf cfg.enable {
@ -61,12 +54,6 @@ in
}
});
'';
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/amd/include/amd_shared.h#n169
# The overdrive bit
boot.kernelParams = mkIf cfg.gpuOverclock.enable [
"amdgpu.ppfeaturemask=${cfg.gpuOverclock.ppfeaturemask}"
];
};
meta.maintainers = with lib.maintainers; [

View file

@ -16,21 +16,44 @@ in
series cards. Note: this removes support for analog video outputs,
which is only available in the `radeon` driver
'';
initrd.enable = lib.mkEnableOption ''
loading `amdgpu` kernelModule in stage 1.
Can fix lower resolution in boot screen during initramfs phase
'';
overdrive = {
enable = lib.mkEnableOption ''`amdgpu` overdrive mode for overclocking'';
ppfeaturemask = lib.mkOption {
type = lib.types.str;
default = "0xfffd7fff";
example = "0xffffffff";
description = ''
Sets the `amdgpu.ppfeaturemask` kernel option. It can be used to enable the overdrive bit.
Default is `0xfffd7fff` as it is less likely to cause flicker issues. Setting it to
`0xffffffff` enables all features, but also can be unstable. See
[the kernel documentation](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/amd/include/amd_shared.h#n169)
for more information.
'';
};
};
opencl.enable = lib.mkEnableOption ''OpenCL support using ROCM runtime library'';
# cfg.amdvlk option is defined in ./amdvlk.nix module
};
config = {
boot.kernelParams = lib.optionals cfg.legacySupport.enable [
"amdgpu.si_support=1"
"amdgpu.cik_support=1"
"radeon.si_support=0"
"radeon.cik_support=0"
];
boot.kernelParams =
lib.optionals cfg.legacySupport.enable [
"amdgpu.si_support=1"
"amdgpu.cik_support=1"
"radeon.si_support=0"
"radeon.cik_support=0"
]
++ lib.optionals cfg.overdrive.enable [
"amdgpu.ppfeaturemask=${cfg.overdrive.ppfeaturemask}"
];
boot.initrd.kernelModules = lib.optionals cfg.initrd.enable [ "amdgpu" ];

View file

@ -8,16 +8,18 @@ let
cfg = config.programs.tuxclocker;
in
{
imports = [
(lib.mkRenamedOptionModule
[ "programs" "tuxclocker" "enableAMD" ]
[ "hardware" "amdgpu" "overdrive" "enable" ]
)
];
options.programs.tuxclocker = {
enable = lib.mkEnableOption ''
TuxClocker, a hardware control and monitoring program
'';
enableAMD = lib.mkEnableOption ''
AMD GPU controls.
Sets the `amdgpu.ppfeaturemask` kernel parameter to 0xfffd7fff to enable all TuxClocker controls
'';
enabledNVIDIADevices = lib.mkOption {
type = lib.types.listOf lib.types.int;
default = [ ];
@ -72,9 +74,5 @@ in
);
in
lib.concatStrings (map configSection cfg.enabledNVIDIADevices);
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/amd/include/amd_shared.h#n207
# Enable everything modifiable in TuxClocker
boot.kernelParams = lib.mkIf cfg.enableAMD [ "amdgpu.ppfeaturemask=0xfffd7fff" ];
};
}