From bdd095860e6d2d536056e381708d51b48b32f29f Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 30 Aug 2024 21:57:11 -0700 Subject: [PATCH] power: Allow returned GPU clocks range to overridden by a platform config --- data/platforms/jupiter.toml | 4 ++++ src/hardware.rs | 1 + src/manager/user.rs | 1 + src/platform.rs | 1 + src/power.rs | 7 +++++++ 5 files changed, 14 insertions(+) diff --git a/data/platforms/jupiter.toml b/data/platforms/jupiter.toml index 3e277d4..f125607 100644 --- a/data/platforms/jupiter.toml +++ b/data/platforms/jupiter.toml @@ -23,3 +23,7 @@ systemd = "jupiter-fan-control.service" [tdp_limit] min = 3 max = 15 + +[gpu_clocks] +min = 200 +max = 1600 diff --git a/src/hardware.rs b/src/hardware.rs index a9df96c..ef7a0b0 100644 --- a/src/hardware.rs +++ b/src/hardware.rs @@ -370,6 +370,7 @@ pub mod test { "jupiter-fan-control.service", ))), tdp_limit: None, + gpu_clocks: None, })); let fan_control = FanControl::new(connection); diff --git a/src/manager/user.rs b/src/manager/user.rs index fec03dc..dfdc247 100644 --- a/src/manager/user.rs +++ b/src/manager/user.rs @@ -692,6 +692,7 @@ mod test { "jupiter-fan-control.service", ))), tdp_limit: Some(RangeConfig::new(3, 15)), + gpu_clocks: Some(RangeConfig::new(200, 1600)), }) } diff --git a/src/platform.rs b/src/platform.rs index 97d1fcc..87a63b2 100644 --- a/src/platform.rs +++ b/src/platform.rs @@ -27,6 +27,7 @@ pub(crate) struct PlatformConfig { pub storage: Option, pub fan_control: Option, pub tdp_limit: Option>, + pub gpu_clocks: Option>, } #[derive(Clone, Deserialize, Debug)] diff --git a/src/power.rs b/src/power.rs index 00da621..6723775 100644 --- a/src/power.rs +++ b/src/power.rs @@ -268,6 +268,13 @@ pub(crate) async fn set_cpu_scaling_governor(governor: CPUScalingGovernor) -> Re } pub(crate) async fn get_gpu_clocks_range() -> Result<(u32, u32)> { + if let Some(range) = platform_config() + .await? + .as_ref() + .and_then(|config| config.gpu_clocks) + { + return Ok((range.min, range.max)); + } let contents = read_gpu_sysfs_contents(GPU_CLOCK_LEVELS_SUFFIX).await?; let lines = contents.lines(); let mut min = 1_000_000;