Skip to content

Commit 2ca8e62

Browse files
committed
Revert "ACPI: Pass the same capabilities to the _OSC regardless of the query flag"
Revert commit 159d8c2 ("ACPI: Pass the same capabilities to the _OSC regardless of the query flag") which caused legitimate usage scenarios (when the platform firmware does not want the OS to control certain platform features controlled by the system bus scope _OSC) to break and was misguided by some misleading language in the _OSC definition in the ACPI specification (in particular, Section 6.2.11.1.3 "Sequence of _OSC Calls" that contradicts other perts of the _OSC definition). Link: https://lore.kernel.org/linux-acpi/CAJZ5v0iStA0JmO0H3z+VgQsVuQONVjKPpw0F5HKfiq=Gb6B5yw@mail.gmail.com Reported-by: Mario Limonciello <Mario.Limonciello@amd.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Mario Limonciello <mario.limonciello@amd.com> Acked-by: Huang Rui <ray.huang@amd.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
1 parent 3c36fe9 commit 2ca8e62

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

drivers/acpi/bus.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,21 +332,32 @@ static void acpi_bus_osc_negotiate_platform_control(void)
332332
if (ACPI_FAILURE(acpi_run_osc(handle, &context)))
333333
return;
334334

335-
kfree(context.ret.pointer);
335+
capbuf_ret = context.ret.pointer;
336+
if (context.ret.length <= OSC_SUPPORT_DWORD) {
337+
kfree(context.ret.pointer);
338+
return;
339+
}
336340

337-
/* Now run _OSC again with query flag clear */
341+
/*
342+
* Now run _OSC again with query flag clear and with the caps
343+
* supported by both the OS and the platform.
344+
*/
338345
capbuf[OSC_QUERY_DWORD] = 0;
346+
capbuf[OSC_SUPPORT_DWORD] = capbuf_ret[OSC_SUPPORT_DWORD];
347+
kfree(context.ret.pointer);
339348

340349
if (ACPI_FAILURE(acpi_run_osc(handle, &context)))
341350
return;
342351

343352
capbuf_ret = context.ret.pointer;
344-
osc_sb_apei_support_acked =
345-
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT;
346-
osc_pc_lpi_support_confirmed =
347-
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT;
348-
osc_sb_native_usb4_support_confirmed =
349-
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT;
353+
if (context.ret.length > OSC_SUPPORT_DWORD) {
354+
osc_sb_apei_support_acked =
355+
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT;
356+
osc_pc_lpi_support_confirmed =
357+
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT;
358+
osc_sb_native_usb4_support_confirmed =
359+
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT;
360+
}
350361

351362
kfree(context.ret.pointer);
352363
}

0 commit comments

Comments
 (0)