* [PATCH] platform/x86: asus-wmi: write the thermal policy only when it changes
@ 2026-11-11 21:43 Andrei Rusu de Castro
0 siblings, 0 replies; only message in thread
From: Andrei Rusu de Castro @ 2026-11-11 21:43 UTC (permalink / raw)
To: Corentin Chary, Luke D. Jones, Denis Benato, Hans de Goede,
Ilpo Järvinen
Cc: platform-driver-x86, linux-kernel
On the ROG Flow Z13 (GZ302EA), writing the throttle thermal policy makes
the firmware re-apply its own package power limits for that mode, also
when the written mode is the one already set. Userspace re-asserts the
current platform profile on events such as AC plug and unplug, so power
limits tuned after a profile change are silently replaced by the
firmware's table for the unchanged mode.
Remember whether the firmware is known to be in the cached mode and skip
the WMI call in the platform_profile handler when the requested profile
matches it. A failed write clears that state, and so does restore from
hibernation, where the firmware starts afresh, so the next profile write
reaches it again. The throttle_thermal_policy attribute and the fan
curve reset still write the mode every time.
On a GZ302EA running 7.4-rc2 with this change, re-asserting the current
profile, as happens on AC unplug, leaves package power limits set from
userspace in place.
An LLM assisted with finding the cause, writing this change and its
description, and running the test above on my GZ302EA.
Signed-off-by: Andrei Rusu de Castro <arc@empyreal.works>
---
drivers/platform/x86/asus-wmi.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index b33ebdb21..4f37a83c2 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -315,6 +315,8 @@ struct asus_wmi {
u8 throttle_thermal_policy_mode;
u32 throttle_thermal_policy_dev;
+ /* the firmware is known to be in throttle_thermal_policy_mode */
+ bool throttle_thermal_policy_synced;
bool cpu_fan_curve_available;
bool gpu_fan_curve_available;
@@ -4183,9 +4185,11 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus)
"throttle_thermal_policy");
if (err) {
+ asus->throttle_thermal_policy_synced = false;
pr_warn("Failed to set throttle thermal policy: %d\n", err);
return err;
}
+ asus->throttle_thermal_policy_synced = true;
/* Must set to disabled if mode is toggled */
if (asus->cpu_fan_curve_available)
@@ -4302,6 +4306,16 @@ static int asus_wmi_platform_profile_set(struct device *dev,
return -EOPNOTSUPP;
}
+ /*
+ * Write the mode only when it changes. The firmware applies its whole
+ * power table for a mode each time the mode is written, replacing
+ * package power limits tuned since then (ROG Flow Z13 GZ302EA), and
+ * userspace re-asserts the current profile on power-supply events.
+ */
+ if (asus->throttle_thermal_policy_synced &&
+ asus->throttle_thermal_policy_mode == tp)
+ return 0;
+
asus->throttle_thermal_policy_mode = tp;
return throttle_thermal_policy_write(asus);
}
@@ -5404,6 +5418,9 @@ static int asus_hotk_restore(struct device *device)
struct asus_wmi *asus = dev_get_drvdata(device);
int bl;
+ /* The firmware booted afresh; the next profile write must reach it. */
+ asus->throttle_thermal_policy_synced = false;
+
/* Refresh both wlan rfkill state and pci hotplug */
if (asus->wlan.rfkill)
asus_rfkill_hotplug(asus);
--
2.56.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-11 21:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 21:43 [PATCH] platform/x86: asus-wmi: write the thermal policy only when it changes Andrei Rusu de Castro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®