Skip to contentSkip to conversation

platform/x86: hp-wmi: Add Victus 15-fb0xxx support

PATCH Superseded Radhey Kalra 2 participants 10 messages Jun 6 – Jun 10 x86 platform drivers

v9 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v9 cover platform/x86: hp-wmi: Add Victus 15-fb0xxx support

Hi,

This is a split version of the Victus 15-fb0xxx support change. Patches 1 and 2 are no-functional-changes-intended refactors which move the existing thermal-profile and fan-control decisions into board-specific .driver_data. Patch 3 adds support for Victus 15-fb0xxx board 8A3D.

v9 keeps the gpu_delta fan-table parsing fix out of this series. Ilpo suggested postponing that part to the other GPU fan series, so this version keeps only the board-data and 8A3D support pieces.

The last public review discussion was on the earlier v6 0/4 thread. This series follows up on that by dropping the gpu_delta patch from this series, testing the Victus S thermal-profile path on 8A3D, and keeping 8A3D on the Victus S thermal-profile and fan-control data.

v9 is a resend after one week with no review comments. There are no code changes from v8 because platform-drivers-x86/review-ilpo-next and for-next have not moved since v8. v8 already rebased the v7 series from commit 5fdac9983681 to a167ae8eace5, preserving the newer 8902 board entry and the system_dfl_wq delayed-work change.

I accidentally sent the corrected 3-patch version as v6 after an earlier v6 had already been sent. v7 fixed the version number for that corrected structure.

v9 is based on platform-drivers-x86/review-ilpo-next commit a167ae8eace52dd6c80438b77d92450fe12cd4be, which is still current on review-ilpo-next and for-next. It preserves the newer 8902 hp-wmi board entry.

8A3D is added with both the Victus S thermal-profile data and the Victus fan-control data. The existing generic platform-profile sysfs path on 8A3D accepts writes/readbacks without hp_wmi errors, and the Victus fan table/control path exposes working PWM control.

Tested on a Victus by HP Gaming Laptop 15-fb0xxx, board 8A3D, BIOS F.22. With the series applied, the platform-profile choices are low-power, balanced, and performance. Writes to all three profiles succeeded and read back the selected value. In a CPU stress test with powerprofilesctl held at performance, low-power reduced CPU package power to about 30 W, while balanced and performance both ran at about 47 W. In a light PRIME offload test, low-power also kept the NVIDIA GPU at lower clocks and power than the other profiles. pwm1 and pwm1_enable are exposed through hwmon.

Radhey Kalra (3):
platform/x86: hp-wmi: Introduce board-specific feature data platform/x86: hp-wmi: Drive fan control from board data platform/x86: hp-wmi: Add Victus 15-fb0xxx support

 drivers/platform/x86/hp/hp-wmi.c | 209 ++++++++++++++++++++++---------
 1 file changed, 150 insertions(+), 59 deletions(-)

---
Changes in v9:
- Resend after one week with no review comments.
- Clarify that the series follows up on the earlier v6 0/4 review by dropping the gpu_delta patch and using the tested Victus S path.
- No code changes from v8 because the target platform-drivers-x86 branch has not moved since v8.
- Recheck that platform-drivers-x86/review-ilpo-next and for-next still point at commit a167ae8eace5.

Changes in v8:
- Resend after one week with no review comments.
- Rebase on platform-drivers-x86/review-ilpo-next commit a167ae8eace5 to preserve the newer 8902 hp-wmi board entry.
- Keep the gpu_delta fan-table parser fix out of this series; it can be handled with the other GPU fan series.
- Add Hans de Goede to Cc per MAINTAINERS for X86 PLATFORM DRIVERS.

Changes in v7:
- Bump the version because v6 was already sent.
- Note that the corrected 3-patch version was accidentally sent as v6 after an earlier v6 had already been sent.
- Keep the gpu_delta fan-table parser fix out of this series; it can be handled with the other GPU fan series.
- Keep 8A3D on the Victus S thermal-profile path after testing profile writes/readbacks, CPU package power, and light PRIME offload behavior.

Changes in v6:
- Drop the gpu_delta fan-table parser fix for now; it can be handled with the other GPU fan series.
- Rebase on platform-drivers-x86/for-next commit 5fdac9983681.
- Preserve the recently added 8BC2 board entry.
- Preserve the 8D41 switch to omen_v1_no_ec_thermal_params.
- Add 8A3D with Victus S thermal-profile data and Victus fan-control data.

Changes in v5:
- Drop the active_thermal_profile_params global and dereference the thermal-profile data through active_board_params.
- Move the generic fan-only board handling into patch 1, keeping the final 8A3D patch focused on adding the board data and DMI match.
- Wrap the setup comment added in patch 1 to stay under 80 columns.

Changes in v4:
- Split v3 into two no-functional-changes-intended refactors, one fan-table parsing fix, and one 8A3D support patch.
- Rebase on platform-drivers-x86/for-next commit 165e81354eefd555.
- Move revision notes to the cover letter.

Changes in v3:
- Rebase on platform-drivers-x86/for-next commit 165e81354eefd555.
- Keep the v2 board-data approach and 8A3D fan-control-only handling.

Changes in v2:
- Use real name in Signed-off-by.
- Replace the ad-hoc fan-control DMI table with board data in .driver_data.
- Keep 8A3D fan-control-only instead of enabling Victus S thermal profiles.
- Use the fixed fan-table parser path and derive gpu_delta from the first non-zero GPU row.

Signature · 1 line
2.54.0
#1 lore raw

PATCH v9 1/3 platform/x86: hp-wmi: Introduce board-specific feature data

The hp_wmi DMI table is about to carry more than thermal-profile data. Replace the direct thermal_profile_params .driver_data pointers with hp_wmi_board_params and rename the table/setup helper accordingly.

No functional changes intended.

---
 drivers/platform/x86/hp/hp-wmi.c | 121 ++++++++++++++++++++-----------
 1 file changed, 77 insertions(+), 44 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +77 -44
index 48292cc..4a795e6 100644
@@ -133,11 +133,35 @@ static const struct thermal_profile_params omen_v1_no_ec_thermal_params = {
 	.ec_tp_offset	= HP_NO_THERMAL_PROFILE_OFFSET,
 };
 
