Reset PPT to max when limits disabled

This commit is contained in:
NGnius (Graham) 2023-04-01 20:11:02 -04:00
parent 47d457dd2a
commit 0d68ae996c
2 changed files with 36 additions and 0 deletions

View file

@ -199,6 +199,22 @@ impl Gpu {
let mut errors = Vec::new();
// set fast PPT
if let Some(fast_ppt) = &self.fast_ppt {
self.state.fast_ppt_set = true;
let fast_ppt_path = gpu_power_path(FAST_PPT);
usdpl_back::api::files::write_single(&fast_ppt_path, fast_ppt)
.map_err(|e| SettingError {
msg: format!(
"Failed to write `{}` to `{}`: {}",
fast_ppt, &fast_ppt_path, e
),
setting: crate::settings::SettingVariant::Gpu,
})
.unwrap_or_else(|e| {
errors.push(e);
});
} else if self.state.fast_ppt_set {
self.state.fast_ppt_set = false;
let fast_ppt = self.limits.fast_ppt.max;
let fast_ppt_path = gpu_power_path(FAST_PPT);
usdpl_back::api::files::write_single(&fast_ppt_path, fast_ppt)
.map_err(|e| SettingError {
@ -214,6 +230,22 @@ impl Gpu {
}
// set slow PPT
if let Some(slow_ppt) = &self.slow_ppt {
self.state.slow_ppt_set = true;
let slow_ppt_path = gpu_power_path(SLOW_PPT);
usdpl_back::api::files::write_single(&slow_ppt_path, slow_ppt)
.map_err(|e| SettingError {
msg: format!(
"Failed to write `{}` to `{}`: {}",
slow_ppt, &slow_ppt_path, e
),
setting: crate::settings::SettingVariant::Gpu,
})
.unwrap_or_else(|e| {
errors.push(e);
});
} else if self.state.slow_ppt_set {
self.state.slow_ppt_set = false;
let slow_ppt = self.limits.slow_ppt.max;
let slow_ppt_path = gpu_power_path(SLOW_PPT);
usdpl_back::api::files::write_single(&slow_ppt_path, slow_ppt)
.map_err(|e| SettingError {

View file

@ -1,6 +1,8 @@
#[derive(Debug, Clone)]
pub struct Gpu {
pub clock_limits_set: bool,
pub fast_ppt_set: bool,
pub slow_ppt_set: bool,
pub is_resuming: bool,
}
@ -8,6 +10,8 @@ impl std::default::Default for Gpu {
fn default() -> Self {
Self {
clock_limits_set: true,
fast_ppt_set: false,
slow_ppt_set: false,
is_resuming: false,
}
}