From 57d419c92f24f01852edfaccd555d993f0925c3e Mon Sep 17 00:00:00 2001 From: Ilya Zlobintsev Date: Sat, 13 Jan 2024 12:10:22 +0200 Subject: [PATCH] feat: use gpu-provided allowed range for voltage offset when it is available --- Cargo.lock | 4 ++-- lact-daemon/src/server/gpu_controller/mod.rs | 5 ++++- lact-gui/src/app/root_stack/oc_page/clocks_frame.rs | 12 +++++++++--- lact-schema/Cargo.toml | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c257b39..e4a4c46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,9 +41,9 @@ dependencies = [ [[package]] name = "amdgpu-sysfs" -version = "0.12.10" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aeb473ff5972754ae1f0eed1971bbc0c88904a0282c795d79dec3862e56ae0" +checksum = "04b3c8f53aaed3c9a8f9b71c7d261a4343703ed3a5758eda16646e9b57c4e263" dependencies = [ "enum_dispatch", "serde", diff --git a/lact-daemon/src/server/gpu_controller/mod.rs b/lact-daemon/src/server/gpu_controller/mod.rs index 41b18b2..31c243b 100644 --- a/lact-daemon/src/server/gpu_controller/mod.rs +++ b/lact-daemon/src/server/gpu_controller/mod.rs @@ -683,7 +683,10 @@ impl ClocksConfiguration { // Normalize the VDDC curve - make sure all of the values are within the allowed range table.normalize_vddc_curve(); - table.voltage_offset = self.voltage_offset; + match self.voltage_offset { + Some(offset) => table.set_voltage_offset(offset)?, + None => table.voltage_offset = None, + } } if let Some(min_clockspeed) = self.min_core_clock { diff --git a/lact-gui/src/app/root_stack/oc_page/clocks_frame.rs b/lact-gui/src/app/root_stack/oc_page/clocks_frame.rs index 8297f59..30b2c8f 100644 --- a/lact-gui/src/app/root_stack/oc_page/clocks_frame.rs +++ b/lact-gui/src/app/root_stack/oc_page/clocks_frame.rs @@ -8,7 +8,7 @@ use std::rc::Rc; use std::sync::atomic::{AtomicBool, Ordering}; use tracing::debug; -const VOLTAGE_OFFSET_RANGE: f64 = 250.0; +const DEFAULT_VOLTAGE_OFFSET_RANGE: i32 = 250; const WARNING_TEXT: &str = "Warning: changing these values may lead to system instability and potentially damage your hardware!"; // The AtomicBool stores if the value was changed @@ -233,12 +233,18 @@ impl ClocksFrame { if let ClocksTableGen::Vega20(table) = table { if let Some(offset) = table.voltage_offset { + let (min_offset, max_offset) = table + .od_range + .voltage_offset + .and_then(|range| range.into_full()) + .unwrap_or((-DEFAULT_VOLTAGE_OFFSET_RANGE, DEFAULT_VOLTAGE_OFFSET_RANGE)); + self.voltage_offset_adjustment .0 - .set_lower(VOLTAGE_OFFSET_RANGE * -1.0); + .set_lower(min_offset as f64); self.voltage_offset_adjustment .0 - .set_upper(VOLTAGE_OFFSET_RANGE); + .set_upper(max_offset as f64); self.voltage_offset_adjustment.0.set_value(offset.into()); } else { self.voltage_offset_adjustment.0.set_upper(0.0); diff --git a/lact-schema/Cargo.toml b/lact-schema/Cargo.toml index c9672c5..0b424c9 100644 --- a/lact-schema/Cargo.toml +++ b/lact-schema/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" args = ["clap"] [dependencies] -amdgpu-sysfs = { version = "0.12.10", features = ["serde"] } +amdgpu-sysfs = { version = "0.13.0", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } indexmap = { version = "*", features = ["serde"] } clap = { version = "4.4.11", features = ["derive"], optional = true }