-/*
- * A generic pointer for the currently-active board's thermal profile
- * parameters.
- */
-static struct thermal_profile_params *active_thermal_profile_params;
+struct hp_wmi_board_params {
+	const struct thermal_profile_params *thermal_profile;
+};
+
+static const struct hp_wmi_board_params victus_s_board_params = {
+	.thermal_profile	= &victus_s_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_board_params = {
+	.thermal_profile	= &omen_v1_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_legacy_board_params = {
+	.thermal_profile	= &omen_v1_legacy_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_no_ec_board_params = {
+	.thermal_profile	= &omen_v1_no_ec_thermal_params,
+};
+
+static const struct hp_wmi_board_params *active_board_params;
+
+static const struct thermal_profile_params *hp_wmi_thermal_profile(void)
+{
+	if (!active_board_params)
+		return NULL;
+
+	return active_board_params->thermal_profile;
+}
 
 /* DMI board names of devices that should use the omen specific path for
  * thermal profiles.
@@ -187,75 +211,75 @@ static const char * const victus_thermal_profile_boards[] = {
 	"8A25",
 };
 
-/* DMI Board names of Victus 16-r and Victus 16-s laptops */
-static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst = {
+/* DMI board-specific feature data for Omen and Victus laptops. */
+static const struct dmi_system_id hp_wmi_feature_boards[] __initconst = {
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8902") },
-		.driver_data = (void *)&omen_v1_legacy_thermal_params,
+		.driver_data = (void *)&omen_v1_legacy_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8A44") },
-		.driver_data = (void *)&omen_v1_legacy_thermal_params,
+		.driver_data = (void *)&omen_v1_legacy_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8A4D") },
-		.driver_data = (void *)&omen_v1_legacy_thermal_params,
+		.driver_data = (void *)&omen_v1_legacy_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BAB") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BBE") },
-		.driver_data = (void *)&victus_s_thermal_params,
+		.driver_data = (void *)&victus_s_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BC2") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BCA") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BCD") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD4") },
-		.driver_data = (void *)&victus_s_thermal_params,
+		.driver_data = (void *)&victus_s_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD5") },
-		.driver_data = (void *)&victus_s_thermal_params,
+		.driver_data = (void *)&victus_s_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C76") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C77") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C78") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C99") },
-		.driver_data = (void *)&victus_s_thermal_params,
+		.driver_data = (void *)&victus_s_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C9C") },
-		.driver_data = (void *)&victus_s_thermal_params,
+		.driver_data = (void *)&victus_s_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8D41") },
-		.driver_data = (void *)&omen_v1_no_ec_thermal_params,
+		.driver_data = (void *)&omen_v1_no_ec_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8D87") },
-		.driver_data = (void *)&omen_v1_no_ec_thermal_params,
+		.driver_data = (void *)&omen_v1_no_ec_board_params,
 	},
 	{},
 };
@@ -1862,7 +1886,10 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
 	u8 current_dstate, current_gpu_slowdown_temp, tp;
 	const struct thermal_profile_params *params;
 
-	params = active_thermal_profile_params;
+	params = hp_wmi_thermal_profile();
+	if (!params)
+		return -ENODEV;
+
 	if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
 	    params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
 		*profile = active_platform_profile;
@@ -1874,10 +1901,10 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
 		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.
