Skip to contentSkip to conversation

Fix Omen 16-wf1xxx thermal profile and add EC readback

PATCH Superseded Krishna Chomal 2 participants 16 messages Dec 18, 2025 – Jan 31 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

v4 cover Fix Omen 16-wf1xxx thermal profile and add EC readback

This series fixes incorrect thermal profile parameters sent for HP Omen 16-wf1xxx and implements hardware readback support for Victus S thermal profiles.

The first patch refactors the DMI handling for Victus S boards. By moving from simple string list to DMI system id table with driver_data, we can now map each board to its correct thermal parameters.

The second patch implements "get" callback for the platform profile API. It reads the hardware state from EC register 0x59. This ensures that the driver stays in sync with the hardware during driver init and power source change events.

Changes in v4:
- Fixed driver load failure caused in v3
- Handle err after calling victus_s_gpu_thermal_profile_get()
- Fixed wrong function call victus_s_powersource_event()

Changes in v3:
- Moved DMI lookup to hp_wmi_init()
- Marked DMI table as __initconst
- Renamed eco to low_power
- Added second patch to implement "get" support for Victus S devices

Changes in v2:
- Refactored victus_s_thermal_profile_boards to use DMI table
- Implemented driver_data to handle thermal profile parameters
- Moved enum definitions earlier in the file for thermal profile parameters

Changes in v1:
Initial fix for Omen 16-wf1xxx thermal profile values

Krishna Chomal (2):
platform/x86: hp-wmi: fix platform profile values for Omen 16-wf1xxx platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile

 drivers/platform/x86/hp/hp-wmi.c | 269 ++++++++++++++++++++++++-------
 1 file changed, 207 insertions(+), 62 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH v4 1/2 platform/x86: hp-wmi: fix platform profile values for Omen 16-wf1xxx

HP Omen 16-wf1xxx (board ID 8C78) currently sends the incorrect Victus-specific thermal profile values via WMI, leading to a logical inconsistency when switching between platform profiles.

The driver currently uses Victus S values:
0x00 => Balanced / Low-Power
0x01 => Performance

However, Omen Gaming Hub logs / EC register inspection on Windows shows that this board is intended to use:
0x30 => Balanced / Low-Power
0x31 => Performance

This patch corrects the thermal profile command values to match the values observed from Omen Gaming Hub logs. The performance benchmarks and peak power draw (from both CPU and GPU) show no observable change with this correction (suggesting that the firmware is currently tolerant of the incorrect values). However sending the correct values prevents potential regressions after future firmware updates.

Refactor victus_s_thermal_profile_boards from a list of strings to a dmi_system_id table and move the lookup to module init. The new struct thermal_profile_params is used to store board-specific WMI parameters, allowing the driver to cache these values in a static pointer. This avoids repeated DMI string comparisons and allows marking of DMI table as __initconst.

Testing on HP Omen 16-wf1xxx (board 8C78) confirmed WMI codes 0x30/0x31 are now sent, resolving the logical inconsistency and ensuring the value visible in EC registers match the Windows state for this profile.

Fixes fb146a38cb11 ("platform/x86: hp-wmi: Add Omen 16-wf1xxx fan support")

---
Changes in v3:
- Fixed minor formatting issues.
- Renamed struct field eco to low_power for consistency.
- Marked the DMI table as __initconst.
- Moved DMI lookup to hp_wmi_init() and save the active thermal profile params.
- Added a static boolean flag to optimize is_victus_s_thermal_profile().

Changes in v2:
- Refactored victus_s_thermal_profile_boards to use struct dmi_system_id
- Implemented driver_data to handle thermal profile parameters, replacing the conditional checks in platform_profile_victus_s_set_ec
- Moved enum definitions for thermal profile values earlier in the file to support the new struct thermal_profile_params.

---
 drivers/platform/x86/hp/hp-wmi.c | 179 ++++++++++++++++++++++---------
 1 file changed, 127 insertions(+), 52 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +127 -52
index f4ea1ea05997..24d065ddfc6a 100644
@@ -53,6 +53,66 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4");
 
 #define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when zero insize is required
 
+enum hp_thermal_profile_omen_v0 {
+	HP_OMEN_V0_THERMAL_PROFILE_DEFAULT		= 0x00,
+	HP_OMEN_V0_THERMAL_PROFILE_PERFORMANCE		= 0x01,
+	HP_OMEN_V0_THERMAL_PROFILE_COOL			= 0x02,
+};
+
+enum hp_thermal_profile_omen_v1 {
+	HP_OMEN_V1_THERMAL_PROFILE_DEFAULT		= 0x30,
+	HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE		= 0x31,
+	HP_OMEN_V1_THERMAL_PROFILE_COOL			= 0x50,
+};
+
+enum hp_thermal_profile_omen_flags {
+	HP_OMEN_EC_FLAGS_TURBO				= 0x04,
+	HP_OMEN_EC_FLAGS_NOTIMER			= 0x02,
+	HP_OMEN_EC_FLAGS_JUSTSET			= 0x01,
+};
+
+enum hp_thermal_profile_victus {
+	HP_VICTUS_THERMAL_PROFILE_DEFAULT		= 0x00,
+	HP_VICTUS_THERMAL_PROFILE_PERFORMANCE		= 0x01,
+	HP_VICTUS_THERMAL_PROFILE_QUIET			= 0x03,
+};
+
+enum hp_thermal_profile_victus_s {
+	HP_VICTUS_S_THERMAL_PROFILE_DEFAULT		= 0x00,
+	HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE		= 0x01,
+};
+
+enum hp_thermal_profile {
+	HP_THERMAL_PROFILE_PERFORMANCE			= 0x00,
+	HP_THERMAL_PROFILE_DEFAULT			= 0x01,
+	HP_THERMAL_PROFILE_COOL				= 0x02,
+	HP_THERMAL_PROFILE_QUIET			= 0x03,
+};
+
+struct thermal_profile_params {
+	u8 performance;
+	u8 balanced;
+	u8 low_power;
+};
+
+static const struct thermal_profile_params victus_s_thermal_params = {
+	.performance	= HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE,
+	.balanced	= HP_VICTUS_S_THERMAL_PROFILE_DEFAULT,
+	.low_power	= HP_VICTUS_S_THERMAL_PROFILE_DEFAULT,
+};
+
+static const struct thermal_profile_params omen_v1_thermal_params = {
+	.performance	= HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE,
+	.balanced	= HP_OMEN_V1_THERMAL_PROFILE_DEFAULT,
+	.low_power	= HP_OMEN_V1_THERMAL_PROFILE_DEFAULT,
+};
+
+/*
+ * A generic pointer for the currently-active board's thermal profile
+ * parameters.
+ */
+static struct thermal_profile_params *active_thermal_profile_params;
+
 /* DMI board names of devices that should use the omen specific path for
  * thermal profiles.
  * This was obtained by taking a look in the windows omen command center
@@ -99,12 +159,40 @@ static const char * const victus_thermal_profile_boards[] = {
 };
 
 /* DMI Board names of Victus 16-r and Victus 16-s laptops */
-static const char * const victus_s_thermal_profile_boards[] = {
-	"8BBE", "8BD4", "8BD5",
-	"8C78", "8C99", "8C9C",
-	"8D41",
+static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst = {
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BBE") },
+		.driver_data = (void *)&victus_s_thermal_params,
+	},
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD4") },
+		.driver_data = (void *)&victus_s_thermal_params,
+	},
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD5") },
+		.driver_data = (void *)&victus_s_thermal_params,
+	},
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C78") },
+		.driver_data = (void *)&omen_v1_thermal_params,
+	},
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C99") },
+		.driver_data = (void *)&victus_s_thermal_params,
+	},
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C9C") },
+		.driver_data = (void *)&victus_s_thermal_params,
+	},
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8D41") },
+		.driver_data = (void *)&victus_s_thermal_params,
+	},
+	{},
 };
 
