From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Emre Cecanpunar <emreleno@gmail.com>
Cc: platform-driver-x86@vger.kernel.org,
Hans de Goede <hansg@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
krishna.chomal108@gmail.com, radheykalra901@gmail.com,
edip@medip.dev, hello@kursatabayli.dev, mjg59@srcf.ucam.org,
akpm@linux-foundation.org, jorge.lopez2@hp.com, jes965@nyu.edu,
mario.limonciello@amd.com, julien.robin28@free.fr
Subject: Re: [PATCH 4/5] platform/x86: hp-wmi: normalize GPU thermal mode errors
Date: Tue, 21 Jul 2026 18:57:39 +0300 (EEST) [thread overview]
Message-ID: <36e76e24-07bb-9a2f-72cd-b50591cd71b4@linux.intel.com> (raw)
In-Reply-To: <4dcb4c0b0aac63d03b8e8a3c68e41b88b8d303e6.1784195117.git.emreleno@gmail.com>
On Thu, 16 Jul 2026, Emre Cecanpunar wrote:
> The GPU thermal mode helpers return positive firmware error codes, but
> their callers only treat negative values as failures. If the mode query
> is rejected, its output parameters remain uninitialized and are then
> used to select a profile or sent back to firmware as the GPU slowdown
> temperature. A rejected mode update is likewise reported as successful.
Does this happen with some HW? Please add the info.
> Zero the query buffer and convert positive firmware status codes to
> -EINVAL in both helpers so callers never consume missing output or ignore
> a failed update.
>
> Fixes: 6e4ab59b8391 ("platform/x86: hp-wmi: Add fan and thermal profile support for Victus 16-s1000")
> Signed-off-by: Emre Cecanpunar <emreleno@gmail.com>
> ---
> drivers/platform/x86/hp/hp-wmi.c | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
> index 29881749aae6..65c3bac17ad6 100644
> --- a/drivers/platform/x86/hp/hp-wmi.c
> +++ b/drivers/platform/x86/hp/hp-wmi.c
> @@ -1885,20 +1885,21 @@ static int victus_s_gpu_thermal_profile_get(bool *ctgp_enable,
> u8 *dstate,
> u8 *gpu_slowdown_temp)
> {
> - struct victus_gpu_power_modes gpu_power_modes;
> + struct victus_gpu_power_modes gpu_power_modes = {};
Why is this necessary if you return error after the if change?
> int ret;
>
> ret = hp_wmi_perform_query(HPWMI_GET_GPU_THERMAL_MODES_QUERY, HPWMI_GM,
> &gpu_power_modes, sizeof(gpu_power_modes),
> sizeof(gpu_power_modes));
> - if (ret == 0) {
> - *ctgp_enable = gpu_power_modes.ctgp_enable ? true : false;
> - *ppab_enable = gpu_power_modes.ppab_enable ? true : false;
> - *dstate = gpu_power_modes.dstate;
> - *gpu_slowdown_temp = gpu_power_modes.gpu_slowdown_temp;
> - }
> + if (ret)
> + return ret < 0 ? ret : -EINVAL;
Use two separate ifs instead.
> - return ret;
> + *ctgp_enable = gpu_power_modes.ctgp_enable ? true : false;
> + *ppab_enable = gpu_power_modes.ppab_enable ? true : false;
> + *dstate = gpu_power_modes.dstate;
> + *gpu_slowdown_temp = gpu_power_modes.gpu_slowdown_temp;
> +
> + return 0;
> }
>
> static int victus_s_gpu_thermal_profile_set(bool ctgp_enable,
> @@ -1929,8 +1930,10 @@ static int victus_s_gpu_thermal_profile_set(bool ctgp_enable,
>
> ret = hp_wmi_perform_query(HPWMI_SET_GPU_THERMAL_MODES_QUERY, HPWMI_GM,
> &gpu_power_modes, sizeof(gpu_power_modes), 0);
> + if (ret)
> + return ret < 0 ? ret : -EINVAL;
>
> - return ret;
> + return 0;
Now this could be:
if (ret > 0)
return -EINVAL;
return ret;
--
i.
next prev parent reply other threads:[~2026-07-21 15:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 9:54 [PATCH 0/5] platform/x86: hp-wmi: Fix WMI error handling Emre Cecanpunar
2026-07-16 9:54 ` [PATCH 1/5] platform/x86: hp-wmi: validate WMI response header size Emre Cecanpunar
2026-07-21 15:42 ` Ilpo Järvinen
2026-07-16 9:54 ` [PATCH 2/5] platform/x86: hp-wmi: handle firmware errors in tablet mode query Emre Cecanpunar
2026-07-21 15:50 ` Ilpo Järvinen
2026-07-16 9:54 ` [PATCH 3/5] platform/x86: hp-wmi: handle errors in the OMEN key event Emre Cecanpunar
2026-07-21 15:52 ` Ilpo Järvinen
2026-07-16 9:54 ` [PATCH 4/5] platform/x86: hp-wmi: normalize GPU thermal mode errors Emre Cecanpunar
2026-07-21 15:57 ` Ilpo Järvinen [this message]
2026-07-16 9:54 ` [PATCH 5/5] platform/x86: hp-wmi: report fan speed command failures Emre Cecanpunar
2026-07-21 15:58 ` Ilpo Järvinen
2026-07-21 16:14 ` [PATCH 0/5] platform/x86: hp-wmi: Fix WMI error handling Emre Cecanpunar
2026-07-21 16:15 ` Emre Cecanpunar
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=36e76e24-07bb-9a2f-72cd-b50591cd71b4@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=edip@medip.dev \
--cc=emreleno@gmail.com \
--cc=hansg@kernel.org \
--cc=hello@kursatabayli.dev \
--cc=jes965@nyu.edu \
--cc=jorge.lopez2@hp.com \
--cc=julien.robin28@free.fr \
--cc=krishna.chomal108@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=mjg59@srcf.ucam.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=radheykalra901@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox