Only set Steam Deck memory speed in dpm force perf manual mode

This commit is contained in:
NGnius (Graham) 2024-02-17 09:44:42 -05:00
parent 808ce76eee
commit af8e8f5258
3 changed files with 57 additions and 21 deletions

View file

@ -104,12 +104,22 @@ impl TGpu for Gpu {
min: lim.min.unwrap_or(11_000_000) / ppt_divisor, min: lim.min.unwrap_or(11_000_000) / ppt_divisor,
max: lim.max.unwrap_or(42_000_000) / ppt_divisor, max: lim.max.unwrap_or(42_000_000) / ppt_divisor,
}), }),
fast_ppt_default: self.limits.fast_ppt_default.or_else(|| self.limits.fast_ppt.and_then(|x| x.max)).unwrap_or(2_000_000) / ppt_divisor, fast_ppt_default: self
.limits
.fast_ppt_default
.or_else(|| self.limits.fast_ppt.and_then(|x| x.max))
.unwrap_or(2_000_000)
/ ppt_divisor,
slow_ppt_limits: self.limits.slow_ppt.map(|lim| crate::api::RangeLimit { slow_ppt_limits: self.limits.slow_ppt.map(|lim| crate::api::RangeLimit {
min: lim.min.unwrap_or(7_000_000) / ppt_divisor, min: lim.min.unwrap_or(7_000_000) / ppt_divisor,
max: lim.max.unwrap_or(69_000_000) / ppt_divisor, max: lim.max.unwrap_or(69_000_000) / ppt_divisor,
}), }),
slow_ppt_default: self.limits.slow_ppt_default.or_else(|| self.limits.slow_ppt.and_then(|x| x.max)).unwrap_or(3_000_000) / ppt_divisor, slow_ppt_default: self
.limits
.slow_ppt_default
.or_else(|| self.limits.slow_ppt.and_then(|x| x.max))
.unwrap_or(3_000_000)
/ ppt_divisor,
ppt_step: self.limits.ppt_step.unwrap_or(1), ppt_step: self.limits.ppt_step.unwrap_or(1),
tdp_limits: self.limits.tdp.map(|lim| crate::api::RangeLimit { tdp_limits: self.limits.tdp.map(|lim| crate::api::RangeLimit {
min: lim.min.unwrap_or(11_000_000) / tdp_divisor, min: lim.min.unwrap_or(11_000_000) / tdp_divisor,
@ -135,7 +145,10 @@ impl TGpu for Gpu {
}), }),
memory_step: self.limits.memory_clock_step.unwrap_or(400), memory_step: self.limits.memory_clock_step.unwrap_or(400),
}; };
log::debug!("dev_mode_Gpu::limits(self) -> {}", serde_json::to_string_pretty(&limit_struct).unwrap()); log::debug!(
"dev_mode_Gpu::limits(self) -> {}",
serde_json::to_string_pretty(&limit_struct).unwrap()
);
limit_struct limit_struct
} }

View file

