mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86: hp-wmi: Use only the low byte of the thermal profile
@ 2026-10-26  3:06 Akhil Boyapati
  2026-11-09 18:43 ` Ilpo Järvinen
  0 siblings, 1 reply; 2+ messages in thread
From: Akhil Boyapati @ 2026-10-26  3:06 UTC (permalink / raw)
  To: platform-driver-x86
  Cc: Hans de Goede, Ilpo Järvinen, linux-kernel, Akhil Boyapati

On the HP Spectre x360 14 (board 8C15) the firmware answers the
thermal profile query (0x4C, read) with more than the profile: the
DSDT's GTPS method returns the profile in byte 0, OEM flags in byte 1
and the device posture in byte 2. In Quiet mode in laptop posture the
value is 0x00041103.

thermal_profile_get() returns the whole value, so
hp_wmi_platform_profile_get() matches no profile and reading
/sys/firmware/acpi/platform_profile fails with -EINVAL. This also
breaks power-profiles-daemon and tuned-ppd. Probe writes the
unmasked value back, which only works because the firmware's write
method (STPS) uses byte 0.

Mask the value to its low byte. Boards that return only the profile
are unaffected.

Tested on board 8C15 (kernel 7.2.11, module built from this tree's
driver with the change applied): platform_profile reads back correctly
after setting each of cool, quiet, balanced and performance, and the
firmware's ODVP0 follows (3, 4, 2, 1). Not tested on other boards.

Fixes: 4296f679ca50 ("platform/x86: hp-wmi: add platform profile support")
Assisted-by: LLM
Signed-off-by: Akhil Boyapati <boyakhil978@gmail.com>
---
 drivers/platform/x86/hp/hp-wmi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index 52077833a..6180f1d21 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -2117,7 +2117,13 @@ static int platform_profile_omen_set(struct device *dev,
 
 static int thermal_profile_get(void)
 {
-	return hp_wmi_read_int(HPWMI_THERMAL_PROFILE_QUERY);
+	int tp = hp_wmi_read_int(HPWMI_THERMAL_PROFILE_QUERY);
+
+	/*
+	 * Only the low byte is the thermal profile. Some firmware (e.g. board
+	 * 8C15) packs OEM flags and the device posture into the upper bytes.
+	 */
+	return tp < 0 ? tp : tp & 0xff;
 }
 
 static int thermal_profile_set(int thermal_profile)
-- 
2.56.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] platform/x86: hp-wmi: Use only the low byte of the thermal profile
  2026-10-26  3:06 [PATCH] platform/x86: hp-wmi: Use only the low byte of the thermal profile Akhil Boyapati
@ 2026-11-09 18:43 ` Ilpo Järvinen
  0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2026-11-09 18:43 UTC (permalink / raw)
  To: Akhil Boyapati; +Cc: platform-driver-x86, Hans de Goede, LKML

On Sun, 25 Oct 2026, Akhil Boyapati wrote:

> On the HP Spectre x360 14 (board 8C15) the firmware answers the
> thermal profile query (0x4C, read) with more than the profile: the
> DSDT's GTPS method returns the profile in byte 0, OEM flags in byte 1
> and the device posture in byte 2. In Quiet mode in laptop posture the
> value is 0x00041103.
> 
> thermal_profile_get() returns the whole value, so
> hp_wmi_platform_profile_get() matches no profile and reading
> /sys/firmware/acpi/platform_profile fails with -EINVAL. This also
> breaks power-profiles-daemon and tuned-ppd. Probe writes the
> unmasked value back, which only works because the firmware's write
> method (STPS) uses byte 0.
> 
> Mask the value to its low byte. Boards that return only the profile
> are unaffected.
> 
> Tested on board 8C15 (kernel 7.2.11, module built from this tree's
> driver with the change applied): platform_profile reads back correctly
> after setting each of cool, quiet, balanced and performance, and the
> firmware's ODVP0 follows (3, 4, 2, 1). Not tested on other boards.
> 
> Fixes: 4296f679ca50 ("platform/x86: hp-wmi: add platform profile support")
> Assisted-by: LLM
> Signed-off-by: Akhil Boyapati <boyakhil978@gmail.com>
> ---
>  drivers/platform/x86/hp/hp-wmi.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
> index 52077833a..6180f1d21 100644
> --- a/drivers/platform/x86/hp/hp-wmi.c
> +++ b/drivers/platform/x86/hp/hp-wmi.c
> @@ -2117,7 +2117,13 @@ static int platform_profile_omen_set(struct device *dev,
>  
>  static int thermal_profile_get(void)
>  {
> -	return hp_wmi_read_int(HPWMI_THERMAL_PROFILE_QUERY);
> +	int tp = hp_wmi_read_int(HPWMI_THERMAL_PROFILE_QUERY);
> +
> +	/*
> +	 * Only the low byte is the thermal profile. Some firmware (e.g. board
> +	 * 8C15) packs OEM flags and the device posture into the upper bytes.
> +	 */
> +	return tp < 0 ? tp : tp & 0xff;

Add a named define and use FIELD_GET(). Then the comment doesn't seem even 
required.

Please keep call and it's error handling next to each other (convert 
this to the usual error handling pattern with if). Because of that you 
cannot make the call in variable declaration block but that's fine.

-- 
 i.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-09 18:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26  3:06 [PATCH] platform/x86: hp-wmi: Use only the low byte of the thermal profile Akhil Boyapati
2026-11-09 18:43 ` Ilpo Järvinen

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®