Skip to content

Commit 65f936f

Browse files
whyfujwrdegoede
authored andcommitted
platform/x86: hp-wmi: Use zero insize parameter only when supported
commit be9d73e ("platform/x86: hp-wmi: Fix 0x05 error code reported by several WMI calls") and commit 12b19f1 ("platform/x86: hp-wmi: Fix hp_wmi_read_int() reporting error (0x05)") cause ACPI BIOS Error (bug): Attempt to CreateField of length zero (20211217/dsopcode-133) because of the ACPI method HWMC, which unconditionally creates a Field of size (insize*8) bits: CreateField (Arg1, 0x80, (Local5 * 0x08), DAIN) In cases where args->insize = 0, the Field size is 0, resulting in an error. Fix this by using zero insize only if 0x5 error code is returned Tested on Omen 15 AMD (2020) board ID: 8786. Fixes: be9d73e ("platform/x86: hp-wmi: Fix 0x05 error code reported by several WMI calls") Signed-off-by: Bedant Patnaik <[email protected]> Tested-by: Jorge Lopez <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent dc6a6ab commit 65f936f

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

drivers/platform/x86/hp-wmi.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
3838
#define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C"
3939
#define HPWMI_BIOS_GUID "5FB7F034-2C63-45e9-BE91-3D44E2C707E4"
4040
#define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95
41+
#define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when zero insize is required
4142

4243
/* DMI board names of devices that should use the omen specific path for
4344
* thermal profiles.
@@ -220,6 +221,7 @@ static struct input_dev *hp_wmi_input_dev;
220221
static struct platform_device *hp_wmi_platform_dev;
221222
static struct platform_profile_handler platform_profile_handler;
222223
static bool platform_profile_support;
224+
static bool zero_insize_support;
223225

224226
static struct rfkill *wifi_rfkill;
225227
static struct rfkill *bluetooth_rfkill;
@@ -376,7 +378,7 @@ static int hp_wmi_read_int(int query)
376378
int val = 0, ret;
377379

378380
ret = hp_wmi_perform_query(query, HPWMI_READ, &val,
379-
0, sizeof(val));
381+
zero_if_sup(val), sizeof(val));
380382

381383
if (ret)
382384
return ret < 0 ? ret : -EINVAL;
@@ -412,7 +414,8 @@ static int hp_wmi_get_tablet_mode(void)
412414
return -ENODEV;
413415

414416
ret = hp_wmi_perform_query(HPWMI_SYSTEM_DEVICE_MODE, HPWMI_READ,
415-
system_device_mode, 0, sizeof(system_device_mode));
417+
system_device_mode, zero_if_sup(system_device_mode),
418+
sizeof(system_device_mode));
416419
if (ret < 0)
417420
return ret;
418421

@@ -499,7 +502,7 @@ static int hp_wmi_fan_speed_max_get(void)
499502
int val = 0, ret;
500503

501504
ret = hp_wmi_perform_query(HPWMI_FAN_SPEED_MAX_GET_QUERY, HPWMI_GM,
502-
&val, 0, sizeof(val));
505+
&val, zero_if_sup(val), sizeof(val));
503506

504507
if (ret)
505508
return ret < 0 ? ret : -EINVAL;
@@ -511,7 +514,7 @@ static int __init hp_wmi_bios_2008_later(void)
511514
{
512515
int state = 0;
513516
int ret = hp_wmi_perform_query(HPWMI_FEATURE_QUERY, HPWMI_READ, &state,
514-
0, sizeof(state));
517+
zero_if_sup(state), sizeof(state));
515518
if (!ret)
516519
return 1;
517520

@@ -522,7 +525,7 @@ static int __init hp_wmi_bios_2009_later(void)
522525
{
523526
u8 state[128];
524527
int ret = hp_wmi_perform_query(HPWMI_FEATURE2_QUERY, HPWMI_READ, &state,
525-
0, sizeof(state));
528+
zero_if_sup(state), sizeof(state));
526529
if (!ret)
527530
return 1;
528531

@@ -600,7 +603,7 @@ static int hp_wmi_rfkill2_refresh(void)
600603
int err, i;
601604

602605
err = hp_wmi_perform_query(HPWMI_WIRELESS2_QUERY, HPWMI_READ, &state,
603-
0, sizeof(state));
606+
zero_if_sup(state), sizeof(state));
604607
if (err)
605608
return err;
606609

@@ -1009,7 +1012,7 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device)
10091012
int err, i;
10101013

10111014
err = hp_wmi_perform_query(HPWMI_WIRELESS2_QUERY, HPWMI_READ, &state,
1012-
0, sizeof(state));
1015+
zero_if_sup(state), sizeof(state));
10131016
if (err)
10141017
return err < 0 ? err : -EINVAL;
10151018

@@ -1485,11 +1488,15 @@ static int __init hp_wmi_init(void)
14851488
{
14861489
int event_capable = wmi_has_guid(HPWMI_EVENT_GUID);
14871490
int bios_capable = wmi_has_guid(HPWMI_BIOS_GUID);
1488-
int err;
1491+
int err, tmp = 0;
14891492

14901493
if (!bios_capable && !event_capable)
14911494
return -ENODEV;
14921495

1496+
if (hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, HPWMI_READ, &tmp,
1497+
sizeof(tmp), sizeof(tmp)) == HPWMI_RET_INVALID_PARAMETERS)
1498+
zero_insize_support = true;
1499+
14931500
if (event_capable) {
14941501
err = hp_wmi_input_setup();
14951502
if (err)

0 commit comments

Comments
 (0)