Skip to content

Commit dc6a6ab

Browse files
Jorge Lopezjwrdegoede
authored andcommitted
platform/x86: hp-wmi: Resolve WMI query failures on some devices
WMI queries fail on some devices where the ACPI method HWMC unconditionally attempts to create Fields beyond the buffer if the buffer is too small, this breaks essential features such as power profiles: CreateByteField (Arg1, 0x10, D008) CreateByteField (Arg1, 0x11, D009) CreateByteField (Arg1, 0x12, D010) CreateDWordField (Arg1, 0x10, D032) CreateField (Arg1, 0x80, 0x0400, D128) In cases where args->data had zero length, ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT, Field [D008] at bit offset/length 128/8 exceeds size of target Buffer (128 bits) (20211217/dsopcode-198) was obtained. ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT, Field [D009] at bit offset/length 136/8 exceeds size of target Buffer (136bits) (20211217/dsopcode-198) The original code created a buffer size of 128 bytes regardless if the WMI call required a smaller buffer or not. This particular behavior occurs in older BIOS and reproduced in OMEN laptops. Newer BIOS handles buffer sizes properly and meets the latest specification requirements. This is the reason why testing with a dynamically allocated buffer did not uncover any failures with the test systems at hand. This patch was tested on several OMEN, Elite, and Zbooks. It was confirmed the patch resolves HPWMI_FAN GET/SET calls in an OMEN Laptop 15-ek0xxx. No problems were reported when testing on several Elite and Zbooks notebooks. Fixes: 4b4967c ("platform/x86: hp-wmi: Changing bios_args.data to be dynamically allocated") Signed-off-by: Jorge Lopez <[email protected]> Reviewed-by: Andy Shevchenko <[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 c6bc7e8 commit dc6a6ab

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/platform/x86/hp-wmi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,16 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
290290
struct bios_return *bios_return;
291291
union acpi_object *obj = NULL;
292292
struct bios_args *args = NULL;
293-
int mid, actual_outsize, ret;
293+
int mid, actual_insize, actual_outsize;
294294
size_t bios_args_size;
295+
int ret;
295296

296297
mid = encode_outsize_for_pvsz(outsize);
297298
if (WARN_ON(mid < 0))
298299
return mid;
299300

300-
bios_args_size = struct_size(args, data, insize);
301+
actual_insize = max(insize, 128);
302+
bios_args_size = struct_size(args, data, actual_insize);
301303
args = kmalloc(bios_args_size, GFP_KERNEL);
302304
if (!args)
303305
return -ENOMEM;

0 commit comments

Comments
 (0)