Make CPU reset workaround skip resume from sleep

This commit is contained in:
NGnius (Graham) 2023-08-24 20:02:31 -04:00
parent b1d53ab038
commit 5f6370e778
4 changed files with 24 additions and 20 deletions

2
backend/Cargo.lock generated
View file

@ -1052,7 +1052,7 @@ dependencies = [
[[package]]
name = "powertools"
version = "1.4.0-beta2"
version = "1.4.0-beta3"
dependencies = [
"async-trait",
"libryzenadj",

View file

@ -1,6 +1,6 @@
[package]
name = "powertools"
version = "1.4.0-beta2"
version = "1.4.0-beta3"
edition = "2021"
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
description = "Backend (superuser) functionality for PowerTools"

View file

@ -375,25 +375,29 @@ impl Cpu {
// https://github.com/NGnius/PowerTools/issues/107
fn clock_unset_workaround(&self) -> Result<(), Vec<SettingError>> {
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(())
}
}

View file

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