From 367db696abbd3b6f39856a0e5fe9883e7908a7c3 Mon Sep 17 00:00:00 2001 From: IoriAkatsuki Date: Thu, 2 Jul 2026 16:06:48 +0800 Subject: [PATCH] fix(asusd): apply PPT limits on set even without ppt_enabled attribute PPT (ppt_pl1_spl/ppt_pl2_sppt) writes were silently discarded on kernels where asus-armoury does not expose a `ppt_enabled` firmware attribute. The per-profile Tuning.enabled flag gates whether PPT values are written to sysfs, but nothing ever sets it to true when ppt_enabled is absent, so tuning could never be enabled and every set was skipped. The PPT current_value getter also returned the cached config value instead of the real sysfs value, masking the failure (get reports success, hardware unchanged). - set_current_value: auto-enable the profile's tuning on an explicit PPT set so the value is actually written to hardware. - current_value: read the real value from sysfs instead of the cache. --- asusd/src/asus_armoury.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/asusd/src/asus_armoury.rs b/asusd/src/asus_armoury.rs index d7225b64..5d3ce99e 100644 --- a/asusd/src/asus_armoury.rs +++ b/asusd/src/asus_armoury.rs @@ -368,21 +368,11 @@ impl AsusArmouryAttribute { #[zbus(property)] async fn current_value(&self) -> fdo::Result { if self.name().property_type() == FirmwareAttributeType::Ppt { - let profile: PlatformProfile = self.platform.get_platform_profile()?.into(); - let power_plugged = self - .power - .get_online() - .map_err(|e| { - error!("Could not get power status: {e:?}"); - e - }) - .unwrap_or_default() - == 1; - let config = self.config.lock().await; - if let Some(tuning) = config.select_tunings_ref(power_plugged, profile) { - if let Some(tune) = tuning.group.get(&self.name()) { - return Ok(*tune); - } + // Fix: report the real hardware value read from sysfs, not the cached + // per-profile config value. Returning the config value made tools show + // a PPT limit that may never have been written to the firmware. + if let Ok(AttrValue::Integer(i)) = self.attr.current_value() { + return Ok(i); } if let AttrValue::Integer(i) = self.attr.default_value() { return Ok(*i); @@ -445,6 +435,15 @@ impl AsusArmouryAttribute { debug!("Store tuning config for {name} = {:?}", value); } + // Fix: an explicit user set implies intent to apply. On kernels + // without a `ppt_enabled` firmware attribute there is no other + // path to flip this per-profile flag, so enabling it here avoids + // silently discarding the write while the getter reports success. + if !tuning.enabled { + info!("Auto-enabling PPT tuning for this profile on explicit set"); + tuning.enabled = true; + } + match tuning.enabled { true => { debug!("Tuning is enabled: setting value to PPT property {name} = {value}");