+static bool is_victus_s_board;
+
 enum hp_wmi_radio {
 	HPWMI_WIFI	= 0x0,
 	HPWMI_BLUETOOTH	= 0x1,
@@ -225,42 +313,6 @@ enum hp_wireless2_bits {
 	HPWMI_POWER_FW_OR_HW	= HPWMI_POWER_BIOS | HPWMI_POWER_HARD,
 };
 
-enum hp_thermal_profile_omen_v0 {
-	HP_OMEN_V0_THERMAL_PROFILE_DEFAULT     = 0x00,
-	HP_OMEN_V0_THERMAL_PROFILE_PERFORMANCE = 0x01,
-	HP_OMEN_V0_THERMAL_PROFILE_COOL        = 0x02,
-};
-
-enum hp_thermal_profile_omen_v1 {
-	HP_OMEN_V1_THERMAL_PROFILE_DEFAULT	= 0x30,
-	HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE	= 0x31,
-	HP_OMEN_V1_THERMAL_PROFILE_COOL		= 0x50,
-};
-
-enum hp_thermal_profile_omen_flags {
-	HP_OMEN_EC_FLAGS_TURBO		= 0x04,
-	HP_OMEN_EC_FLAGS_NOTIMER	= 0x02,
-	HP_OMEN_EC_FLAGS_JUSTSET	= 0x01,
-};
-
-enum hp_thermal_profile_victus {
-	HP_VICTUS_THERMAL_PROFILE_DEFAULT		= 0x00,
-	HP_VICTUS_THERMAL_PROFILE_PERFORMANCE		= 0x01,
-	HP_VICTUS_THERMAL_PROFILE_QUIET			= 0x03,
-};
-
-enum hp_thermal_profile_victus_s {
-	HP_VICTUS_S_THERMAL_PROFILE_DEFAULT		= 0x00,
-	HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE		= 0x01,
-};
-
-enum hp_thermal_profile {
-	HP_THERMAL_PROFILE_PERFORMANCE	= 0x00,
-	HP_THERMAL_PROFILE_DEFAULT		= 0x01,
-	HP_THERMAL_PROFILE_COOL			= 0x02,
-	HP_THERMAL_PROFILE_QUIET		= 0x03,
-};
-
 #define IS_HWBLOCKED(x) ((x & HPWMI_POWER_FW_OR_HW) != HPWMI_POWER_FW_OR_HW)
 #define IS_SWBLOCKED(x) !(x & HPWMI_POWER_SOFT)
 
@@ -1581,15 +1633,8 @@ static int platform_profile_victus_set_ec(enum platform_profile_option profile)
 
 static bool is_victus_s_thermal_profile(void)
 {
-	const char *board_name;
-
-	board_name = dmi_get_system_info(DMI_BOARD_NAME);
-	if (!board_name)
-		return false;
-
-	return match_string(victus_s_thermal_profile_boards,
-			    ARRAY_SIZE(victus_s_thermal_profile_boards),
-			    board_name) >= 0;
+	/* Initialised in driver init, hence safe to use here */
+	return is_victus_s_board;
 }
 
 static int victus_s_gpu_thermal_profile_get(bool *ctgp_enable,
@@ -1672,25 +1717,30 @@ static int victus_s_set_cpu_pl1_pl2(u8 pl1, u8 pl2)
 
 static int platform_profile_victus_s_set_ec(enum platform_profile_option profile)
 {
+	struct thermal_profile_params *params;
 	bool gpu_ctgp_enable, gpu_ppab_enable;
 	u8 gpu_dstate; /* Test shows 1 = 100%, 2 = 50%, 3 = 25%, 4 = 12.5% */
 	int err, tp;
 
+	params = active_thermal_profile_params;
+	if (!params)
+		return -ENODEV;
+
 	switch (profile) {
 	case PLATFORM_PROFILE_PERFORMANCE:
-		tp = HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE;
+		tp = params->performance;
 		gpu_ctgp_enable = true;
 		gpu_ppab_enable = true;
 		gpu_dstate = 1;
 		break;
 	case PLATFORM_PROFILE_BALANCED:
-		tp = HP_VICTUS_S_THERMAL_PROFILE_DEFAULT;
+		tp = params->balanced;
 		gpu_ctgp_enable = false;
 		gpu_ppab_enable = true;
 		gpu_dstate = 1;
 		break;
 	case PLATFORM_PROFILE_LOW_POWER:
-		tp = HP_VICTUS_S_THERMAL_PROFILE_DEFAULT;
+		tp = params->low_power;
 		gpu_ctgp_enable = false;
 		gpu_ppab_enable = false;
 		gpu_dstate = 1;
@@ -2227,6 +2277,26 @@ static int hp_wmi_hwmon_init(void)
 	return 0;
 }
 
+static void __init setup_active_thermal_profile_params(void)
+{
+	const struct dmi_system_id *id;
+
+	/*
+	 * Currently only victus_s devices use the
+	 * active_thermal_profile_params
+	 */
+	id = dmi_first_match(victus_s_thermal_profile_boards);
+	if (id) {
+		/*
+		 * Marking this boolean is required to ensure that
+		 * is_victus_s_thermal_profile() behaves like a valid
+		 * wrapper.
+		 */
+		is_victus_s_board = true;
+		active_thermal_profile_params = id->driver_data;
+	}
+}
+
 static int __init hp_wmi_init(void)
 {
 	int event_capable = wmi_has_guid(HPWMI_EVENT_GUID);
@@ -2254,6 +2324,11 @@ static int __init hp_wmi_init(void)
 			goto err_destroy_input;
 		}
 
+		/*
+		 * Setup active board's thermal profile parameters before
+		 * starting platform driver probe.
+		 */
+		setup_active_thermal_profile_params();
 		err = platform_driver_probe(&hp_wmi_driver, hp_wmi_bios_setup);
 		if (err)
 			goto err_unregister_device;
Signature · 1 line
2.52.0
#2 lore raw

PATCH v4 2/2 platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile

In reply to Krishna Chomal

The current implementation for Victus S thermal profiles only supports setting the profile. The driver was missing the logic to read the hardware state, meaning it would default to "Balanced" on driver load, overriding the currently active profile. Furthermore, the driver could not detect if the firmware reset the profile on a power source change.

Add platform_profile_victus_s_get_ec() to read the current thermal profile state directly from EC offset 0x59. Since both Balanced and Low-Power profiles share the same thermal profile value, differentiate them by querying the GPU CTGP and PPAB states via existing functions. Additionally, update the power source event notifier to use the actual hardware state when re-trigger CPU power limits actualization.

Testing on HP Omen 16-wf1xxx (board ID 8C78) confirmed that the thermal profile is now persistent across driver loads.

---
Changes in v4:
- Fixed platform_profile_victus_s_get_ec() to use both victus_s_thermal_params and omen_v1_thermal_params instead of active_thermal_params to fix regression caused in v3.
- Handle err after calling victus_s_gpu_thermal_profile_get().
- Fixed a wrong function call in victus_s_powersource_event().

Changes in v3:
- New patch in this series

---
 drivers/platform/x86/hp/hp-wmi.c | 94 ++++++++++++++++++++++++++++----
 1 file changed, 82 insertions(+), 12 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +82 -12
index 24d065ddfc6a..010082a03cc2 100644
@@ -44,6 +44,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4");
 #define HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET 0x62
 #define HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET 0x63
 #define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95
+#define HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET 0x59
 
 #define HP_FAN_SPEED_AUTOMATIC	 0x00
 #define HP_POWER_LIMIT_DEFAULT	 0x00
@@ -640,6 +641,12 @@ static bool is_omen_thermal_profile(void)
 			    board_name) >= 0;
 }
 
+static bool is_victus_s_thermal_profile(void)
+{
+	/* Initialised in driver init, hence safe to use here */
+	return is_victus_s_board;
+}
+
 static int omen_get_thermal_policy_version(void)
 {
 	unsigned char buffer[8] = { 0 };
@@ -666,9 +673,16 @@ static int omen_get_thermal_policy_version(void)
 
 static int omen_thermal_profile_get(void)
 {
+	u8 addr;
 	u8 data;
+	int ret;
 
-	int ret = ec_read(HP_OMEN_EC_THERMAL_PROFILE_OFFSET, &data);
+	if (is_victus_s_thermal_profile())
+		addr = HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET;
+	else
+		addr = HP_OMEN_EC_THERMAL_PROFILE_OFFSET;
+
+	ret = ec_read(addr, &data);
 
 	if (ret)
 		return ret;
@@ -1631,12 +1645,6 @@ static int platform_profile_victus_set_ec(enum platform_profile_option profile)
 	return 0;
 }
 
-static bool is_victus_s_thermal_profile(void)
-{
-	/* Initialised in driver init, hence safe to use here */
-	return is_victus_s_board;
-}
-
 static int victus_s_gpu_thermal_profile_get(bool *ctgp_enable,
 					    bool *ppab_enable,
 					    u8 *dstate,
@@ -1715,6 +1723,54 @@ static int victus_s_set_cpu_pl1_pl2(u8 pl1, u8 pl2)
 	return ret;
 }
 
+static int platform_profile_victus_s_get_ec(enum platform_profile_option *profile)
+{
+	int ret;
+	int tp;
+	bool current_ctgp_state, current_ppab_state;
+	u8 current_dstate, current_gpu_slowdown_temp;
+
+	tp = omen_thermal_profile_get();
+	if (tp < 0)
+		return tp;
+
+	/*
+	 * We cannot use active_thermal_profile_params here, because boards
+	 * like 8C78 have tp == 0x0 || tp == 0x1 after cold boot, but logically
+	 * it should have tp == 0x30 || tp == 0x31, as corrected by the Omen
+	 * Gaming Hub on windows. Hence accept both of these values.
+	 */
+	if (tp == victus_s_thermal_params.performance ||
+	    tp == omen_v1_thermal_params.performance) {
+		*profile = PLATFORM_PROFILE_PERFORMANCE;
+	} else if (tp == victus_s_thermal_params.balanced ||
+		   tp == omen_v1_thermal_params.balanced) {
+		/*
+		 * Since both PLATFORM_PROFILE_LOW_POWER and
+		 * PLATFORM_PROFILE_BALANCED share the same thermal profile
+		 * parameter value, hence to differentiate between them, we
+		 * query the GPU CTGP and PPAB states and compare based off of
+		 * that.
+		 */
+		ret = victus_s_gpu_thermal_profile_get(&current_ctgp_state,
+						       &current_ppab_state,
+						       &current_dstate,
+						       &current_gpu_slowdown_temp);
+		if (ret < 0)
+			return ret;
+		if (current_ctgp_state == 0 && current_ppab_state == 0)
+			*profile = PLATFORM_PROFILE_LOW_POWER;
+		else if (current_ctgp_state == 0 && current_ppab_state == 1)
+			*profile = PLATFORM_PROFILE_BALANCED;
+		else
+			return -EINVAL;
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int platform_profile_victus_s_set_ec(enum platform_profile_option profile)
 {
 	struct thermal_profile_params *params;
@@ -1882,6 +1938,7 @@ static int victus_s_powersource_event(struct notifier_block *nb,
 				      void *data)
 {
 	struct acpi_bus_event *event_entry = data;
+	enum platform_profile_option actual_profile;
 	int err;
 
 	if (strcmp(event_entry->device_class, ACPI_AC_CLASS) != 0)
@@ -1889,6 +1946,17 @@ static int victus_s_powersource_event(struct notifier_block *nb,
 
 	pr_debug("Received power source device event\n");
 
+	guard(mutex)(&active_platform_profile_lock);
+	err = platform_profile_victus_s_get_ec(&actual_profile);
+	if (err < 0) {
+		/*
+		 * Although we failed to get the current platform profile, we
+		 * still want the other event consumers to process it.
+		 */
+		pr_warn("Failed to read current platform profile (%d)\n", err);
+		return NOTIFY_DONE;
+	}
+
 	/*
 	 * Switching to battery power source while Performance mode is active
 	 * needs manual triggering of CPU power limits. Same goes when switching
@@ -1897,7 +1965,7 @@ static int victus_s_powersource_event(struct notifier_block *nb,
 	 * Seen on HP 16-s1034nf (board 8C9C) with F.11 and F.13 BIOS versions.
 	 */
 
-	if (active_platform_profile == PLATFORM_PROFILE_PERFORMANCE) {
+	if (actual_profile == PLATFORM_PROFILE_PERFORMANCE) {
 		pr_debug("Triggering CPU PL1/PL2 actualization\n");
 		err = victus_s_set_cpu_pl1_pl2(HP_POWER_LIMIT_DEFAULT,
 					       HP_POWER_LIMIT_DEFAULT);
@@ -2007,12 +2075,14 @@ static int thermal_profile_setup(struct platform_device *device)
 
 		ops = &platform_profile_victus_ops;
 	} else if (is_victus_s_thermal_profile()) {
+		err = platform_profile_victus_s_get_ec(&active_platform_profile);
+		if (err < 0)
+			return err;
+
 		/*
-		 * Being unable to retrieve laptop's current thermal profile,
-		 * during this setup, we set it to Balanced by default.
+		 * call thermal profile write command to ensure that the
+		 * firmware correctly sets the OEM variables
 		 */
-		active_platform_profile = PLATFORM_PROFILE_BALANCED;
-
 		err = platform_profile_victus_s_set_ec(active_platform_profile);
 		if (err < 0)
 			return err;
Signature · 1 line
2.52.0
maintainer
#3 lore raw
In reply to Krishna Chomal
Quoted 9 lines · Krishna Chomal

This series fixes incorrect thermal profile parameters sent for HP Omen 16-wf1xxx and implements hardware readback support for Victus S thermal profiles.

The first patch refactors the DMI handling for Victus S boards. By moving from simple string list to DMI system id table with driver_data, we can now map each board to its correct thermal parameters.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

The list of commits applied:
[1/2] platform/x86: hp-wmi: fix platform profile values for Omen 16-wf1xxx

      commit: d8bf01424f9eb555bf13b802a8ddffbb49f221a7
[2/2] platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile
      commit: 2511dd4dbb76ef6914c9b45ccba2492da25d772d

--
i.

#4 lore raw
Quoted 18 lines · Ilpo Järvinen
Quoted 9 lines · Krishna Chomal

This series fixes incorrect thermal profile parameters sent for HP Omen 16-wf1xxx and implements hardware readback support for Victus S thermal profiles.

The first patch refactors the DMI handling for Victus S boards. By moving from simple string list to DMI system id table with driver_data, we can now map each board to its correct thermal parameters.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

Quoted 9 lines

The list of commits applied:
[1/2] platform/x86: hp-wmi: fix platform profile values for Omen 16-wf1xxx

     commit: d8bf01424f9eb555bf13b802a8ddffbb49f221a7
[2/2] platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile
     commit: 2511dd4dbb76ef6914c9b45ccba2492da25d772d

--
i.

Hi Ilpo,

I want to inform you about a potential issue in patch 2/2. My implementation assumed a strict correlation between WMI command types and EC layouts, but I have discovered this isn't universal. Some boards (like 8E35, not present in this driver right now) use Victus S WMI commands but retain the older EC layout (thermal profile offset: 0x95). Directly using offset 0x59 for victus_s devices would not work for boards like 8E35.

To fix this, I suggest updating platform_profile_victus_s_get_ec(), to check both of these offsets for a valid thermal profile.

I can either:
1. Send a follow-up patch to implement this iterative check.
2. Send a v5 with this logic integrated, if you prefer to drop the current series from your review branch.

Please let me know which path you prefer.

maintainer
#5 lore raw
Quoted 41 lines · Krishna Chomal
Quoted 18 lines · Ilpo Järvinen
Quoted 9 lines · Krishna Chomal

This series fixes incorrect thermal profile parameters sent for HP Omen 16-wf1xxx and implements hardware readback support for Victus S thermal profiles.

The first patch refactors the DMI handling for Victus S boards. By moving from simple string list to DMI system id table with driver_data, we can now map each board to its correct thermal parameters.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

Quoted 9 lines

The list of commits applied:
[1/2] platform/x86: hp-wmi: fix platform profile values for Omen 16-wf1xxx

     commit: d8bf01424f9eb555bf13b802a8ddffbb49f221a7
[2/2] platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile
     commit: 2511dd4dbb76ef6914c9b45ccba2492da25d772d

--
i.

Hi Ilpo,

I want to inform you about a potential issue in patch 2/2. My implementation assumed a strict correlation between WMI command types and EC layouts, but I have discovered this isn't universal. Some boards (like 8E35, not present in this driver right now) use Victus S WMI commands but retain the older EC layout (thermal profile offset: 0x95). Directly using offset 0x59 for victus_s devices would not work for boards like 8E35.

To fix this, I suggest updating platform_profile_victus_s_get_ec(), to check both of these offsets for a valid thermal profile.

Quoted 6 lines

I can either:
1. Send a follow-up patch to implement this iterative check.
2. Send a v5 with this logic integrated, if you prefer to drop the current series from your review branch.

Please let me know which path you prefer.

Thanks for following through!

Please just send v5 as I had to drop the wmi series anyway from the review-ilpo-next branch so this was easy drop while at it.

Signature · 1 line
 i.
#6 lore raw

v5 cover Fix Omen 16-wf1xxx thermal profile and add EC readback

In reply to Krishna Chomal

This series fixes incorrect thermal profile parameters sent for HP Omen 16-wf1xxx and implements hardware readback support for Victus S thermal profiles.

The first patch refactors the DMI handling for Victus S boards. By moving from simple string list to DMI system id table with driver_data, we can now map each board to its correct thermal parameters.

The second patch implements "get" callback for the platform profile API. It reads the hardware state from EC register 0x59. This ensures that the driver stays in sync with the hardware during driver init and power source change events.

Changes in v5:
- Improved platform_profile_victus_s_get_ec() to support multiple EC layouts by iteratively probing offsets.
Changes in v4:
- Fixed driver load failure caused in v3
- Handle err after calling victus_s_gpu_thermal_profile_get()
- Fixed wrong function call victus_s_powersource_event() Changes in v3:
- Moved DMI lookup to hp_wmi_init()
- Marked DMI table as __initconst
- Renamed eco to low_power
- Added second patch to implement "get" support for Victus S devices Changes in v2:
- Refactored victus_s_thermal_profile_boards to use DMI table
- Implemented driver_data to handle thermal profile parameters
- Moved enum definitions earlier in the file for thermal profile parameters
Changes in v1:
Initial fix for Omen 16-wf1xxx thermal profile values

Krishna Chomal (2):
platform/x86: hp-wmi: fix platform profile values for Omen 16-wf1xxx platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile

 drivers/platform/x86/hp/hp-wmi.c | 275 ++++++++++++++++++++++++-------
 1 file changed, 214 insertions(+), 61 deletions(-)
Signature · 1 line
2.52.0
#7 lore raw

PATCH v5 1/2 platform/x86: hp-wmi: fix platform profile values for Omen 16-wf1xxx

HP Omen 16-wf1xxx (board ID 8C78) currently sends the incorrect Victus-specific thermal profile values via WMI, leading to a logical inconsistency when switching between platform profiles.

The driver currently uses Victus S values:
0x00 => Balanced / Low-Power
0x01 => Performance

However, Omen Gaming Hub logs / EC register inspection on Windows shows that this board is intended to use:
0x30 => Balanced / Low-Power
0x31 => Performance

This patch corrects the thermal profile command values to match the values observed from Omen Gaming Hub logs. The performance benchmarks and peak power draw (from both CPU and GPU) show no observable change with this correction (suggesting that the firmware is currently tolerant of the incorrect values). However sending the correct values prevents potential regressions after future firmware updates.

Refactor victus_s_thermal_profile_boards from a list of strings to a dmi_system_id table and move the lookup to module init. The new struct thermal_profile_params is used to store board-specific WMI parameters, allowing the driver to cache these values in a static pointer. This avoids repeated DMI string comparisons and allows marking of DMI table as __initconst.

Testing on HP Omen 16-wf1xxx (board 8C78) confirmed WMI codes 0x30/0x31 are now sent, resolving the logical inconsistency and ensuring the value visible in EC registers match the Windows state for this profile.

Fixes fb146a38cb11 ("platform/x86: hp-wmi: Add Omen 16-wf1xxx fan support")

---
Changes in v3:
- Fixed minor formatting issues.
- Renamed struct field eco to low_power for consistency.
- Marked the DMI table as __initconst.
- Moved DMI lookup to hp_wmi_init() and save the active thermal profile params.
- Added a static boolean flag to optimize is_victus_s_thermal_profile(). Changes in v2:
- Refactored victus_s_thermal_profile_boards to use struct dmi_system_id
- Implemented driver_data to handle thermal profile parameters, replacing the conditional checks in platform_profile_victus_s_set_ec
- Moved enum definitions for thermal profile values earlier in the file to support the new struct thermal_profile_params.

---
 drivers/platform/x86/hp/hp-wmi.c | 179 ++++++++++++++++++++++---------
 1 file changed, 127 insertions(+), 52 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +127 -52
index f4ea1ea05997..24d065ddfc6a 100644
@@ -53,6 +53,66 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4");
 
 #define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when zero insize is required
 
+enum hp_thermal_profile_omen_v0 {
+	HP_OMEN_V0_THERMAL_PROFILE_DEFAULT		= 0x00,
+	HP_OMEN_V0_THERMAL_PROFILE_PERFORMANCE		= 0x01,
+	HP_OMEN_V0_THERMAL_PROFILE_COOL			= 0x02,
+};
+
+enum hp_thermal_profile_omen_v1 {
+	HP_OMEN_V1_THERMAL_PROFILE_DEFAULT		= 0x30,
+	HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE		= 0x31,
+	HP_OMEN_V1_THERMAL_PROFILE_COOL			= 0x50,
+};
+
+enum hp_thermal_profile_omen_flags {
+	HP_OMEN_EC_FLAGS_TURBO				= 0x04,
+	HP_OMEN_EC_FLAGS_NOTIMER			= 0x02,
+	HP_OMEN_EC_FLAGS_JUSTSET			= 0x01,
+};
+
+enum hp_thermal_profile_victus {
+	HP_VICTUS_THERMAL_PROFILE_DEFAULT		= 0x00,
+	HP_VICTUS_THERMAL_PROFILE_PERFORMANCE		= 0x01,
+	HP_VICTUS_THERMAL_PROFILE_QUIET			= 0x03,
+};
+
+enum hp_thermal_profile_victus_s {
+	HP_VICTUS_S_THERMAL_PROFILE_DEFAULT		= 0x00,
+	HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE		= 0x01,
+};
+
+enum hp_thermal_profile {
+	HP_THERMAL_PROFILE_PERFORMANCE			= 0x00,
+	HP_THERMAL_PROFILE_DEFAULT			= 0x01,
+	HP_THERMAL_PROFILE_COOL				= 0x02,
+	HP_THERMAL_PROFILE_QUIET			= 0x03,
+};
+
+struct thermal_profile_params {
+	u8 performance;
+	u8 balanced;
+	u8 low_power;
+};
+
+static const struct thermal_profile_params victus_s_thermal_params = {
+	.performance	= HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE,
+	.balanced	= HP_VICTUS_S_THERMAL_PROFILE_DEFAULT,
+	.low_power	= HP_VICTUS_S_THERMAL_PROFILE_DEFAULT,
+};
+
+static const struct thermal_profile_params omen_v1_thermal_params = {
+	.performance	= HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE,
+	.balanced	= HP_OMEN_V1_THERMAL_PROFILE_DEFAULT,
+	.low_power	= HP_OMEN_V1_THERMAL_PROFILE_DEFAULT,
+};
+
+/*
+ * A generic pointer for the currently-active board's thermal profile
+ * parameters.
+ */
+static struct thermal_profile_params *active_thermal_profile_params;
+
 /* DMI board names of devices that should use the omen specific path for
  * thermal profiles.
  * This was obtained by taking a look in the windows omen command center
@@ -99,12 +159,40 @@ static const char * const victus_thermal_profile_boards[] = {
 };
 
 /* DMI Board names of Victus 16-r and Victus 16-s laptops */
-static const char * const victus_s_thermal_profile_boards[] = {
-	"8BBE", "8BD4", "8BD5",
-	"8C78", "8C99", "8C9C",
-	"8D41",
+static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst = {
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BBE") },
+		.driver_data = (void *)&victus_s_thermal_params,
+	},
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD4") },
+		.driver_data = (void *)&victus_s_thermal_params,
+	},
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD5") },
+		.driver_data = (void *)&victus_s_thermal_params,
+	},
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C78") },
+		.driver_data = (void *)&omen_v1_thermal_params,
+	},
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C99") },
+		.driver_data = (void *)&victus_s_thermal_params,
+	},
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C9C") },
+		.driver_data = (void *)&victus_s_thermal_params,
+	},
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8D41") },
+		.driver_data = (void *)&victus_s_thermal_params,
+	},
+	{},
 };
 
+static bool is_victus_s_board;
+
 enum hp_wmi_radio {
 	HPWMI_WIFI	= 0x0,
 	HPWMI_BLUETOOTH	= 0x1,
@@ -225,42 +313,6 @@ enum hp_wireless2_bits {
 	HPWMI_POWER_FW_OR_HW	= HPWMI_POWER_BIOS | HPWMI_POWER_HARD,
 };
 
-enum hp_thermal_profile_omen_v0 {
-	HP_OMEN_V0_THERMAL_PROFILE_DEFAULT     = 0x00,
-	HP_OMEN_V0_THERMAL_PROFILE_PERFORMANCE = 0x01,
-	HP_OMEN_V0_THERMAL_PROFILE_COOL        = 0x02,
-};
-
-enum hp_thermal_profile_omen_v1 {
-	HP_OMEN_V1_THERMAL_PROFILE_DEFAULT	= 0x30,
-	HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE	= 0x31,
-	HP_OMEN_V1_THERMAL_PROFILE_COOL		= 0x50,
-};
-
-enum hp_thermal_profile_omen_flags {
-	HP_OMEN_EC_FLAGS_TURBO		= 0x04,
-	HP_OMEN_EC_FLAGS_NOTIMER	= 0x02,
-	HP_OMEN_EC_FLAGS_JUSTSET	= 0x01,
-};
-
-enum hp_thermal_profile_victus {
-	HP_VICTUS_THERMAL_PROFILE_DEFAULT		= 0x00,
-	HP_VICTUS_THERMAL_PROFILE_PERFORMANCE		= 0x01,
-	HP_VICTUS_THERMAL_PROFILE_QUIET			= 0x03,
-};
-
-enum hp_thermal_profile_victus_s {
-	HP_VICTUS_S_THERMAL_PROFILE_DEFAULT		= 0x00,
-	HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE		= 0x01,
-};
-
-enum hp_thermal_profile {
-	HP_THERMAL_PROFILE_PERFORMANCE	= 0x00,
-	HP_THERMAL_PROFILE_DEFAULT		= 0x01,
-	HP_THERMAL_PROFILE_COOL			= 0x02,
-	HP_THERMAL_PROFILE_QUIET		= 0x03,
-};
-
 #define IS_HWBLOCKED(x) ((x & HPWMI_POWER_FW_OR_HW) != HPWMI_POWER_FW_OR_HW)
 #define IS_SWBLOCKED(x) !(x & HPWMI_POWER_SOFT)
 
@@ -1581,15 +1633,8 @@ static int platform_profile_victus_set_ec(enum platform_profile_option profile)
 
 static bool is_victus_s_thermal_profile(void)
 {
-	const char *board_name;
-
-	board_name = dmi_get_system_info(DMI_BOARD_NAME);
-	if (!board_name)
-		return false;
-
-	return match_string(victus_s_thermal_profile_boards,
-			    ARRAY_SIZE(victus_s_thermal_profile_boards),
-			    board_name) >= 0;
+	/* Initialised in driver init, hence safe to use here */
+	return is_victus_s_board;
 }
 
 static int victus_s_gpu_thermal_profile_get(bool *ctgp_enable,
@@ -1672,25 +1717,30 @@ static int victus_s_set_cpu_pl1_pl2(u8 pl1, u8 pl2)
 
 static int platform_profile_victus_s_set_ec(enum platform_profile_option profile)
 {
+	struct thermal_profile_params *params;
 	bool gpu_ctgp_enable, gpu_ppab_enable;
 	u8 gpu_dstate; /* Test shows 1 = 100%, 2 = 50%, 3 = 25%, 4 = 12.5% */
 	int err, tp;
 
+	params = active_thermal_profile_params;
+	if (!params)
+		return -ENODEV;
+
 	switch (profile) {
 	case PLATFORM_PROFILE_PERFORMANCE:
-		tp = HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE;
+		tp = params->performance;
 		gpu_ctgp_enable = true;
 		gpu_ppab_enable = true;
 		gpu_dstate = 1;
 		break;
 	case PLATFORM_PROFILE_BALANCED:
-		tp = HP_VICTUS_S_THERMAL_PROFILE_DEFAULT;
+		tp = params->balanced;
 		gpu_ctgp_enable = false;
 		gpu_ppab_enable = true;
 		gpu_dstate = 1;
 		break;
 	case PLATFORM_PROFILE_LOW_POWER:
-		tp = HP_VICTUS_S_THERMAL_PROFILE_DEFAULT;
+		tp = params->low_power;
 		gpu_ctgp_enable = false;
 		gpu_ppab_enable = false;
 		gpu_dstate = 1;
@@ -2227,6 +2277,26 @@ static int hp_wmi_hwmon_init(void)
 	return 0;
 }
 
+static void __init setup_active_thermal_profile_params(void)
+{
+	const struct dmi_system_id *id;
+
+	/*
+	 * Currently only victus_s devices use the
+	 * active_thermal_profile_params
+	 */
+	id = dmi_first_match(victus_s_thermal_profile_boards);
+	if (id) {
+		/*
+		 * Marking this boolean is required to ensure that
+		 * is_victus_s_thermal_profile() behaves like a valid
+		 * wrapper.
+		 */
+		is_victus_s_board = true;
+		active_thermal_profile_params = id->driver_data;
+	}
+}
+
 static int __init hp_wmi_init(void)
 {
 	int event_capable = wmi_has_guid(HPWMI_EVENT_GUID);
@@ -2254,6 +2324,11 @@ static int __init hp_wmi_init(void)
 			goto err_destroy_input;
 		}
 
+		/*
+		 * Setup active board's thermal profile parameters before
+		 * starting platform driver probe.
+		 */
+		setup_active_thermal_profile_params();
 		err = platform_driver_probe(&hp_wmi_driver, hp_wmi_bios_setup);
 		if (err)
 			goto err_unregister_device;
Signature · 1 line
2.52.0
#8 lore raw

PATCH v5 2/2 platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile

In reply to Krishna Chomal

The current implementation for Victus S thermal profiles only supports setting the profile. The driver was missing the logic to read the hardware state, meaning it would default to "Balanced" on driver load, overriding the currently active profile. Furthermore, the driver could not detect if the firmware reset the profile on a power source change.

Add platform_profile_victus_s_get_ec() to read the current thermal profile state directly from EC offset 0x59. Since both Balanced and Low-Power profiles share the same thermal profile value, differentiate them by querying the GPU CTGP and PPAB states via existing functions. Additionally, update the power source event notifier to use the actual hardware state when re-trigger CPU power limits actualization.

Testing on HP Omen 16-wf1xxx (board ID 8C78) confirmed that the thermal profile is now persistent across driver loads and power source change events.

---
Changes in v5:
- Improved platform_profile_victus_s_get_ec() to support multiple EC layouts by iteratively probing offsets.
Changes in v4:
- Fixed platform_profile_victus_s_get_ec() to use both victus_s_thermal_params and omen_v1_thermal_params instead of active_thermal_params to fix regression caused in v3.
- Handle err after calling victus_s_gpu_thermal_profile_get().
- Fixed a wrong function call in victus_s_powersource_event(). Changes in v3:
- New patch in this series

---
 drivers/platform/x86/hp/hp-wmi.c | 100 +++++++++++++++++++++++++++----
 1 file changed, 89 insertions(+), 11 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +89 -11
index 24d065ddfc6a..ed52c697d2ea 100644
@@ -13,6 +13,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/array_size.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -44,6 +45,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4");
 #define HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET 0x62
 #define HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET 0x63
 #define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95
+#define HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET 0x59
 
 #define HP_FAN_SPEED_AUTOMATIC	 0x00
 #define HP_POWER_LIMIT_DEFAULT	 0x00
@@ -640,6 +642,12 @@ static bool is_omen_thermal_profile(void)
 			    board_name) >= 0;
 }
 
+static bool is_victus_s_thermal_profile(void)
+{
+	/* Initialised in driver init, hence safe to use here */
+	return is_victus_s_board;
+}
+
 static int omen_get_thermal_policy_version(void)
 {
 	unsigned char buffer[8] = { 0 };
@@ -1631,12 +1639,6 @@ static int platform_profile_victus_set_ec(enum platform_profile_option profile)
 	return 0;
 }
 
-static bool is_victus_s_thermal_profile(void)
-{
-	/* Initialised in driver init, hence safe to use here */
-	return is_victus_s_board;
-}
-
 static int victus_s_gpu_thermal_profile_get(bool *ctgp_enable,
 					    bool *ppab_enable,
 					    u8 *dstate,
@@ -1715,6 +1717,68 @@ static int victus_s_set_cpu_pl1_pl2(u8 pl1, u8 pl2)
 	return ret;
 }
 
+static int platform_profile_victus_s_get_ec(enum platform_profile_option *profile)
+{
+	int ret, i;
+	bool current_ctgp_state, current_ppab_state;
+	u8 current_dstate, current_gpu_slowdown_temp, tp;
+	static const u8 tp_ec_offsets[2] = { HP_OMEN_EC_THERMAL_PROFILE_OFFSET,
+					     HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET };
+
+	/*
+	 * Victus S devices have more than 1 EC layouts, hence we cannot directly
+	 * call omen_thermal_profile_get() like other platform_profile_*_get_ec()
+	 * variants, since it would only resolve to that 1 type of board. Hence
+	 * we iteratively query a set of candidates: tp_ec_offsets[] until we
+	 * find a valid thermal profile.
+	 */
+	for (i = 0 ; i < ARRAY_SIZE(tp_ec_offsets) ; i++) {
+		ret = ec_read(tp_ec_offsets[i], &tp);
+		if (ret)
+			return ret;
+
+		/*
+		 * We cannot use active_thermal_profile_params here, because boards
+		 * like 8C78 have tp == 0x0 || tp == 0x1 after cold boot, but logically
+		 * it should have tp == 0x30 || tp == 0x31, as corrected by the Omen
+		 * Gaming Hub on windows. Hence accept both of these values.
+		 */
+		if (tp == victus_s_thermal_params.performance ||
+		    tp == omen_v1_thermal_params.performance) {
+			*profile = PLATFORM_PROFILE_PERFORMANCE;
+			return 0;
+		} else if (tp == victus_s_thermal_params.balanced ||
+			   tp == omen_v1_thermal_params.balanced) {
+			/*
+			 * Since both PLATFORM_PROFILE_LOW_POWER and
+			 * PLATFORM_PROFILE_BALANCED share the same thermal
+			 * profile parameter value, hence to differentiate
+			 * between them, we query the GPU CTGP and PPAB states
+			 * and compare based off of that.
+			 */
+			ret = victus_s_gpu_thermal_profile_get(&current_ctgp_state,
+							       &current_ppab_state,
+							       &current_dstate,
+							       &current_gpu_slowdown_temp);
+			if (ret < 0)
+				return ret;
+
+			if (current_ctgp_state == 0 && current_ppab_state == 0) {
+				*profile = PLATFORM_PROFILE_LOW_POWER;
+				return 0;
+			} else if (current_ctgp_state == 0 && current_ppab_state == 1) {
+				*profile = PLATFORM_PROFILE_BALANCED;
+				return 0;
+			} else {
+				return -EINVAL;
+			}
+		}
+	}
+
+	/* Failed to get thermal profile from all EC offsets */
+	return -EINVAL;
+}
+
 static int platform_profile_victus_s_set_ec(enum platform_profile_option profile)
 {
 	struct thermal_profile_params *params;
@@ -1882,6 +1946,7 @@ static int victus_s_powersource_event(struct notifier_block *nb,
 				      void *data)
 {
 	struct acpi_bus_event *event_entry = data;
+	enum platform_profile_option actual_profile;
 	int err;
 
 	if (strcmp(event_entry->device_class, ACPI_AC_CLASS) != 0)
@@ -1889,6 +1954,17 @@ static int victus_s_powersource_event(struct notifier_block *nb,
 
 	pr_debug("Received power source device event\n");
 
+	guard(mutex)(&active_platform_profile_lock);
+	err = platform_profile_victus_s_get_ec(&actual_profile);
+	if (err < 0) {
+		/*
+		 * Although we failed to get the current platform profile, we
+		 * still want the other event consumers to process it.
+		 */
+		pr_warn("Failed to read current platform profile (%d)\n", err);
+		return NOTIFY_DONE;
+	}
+
 	/*
 	 * Switching to battery power source while Performance mode is active
 	 * needs manual triggering of CPU power limits. Same goes when switching
@@ -1897,7 +1973,7 @@ static int victus_s_powersource_event(struct notifier_block *nb,
 	 * Seen on HP 16-s1034nf (board 8C9C) with F.11 and F.13 BIOS versions.
 	 */
 
-	if (active_platform_profile == PLATFORM_PROFILE_PERFORMANCE) {
+	if (actual_profile == PLATFORM_PROFILE_PERFORMANCE) {
 		pr_debug("Triggering CPU PL1/PL2 actualization\n");
 		err = victus_s_set_cpu_pl1_pl2(HP_POWER_LIMIT_DEFAULT,
 					       HP_POWER_LIMIT_DEFAULT);
@@ -2007,12 +2083,14 @@ static int thermal_profile_setup(struct platform_device *device)
 
 		ops = &platform_profile_victus_ops;
 	} else if (is_victus_s_thermal_profile()) {
+		err = platform_profile_victus_s_get_ec(&active_platform_profile);
+		if (err < 0)
+			return err;
+
 		/*
-		 * Being unable to retrieve laptop's current thermal profile,
-		 * during this setup, we set it to Balanced by default.
+		 * call thermal profile write command to ensure that the
+		 * firmware correctly sets the OEM variables
 		 */
-		active_platform_profile = PLATFORM_PROFILE_BALANCED;
-
 		err = platform_profile_victus_s_set_ec(active_platform_profile);
 		if (err < 0)
 			return err;
Signature · 1 line
2.52.0
maintainer
#9 lore raw

Re: [PATCH v5 2/2] platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile

Quoted 91 lines · Krishna Chomal

The current implementation for Victus S thermal profiles only supports setting the profile. The driver was missing the logic to read the hardware state, meaning it would default to "Balanced" on driver load, overriding the currently active profile. Furthermore, the driver could not detect if the firmware reset the profile on a power source change.

Add platform_profile_victus_s_get_ec() to read the current thermal profile state directly from EC offset 0x59. Since both Balanced and Low-Power profiles share the same thermal profile value, differentiate them by querying the GPU CTGP and PPAB states via existing functions. Additionally, update the power source event notifier to use the actual hardware state when re-trigger CPU power limits actualization.

Testing on HP Omen 16-wf1xxx (board ID 8C78) confirmed that the thermal profile is now persistent across driver loads and power source change events.

---
Changes in v5:
- Improved platform_profile_victus_s_get_ec() to support multiple EC layouts by iteratively probing offsets.
Changes in v4:
- Fixed platform_profile_victus_s_get_ec() to use both victus_s_thermal_params and omen_v1_thermal_params instead of active_thermal_params to fix regression caused in v3.
- Handle err after calling victus_s_gpu_thermal_profile_get().
- Fixed a wrong function call in victus_s_powersource_event(). Changes in v3:
- New patch in this series

---
 drivers/platform/x86/hp/hp-wmi.c | 100 +++++++++++++++++++++++++++----
 1 file changed, 89 insertions(+), 11 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +15 -6
index 24d065ddfc6a..ed52c697d2ea 100644
@@ -13,6 +13,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/array_size.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -44,6 +45,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4");
 #define HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET 0x62
 #define HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET 0x63
 #define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95
+#define HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET 0x59
 
 #define HP_FAN_SPEED_AUTOMATIC	 0x00
 #define HP_POWER_LIMIT_DEFAULT	 0x00
@@ -640,6 +642,12 @@ static bool is_omen_thermal_profile(void)
 			    board_name) >= 0;
 }
 
+static bool is_victus_s_thermal_profile(void)
+{
+	/* Initialised in driver init, hence safe to use here */
+	return is_victus_s_board;
+}
+
 static int omen_get_thermal_policy_version(void)
 {
 	unsigned char buffer[8] = { 0 };
@@ -1631,12 +1639,6 @@ static int platform_profile_victus_set_ec(enum platform_profile_option profile)
 	return 0;
 }
 
-static bool is_victus_s_thermal_profile(void)
-{
-	/* Initialised in driver init, hence safe to use here */
-	return is_victus_s_board;
-}
-
 static int victus_s_gpu_thermal_profile_get(bool *ctgp_enable,
 					    bool *ppab_enable,
 					    u8 *dstate,
@@ -1715,6 +1717,68 @@ static int victus_s_set_cpu_pl1_pl2(u8 pl1, u8 pl2)
 	return ret;
 }
 
+static int platform_profile_victus_s_get_ec(enum platform_profile_option *profile)
+{
+	int ret, i;
+	bool current_ctgp_state, current_ppab_state;
+	u8 current_dstate, current_gpu_slowdown_temp, tp;
+	static const u8 tp_ec_offsets[2] = { HP_OMEN_EC_THERMAL_PROFILE_OFFSET,
+					     HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET };

drivers/platform/x86/hp/hp-wmi.c static int victus_s_set_cpu_pl1_pl2(u8 pl1, u8 pl2) · line 1736

Quoted 10 lines
drivers/platform/x86/hp/hp-wmi.c +10 -0
+
+	/*
+	 * Victus S devices have more than 1 EC layouts, hence we cannot directly
+	 * call omen_thermal_profile_get() like other platform_profile_*_get_ec()
+	 * variants, since it would only resolve to that 1 type of board. Hence
+	 * we iteratively query a set of candidates: tp_ec_offsets[] until we
+	 * find a valid thermal profile.
+	 */
+	for (i = 0 ; i < ARRAY_SIZE(tp_ec_offsets) ; i++) {
+		ret = ec_read(tp_ec_offsets[i], &tp);

I'm not so sure about this. Reading EC offsets and hoping we find the correct one doesn't sound the best idea. I'd prefer we store the information like we already do for thermal profiles. Unless there's some other way to detect which layout it is?

FYI, I took the first patch of this series again into the review-ilpo-next branch as it seems uncontested and fixes a problem in the existing code.

Signature · 1 line
 i.
Quoted 103 lines
drivers/platform/x86/hp/hp-wmi.c +64 -5
+		if (ret)
+			return ret;
+
+		/*
+		 * We cannot use active_thermal_profile_params here, because boards
+		 * like 8C78 have tp == 0x0 || tp == 0x1 after cold boot, but logically
+		 * it should have tp == 0x30 || tp == 0x31, as corrected by the Omen
+		 * Gaming Hub on windows. Hence accept both of these values.
+		 */
+		if (tp == victus_s_thermal_params.performance ||
+		    tp == omen_v1_thermal_params.performance) {
+			*profile = PLATFORM_PROFILE_PERFORMANCE;
+			return 0;
+		} else if (tp == victus_s_thermal_params.balanced ||
+			   tp == omen_v1_thermal_params.balanced) {
+			/*
+			 * Since both PLATFORM_PROFILE_LOW_POWER and
+			 * PLATFORM_PROFILE_BALANCED share the same thermal
+			 * profile parameter value, hence to differentiate
+			 * between them, we query the GPU CTGP and PPAB states
+			 * and compare based off of that.
+			 */
+			ret = victus_s_gpu_thermal_profile_get(&current_ctgp_state,
+							       &current_ppab_state,
+							       &current_dstate,
+							       &current_gpu_slowdown_temp);
+			if (ret < 0)
+				return ret;
+
+			if (current_ctgp_state == 0 && current_ppab_state == 0) {
+				*profile = PLATFORM_PROFILE_LOW_POWER;
+				return 0;
+			} else if (current_ctgp_state == 0 && current_ppab_state == 1) {
+				*profile = PLATFORM_PROFILE_BALANCED;
+				return 0;
+			} else {
+				return -EINVAL;
+			}
+		}
+	}
+
+	/* Failed to get thermal profile from all EC offsets */
+	return -EINVAL;
+}
+
 static int platform_profile_victus_s_set_ec(enum platform_profile_option profile)
 {
 	struct thermal_profile_params *params;
@@ -1882,6 +1946,7 @@ static int victus_s_powersource_event(struct notifier_block *nb,
 				      void *data)
 {
 	struct acpi_bus_event *event_entry = data;
+	enum platform_profile_option actual_profile;
 	int err;
 
 	if (strcmp(event_entry->device_class, ACPI_AC_CLASS) != 0)
@@ -1889,6 +1954,17 @@ static int victus_s_powersource_event(struct notifier_block *nb,
 
 	pr_debug("Received power source device event\n");
 
+	guard(mutex)(&active_platform_profile_lock);
+	err = platform_profile_victus_s_get_ec(&actual_profile);
+	if (err < 0) {
+		/*
+		 * Although we failed to get the current platform profile, we
+		 * still want the other event consumers to process it.
+		 */
+		pr_warn("Failed to read current platform profile (%d)\n", err);
+		return NOTIFY_DONE;
+	}
+
 	/*
 	 * Switching to battery power source while Performance mode is active
 	 * needs manual triggering of CPU power limits. Same goes when switching
@@ -1897,7 +1973,7 @@ static int victus_s_powersource_event(struct notifier_block *nb,
 	 * Seen on HP 16-s1034nf (board 8C9C) with F.11 and F.13 BIOS versions.
 	 */
 
-	if (active_platform_profile == PLATFORM_PROFILE_PERFORMANCE) {
+	if (actual_profile == PLATFORM_PROFILE_PERFORMANCE) {
 		pr_debug("Triggering CPU PL1/PL2 actualization\n");
 		err = victus_s_set_cpu_pl1_pl2(HP_POWER_LIMIT_DEFAULT,
 					       HP_POWER_LIMIT_DEFAULT);
@@ -2007,12 +2083,14 @@ static int thermal_profile_setup(struct platform_device *device)
 
 		ops = &platform_profile_victus_ops;
 	} else if (is_victus_s_thermal_profile()) {
+		err = platform_profile_victus_s_get_ec(&active_platform_profile);
+		if (err < 0)
+			return err;
+
 		/*
-		 * Being unable to retrieve laptop's current thermal profile,
-		 * during this setup, we set it to Balanced by default.
+		 * call thermal profile write command to ensure that the
+		 * firmware correctly sets the OEM variables
 		 */
-		active_platform_profile = PLATFORM_PROFILE_BALANCED;
-
 		err = platform_profile_victus_s_set_ec(active_platform_profile);
 		if (err < 0)
 			return err;
#10 lore raw

Re: [PATCH v5 2/2] platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile

On Thu, Jan 15, 2026 at 03:26:45PM +0200, Ilpo Järvinen wrote:
[snip]

Quoted 14 lines
Quoted 14 lines
drivers/platform/x86/hp/hp-wmi.c +14 -0
+static int platform_profile_victus_s_get_ec(enum platform_profile_option *profile)
+{
+	int ret, i;
+	bool current_ctgp_state, current_ppab_state;
+	u8 current_dstate, current_gpu_slowdown_temp, tp;
+	static const u8 tp_ec_offsets[2] = { HP_OMEN_EC_THERMAL_PROFILE_OFFSET,
+					     HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET };
+
+	/*
+	 * Victus S devices have more than 1 EC layouts, hence we cannot directly
+	 * call omen_thermal_profile_get() like other platform_profile_*_get_ec()
+	 * variants, since it would only resolve to that 1 type of board. Hence
+	 * we iteratively query a set of candidates: tp_ec_offsets[] until we
+	 * find a valid thermal profile.
Quoted 8 lines

drivers/platform/x86/hp/hp-wmi.c static int victus_s_set_cpu_pl1_pl2(u8 pl1, u8 pl2) · line 1736

Quoted 3 lines
drivers/platform/x86/hp/hp-wmi.c +3 -0
+	 */
+	for (i = 0 ; i < ARRAY_SIZE(tp_ec_offsets) ; i++) {
+		ret = ec_read(tp_ec_offsets[i], &tp);

I'm not so sure about this. Reading EC offsets and hoping we find the correct one doesn't sound the best idea. I'd prefer we store the information like we already do for thermal profiles. Unless there's some other way to detect which layout it is?

I explored the Omen Gaming Hub (OGH) behavior on Windows to see if a WMI query exists for readback. OGH appears to default to "Balanced" on first run and tracks state via a profile.json file on the disk. Deleting this file causes the app to lose the current state, suggesting that there is no official WMI readback query. By implementing EC reads, the driver can actually remain more consistent with the real hardware state than the offcial software.

I agree that iterative EC reads are not ideal. However, since these two offsets (0x95 and 0x59) cover all (or almost all) known Victus/Omen layouts, the risk of "hoping" is low.

Storing them at compile time in the victus_s array as a part of .driver_data is indeed the best thing. But since we do not know what EC layout is followed by the existing boards in the array, we can take a hybrid approach here:
1. I (and subsequent additions) will store their EC offset in the .driver_data field struct.
2. For already existing boards we will perform this iterative probe once during init, and store it somewhere common.
3. Then platform_profile_victus_s_get_ec() can simply use this "definite" offset to perform the EC read.

Quoted 7 lines

FYI, I took the first patch of this series again into the review-ilpo-next branch as it seems uncontested and fixes a problem in the existing code.

Signature · 1 line
i.

Thank you :)

maintainer
#11 lore raw

Re: [PATCH v5 2/2] platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile

Quoted 43 lines · Krishna Chomal

On Thu, Jan 15, 2026 at 03:26:45PM +0200, Ilpo Järvinen wrote:
[snip]

Quoted 20 lines
Quoted 20 lines

+static int platform_profile_victus_s_get_ec(enum platform_profile_option *profile)

drivers/platform/x86/hp/hp-wmi.c +5 -0
+{
+	int ret, i;
+	bool current_ctgp_state, current_ppab_state;
+	u8 current_dstate, current_gpu_slowdown_temp, tp;
+	static const u8 tp_ec_offsets[2] = {

HP_OMEN_EC_THERMAL_PROFILE_OFFSET,
+
HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET };

drivers/platform/x86/hp/hp-wmi.c +3 -0
+
+	/*
+	 * Victus S devices have more than 1 EC layouts, hence we cannot

directly

(quoted diff) +1 -0
+	 * call omen_thermal_profile_get() like other

platform_profile_*_get_ec()

(quoted diff) +1 -0
+	 * variants, since it would only resolve to that 1 type of board.

Hence

drivers/platform/x86/hp/hp-wmi.c +2 -0
+	 * we iteratively query a set of candidates: tp_ec_offsets[] until we
+	 * find a valid thermal profile.
Quoted 8 lines

drivers/platform/x86/hp/hp-wmi.c static int victus_s_set_cpu_pl1_pl2(u8 pl1, u8 pl2) · line 1736

Quoted 3 lines
drivers/platform/x86/hp/hp-wmi.c +3 -0
+	 */
+	for (i = 0 ; i < ARRAY_SIZE(tp_ec_offsets) ; i++) {
+		ret = ec_read(tp_ec_offsets[i], &tp);

I'm not so sure about this. Reading EC offsets and hoping we find the correct one doesn't sound the best idea. I'd prefer we store the information like we already do for thermal profiles. Unless there's some other way to detect which layout it is?

I explored the Omen Gaming Hub (OGH) behavior on Windows to see if a WMI query exists for readback. OGH appears to default to "Balanced" on first run and tracks state via a profile.json file on the disk. Deleting this file causes the app to lose the current state, suggesting that there is no official WMI readback query. By implementing EC reads, the driver can actually remain more consistent with the real hardware state than the offcial software.

I agree that iterative EC reads are not ideal. However, since these two offsets (0x95 and 0x59) cover all (or almost all) known Victus/Omen layouts, the risk of "hoping" is low.

Quoted 10 lines

Storing them at compile time in the victus_s array as a part of .driver_data is indeed the best thing. But since we do not know what EC layout is followed by the existing boards in the array, we can take a hybrid approach here:
1. I (and subsequent additions) will store their EC offset in the .driver_data field struct.
2. For already existing boards we will perform this iterative probe once during init, and store it somewhere common.
3. Then platform_profile_victus_s_get_ec() can simply use this "definite" offset to perform the EC read.

I guess we'll have to settle to that but it likely means we'll never be able to source those offsets because things appear "working" and therefore cannot get rid of the extra code necessary for the EC offset iteration.

Another alternative would be to add pr_warn() if we don't have the EC offset yet for a board and not read anything (and hope somebody who has one of those boards will come to us with the information or patch).

Signature · 1 line
 i.
#12 lore raw

Re: [PATCH v5 2/2] platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile

On Tue, Jan 20, 2026 at 05:10:00PM +0200, Ilpo Järvinen wrote:
[snip]

Quoted 15 lines
Quoted 4 lines

I agree that iterative EC reads are not ideal. However, since these two offsets (0x95 and 0x59) cover all (or almost all) known Victus/Omen layouts, the risk of "hoping" is low.

Quoted 10 lines

Storing them at compile time in the victus_s array as a part of .driver_data is indeed the best thing. But since we do not know what EC layout is followed by the existing boards in the array, we can take a hybrid approach here:
1. I (and subsequent additions) will store their EC offset in the .driver_data field struct.
2. For already existing boards we will perform this iterative probe once during init, and store it somewhere common.
3. Then platform_profile_victus_s_get_ec() can simply use this "definite" offset to perform the EC read.

Quoted 10 lines

I guess we'll have to settle to that but it likely means we'll never be able to source those offsets because things appear "working" and therefore cannot get rid of the extra code necessary for the EC offset iteration.

Another alternative would be to add pr_warn() if we don't have the EC offset yet for a board and not read anything (and hope somebody who has one of those boards will come to us with the information or patch).

Signature · 1 line
i.

Hi Ilpo,

That is a very fair point, if the driver just works, we would never get the actual offsets. I have adopted a stricter version for v6:
1. I removed the iterative probing entirely.
2. Added a pr_warn() in setup_active_thermal_profile_params() for unknown boards.
3. Known boards (like 8C78) now have their offsets hardcoded in the DMI table.

This ensures that thermal profile readback is only enabled when we have definite hardware data. I will send v6, based on the for-next branch, shortly after thorough testing.

Thanks for the guidance!

#13 lore raw

PATCH v6 1/1 platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile

In reply to Krishna Chomal

The current implementation for Victus S thermal profiles only supports setting the profile. The driver was missing the logic to read the hardware state, meaning it would default to "Balanced" on driver load, overriding the currently active profile. Furthermore, the driver could not detect if the firmware reset the profile on a power source change.

Statically store the known EC offsets for reading thermal profile in the new .ec_tp_offset field of struct thermal_profile_params. Implement platform_profile_victus_s_get_ec() to use this offset to read the real hardware state. Additionally, update the power source event notifier to use the actual hardware state when re-triggering CPU power limits actualization.

Testing on HP Omen 16-wf1xxx (board ID 8C78) confirmed that the thermal profile is now persistent across driver loads and power source change events.

---
NOTE: Patch 1/2 of the v5 series (platform/x86: hp-wmi: fix platform profile values for Omen 16-wf1xxx) is already accepted into pdx86/for-next. This v6 contains only the remaining logic for EC readback and is based on the for-next branch.

Changes in v6:
- Update struct thermal_profile_params to include .ec_tp_offset field.
- Use this field for reading from the embedded-controller.
- Add a pr_warn for "unknown ec layout" boards once during init. Changes in v5:
- Improved platform_profile_victus_s_get_ec() to support multiple EC layouts by iteratively probing offsets.
Changes in v4:
- Fixed platform_profile_victus_s_get_ec() to use both victus_s_thermal_params and omen_v1_thermal_params instead of active_thermal_params to fix regression caused in v3.
- Handle err after calling victus_s_gpu_thermal_profile_get().
- Fixed a wrong function call in victus_s_powersource_event(). Changes in v3:
- New patch in this series.

---
 drivers/platform/x86/hp/hp-wmi.c | 103 ++++++++++++++++++++++++++++---
 1 file changed, 96 insertions(+), 7 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +96 -7
index 31c6cca6ec34..304d9ac63c8a 100644
@@ -46,9 +46,13 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4");
 #define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C"
 #define HPWMI_BIOS_GUID "5FB7F034-2C63-45E9-BE91-3D44E2C707E4"
 
-#define HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET 0x62
-#define HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET 0x63
-#define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95
+enum hp_ec_offsets {
+	HP_EC_OFFSET_UNKNOWN				= 0x00,
+	HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET		= 0x59,
+	HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET		= 0x62,
+	HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET		= 0x63,
+	HP_OMEN_EC_THERMAL_PROFILE_OFFSET		= 0x95,
+};
 
 #define HP_FAN_SPEED_AUTOMATIC	 0x00
 #define HP_POWER_LIMIT_DEFAULT	 0x00
@@ -94,22 +98,26 @@ enum hp_thermal_profile {
 	HP_THERMAL_PROFILE_QUIET			= 0x03,
 };
 
+
 struct thermal_profile_params {
 	u8 performance;
 	u8 balanced;
 	u8 low_power;
+	u8 ec_tp_offset;
 };
 
 static const struct thermal_profile_params victus_s_thermal_params = {
 	.performance	= HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE,
 	.balanced	= HP_VICTUS_S_THERMAL_PROFILE_DEFAULT,
 	.low_power	= HP_VICTUS_S_THERMAL_PROFILE_DEFAULT,
+	.ec_tp_offset	= HP_EC_OFFSET_UNKNOWN,
 };
 
 static const struct thermal_profile_params omen_v1_thermal_params = {
 	.performance	= HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE,
 	.balanced	= HP_OMEN_V1_THERMAL_PROFILE_DEFAULT,
 	.low_power	= HP_OMEN_V1_THERMAL_PROFILE_DEFAULT,
+	.ec_tp_offset	= HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET,
 };
 
 /*
@@ -1785,6 +1793,60 @@ static int victus_s_set_cpu_pl1_pl2(u8 pl1, u8 pl2)
 	return ret;
 }
 
+static int platform_profile_victus_s_get_ec(enum platform_profile_option *profile)
+{
+	int ret = 0;
+	bool current_ctgp_state, current_ppab_state;
+	u8 current_dstate, current_gpu_slowdown_temp, tp;
+	const struct thermal_profile_params *params;
+
+	params = active_thermal_profile_params;
+	if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) {
+		*profile = active_platform_profile;
+		return 0;
+	}
+
+	ret = ec_read(params->ec_tp_offset, &tp);
+	if (ret)
+		return ret;
+
+	/*
+	 * We cannot use active_thermal_profile_params here, because boards
+	 * like 8C78 have tp == 0x0 || tp == 0x1 after cold boot, but logically
+	 * it should have tp == 0x30 || tp == 0x31, as corrected by the Omen
+	 * Gaming Hub on windows. Hence accept both of these values.
+	 */
+	if (tp == victus_s_thermal_params.performance ||
+	    tp == omen_v1_thermal_params.performance) {
+		*profile = PLATFORM_PROFILE_PERFORMANCE;
+	} else if (tp == victus_s_thermal_params.balanced ||
+		   tp == omen_v1_thermal_params.balanced) {
+		/*
+		 * Since both PLATFORM_PROFILE_LOW_POWER and
+		 * PLATFORM_PROFILE_BALANCED share the same thermal profile
+		 * parameter value, hence to differentiate between them, we
+		 * query the GPU CTGP and PPAB states and compare based off of
+		 * that.
+		 */
+		ret = victus_s_gpu_thermal_profile_get(&current_ctgp_state,
+						       &current_ppab_state,
+						       &current_dstate,
+						       &current_gpu_slowdown_temp);
+		if (ret < 0)
+			return ret;
+		if (current_ctgp_state == 0 && current_ppab_state == 0)
+			*profile = PLATFORM_PROFILE_LOW_POWER;
+		else if (current_ctgp_state == 0 && current_ppab_state == 1)
+			*profile = PLATFORM_PROFILE_BALANCED;
+		else
+			return -EINVAL;
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int platform_profile_victus_s_set_ec(enum platform_profile_option profile)
 {
 	struct thermal_profile_params *params;
@@ -1952,6 +2014,7 @@ static int victus_s_powersource_event(struct notifier_block *nb,
 				      void *data)
 {
 	struct acpi_bus_event *event_entry = data;
+	enum platform_profile_option actual_profile;
 	int err;
 
 	if (strcmp(event_entry->device_class, ACPI_AC_CLASS) != 0)
@@ -1959,6 +2022,17 @@ static int victus_s_powersource_event(struct notifier_block *nb,
 
 	pr_debug("Received power source device event\n");
 
+	guard(mutex)(&active_platform_profile_lock);
+	err = platform_profile_victus_s_get_ec(&actual_profile);
+	if (err < 0) {
+		/*
+		 * Although we failed to get the current platform profile, we
+		 * still want the other event consumers to process it.
+		 */
+		pr_warn("Failed to read current platform profile (%d)\n", err);
+		return NOTIFY_DONE;
+	}
+
 	/*
 	 * Switching to battery power source while Performance mode is active
 	 * needs manual triggering of CPU power limits. Same goes when switching
@@ -1967,7 +2041,7 @@ static int victus_s_powersource_event(struct notifier_block *nb,
 	 * Seen on HP 16-s1034nf (board 8C9C) with F.11 and F.13 BIOS versions.
 	 */
 
-	if (active_platform_profile == PLATFORM_PROFILE_PERFORMANCE) {
+	if (actual_profile == PLATFORM_PROFILE_PERFORMANCE) {
 		pr_debug("Triggering CPU PL1/PL2 actualization\n");
 		err = victus_s_set_cpu_pl1_pl2(HP_POWER_LIMIT_DEFAULT,
 					       HP_POWER_LIMIT_DEFAULT);
@@ -2078,11 +2152,22 @@ static int thermal_profile_setup(struct platform_device *device)
 		ops = &platform_profile_victus_ops;
 	} else if (is_victus_s_thermal_profile()) {
 		/*
-		 * Being unable to retrieve laptop's current thermal profile,
-		 * during this setup, we set it to Balanced by default.
+		 * For an unknown EC layout board, platform_profile_victus_s_get_ec(),
+		 * behaves like a wrapper around active_platform_profile, to avoid using
+		 * uninitialized data, we default to PLATFORM_PROFILE_BALANCED.
 		 */
-		active_platform_profile = PLATFORM_PROFILE_BALANCED;
+		if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) {
+			active_platform_profile = PLATFORM_PROFILE_BALANCED;
+		} else {
+			err = platform_profile_victus_s_get_ec(&active_platform_profile);
+			if (err < 0)
+				return err;
+		}
 
+		/*
+		 * call thermal profile write command to ensure that the
+		 * firmware correctly sets the OEM variables
+		 */
 		err = platform_profile_victus_s_set_ec(active_platform_profile);
 		if (err < 0)
 			return err;
@@ -2505,6 +2590,10 @@ static void __init setup_active_thermal_profile_params(void)
 		 */
 		is_victus_s_board = true;
 		active_thermal_profile_params = id->driver_data;
+		if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) {
+			pr_warn("Unknown EC layout for board %s. Thermal profile readback will be disabled. Please report this to [email protected]\n",
+				dmi_get_system_info(DMI_BOARD_NAME));
+		}
 	}
 }
 
Signature · 1 line
2.52.0
maintainer
#14 lore raw
In reply to Krishna Chomal
Quoted 9 lines · Krishna Chomal

This series fixes incorrect thermal profile parameters sent for HP Omen 16-wf1xxx and implements hardware readback support for Victus S thermal profiles.

The first patch refactors the DMI handling for Victus S boards. By moving from simple string list to DMI system id table with driver_data, we can now map each board to its correct thermal parameters.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile

      commit: eeeb4c9874bb7ad11d322156443b1d3ebfaaa1cf

--
i.

#15 lore raw
Quoted 18 lines · Ilpo Järvinen
Quoted 9 lines · Krishna Chomal

This series fixes incorrect thermal profile parameters sent for HP Omen 16-wf1xxx and implements hardware readback support for Victus S thermal profiles.

The first patch refactors the DMI handling for Victus S boards. By moving from simple string list to DMI system id table with driver_data, we can now map each board to its correct thermal parameters.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

Quoted 7 lines

The list of commits applied:
[1/1] platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile

     commit: eeeb4c9874bb7ad11d322156443b1d3ebfaaa1cf

--
i.

Thank you :)