+	 * 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) {
@@ -1912,12 +1939,12 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
 
 static int platform_profile_victus_s_set_ec(enum platform_profile_option profile)
 {
-	struct thermal_profile_params *params;
+	const 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;
+	params = hp_wmi_thermal_profile();
 	if (!params)
 		return -ENODEV;
 
@@ -2183,6 +2210,7 @@ static const struct platform_profile_ops hp_wmi_platform_profile_ops = {
 static int thermal_profile_setup(struct platform_device *device)
 {
 	const struct platform_profile_ops *ops;
+	const struct thermal_profile_params *params;
 	int err, tp;
 
 	if (is_omen_thermal_profile()) {
@@ -2214,13 +2242,17 @@ static int thermal_profile_setup(struct platform_device *device)
 
 		ops = &platform_profile_victus_ops;
 	} else if (is_victus_s_thermal_profile()) {
+		params = hp_wmi_thermal_profile();
+		if (!params)
+			return -ENODEV;
+
 		/*
 		 * 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.
 		 */
-		if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
-		    active_thermal_profile_params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
+		if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
+		    params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
 			active_platform_profile = PLATFORM_PROFILE_BALANCED;
 		} else {
 			err = platform_profile_victus_s_get_ec(&active_platform_profile);
@@ -2681,24 +2713,25 @@ static int hp_wmi_hwmon_init(void)
 	return 0;
 }
 
-static void __init setup_active_thermal_profile_params(void)
+static void __init setup_active_board_params(void)
 {
 	const struct dmi_system_id *id;
+	const struct thermal_profile_params *params;
 
-	/*
-	 * Currently only victus_s devices use the
-	 * active_thermal_profile_params
-	 */
-	id = dmi_first_match(victus_s_thermal_profile_boards);
+	id = dmi_first_match(hp_wmi_feature_boards);
 	if (id) {
+		active_board_params = id->driver_data;
+		params = hp_wmi_thermal_profile();
+		if (!params)
+			return;
+
 		/*
 		 * 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;
-		if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) {
+		if (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));
 		}
@@ -2733,10 +2766,10 @@ static int __init hp_wmi_init(void)
 		}
 
 		/*
-		 * Setup active board's thermal profile parameters before
-		 * starting platform driver probe.
+		 * Setup active board feature data before starting platform
+		 * driver probe.
 		 */
-		setup_active_thermal_profile_params();
+		setup_active_board_params();
 		err = platform_driver_probe(&hp_wmi_driver, hp_wmi_bios_setup);
 		if (err)
 			goto err_unregister_device;
Signature · 1 line
2.54.0
maintainer
#2 lore raw

Re: [PATCH v9 1/3] platform/x86: hp-wmi: Introduce board-specific feature data

Quoted 141 lines · Radhey Kalra

The hp_wmi DMI table is about to carry more than thermal-profile data. Replace the direct thermal_profile_params .driver_data pointers with hp_wmi_board_params and rename the table/setup helper accordingly.

No functional changes intended.

---
 drivers/platform/x86/hp/hp-wmi.c | 121 ++++++++++++++++++++-----------
 1 file changed, 77 insertions(+), 44 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +46 -22
index 48292cc..4a795e6 100644
@@ -133,11 +133,35 @@ static const struct thermal_profile_params omen_v1_no_ec_thermal_params = {
 	.ec_tp_offset	= HP_NO_THERMAL_PROFILE_OFFSET,
 };
 
-/*
- * A generic pointer for the currently-active board's thermal profile
- * parameters.
- */
-static struct thermal_profile_params *active_thermal_profile_params;
+struct hp_wmi_board_params {
+	const struct thermal_profile_params *thermal_profile;
+};
+
+static const struct hp_wmi_board_params victus_s_board_params = {
+	.thermal_profile	= &victus_s_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_board_params = {
+	.thermal_profile	= &omen_v1_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_legacy_board_params = {
+	.thermal_profile	= &omen_v1_legacy_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_no_ec_board_params = {
+	.thermal_profile	= &omen_v1_no_ec_thermal_params,
+};
+
+static const struct hp_wmi_board_params *active_board_params;
+
+static const struct thermal_profile_params *hp_wmi_thermal_profile(void)
+{
+	if (!active_board_params)
+		return NULL;
+
+	return active_board_params->thermal_profile;
+}
 
 /* DMI board names of devices that should use the omen specific path for
  * thermal profiles.
@@ -187,75 +211,75 @@ static const char * const victus_thermal_profile_boards[] = {
 	"8A25",
 };
 
-/* DMI Board names of Victus 16-r and Victus 16-s laptops */
-static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst = {
+/* DMI board-specific feature data for Omen and Victus laptops. */
+static const struct dmi_system_id hp_wmi_feature_boards[] __initconst = {
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8902") },
-		.driver_data = (void *)&omen_v1_legacy_thermal_params,
+		.driver_data = (void *)&omen_v1_legacy_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8A44") },
-		.driver_data = (void *)&omen_v1_legacy_thermal_params,
+		.driver_data = (void *)&omen_v1_legacy_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8A4D") },
-		.driver_data = (void *)&omen_v1_legacy_thermal_params,
+		.driver_data = (void *)&omen_v1_legacy_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BAB") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BBE") },
-		.driver_data = (void *)&victus_s_thermal_params,
+		.driver_data = (void *)&victus_s_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BC2") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BCA") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BCD") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD4") },
-		.driver_data = (void *)&victus_s_thermal_params,
+		.driver_data = (void *)&victus_s_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD5") },
-		.driver_data = (void *)&victus_s_thermal_params,
+		.driver_data = (void *)&victus_s_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C76") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C77") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C78") },
-		.driver_data = (void *)&omen_v1_thermal_params,
+		.driver_data = (void *)&omen_v1_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C99") },
-		.driver_data = (void *)&victus_s_thermal_params,
+		.driver_data = (void *)&victus_s_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8C9C") },
-		.driver_data = (void *)&victus_s_thermal_params,
+		.driver_data = (void *)&victus_s_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8D41") },

drivers/platform/x86/hp/hp-wmi.c static const char * const victus_thermal_profile_boards[] = { · line 285

Quoted 10 lines
drivers/platform/x86/hp/hp-wmi.c +2 -2
-		.driver_data = (void *)&omen_v1_no_ec_thermal_params,
+		.driver_data = (void *)&omen_v1_no_ec_board_params,
 	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8D87") },
-		.driver_data = (void *)&omen_v1_no_ec_thermal_params,
+		.driver_data = (void *)&omen_v1_no_ec_board_params,
 	},
 	{},
 };

Could you do a rebase for this as there are a few ID additions in the for-next branch so I don't need to handle the conversion myself.

Quoted 119 lines
drivers/platform/x86/hp/hp-wmi.c +29 -20
@@ -1862,7 +1886,10 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
 	u8 current_dstate, current_gpu_slowdown_temp, tp;
 	const struct thermal_profile_params *params;
 
-	params = active_thermal_profile_params;
+	params = hp_wmi_thermal_profile();
+	if (!params)
+		return -ENODEV;
+
 	if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
 	    params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
 		*profile = active_platform_profile;
@@ -1874,10 +1901,10 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
 		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.
+	 * 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) {
@@ -1912,12 +1939,12 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
 
 static int platform_profile_victus_s_set_ec(enum platform_profile_option profile)
 {
-	struct thermal_profile_params *params;
+	const 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;
+	params = hp_wmi_thermal_profile();
 	if (!params)
 		return -ENODEV;
 
@@ -2183,6 +2210,7 @@ static const struct platform_profile_ops hp_wmi_platform_profile_ops = {
 static int thermal_profile_setup(struct platform_device *device)
 {
 	const struct platform_profile_ops *ops;
+	const struct thermal_profile_params *params;
 	int err, tp;
 
 	if (is_omen_thermal_profile()) {
@@ -2214,13 +2242,17 @@ static int thermal_profile_setup(struct platform_device *device)
 
 		ops = &platform_profile_victus_ops;
 	} else if (is_victus_s_thermal_profile()) {
+		params = hp_wmi_thermal_profile();
+		if (!params)
+			return -ENODEV;
+
 		/*
 		 * 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.
 		 */
-		if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
-		    active_thermal_profile_params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
+		if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
+		    params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
 			active_platform_profile = PLATFORM_PROFILE_BALANCED;
 		} else {
 			err = platform_profile_victus_s_get_ec(&active_platform_profile);
@@ -2681,24 +2713,25 @@ static int hp_wmi_hwmon_init(void)
 	return 0;
 }
 
-static void __init setup_active_thermal_profile_params(void)
+static void __init setup_active_board_params(void)
 {
 	const struct dmi_system_id *id;
+	const struct thermal_profile_params *params;
 
-	/*
-	 * Currently only victus_s devices use the
-	 * active_thermal_profile_params
-	 */
-	id = dmi_first_match(victus_s_thermal_profile_boards);
+	id = dmi_first_match(hp_wmi_feature_boards);
 	if (id) {
+		active_board_params = id->driver_data;
+		params = hp_wmi_thermal_profile();
+		if (!params)
+			return;
+
 		/*
 		 * 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;
-		if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) {
+		if (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));
 		}
@@ -2733,10 +2766,10 @@ static int __init hp_wmi_init(void)
 		}
 
 		/*
-		 * Setup active board's thermal profile parameters before
-		 * starting platform driver probe.
+		 * Setup active board feature data before starting platform
+		 * driver probe.
 		 */
-		setup_active_thermal_profile_params();
+		setup_active_board_params();
 		err = platform_driver_probe(&hp_wmi_driver, hp_wmi_bios_setup);
 		if (err)
 			goto err_unregister_device;
Signature · 1 line
 i.
#3 lore raw

Re: [PATCH v9 1/3] platform/x86: hp-wmi: Introduce board-specific feature data

Hi Ilpo,

Will do. I'll rebase this series against for-next and send v10 shortly.

Thanks, Radhey

Quoted 281 lines · Ilpo Järvinen
Quoted 141 lines · Radhey Kalra

The hp_wmi DMI table is about to carry more than thermal-profile data. Replace the direct thermal_profile_params .driver_data pointers with hp_wmi_board_params and rename the table/setup helper accordingly.

No functional changes intended.

---
 drivers/platform/x86/hp/hp-wmi.c | 121 ++++++++++++++++++++-----------
 1 file changed, 77 insertions(+), 44 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +46 -22
index 48292cc..4a795e6 100644
@@ -133,11 +133,35 @@ static const struct thermal_profile_params omen_v1_no_ec_thermal_params = {
      .ec_tp_offset   = HP_NO_THERMAL_PROFILE_OFFSET,
 };
 
-/*
- * A generic pointer for the currently-active board's thermal profile
- * parameters.
- */
-static struct thermal_profile_params *active_thermal_profile_params;
+struct hp_wmi_board_params {
+     const struct thermal_profile_params *thermal_profile;
+};
+
+static const struct hp_wmi_board_params victus_s_board_params = {
+     .thermal_profile        = &victus_s_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_board_params = {
+     .thermal_profile        = &omen_v1_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_legacy_board_params = {
+     .thermal_profile        = &omen_v1_legacy_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_no_ec_board_params = {
+     .thermal_profile        = &omen_v1_no_ec_thermal_params,
+};
+
+static const struct hp_wmi_board_params *active_board_params;
+
+static const struct thermal_profile_params *hp_wmi_thermal_profile(void)
+{
+     if (!active_board_params)
+             return NULL;
+
+     return active_board_params->thermal_profile;
+}
 
 /* DMI board names of devices that should use the omen specific path for
  * thermal profiles.
@@ -187,75 +211,75 @@ static const char * const victus_thermal_profile_boards[] = {
      "8A25",
 };
 
-/* DMI Board names of Victus 16-r and Victus 16-s laptops */
-static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst = {
+/* DMI board-specific feature data for Omen and Victus laptops. */
+static const struct dmi_system_id hp_wmi_feature_boards[] __initconst = {
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8902") },
-             .driver_data = (void *)&omen_v1_legacy_thermal_params,
+             .driver_data = (void *)&omen_v1_legacy_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8A44") },
-             .driver_data = (void *)&omen_v1_legacy_thermal_params,
+             .driver_data = (void *)&omen_v1_legacy_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8A4D") },
-             .driver_data = (void *)&omen_v1_legacy_thermal_params,
+             .driver_data = (void *)&omen_v1_legacy_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BAB") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BBE") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BC2") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BCA") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BCD") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD4") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD5") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C76") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C77") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C78") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C99") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C9C") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8D41") },

drivers/platform/x86/hp/hp-wmi.c static const char * const victus_thermal_profile_boards[] = { · line 285

Quoted 10 lines
drivers/platform/x86/hp/hp-wmi.c +2 -2
-             .driver_data = (void *)&omen_v1_no_ec_thermal_params,
+             .driver_data = (void *)&omen_v1_no_ec_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8D87") },
-             .driver_data = (void *)&omen_v1_no_ec_thermal_params,
+             .driver_data = (void *)&omen_v1_no_ec_board_params,
      },
      {},
 };

Could you do a rebase for this as there are a few ID additions in the for-next branch so I don't need to handle the conversion myself.

Quoted 109 lines
drivers/platform/x86/hp/hp-wmi.c +26 -17
@@ -1862,7 +1886,10 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
      u8 current_dstate, current_gpu_slowdown_temp, tp;
      const struct thermal_profile_params *params;
 
-     params = active_thermal_profile_params;
+     params = hp_wmi_thermal_profile();
+     if (!params)
+             return -ENODEV;
+
      if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
          params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
              *profile = active_platform_profile;
@@ -1874,10 +1901,10 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
              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.
+      * 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) {
@@ -1912,12 +1939,12 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
 
 static int platform_profile_victus_s_set_ec(enum platform_profile_option profile)
 {
-     struct thermal_profile_params *params;
+     const 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;
+     params = hp_wmi_thermal_profile();
      if (!params)
              return -ENODEV;
 
@@ -2183,6 +2210,7 @@ static const struct platform_profile_ops hp_wmi_platform_profile_ops = {
 static int thermal_profile_setup(struct platform_device *device)
 {
      const struct platform_profile_ops *ops;
+     const struct thermal_profile_params *params;
      int err, tp;
 
      if (is_omen_thermal_profile()) {
@@ -2214,13 +2242,17 @@ static int thermal_profile_setup(struct platform_device *device)
 
              ops = &platform_profile_victus_ops;
      } else if (is_victus_s_thermal_profile()) {
+             params = hp_wmi_thermal_profile();
+             if (!params)
+                     return -ENODEV;
+
              /*
               * 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.
               */
-             if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
-                 active_thermal_profile_params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
+             if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
+                 params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
                      active_platform_profile = PLATFORM_PROFILE_BALANCED;
              } else {
                      err = platform_profile_victus_s_get_ec(&active_platform_profile);
@@ -2681,24 +2713,25 @@ static int hp_wmi_hwmon_init(void)
      return 0;
 }
 
-static void __init setup_active_thermal_profile_params(void)
+static void __init setup_active_board_params(void)
 {
      const struct dmi_system_id *id;
+     const struct thermal_profile_params *params;
 
-     /*
-      * Currently only victus_s devices use the
-      * active_thermal_profile_params
-      */
-     id = dmi_first_match(victus_s_thermal_profile_boards);
+     id = dmi_first_match(hp_wmi_feature_boards);
      if (id) {
+             active_board_params = id->driver_data;
+             params = hp_wmi_thermal_profile();
+             if (!params)
+                     return;
+
              /*
               * 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;
-             if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) {
+             if (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));
              }
@@ -2733,10 +2766,10 @@ static int __init hp_wmi_init(void)
              }
 
              /*

drivers/platform/x86/hp/hp-wmi.c static int __init hp_wmi_init(void) · line 2775

Quoted 10 lines
drivers/platform/x86/hp/hp-wmi.c +3 -3
-              * Setup active board's thermal profile parameters before
-              * starting platform driver probe.
+              * Setup active board feature data before starting platform
+              * driver probe.
               */
-             setup_active_thermal_profile_params();
+             setup_active_board_params();
              err = platform_driver_probe(&hp_wmi_driver, hp_wmi_bios_setup);
              if (err)
                      goto err_unregister_device;

--
i.

maintainer
#4 lore raw

Re: [PATCH v9 1/3] platform/x86: hp-wmi: Introduce board-specific feature data

Quoted 3 lines · Radhey Kalra

Hi Ilpo,

Will do. I'll rebase this series against for-next and send v10 shortly.

It seems I had a problem in my end, so all the ID changes are only now in for-next. I'm sorry about the extra hassle.

--
i.

Quoted 287 lines

Thanks, Radhey

Quoted 281 lines · Ilpo Järvinen
Quoted 141 lines · Radhey Kalra

The hp_wmi DMI table is about to carry more than thermal-profile data. Replace the direct thermal_profile_params .driver_data pointers with hp_wmi_board_params and rename the table/setup helper accordingly.

No functional changes intended.

---
 drivers/platform/x86/hp/hp-wmi.c | 121 ++++++++++++++++++++-----------
 1 file changed, 77 insertions(+), 44 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +46 -22
index 48292cc..4a795e6 100644
@@ -133,11 +133,35 @@ static const struct thermal_profile_params omen_v1_no_ec_thermal_params = {
      .ec_tp_offset   = HP_NO_THERMAL_PROFILE_OFFSET,
 };
 
-/*
- * A generic pointer for the currently-active board's thermal profile
- * parameters.
- */
-static struct thermal_profile_params *active_thermal_profile_params;
+struct hp_wmi_board_params {
+     const struct thermal_profile_params *thermal_profile;
+};
+
+static const struct hp_wmi_board_params victus_s_board_params = {
+     .thermal_profile        = &victus_s_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_board_params = {
+     .thermal_profile        = &omen_v1_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_legacy_board_params = {
+     .thermal_profile        = &omen_v1_legacy_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_no_ec_board_params = {
+     .thermal_profile        = &omen_v1_no_ec_thermal_params,
+};
+
+static const struct hp_wmi_board_params *active_board_params;
+
+static const struct thermal_profile_params *hp_wmi_thermal_profile(void)
+{
+     if (!active_board_params)
+             return NULL;
+
+     return active_board_params->thermal_profile;
+}
 
 /* DMI board names of devices that should use the omen specific path for
  * thermal profiles.
@@ -187,75 +211,75 @@ static const char * const victus_thermal_profile_boards[] = {
      "8A25",
 };
 
-/* DMI Board names of Victus 16-r and Victus 16-s laptops */
-static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst = {
+/* DMI board-specific feature data for Omen and Victus laptops. */
+static const struct dmi_system_id hp_wmi_feature_boards[] __initconst = {
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8902") },
-             .driver_data = (void *)&omen_v1_legacy_thermal_params,
+             .driver_data = (void *)&omen_v1_legacy_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8A44") },
-             .driver_data = (void *)&omen_v1_legacy_thermal_params,
+             .driver_data = (void *)&omen_v1_legacy_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8A4D") },
-             .driver_data = (void *)&omen_v1_legacy_thermal_params,
+             .driver_data = (void *)&omen_v1_legacy_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BAB") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BBE") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BC2") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BCA") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BCD") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD4") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD5") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C76") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C77") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C78") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C99") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C9C") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8D41") },

drivers/platform/x86/hp/hp-wmi.c static const char * const victus_thermal_profile_boards[] = { · line 285

Quoted 10 lines
drivers/platform/x86/hp/hp-wmi.c +2 -2
-             .driver_data = (void *)&omen_v1_no_ec_thermal_params,
+             .driver_data = (void *)&omen_v1_no_ec_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8D87") },
-             .driver_data = (void *)&omen_v1_no_ec_thermal_params,
+             .driver_data = (void *)&omen_v1_no_ec_board_params,
      },
      {},
 };

Could you do a rebase for this as there are a few ID additions in the for-next branch so I don't need to handle the conversion myself.

Quoted 109 lines
drivers/platform/x86/hp/hp-wmi.c +26 -17
@@ -1862,7 +1886,10 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
      u8 current_dstate, current_gpu_slowdown_temp, tp;
      const struct thermal_profile_params *params;
 
-     params = active_thermal_profile_params;
+     params = hp_wmi_thermal_profile();
+     if (!params)
+             return -ENODEV;
+
      if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
          params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
              *profile = active_platform_profile;
@@ -1874,10 +1901,10 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
              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.
+      * 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) {
@@ -1912,12 +1939,12 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
 
 static int platform_profile_victus_s_set_ec(enum platform_profile_option profile)
 {
-     struct thermal_profile_params *params;
+     const 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;
+     params = hp_wmi_thermal_profile();
      if (!params)
              return -ENODEV;
 
@@ -2183,6 +2210,7 @@ static const struct platform_profile_ops hp_wmi_platform_profile_ops = {
 static int thermal_profile_setup(struct platform_device *device)
 {
      const struct platform_profile_ops *ops;
+     const struct thermal_profile_params *params;
      int err, tp;
 
      if (is_omen_thermal_profile()) {
@@ -2214,13 +2242,17 @@ static int thermal_profile_setup(struct platform_device *device)
 
              ops = &platform_profile_victus_ops;
      } else if (is_victus_s_thermal_profile()) {
+             params = hp_wmi_thermal_profile();
+             if (!params)
+                     return -ENODEV;
+
              /*
               * 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.
               */
-             if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
-                 active_thermal_profile_params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
+             if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
+                 params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
                      active_platform_profile = PLATFORM_PROFILE_BALANCED;
              } else {
                      err = platform_profile_victus_s_get_ec(&active_platform_profile);
@@ -2681,24 +2713,25 @@ static int hp_wmi_hwmon_init(void)
      return 0;
 }
 
-static void __init setup_active_thermal_profile_params(void)
+static void __init setup_active_board_params(void)
 {
      const struct dmi_system_id *id;
+     const struct thermal_profile_params *params;
 
-     /*
-      * Currently only victus_s devices use the
-      * active_thermal_profile_params
-      */
-     id = dmi_first_match(victus_s_thermal_profile_boards);
+     id = dmi_first_match(hp_wmi_feature_boards);
      if (id) {
+             active_board_params = id->driver_data;
+             params = hp_wmi_thermal_profile();
+             if (!params)
+                     return;
+
              /*
               * 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;
-             if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) {
+             if (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));
              }
@@ -2733,10 +2766,10 @@ static int __init hp_wmi_init(void)
              }
 
              /*

drivers/platform/x86/hp/hp-wmi.c static int __init hp_wmi_init(void) · line 2775

Quoted 10 lines
drivers/platform/x86/hp/hp-wmi.c +3 -3
-              * Setup active board's thermal profile parameters before
-              * starting platform driver probe.
+              * Setup active board feature data before starting platform
+              * driver probe.
               */
-             setup_active_thermal_profile_params();
+             setup_active_board_params();
              err = platform_driver_probe(&hp_wmi_driver, hp_wmi_bios_setup);
              if (err)
                      goto err_unregister_device;

--
i.

#5 lore raw

Re: [PATCH v9 1/3] platform/x86: hp-wmi: Introduce board-specific feature data

No problem, I understand.

Quoted 300 lines · Ilpo Järvinen
Quoted 3 lines · Radhey Kalra

Hi Ilpo,

Will do. I'll rebase this series against for-next and send v10 shortly.

It seems I had a problem in my end, so all the ID changes are only now in for-next. I'm sorry about the extra hassle.

--
i.

Quoted 287 lines

Thanks, Radhey

Quoted 281 lines · Ilpo Järvinen
Quoted 141 lines · Radhey Kalra

The hp_wmi DMI table is about to carry more than thermal-profile data. Replace the direct thermal_profile_params .driver_data pointers with hp_wmi_board_params and rename the table/setup helper accordingly.

No functional changes intended.

---
 drivers/platform/x86/hp/hp-wmi.c | 121 ++++++++++++++++++++-----------
 1 file changed, 77 insertions(+), 44 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +46 -22
index 48292cc..4a795e6 100644
@@ -133,11 +133,35 @@ static const struct thermal_profile_params omen_v1_no_ec_thermal_params = {
      .ec_tp_offset   = HP_NO_THERMAL_PROFILE_OFFSET,
 };
 
-/*
- * A generic pointer for the currently-active board's thermal profile
- * parameters.
- */
-static struct thermal_profile_params *active_thermal_profile_params;
+struct hp_wmi_board_params {
+     const struct thermal_profile_params *thermal_profile;
+};
+
+static const struct hp_wmi_board_params victus_s_board_params = {
+     .thermal_profile        = &victus_s_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_board_params = {
+     .thermal_profile        = &omen_v1_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_legacy_board_params = {
+     .thermal_profile        = &omen_v1_legacy_thermal_params,
+};
+
+static const struct hp_wmi_board_params omen_v1_no_ec_board_params = {
+     .thermal_profile        = &omen_v1_no_ec_thermal_params,
+};
+
+static const struct hp_wmi_board_params *active_board_params;
+
+static const struct thermal_profile_params *hp_wmi_thermal_profile(void)
+{
+     if (!active_board_params)
+             return NULL;
+
+     return active_board_params->thermal_profile;
+}
 
 /* DMI board names of devices that should use the omen specific path for
  * thermal profiles.
@@ -187,75 +211,75 @@ static const char * const victus_thermal_profile_boards[] = {
      "8A25",
 };
 
-/* DMI Board names of Victus 16-r and Victus 16-s laptops */
-static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst = {
+/* DMI board-specific feature data for Omen and Victus laptops. */
+static const struct dmi_system_id hp_wmi_feature_boards[] __initconst = {
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8902") },
-             .driver_data = (void *)&omen_v1_legacy_thermal_params,
+             .driver_data = (void *)&omen_v1_legacy_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8A44") },
-             .driver_data = (void *)&omen_v1_legacy_thermal_params,
+             .driver_data = (void *)&omen_v1_legacy_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8A4D") },
-             .driver_data = (void *)&omen_v1_legacy_thermal_params,
+             .driver_data = (void *)&omen_v1_legacy_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BAB") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BBE") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BC2") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BCA") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BCD") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD4") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8BD5") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C76") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C77") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C78") },
-             .driver_data = (void *)&omen_v1_thermal_params,
+             .driver_data = (void *)&omen_v1_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C99") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C9C") },
-             .driver_data = (void *)&victus_s_thermal_params,
+             .driver_data = (void *)&victus_s_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8D41") },

drivers/platform/x86/hp/hp-wmi.c static const char * const victus_thermal_profile_boards[] = { · line 285

Quoted 10 lines
drivers/platform/x86/hp/hp-wmi.c +2 -2
-             .driver_data = (void *)&omen_v1_no_ec_thermal_params,
+             .driver_data = (void *)&omen_v1_no_ec_board_params,
      },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8D87") },
-             .driver_data = (void *)&omen_v1_no_ec_thermal_params,
+             .driver_data = (void *)&omen_v1_no_ec_board_params,
      },
      {},
 };

Could you do a rebase for this as there are a few ID additions in the for-next branch so I don't need to handle the conversion myself.

Quoted 109 lines
drivers/platform/x86/hp/hp-wmi.c +26 -17
@@ -1862,7 +1886,10 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
      u8 current_dstate, current_gpu_slowdown_temp, tp;
      const struct thermal_profile_params *params;
 
-     params = active_thermal_profile_params;
+     params = hp_wmi_thermal_profile();
+     if (!params)
+             return -ENODEV;
+
      if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
          params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
              *profile = active_platform_profile;
@@ -1874,10 +1901,10 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
              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.
+      * 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) {
@@ -1912,12 +1939,12 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil
 
 static int platform_profile_victus_s_set_ec(enum platform_profile_option profile)
 {
-     struct thermal_profile_params *params;
+     const 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;
+     params = hp_wmi_thermal_profile();
      if (!params)
              return -ENODEV;
 
@@ -2183,6 +2210,7 @@ static const struct platform_profile_ops hp_wmi_platform_profile_ops = {
 static int thermal_profile_setup(struct platform_device *device)
 {
      const struct platform_profile_ops *ops;
+     const struct thermal_profile_params *params;
      int err, tp;
 
      if (is_omen_thermal_profile()) {
@@ -2214,13 +2242,17 @@ static int thermal_profile_setup(struct platform_device *device)
 
              ops = &platform_profile_victus_ops;
      } else if (is_victus_s_thermal_profile()) {
+             params = hp_wmi_thermal_profile();
+             if (!params)
+                     return -ENODEV;
+
              /*
               * 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.
               */
-             if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
-                 active_thermal_profile_params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
+             if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN ||
+                 params->ec_tp_offset == HP_NO_THERMAL_PROFILE_OFFSET) {
                      active_platform_profile = PLATFORM_PROFILE_BALANCED;
              } else {
                      err = platform_profile_victus_s_get_ec(&active_platform_profile);
@@ -2681,24 +2713,25 @@ static int hp_wmi_hwmon_init(void)
      return 0;
 }
 
-static void __init setup_active_thermal_profile_params(void)
+static void __init setup_active_board_params(void)
 {
      const struct dmi_system_id *id;
+     const struct thermal_profile_params *params;
 
-     /*
-      * Currently only victus_s devices use the
-      * active_thermal_profile_params
-      */
-     id = dmi_first_match(victus_s_thermal_profile_boards);
+     id = dmi_first_match(hp_wmi_feature_boards);
      if (id) {
+             active_board_params = id->driver_data;
+             params = hp_wmi_thermal_profile();
+             if (!params)
+                     return;
+
              /*
               * 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;
-             if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) {
+             if (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));
              }
@@ -2733,10 +2766,10 @@ static int __init hp_wmi_init(void)
              }
 
              /*

drivers/platform/x86/hp/hp-wmi.c static int __init hp_wmi_init(void) · line 2775

Quoted 10 lines
drivers/platform/x86/hp/hp-wmi.c +3 -3
-              * Setup active board's thermal profile parameters before
-              * starting platform driver probe.
+              * Setup active board feature data before starting platform
+              * driver probe.
               */
-             setup_active_thermal_profile_params();
+             setup_active_board_params();
              err = platform_driver_probe(&hp_wmi_driver, hp_wmi_bios_setup);
              if (err)
                      goto err_unregister_device;

--
i.

#6 lore raw

PATCH v9 2/3 platform/x86: hp-wmi: Drive fan control from board data

In reply to Radhey Kalra

Use the board-specific .driver_data to describe fan-control support and fan-speed read callbacks. Existing boards keep the same Victus fan-control path, but the hwmon code no longer hardcodes that decision through is_victus_s_thermal_profile().

No functional changes intended.

---
 drivers/platform/x86/hp/hp-wmi.c | 79 ++++++++++++++++++++++++++------
 1 file changed, 64 insertions(+), 15 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +64 -15
index 4a795e6..91578e7 100644
@@ -133,24 +133,41 @@ static const struct thermal_profile_params omen_v1_no_ec_thermal_params = {
 	.ec_tp_offset	= HP_NO_THERMAL_PROFILE_OFFSET,
 };
 
+struct hp_wmi_fan_profile_params {
+	int (*get_fan_speed)(int fan);
+	bool fan_table;
+};
+
 struct hp_wmi_board_params {
 	const struct thermal_profile_params *thermal_profile;
+	const struct hp_wmi_fan_profile_params *fan_profile;
+};
+
+static int hp_wmi_get_fan_speed_victus_s(int fan);
+
+static const struct hp_wmi_fan_profile_params victus_s_fan_profile_params = {
+	.get_fan_speed	= hp_wmi_get_fan_speed_victus_s,
+	.fan_table	= true,
 };
 
 static const struct hp_wmi_board_params victus_s_board_params = {
 	.thermal_profile	= &victus_s_thermal_params,
+	.fan_profile		= &victus_s_fan_profile_params,
 };
 
 static const struct hp_wmi_board_params omen_v1_board_params = {
 	.thermal_profile	= &omen_v1_thermal_params,
+	.fan_profile		= &victus_s_fan_profile_params,
 };
 
 static const struct hp_wmi_board_params omen_v1_legacy_board_params = {
 	.thermal_profile	= &omen_v1_legacy_thermal_params,
+	.fan_profile		= &victus_s_fan_profile_params,
 };
 
 static const struct hp_wmi_board_params omen_v1_no_ec_board_params = {
 	.thermal_profile	= &omen_v1_no_ec_thermal_params,
+	.fan_profile		= &victus_s_fan_profile_params,
 };
 
 static const struct hp_wmi_board_params *active_board_params;
@@ -1801,6 +1818,38 @@ static bool is_victus_s_thermal_profile(void)
 	return is_victus_s_board;
 }
 
+static const struct hp_wmi_fan_profile_params *hp_wmi_fan_profile(void)
+{
+	if (!active_board_params)
+		return NULL;
+
+	return active_board_params->fan_profile;
+}
+
+static bool hp_wmi_fan_control_supported(void)
+{
+	const struct hp_wmi_fan_profile_params *params = hp_wmi_fan_profile();
+
+	return params && params->get_fan_speed;
+}
+
+static bool hp_wmi_fan_table_supported(void)
+{
+	const struct hp_wmi_fan_profile_params *params = hp_wmi_fan_profile();
+
+	return params && params->fan_table;
+}
+
+static int hp_wmi_get_active_fan_speed(int fan)
+{
+	const struct hp_wmi_fan_profile_params *params = hp_wmi_fan_profile();
+
+	if (!params || !params->get_fan_speed)
+		return -EOPNOTSUPP;
+
+	return params->get_fan_speed(fan);
+}
+
 static int victus_s_gpu_thermal_profile_get(bool *ctgp_enable,
 					    bool *ppab_enable,
 					    u8 *dstate,
@@ -2420,7 +2469,7 @@ static int hp_wmi_apply_fan_settings(struct hp_wmi_hwmon_priv *priv)
 
 	switch (priv->mode) {
 	case PWM_MODE_MAX:
-		if (is_victus_s_thermal_profile()) {
+		if (hp_wmi_fan_control_supported()) {
 			ret = hp_wmi_get_fan_count_userdefine_trigger();
 			if (ret < 0)
 				return ret;
@@ -2432,7 +2481,7 @@ static int hp_wmi_apply_fan_settings(struct hp_wmi_hwmon_priv *priv)
 				 secs_to_jiffies(KEEP_ALIVE_DELAY_SECS));
 		return 0;
 	case PWM_MODE_MANUAL:
-		if (!is_victus_s_thermal_profile())
+		if (!hp_wmi_fan_control_supported())
 			return -EOPNOTSUPP;
 		ret = hp_wmi_fan_speed_set(priv, pwm_to_rpm(priv->pwm, priv));
 		if (ret < 0)
@@ -2441,7 +2490,7 @@ static int hp_wmi_apply_fan_settings(struct hp_wmi_hwmon_priv *priv)
 				 secs_to_jiffies(KEEP_ALIVE_DELAY_SECS));
 		return 0;
 	case PWM_MODE_AUTO:
-		if (is_victus_s_thermal_profile()) {
+		if (hp_wmi_fan_control_supported()) {
 			ret = hp_wmi_get_fan_count_userdefine_trigger();
 			if (ret < 0)
 				return ret;
@@ -2465,12 +2514,12 @@ static umode_t hp_wmi_hwmon_is_visible(const void *data,
 {
 	switch (type) {
 	case hwmon_pwm:
-		if (attr == hwmon_pwm_input && !is_victus_s_thermal_profile())
+		if (attr == hwmon_pwm_input && !hp_wmi_fan_control_supported())
 			return 0;
 		return 0644;
 	case hwmon_fan:
-		if (is_victus_s_thermal_profile()) {
-			if (hp_wmi_get_fan_speed_victus_s(channel) >= 0)
+		if (hp_wmi_fan_control_supported()) {
+			if (hp_wmi_get_active_fan_speed(channel) >= 0)
 				return 0444;
 		} else {
 			if (hp_wmi_get_fan_speed(channel) >= 0)
@@ -2494,8 +2543,8 @@ static int hp_wmi_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
 	priv = dev_get_drvdata(dev);
 	switch (type) {
 	case hwmon_fan:
-		if (is_victus_s_thermal_profile())
-			ret = hp_wmi_get_fan_speed_victus_s(channel);
+		if (hp_wmi_fan_control_supported())
+			ret = hp_wmi_get_active_fan_speed(channel);
 		else
 			ret = hp_wmi_get_fan_speed(channel);
 		if (ret < 0)
@@ -2504,10 +2553,10 @@ static int hp_wmi_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
 		return 0;
 	case hwmon_pwm:
 		if (attr == hwmon_pwm_input) {
-			if (!is_victus_s_thermal_profile())
+			if (!hp_wmi_fan_control_supported())
 				return -EOPNOTSUPP;
 
-			rpm = hp_wmi_get_fan_speed_victus_s(channel);
+			rpm = hp_wmi_get_active_fan_speed(channel);
 			if (rpm < 0)
 				return rpm;
 			*val = rpm_to_pwm(rpm / 100, priv);
@@ -2541,7 +2590,7 @@ static int hp_wmi_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
 	switch (type) {
 	case hwmon_pwm:
 		if (attr == hwmon_pwm_input) {
-			if (!is_victus_s_thermal_profile())
+			if (!hp_wmi_fan_control_supported())
 				return -EOPNOTSUPP;
 			/* PWM input is invalid when not in manual mode */
 			if (priv->mode != PWM_MODE_MANUAL)
@@ -2558,13 +2607,13 @@ static int hp_wmi_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
 			priv->mode = PWM_MODE_MAX;
 			return hp_wmi_apply_fan_settings(priv);
 		case PWM_MODE_MANUAL:
-			if (!is_victus_s_thermal_profile())
+			if (!hp_wmi_fan_control_supported())
 				return -EOPNOTSUPP;
 			/*
 			 * When switching to manual mode, set fan speed to
 			 * current RPM values to ensure a smooth transition.
 			 */
-			rpm = hp_wmi_get_fan_speed_victus_s(channel);
+			rpm = hp_wmi_get_active_fan_speed(channel);
 			if (rpm < 0)
 				return rpm;
 			priv->pwm = rpm_to_pwm(rpm / 100, priv);
@@ -2630,8 +2679,8 @@ static int hp_wmi_setup_fan_settings(struct hp_wmi_hwmon_priv *priv)
 	/* Default behaviour on hwmon init is automatic mode */
 	priv->mode = PWM_MODE_AUTO;
 
-	/* Bypass all non-Victus S devices */
-	if (!is_victus_s_thermal_profile())
+	/* Bypass devices without fan control support. */
+	if (!hp_wmi_fan_table_supported())
 		return 0;
 
 	ret = hp_wmi_perform_query(HPWMI_VICTUS_S_GET_FAN_TABLE_QUERY,
Signature · 1 line
2.54.0
#7 lore raw

PATCH v9 3/3 platform/x86: hp-wmi: Add Victus 15-fb0xxx support

In reply to Radhey Kalra

HP Victus 15-fb0xxx board 8A3D exposes the Victus fan table and accepts the existing Victus fan-speed WMI control path. Add board data for the Victus S thermal-profile path and fan-control support.

---
 drivers/platform/x86/hp/hp-wmi.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/platform/x86/hp/hp-wmi.c +9 -0
index 91578e7..c124ad0 100644
@@ -170,6 +170,11 @@ static const struct hp_wmi_board_params omen_v1_no_ec_board_params = {
 	.fan_profile		= &victus_s_fan_profile_params,
 };
 
+static const struct hp_wmi_board_params victus_8a3d_board_params = {
+	.thermal_profile	= &victus_s_thermal_params,
+	.fan_profile		= &victus_s_fan_profile_params,
+};
+
 static const struct hp_wmi_board_params *active_board_params;
 
 static const struct thermal_profile_params *hp_wmi_thermal_profile(void)
@@ -230,6 +235,10 @@ static const char * const victus_thermal_profile_boards[] = {
 
 /* DMI board-specific feature data for Omen and Victus laptops. */
 static const struct dmi_system_id hp_wmi_feature_boards[] __initconst = {
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8A3D") },
+		.driver_data = (void *)&victus_8a3d_board_params,
+	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8902") },
 		.driver_data = (void *)&omen_v1_legacy_board_params,
Signature · 1 line
2.54.0
maintainer
#8 lore raw
Quoted 26 lines · Radhey Kalra

HP Victus 15-fb0xxx board 8A3D exposes the Victus fan table and accepts the existing Victus fan-speed WMI control path. Add board data for the Victus S thermal-profile path and fan-control support.

---
 drivers/platform/x86/hp/hp-wmi.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/platform/x86/hp/hp-wmi.c +5 -0
index 91578e7..c124ad0 100644
@@ -170,6 +170,11 @@ static const struct hp_wmi_board_params omen_v1_no_ec_board_params = {
 	.fan_profile		= &victus_s_fan_profile_params,
 };
 
+static const struct hp_wmi_board_params victus_8a3d_board_params = {
+	.thermal_profile	= &victus_s_thermal_params,
+	.fan_profile		= &victus_s_fan_profile_params,
+};
+
 static const struct hp_wmi_board_params *active_board_params;
 
 static const struct thermal_profile_params *hp_wmi_thermal_profile(void)

drivers/platform/x86/hp/hp-wmi.c static const char * const victus_thermal_profile_boards[] = { · line 243

Quoted 9 lines
drivers/platform/x86/hp/hp-wmi.c +4 -0
@@ -230,6 +235,10 @@ static const char * const victus_thermal_profile_boards[] = {
 
 /* DMI board-specific feature data for Omen and Victus laptops. */
 static const struct dmi_system_id hp_wmi_feature_boards[] __initconst = {
+	{
+		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8A3D") },
+		.driver_data = (void *)&victus_8a3d_board_params,
+	},
 	{
 		.matches = { DMI_MATCH(DMI_BOARD_NAME, "8902") },

Lets try to keep these in order (8902 < 8A3D).

Quoted 2 lines
drivers/platform/x86/hp/hp-wmi.c +0 -0
 		.driver_data = (void *)&omen_v1_legacy_board_params,
Signature · 1 line
 i.
#9 lore raw

Hi Ilpo,

Got it. I'll re-sort them to ensure 8902 comes before 8A3D in the final series.

Thanks, Radhey

Quoted 47 lines · Ilpo Järvinen
Quoted 26 lines · Radhey Kalra

HP Victus 15-fb0xxx board 8A3D exposes the Victus fan table and accepts the existing Victus fan-speed WMI control path. Add board data for the Victus S thermal-profile path and fan-control support.

---
 drivers/platform/x86/hp/hp-wmi.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/platform/x86/hp/hp-wmi.c +5 -0
index 91578e7..c124ad0 100644
@@ -170,6 +170,11 @@ static const struct hp_wmi_board_params omen_v1_no_ec_board_params = {
      .fan_profile            = &victus_s_fan_profile_params,
 };
 
+static const struct hp_wmi_board_params victus_8a3d_board_params = {
+     .thermal_profile        = &victus_s_thermal_params,
+     .fan_profile            = &victus_s_fan_profile_params,
+};
+
 static const struct hp_wmi_board_params *active_board_params;
 
 static const struct thermal_profile_params *hp_wmi_thermal_profile(void)

drivers/platform/x86/hp/hp-wmi.c static const char * const victus_thermal_profile_boards[] = { · line 243

Quoted 9 lines
drivers/platform/x86/hp/hp-wmi.c +4 -0
@@ -230,6 +235,10 @@ static const char * const victus_thermal_profile_boards[] = {
 
 /* DMI board-specific feature data for Omen and Victus laptops. */
 static const struct dmi_system_id hp_wmi_feature_boards[] __initconst = {
+     {
+             .matches = { DMI_MATCH(DMI_BOARD_NAME, "8A3D") },
+             .driver_data = (void *)&victus_8a3d_board_params,
+     },
      {
              .matches = { DMI_MATCH(DMI_BOARD_NAME, "8902") },

Lets try to keep these in order (8902 < 8A3D).

drivers/platform/x86/hp/hp-wmi.c static const char * const victus_thermal_profile_boards[] = { · line 244

Quoted 2 lines
drivers/platform/x86/hp/hp-wmi.c +0 -0
              .driver_data = (void *)&omen_v1_legacy_board_params,

--
i.