-
Notifications
You must be signed in to change notification settings - Fork 44
/
perf-control.nix
40 lines (37 loc) · 1.35 KB
/
perf-control.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{ config, lib, pkgs, ... }:
let
inherit (lib)
mkIf
mkOption
types
;
cfg = config.jovian.devices.steamdeck;
in
{
options = {
jovian.devices.steamdeck = {
enablePerfControlUdevRules = mkOption {
type = types.bool;
default = cfg.enable;
defaultText = lib.literalExpression "config.jovian.devices.steamdeck.enable";
description = ''
Whether to make performance-related device attributes controllable by users.
The Steam Deck Client directly modifies several device attributes to
control the display brightness and to enable performance tuning (TDP
limit, GPU clock control).
'';
};
};
};
config = mkIf (cfg.enablePerfControlUdevRules) {
services.udev.extraRules = ''
# Enables manual GPU clock control in Steam
# - /sys/class/drm/card0/device/power_dpm_force_performance_level
# - /sys/class/drm/card0/device/pp_od_clk_voltage
ACTION=="add", SUBSYSTEM=="pci", DRIVER=="amdgpu", RUN+="${pkgs.coreutils}/bin/chmod a+w /sys/%p/power_dpm_force_performance_level /sys/%p/pp_od_clk_voltage"
# Enables manual TDP limiter in Steam
# - /sys/class/hwmon/hwmon*/power{1,2}_cap
ACTION=="add", SUBSYSTEM=="hwmon", ATTR{name}=="amdgpu", RUN+="${pkgs.coreutils}/bin/chmod a+w /sys/%p/power1_cap /sys/%p/power2_cap"
'';
};
}