fix: set performance level after the clocks table, reset it to auto before applying a custom value (#298)

* fix: set performance level after setting custom clocks

* test
This commit is contained in:
Ilya Zlobintsev 2024-03-30 22:25:39 +02:00 committed by GitHub
parent 219d832b91
commit d9553a91a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -693,16 +693,6 @@ impl GpuController {
} }
} }
if let Some(level) = config.performance_level {
self.handle
.set_power_force_performance_level(level)
.context("Failed to set power performance level")?;
} else if self.handle.get_power_force_performance_level().is_ok() {
self.handle
.set_power_force_performance_level(PerformanceLevel::Auto)
.context("Failed to set performance level to PerformanceLevel::Auto")?;
}
if let Some(mode_index) = config.power_profile_mode_index { if let Some(mode_index) = config.power_profile_mode_index {
if config.performance_level != Some(PerformanceLevel::Manual) { if config.performance_level != Some(PerformanceLevel::Manual) {
return Err(anyhow!( return Err(anyhow!(
@ -718,6 +708,11 @@ impl GpuController {
// Reset the clocks table in case the settings get reverted back to not having a clocks value configured // Reset the clocks table in case the settings get reverted back to not having a clocks value configured
self.handle.reset_clocks_table().ok(); self.handle.reset_clocks_table().ok();
// Reset performance level to work around some GPU quirks (found to be an issue on RDNA2)
self.handle
.set_power_force_performance_level(PerformanceLevel::Auto)
.ok();
if config.is_core_clocks_used() { if config.is_core_clocks_used() {
let mut table = self let mut table = self
.handle .handle
@ -741,6 +736,13 @@ impl GpuController {
.with_context(|| format!("Clocks table commands: {:?}", table.get_commands()))?; .with_context(|| format!("Clocks table commands: {:?}", table.get_commands()))?;
} }
if let Some(level) = config.performance_level {
self.handle
.set_power_force_performance_level(level)
.context("Failed to set power performance level")?;
}
// Else is not needed, it was previously reset to auto already
for (kind, states) in &config.power_states { for (kind, states) in &config.power_states {
if config.performance_level != Some(PerformanceLevel::Manual) { if config.performance_level != Some(PerformanceLevel::Manual) {
return Err(anyhow!( return Err(anyhow!(