From: Denis Benato <denis.benato@linux.dev>
To: Andrei Rusu de Castro <arc@empyreal.works>
Cc: "Corentin Chary" <corentin.chary@gmail.com>,
"Luke D. Jones" <luke@ljones.dev>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: asus-wmi: write the thermal policy only when it changes
Date: Thu, 12 Nov 2026 09:32:21 +0100 [thread overview]
Message-ID: <ec9515fb-6698-4e7e-8a88-5b3fa2f50c51@linux.dev> (raw)
In-Reply-To: <20261111-asus-wmi-tpolicy-5fbc4e09@empyreal.works>
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
next prev parent reply other threads:[~2026-11-12 8:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
2026-11-12 20:27 ` Andrei Rusu de Castro
2026-11-12 20:33 ` Denis Benato
2026-11-12 21:04 ` Andrei Rusu de Castro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ec9515fb-6698-4e7e-8a88-5b3fa2f50c51@linux.dev \
--to=denis.benato@linux.dev \
--cc=arc@empyreal.works \
--cc=corentin.chary@gmail.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luke@ljones.dev \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.