* [PATCH] platform/x86: asus-wmi: write the thermal policy only when it changes
@ 2026-11-11 21:43 Andrei Rusu de Castro
2026-11-12 8:32 ` Denis Benato
0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread* Re: [PATCH] platform/x86: asus-wmi: write the thermal policy only when it changes
2026-11-11 21:43 [PATCH] platform/x86: asus-wmi: write the thermal policy only when it changes Andrei Rusu de Castro
@ 2026-11-12 8:32 ` Denis Benato
0 siblings, 0 replies; 2+ messages in thread
From: Denis Benato @ 2026-11-12 8:32 UTC (permalink / raw)
To: Andrei Rusu de Castro
Cc: Corentin Chary, Luke D. Jones, Hans de Goede, Ilpo Järvinen,
platform-driver-x86, linux-kernel
11 nov 2026 22:44:03 Andrei Rusu de Castro <arc@empyreal.works>:
> 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.
Hi Andrei,
Thanks for spotting this!
>
> 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.
I don't agree with this: if the userspace requests a power profile change the driver must honor that request.
The core issue here is not the application of the requested power profile but the fact that asus-armoury can get out-of-sync with what is set versus what is reported.
I would suggest fixing that issue instead: when the platform profile is changed, if a custom tdp is set you should make limits re-apply (or, perhaps even easier, reflect the fact custom TDP got disabled, albeit I am not sure this is true for every laptop and I highly doubt that).
This way the kernel honors requests from the user without reporting false information, with the added bonus that even if the profile switched (without unplugging/plugging in the laptop) the reported status is faithful.
Best regards,
Denis B.
>
> 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] 2+ messages in thread
end of thread, other threads:[~2026-11-12 8:32 UTC | newest]
Thread overview: 2+ messages (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
2026-11-12 8:32 ` Denis Benato
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®