From d2ee8bc4ee24456fddef264f71628e2588e3144c Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 7 Jun 2021 11:55:57 +0200 Subject: [PATCH] ACPI: Use _OSC query results to determine caps rather then the commit results Commit 719e1f561afb ("ACPI: Execute platform _OSC also with query bit clear") makes acpi_bus_osc_negotiate_platform_control() not only query the platforms capabilities but it also commits the result back to the firmware to let the firmware know which capabilities are supported back by the OS. This also moved the code to set the osc_sb_apei_support_acked, osc_pc_lpi_support_confirmed and osc_sb_native_usb4_support_confirmed flags to after the commit. But it seems that some BIOS-es clear the OSC_SUPPORT_DWORD on return when the query bit is not set. Move the checking of the capabilities back to after the _OSC call with the query bit set to restore the old behavior. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=213023 BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1963717 Fixes: 719e1f561afb ("ACPI: Execute platform _OSC also with query bit clear") Cc: Mario Limonciello Signed-off-by: Hans de Goede --- drivers/acpi/bus.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index be7da23fad76..1e4953c0d5c2 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -336,6 +336,10 @@ static void acpi_bus_osc_negotiate_platform_control(void) return; } + osc_sb_apei_support_acked = capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT; + osc_pc_lpi_support_confirmed = capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT; + osc_sb_native_usb4_support_confirmed = capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT; + /* * Now run _OSC again with query flag clear and with the caps * supported by both the OS and the platform. @@ -347,16 +351,6 @@ static void acpi_bus_osc_negotiate_platform_control(void) if (ACPI_FAILURE(acpi_run_osc(handle, &context))) return; - capbuf_ret = context.ret.pointer; - if (context.ret.length > OSC_SUPPORT_DWORD) { - osc_sb_apei_support_acked = - capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT; - osc_pc_lpi_support_confirmed = - capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT; - osc_sb_native_usb4_support_confirmed = - capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT; - } - kfree(context.ret.pointer); } -- 2.31.1