platform/x86: hp-wmi: Improve support for some HP boards
v2 cover platform/x86: hp-wmi: Improve support for some HP boards
This series improves support for some HP boards.
The first patch fixes an incorrect assumption in the fan table header which leads to a parsing error and eventually failure to load the driver in some devices.
The second patch adds support for board 8D87 by adding it to Victus S list. Unlike other boards, here the EC does not expose platform profile value, so EC readback is disabled.
The third patch adds support for board 8A44 by adding to Victus S list.
The fourth patch adds support for board 8C77 by adding to Victus S list.
Changes in v2:
- Rebased on review-ilpo-next for easier merging.
- No functional changes.
Krishna Chomal (4):
platform/x86: hp-wmi: fix fan table parsing platform/x86: hp-wmi: Add support for OMEN MAX 16-ak0xxx (8D87) platform/x86: hp-wmi: Add support for Omen 16-n0xxx (8A44) platform/x86: hp-wmi: Add support for Omen 16-wf1xxx (8C77)
drivers/platform/x86/hp/hp-wmi.c | 67 +++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 10 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 1/4 platform/x86: hp-wmi: fix fan table parsing
For Victus S devices, the BIOS fan table header was being incorrectly parsed as:
struct {
u8 unknown;
u8 num_entries;
}The first field should be num_fans and the second should be unknown. It is pure coincidence that interpreting an "unknown" field as "num_entries" worked on multiple device, however for board 8D87 (in an upcoming patch), this assumption fails, and the hp-wmi driver fails to load.
We fix this by correcting the header definition and compensating for num_entries by parsing each entry of the fan table until an all-NULL row is obtained, mirroring the behavior of OMEN Gaming Hub on Windows.
--- drivers/platform/x86/hp/hp-wmi.c | 41 +++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 8 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +33 -8
@@ -469,14 +469,14 @@ struct hp_wmi_hwmon_priv { };struct victus_s_fan_table_header { +u8 num_fans;u8 unknown; -u8 num_entries; } __packed;struct victus_s_fan_table_entry {u8 cpu_rpm;u8 gpu_rpm; -u8 unknown; +u8 noise_db; } __packed;struct victus_s_fan_table {
@@ -2563,7 +2563,9 @@ static int hp_wmi_setup_fan_settings(struct hp_wmi_hwmon_priv *priv)u8 fan_data[128 ] = {0 };struct victus_s_fan_table *fan_table;u8 min_rpm, max_rpm; -int gpu_delta, ret; +u8 cpu_rpm, gpu_rpm, noise_db; +int gpu_delta, i, num_entries, ret; +size_t header_size, entry_size;/* Default behaviour on hwmon init is automatic mode */ priv->mode =PWM_MODE_AUTO ;
@@ -2578,13 +2580,36 @@ static int hp_wmi_setup_fan_settings(struct hp_wmi_hwmon_priv *priv)return ret; fan_table = (struct victus_s_fan_table *)fan_data; -if (fan_table->header.num_entries ==0 || -sizeof (struct victus_s_fan_table_header ) + -sizeof (struct victus_s_fan_table_entry ) * fan_table->header.num_entries >sizeof (fan_data)) +if (fan_table->header.num_fans ==0 ) +return -EINVAL ; + + header_size =sizeof (struct victus_s_fan_table_header ); + entry_size =sizeof (struct victus_s_fan_table_entry ); + num_entries = (sizeof (fan_data) - header_size) / entry_size; + min_rpm =U8_MAX ; + max_rpm =0 ; + +for (i =0 ; i < num_entries ; i++) { + cpu_rpm = fan_table->entries[i].cpu_rpm; + gpu_rpm = fan_table->entries[i].gpu_rpm; + noise_db = fan_table->entries[i].noise_db; + +/* +* On some devices, the fan table is truncated with an all-zero row, +* hence we stop parsing here. +*/ +if (cpu_rpm ==0 && gpu_rpm ==0 && noise_db ==0 ) +break ; + +if (cpu_rpm < min_rpm) + min_rpm = cpu_rpm; +if (cpu_rpm > max_rpm) + max_rpm = cpu_rpm; + } + +if (min_rpm ==U8_MAX || max_rpm ==0 )return -EINVAL ; - min_rpm = fan_table->entries[0 ].cpu_rpm; - max_rpm = fan_table->entries[fan_table->header.num_entries -1 ].cpu_rpm; gpu_delta = fan_table->entries[0 ].gpu_rpm - fan_table->entries[0 ].cpu_rpm; priv->min_rpm = min_rpm; priv->max_rpm = max_rpm;
Signature · 1 line
2.53.0
PATCH v2 2/4 platform/x86: hp-wmi: Add support for OMEN MAX 16-ak0xxx (8D87)
In reply to Krishna ChomalThe HP OMEN MAX 16-ak0xxx (8D87) requires the same WMI queries as other Victus S devices, hence it has been added to the corresponding list.
For this reason, platform_profile_victus_s_get_ec() will be called during thermal_profile_setup() and victus_s_powersource_event() to obtain hardware state (platform profile) by reading from the Embedded Controller, however, this particular board's EC does not seem to expose the platform profile value, unlike other boards. Hence EC readback is disabled.
Testing on board 8D87 confirmed that platform profile is registered successfully and fan RPMs are readable and controllable.
--- drivers/platform/x86/hp/hp-wmi.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +16 -2
@@ -48,6 +48,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4");enum hp_ec_offsets {HP_EC_OFFSET_UNKNOWN =0x00 , +HP_NO_THERMAL_PROFILE_OFFSET =0x01 ,HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET =0x59 ,HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET =0x62 ,HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET =0x63 ,
@@ -127,6 +128,13 @@ static const struct thermal_profile_params omen_v1_legacy_thermal_params = { .ec_tp_offset = HP_OMEN_EC_THERMAL_PROFILE_OFFSET, }; +static const struct thermal_profile_params omen_v1_no_ec_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_NO_THERMAL_PROFILE_OFFSET , +}; +/* * A generic pointer for the currently-active board's thermal profile * parameters.
@@ -231,6 +239,10 @@ static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst .matches = { DMI_MATCH(DMI_BOARD_NAME, "8D41") }, .driver_data = (void *)&victus_s_thermal_params, }, + { + .matches = { DMI_MATCH(DMI_BOARD_NAME, "8D87") }, + .driver_data = (void *)&omen_v1_no_ec_thermal_params, + }, {}, };
@@ -1837,7 +1849,8 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profilconst struct thermal_profile_params *params; params = active_thermal_profile_params; -if (params->ec_tp_offset ==HP_EC_OFFSET_UNKNOWN ) { +if (params->ec_tp_offset ==HP_EC_OFFSET_UNKNOWN || + params->ec_tp_offset ==HP_NO_THERMAL_PROFILE_OFFSET ) { *profile = active_platform_profile;return 0 ; }
@@ -2192,7 +2205,8 @@ static int thermal_profile_setup(struct platform_device *device)* 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 ) { +if (active_thermal_profile_params->ec_tp_offset ==HP_EC_OFFSET_UNKNOWN || + active_thermal_profile_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);
Signature · 1 line
2.53.0
PATCH v2 3/4 platform/x86: hp-wmi: Add support for Omen 16-n0xxx (8A44)
In reply to Krishna ChomalThe HP Omen 16-n0xxx (board ID: 8A44) has the same WMI interface as other Victus S boards, but requires quirks for correctly switching thermal profile.
Add the DMI board name to victus_s_thermal_profile_boards[] table and map it to omen_v1_legacy_thermal_params.
Testing on board 8A44 confirmed that platform profile is registered successfully and fan RPMs are readable and controllable.
--- drivers/platform/x86/hp/hp-wmi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/platform/x86/hp/hp-wmi.c +4 -0
@@ -191,6 +191,10 @@ static const char * const victus_thermal_profile_boards[] = {/* DMI Board names of Victus 16-r and Victus 16-s laptops */ static const struct dmi_system_id victus_s_thermal_profile_boards[]__initconst = { + { + .matches = {DMI_MATCH (DMI_BOARD_NAME ,"8A44" ) }, + .driver_data = (void *)&omen_v1_legacy_thermal_params, + }, { .matches = {DMI_MATCH (DMI_BOARD_NAME ,"8A4D" ) }, .driver_data = (void *)&omen_v1_legacy_thermal_params,
Signature · 1 line
2.53.0
PATCH v2 4/4 platform/x86: hp-wmi: Add support for Omen 16-wf1xxx (8C77)
In reply to Krishna ChomalThe HP Omen 16-wf1xxx (board ID: 8C77) has the same WMI interface as other Victus S boards, but requires quirks for correctly switching thermal profile.
Add the DMI board name to victus_s_thermal_profile_boards[] table and map it to omen_v1_thermal_params.
Testing on board 8C77 confirmed that platform profile is registered successfully and fan RPMs are readable and controllable.
--- drivers/platform/x86/hp/hp-wmi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/platform/x86/hp/hp-wmi.c +4 -0
@@ -227,6 +227,10 @@ static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C76") }, .driver_data = (void *)&omen_v1_thermal_params, }, + { + .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C77") }, + .driver_data = (void *)&omen_v1_thermal_params, + }, { .matches = { DMI_MATCH(DMI_BOARD_NAME, "8C78") }, .driver_data = (void *)&omen_v1_thermal_params,
Signature · 1 line
2.53.0
Ilpo Järvinen
maintainerQuoted 11 lines · Krishna Chomal
This series improves support for some HP boards.
The first patch fixes an incorrect assumption in the fan table header which leads to a parsing error and eventually failure to load the driver in some devices.
The second patch adds support for board 8D87 by adding it to Victus S list. Unlike other boards, here the EC does not expose platform profile value, so EC readback is disabled.
[...]
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/4] platform/x86: hp-wmi: fix fan table parsing
commit: 9d317a54e46d3b6420567dc5b63e9d7ff5c064a3
[2/4] platform/x86: hp-wmi: Add support for OMEN MAX 16-ak0xxx (8D87)
commit: 5badf5ebcd1476f4bb38c5909c5020e14384ad7d
[3/4] platform/x86: hp-wmi: Add support for Omen 16-n0xxx (8A44)
commit: 899225257e78585e2e10b0f7ba472b3c212a8d16
[4/4] platform/x86: hp-wmi: Add support for Omen 16-wf1xxx (8C77)
commit: 344bf523d441d44c75c429ea6cdcfa8f12efde4d--
i.