Skip to contentSkip to conversation

platform/x86: asus-wmi: write the thermal policy only when it changes

PATCH In review Andrei Rusu de Castro 2 participants 5 messages Nov 11 – Nov 12

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: asus-wmi: write the thermal policy only when it changes

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.

---
 drivers/platform/x86/asus-wmi.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/platform/x86/asus-wmi.c +17 -0
index b33ebdb21..4f37a83c2 100644
@@ -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);
Signature · 1 line
2.56.0
maintainer
#1 lore raw

11 nov 2026 22:44:03 Andrei Rusu de Castro <[email protected]>:

Quoted 6 lines

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!

Quoted 7 lines

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.

Quoted 67 lines

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.

---
drivers/platform/x86/asus-wmi.c | 17 +++++++++++++++++

1 file changed, 17 insertions(+)
drivers/platform/x86/asus-wmi.c +17 -0
index b33ebdb21..4f37a83c2 100644
@@ -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);
Signature · 1 line
2.56.0
#2 lore raw
Quoted 2 lines · Denis Benato

I don't agree with this: if the userspace requests a power profile change the driver must honor that request.

Hi Denis,

Thanks for the review and the explanation, that makes sense. On my machine the package power limits are set outside asus-armoury, so the re-apply you suggest would not cover them, and I'll keep this change as a local patch instead of pursuing it here.

Thanks,
Andrei

maintainer
#3 lore raw

12 nov 2026 21:27:45 Andrei Rusu de Castro <[email protected]>:

Quoted 10 lines · Denis Benato
Quoted 2 lines

I don't agree with this: if the userspace requests a power profile change the driver must honor that request.

Hi Denis,

Thanks for the review and the explanation, that makes sense. On my machine the package power limits are set outside asus-armoury, so the re-apply you suggest would not cover them, and I'll keep this change as a local patch instead of pursuing it here.

How are you applying limits? The only thing that comes to mind is intel rapl, but it has way lower limits than what asus validated.

Quoted 3 lines

Thanks,
Andrei

#4 lore raw
Quoted 2 lines · Denis Benato

How are you applying limits? The only thing that comes to mind is intel rapl, but it has way lower limits than what asus validated.

With ryzenadj: it writes the package power limits directly to the SMU on this machine, so neither asus-armoury nor RAPL is involved, and when the thermal policy is written again the firmware re-applies its own table for that mode over them.

Andrei