@ -168,7 +168,11 @@ impl TGpu for Gpu {
} }
}), }),
fast_ppt_default: { fast_ppt_default: {
let def = self.limits.fast_ppt_default.or_else(|| self.limits.fast_ppt.and_then(|x| x.max)).unwrap_or(15); let def = self
.limits
.fast_ppt_default
.or_else(|| self.limits.fast_ppt.and_then(|x| x.max))
.unwrap_or(15);
if let Some(ppt_divisor) = self.limits.ppt_divisor { if let Some(ppt_divisor) = self.limits.ppt_divisor {
def / ppt_divisor def / ppt_divisor
} else { } else {
@ -190,7 +194,11 @@ impl TGpu for Gpu {
} }
}), }),
slow_ppt_default: { slow_ppt_default: {
let def = self.limits.slow_ppt_default.or_else(|| self.limits.slow_ppt.and_then(|x| x.max)).unwrap_or(15); let def = self
.limits
.slow_ppt_default
.or_else(|| self.limits.slow_ppt.and_then(|x| x.max))
.unwrap_or(15);
if let Some(ppt_divisor) = self.limits.ppt_divisor { if let Some(ppt_divisor) = self.limits.ppt_divisor {
def / ppt_divisor def / ppt_divisor
} else { } else {

View file

@ -340,19 +340,23 @@ impl Gpu {
} }
fn set_memory_speed(&self, clock: u64) -> Result<(), SettingError> { fn set_memory_speed(&self, clock: u64) -> Result<(), SettingError> {
let path = GPU_MEMORY_DOWNCLOCK_ATTRIBUTE.path(&self.sysfs_card); if POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.needs_manual() {
let payload = self.build_memory_clock_payload(clock); let path = GPU_MEMORY_DOWNCLOCK_ATTRIBUTE.path(&self.sysfs_card);
log::debug!( let payload = self.build_memory_clock_payload(clock);
"Generated payload for gpu fclk (memory): `{}` (is maxed? {})", log::debug!(
payload, "Generated payload for gpu fclk (memory): `{}` (is maxed? {})",
self.is_memory_clock_maxed() payload,
); self.is_memory_clock_maxed()
self.sysfs_card );
.set(GPU_MEMORY_DOWNCLOCK_ATTRIBUTE.to_owned(), payload) self.sysfs_card
.map_err(|e| SettingError { .set(GPU_MEMORY_DOWNCLOCK_ATTRIBUTE.to_owned(), payload)
msg: format!("Failed to write to `{}`: {}", path.display(), e), .map_err(|e| SettingError {
setting: crate::settings::SettingVariant::Gpu, msg: format!("Failed to write to `{}`: {}", path.display(), e),
}) setting: crate::settings::SettingVariant::Gpu,
})
} else {
Ok(())
}
} }
fn set_force_performance_related(&mut self) -> Result<(), Vec<SettingError>> { fn set_force_performance_related(&mut self) -> Result<(), Vec<SettingError>> {
@ -362,7 +366,7 @@ impl Gpu {
POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT
.enforce_level(&self.sysfs_card) .enforce_level(&self.sysfs_card)
.unwrap_or_else(|mut e| errors.append(&mut e)); .unwrap_or_else(|mut e| errors.append(&mut e));
// enable/disable downclock of GPU memory (to 400Mhz?) // enable/disable downclock of GPU memory
self.set_memory_speed( self.set_memory_speed(
self.memory_clock self.memory_clock
.or_else(|| { .or_else(|| {
@ -631,6 +635,7 @@ impl crate::settings::OnLoad for Gpu {
impl crate::settings::OnUnload for Gpu { impl crate::settings::OnUnload for Gpu {
fn on_unload(&mut self) -> Result<(), Vec<SettingError>> { fn on_unload(&mut self) -> Result<(), Vec<SettingError>> {
POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.set_gpu(false);
Ok(()) Ok(())
} }
} }
@ -646,14 +651,24 @@ impl TGpu for Gpu {
max: super::util::range_max_or_fallback(&self.limits.fast_ppt, MAX_FAST_PPT) max: super::util::range_max_or_fallback(&self.limits.fast_ppt, MAX_FAST_PPT)
/ ppt_divisor, / ppt_divisor,
}), }),
fast_ppt_default: self.limits.fast_ppt_default.or_else(|| self.limits.fast_ppt.and_then(|x| x.max)).unwrap_or(MAX_FAST_PPT) / ppt_divisor, fast_ppt_default: self
.limits
.fast_ppt_default
.or_else(|| self.limits.fast_ppt.and_then(|x| x.max))
.unwrap_or(MAX_FAST_PPT)
/ ppt_divisor,
slow_ppt_limits: Some(RangeLimit { slow_ppt_limits: Some(RangeLimit {
min: super::util::range_min_or_fallback(&self.limits.slow_ppt, MIN_SLOW_PPT) min: super::util::range_min_or_fallback(&self.limits.slow_ppt, MIN_SLOW_PPT)
/ ppt_divisor, / ppt_divisor,
max: super::util::range_max_or_fallback(&self.limits.slow_ppt, MIN_SLOW_PPT) max: super::util::range_max_or_fallback(&self.limits.slow_ppt, MIN_SLOW_PPT)
/ ppt_divisor, / ppt_divisor,
}), }),
slow_ppt_default: self.limits.slow_ppt_default.or_else(|| self.limits.slow_ppt.and_then(|x| x.max)).unwrap_or(MAX_SLOW_PPT) / ppt_divisor, slow_ppt_default: self
.limits
.slow_ppt_default
.or_else(|| self.limits.slow_ppt.and_then(|x| x.max))
.unwrap_or(MAX_SLOW_PPT)
/ ppt_divisor,
ppt_step: self.limits.ppt_step.unwrap_or(1), ppt_step: self.limits.ppt_step.unwrap_or(1),
tdp_limits: None, tdp_limits: None,
tdp_boost_limits: None, tdp_boost_limits: None,