feat: use gpu-provided allowed range for voltage offset when it is available

This commit is contained in:
Ilya Zlobintsev 2024-01-13 12:10:22 +02:00
parent 4797ea54f7
commit 57d419c92f
4 changed files with 16 additions and 7 deletions

4
Cargo.lock generated
View File

@ -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",

View File

@ -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 {

View File

@ -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);

View File

@ -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 }