From 5f6370e7780aa96c71c2769a4641db23b8451e53 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Thu, 24 Aug 2023 20:02:31 -0400 Subject: [PATCH] Make CPU reset workaround skip resume from sleep --- backend/Cargo.lock | 2 +- backend/Cargo.toml | 2 +- backend/src/settings/steam_deck/cpu.rs | 38 ++++++++++++++------------ package.json | 2 +- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index c108f06..b36860c 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1052,7 +1052,7 @@ dependencies = [ [[package]] name = "powertools" -version = "1.4.0-beta2" +version = "1.4.0-beta3" dependencies = [ "async-trait", "libryzenadj", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 9a9b81a..c12933c 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "powertools" -version = "1.4.0-beta2" +version = "1.4.0-beta3" edition = "2021" authors = ["NGnius (Graham) "] description = "Backend (superuser) functionality for PowerTools" diff --git a/backend/src/settings/steam_deck/cpu.rs b/backend/src/settings/steam_deck/cpu.rs index 9a85f26..a6e4d10 100644 --- a/backend/src/settings/steam_deck/cpu.rs +++ b/backend/src/settings/steam_deck/cpu.rs @@ -375,25 +375,29 @@ impl Cpu { // https://github.com/NGnius/PowerTools/issues/107 fn clock_unset_workaround(&self) -> Result<(), Vec> { - let mut errors = Vec::new(); - POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.set_cpu(true, self.index); - // always set clock speeds, since it doesn't reset correctly (kernel/hardware bug) - POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.enforce_level(&self.sysfs)?; - // disable manual clock limits - log::debug!("Setting CPU {} to default clockspeed", self.index); - // max clock - self.set_clock_limit(self.index, self.limits.clock_max.max, ClockType::Max) - .unwrap_or_else(|e| errors.push(e)); - // min clock - self.set_clock_limit(self.index, self.limits.clock_min.min, ClockType::Min) - .unwrap_or_else(|e| errors.push(e)); + if !self.state.is_resuming { + let mut errors = Vec::new(); + POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.set_cpu(true, self.index); + // always set clock speeds, since it doesn't reset correctly (kernel/hardware bug) + POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.enforce_level(&self.sysfs)?; + // disable manual clock limits + log::debug!("Setting CPU {} to default clockspeed", self.index); + // max clock + self.set_clock_limit(self.index, self.limits.clock_max.max, ClockType::Max) + .unwrap_or_else(|e| errors.push(e)); + // min clock + self.set_clock_limit(self.index, self.limits.clock_min.min, ClockType::Min) + .unwrap_or_else(|e| errors.push(e)); - self.set_confirm().unwrap_or_else(|e| errors.push(e)); - POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.set_cpu(false, self.index); - if errors.is_empty() { - Ok(()) + self.set_confirm().unwrap_or_else(|e| errors.push(e)); + POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.set_cpu(false, self.index); + if errors.is_empty() { + Ok(()) + } else { + Err(errors) + } } else { - Err(errors) + Ok(()) } } diff --git a/package.json b/package.json index 18b50b0..02e97a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "PowerTools", - "version": "1.4.0-beta2", + "version": "1.4.0-beta3", "description": "Power tweaks for power users", "scripts": { "build": "shx rm -rf dist && rollup -c",