1
Fork 0
mirror of https://github.com/RGBCube/superfreq synced 2025-07-27 17:07:44 +00:00

cpu: simplify turbo management

This commit is contained in:
NotAShelf 2025-05-17 17:42:10 +03:00
parent 806cf64d29
commit cbaab9f160
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF
2 changed files with 14 additions and 11 deletions

View file

@ -213,23 +213,24 @@ fn get_available_governors() -> Result<Vec<String>> {
))
}
// FIXME: I think the Auto Turbo behaviour is still pretty confusing for the end-user
// who might not have read the documentation in detail. We could just make the program
// more verbose here, but I think this is a fundamental design flaw that I will want
// to refactor in the future. For now though, I think this is a good-ish solution.
pub fn set_turbo(setting: TurboSetting) -> Result<()> {
let value_pstate = match setting {
TurboSetting::Always => "0", // no_turbo = 0 means turbo is enabled
TurboSetting::Never => "1", // no_turbo = 1 means turbo is disabled
// Auto mode is handled at the engine level, not directly at the sysfs level
TurboSetting::Auto => {
debug!("Turbo Auto mode is managed by engine logic based on system conditions");
return Ok(());
}
// For Auto, we need to enable the hardware default (which is turbo enabled)
// and we reset to the system default when explicitly set to Auto
TurboSetting::Auto => "0", // Set to enabled (default hardware state) when Auto is requested
};
let value_boost = match setting {
TurboSetting::Always => "1", // boost = 1 means turbo is enabled
TurboSetting::Never => "0", // boost = 0 means turbo is disabled
TurboSetting::Auto => {
debug!("Turbo Auto mode is managed by engine logic based on system conditions");
return Ok(());
}
// For Auto, we need to enable the hardware default (which is turbo enabled)
// and we reset to the system default when explicitly set to Auto
TurboSetting::Auto => "1", // Set to enabled (default hardware state) when Auto is requested
};
// AMD specific paths

View file

@ -118,10 +118,12 @@ pub fn determine_and_apply_settings(
manage_auto_turbo(report, selected_profile_config)?;
} else {
debug!(
"Auto turbo management disabled by configuration, using system default behavior"
"Superfreq's dynamic turbo management is disabled by configuration. Ensuring system uses its default behavior for automatic turbo control."
);
// Make sure the system is set to its default automatic turbo mode.
// This is important if turbo was previously forced off.
try_apply_feature("Turbo boost", "system default (Auto)", || {
cpu::set_turbo(turbo_setting)
cpu::set_turbo(TurboSetting::Auto)
})?;
}
}