ACPI: CPPC: Only probe for _CPC if CPPC v2 is acked
Subsystems (4)
PATCH v4 1/2 ACPI: CPPC: Only probe for _CPC if CPPC v2 is acked
Previously the kernel used to ignore whether the firmware masked CPPC or CPPCv2 and would just pretend that it worked.
When support for the USB4 bit in _OSC was introduced from commit 9e1f561afb ("ACPI: Execute platform _OSC also with query bit clear") the kernel began to look at the return when the query bit was clear.
This caused regressions that were misdiagnosed and attempted to be solved as part of commit 2ca8e6285250 ("Revert "ACPI: Pass the same capabilities to the _OSC regardless of the query flag""). This caused a different regression where non-Intel systems weren't able to negotiate _OSC properly.
This was reverted in commit 2ca8e6285250 ("Revert "ACPI: Pass the same capabilities to the _OSC regardless of the query flag"") and attempted to be fixed by commit c42fa24b4475 ("ACPI: bus: Avoid using CPPC if not supported by firmware") but the regression still returned.
These systems with the regression only load support for CPPC from an SSDT dynamically when _OSC reports CPPC v2. Avoid the problem by not letting CPPC satisfy the requirement in acpi_cppc_processor_probe.
---v3->v4:
* Pick up tags
drivers/acpi/bus.c | 11 +++++------ drivers/acpi/cppc_acpi.c | 4 +++- include/linux/acpi.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-)
drivers/acpi/bus.c +5 -6
@@ -298,7 +298,7 @@ EXPORT_SYMBOL_GPL(osc_cpc_flexible_adr_space_confirmed);bool osc_sb_native_usb4_support_confirmed;EXPORT_SYMBOL_GPL (osc_sb_native_usb4_support_confirmed); -bool osc_sb_cppc_not_supported; +bool osc_sb_cppc2_support_acked;static u8 sb_uuid_str[] ="0811B06E-4A27-44F9-8D60-3CBBC22E7B48" ;static void acpi_bus_osc_negotiate_platform_control (void )
@@ -358,11 +358,6 @@ static void acpi_bus_osc_negotiate_platform_control(void)return ; } -#ifdef CONFIG_ACPI_CPPC_LIB - osc_sb_cppc_not_supported = !(capbuf_ret[OSC_SUPPORT_DWORD ] & - (OSC_SB_CPC_SUPPORT |OSC_SB_CPCV2_SUPPORT )); -#endif -/* * Now run _OSC again with query flag clear and with the caps * supported by both the OS and the platform.
@@ -376,6 +371,10 @@ static void acpi_bus_osc_negotiate_platform_control(void) capbuf_ret = context.ret.pointer;if (context.ret.length >OSC_SUPPORT_DWORD ) { +#ifdef CONFIG_ACPI_CPPC_LIB + osc_sb_cppc2_support_acked = capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_CPCV2_SUPPORT ; +#endif + osc_sb_apei_support_acked = capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_APEI_SUPPORT ; osc_pc_lpi_support_confirmed =
drivers/acpi/cppc_acpi.c +3 -1
@@ -684,8 +684,10 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)acpi_status status;int ret = -ENODATA ; -if (osc_sb_cppc_not_supported) +if (!osc_sb_cppc2_support_acked) { +pr_debug ("CPPC v2 _OSC not acked\n" );return -ENODEV ; + }/* Parse the ACPI _CPC table for this CPU. */ status = acpi_evaluate_object_typed(handle, "_CPC", NULL, &output,
include/linux/acpi.h +1 -1
@@ -584,7 +584,7 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);extern bool osc_sb_apei_support_acked;extern bool osc_pc_lpi_support_confirmed;extern bool osc_sb_native_usb4_support_confirmed; -extern bool osc_sb_cppc_not_supported; +extern bool osc_sb_cppc2_support_acked;extern bool osc_cpc_flexible_adr_space_confirmed;/* USB4 Capabilities */
Signature · 1 line
2.25.1
PATCH v4 2/2 ACPI: CPPC: Don't require _OSC if X86_FEATURE_CPPC is supported
commit 72f2ecb7ece7 ("ACPI: bus: Set CPPC _OSC bits for all and when CPPC_LIB is supported") added support for claiming to support CPPC in _OSC on non-Intel platforms.
This unfortunately caused a regression on a vartiety of AMD platforms in the field because a number of AMD platforms don't set the _OSC bit 5 or 6 to indicate CPPC or CPPC v2 support.
As these AMD platforms already claim CPPC support via a dedicated MSR from X86_FEATURE_CPPC, use this enable this feature rather than requiring the _OSC on platforms with a dedicated MSR.
If there is additional breakage on the shared memory designs also missing this _OSC, additional follow up changes may be needed.
---v3->v4
* Explicitly check for AMD before using X86_FEATURE_CPPCv2->v3
* Rebase on top of solution for _CPC regression on some Intel systemss
* Refactor to avoid #ifdef CONFIG_X86
arch/x86/kernel/acpi/cppc.c | 10 ++++++++++ drivers/acpi/cppc_acpi.c | 16 +++++++++++++++- include/acpi/cppc_acpi.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-)
arch/x86/kernel/acpi/cppc.c +10 -0
@@ -11,6 +11,16 @@/* Refer to drivers/acpi/cppc_acpi.c for the description of functions */ +bool cpc_supported_by_cpu (void ) +{ +switch (boot_cpu_data.x86_vendor) { +case X86_VENDOR_AMD : +case X86_VENDOR_HYGON : +return boot_cpu_has (X86_FEATURE_CPPC ); + } +return false; +} +bool cpc_ffh_supported (void ) {return true;
drivers/acpi/cppc_acpi.c +15 -1
@@ -577,6 +577,19 @@ bool __weak cpc_ffh_supported(void)return false; } +/** +* cpc_supported_by_cpu() - check if CPPC is supported by CPU +* +* Check if the architectural support for CPPC is present even +* if the _OSC hasn't prescribed it +* +* Return: true for supported, false for not supported +*/ +bool __weak cpc_supported_by_cpu (void ) +{ +return false; +} +/** * pcc_data_alloc() - Allocate the pcc_data memory for pcc subspace *
@@ -686,7 +699,8 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)if (!osc_sb_cppc2_support_acked) {pr_debug ("CPPC v2 _OSC not acked\n" ); -return -ENODEV ; +if (!cpc_supported_by_cpu ()) +return -ENODEV ; }/* Parse the ACPI _CPC table for this CPU. */
include/acpi/cppc_acpi.h +1 -0
@@ -145,6 +145,7 @@ extern bool cppc_allow_fast_switch(void);extern int acpi_get_psd_map (unsigned int cpu,struct cppc_cpudata *cpu_data);extern unsigned int cppc_get_transition_latency (int cpu);extern bool cpc_ffh_supported (void ); +extern bool cpc_supported_by_cpu (void );extern int cpc_read_ffh (int cpunum,struct cpc_reg *reg,u64 *val);extern int cpc_write_ffh (int cpunum,struct cpc_reg *reg,u64 val);#else /* !CONFIG_ACPI_CPPC_LIB */
Signature · 1 line
2.25.1
Rafael J. Wysocki
maintainerQuoted 101 lines · Mario Limonciello
Previously the kernel used to ignore whether the firmware masked CPPC or CPPCv2 and would just pretend that it worked.
When support for the USB4 bit in
_OSCwas introduced from commit9e1f561afb("ACPI: Execute platform_OSCalso with query bit clear") the kernel began to look at the return when the query bit was clear.This caused regressions that were misdiagnosed and attempted to be solved as part of commit
2ca8e6285250("Revert "ACPI: Pass the same capabilities to the_OSCregardless of the query flag""). This caused a different regression where non-Intel systems weren't able to negotiate_OSCproperly.This was reverted in commit
2ca8e6285250("Revert "ACPI: Pass the same capabilities to the_OSCregardless of the query flag"") and attempted to be fixed by commitc42fa24b4475("ACPI: bus: Avoid using CPPC if not supported by firmware") but the regression still returned.These systems with the regression only load support for CPPC from an SSDT dynamically when
_OSCreports CPPC v2. Avoid the problem by not letting CPPC satisfy the requirement inacpi_cppc_processor_probe.Reported-by CUI Hao <[email protected]>Reported-by [email protected]Reported-by [email protected]Reported-by [email protected]Reported-by [email protected]Fixes c42fa24b4475 ("ACPI: bus: Avoid using CPPC if not supported by firmware")Fixes 2ca8e6285250 ("Revert "ACPI Pass the same capabilities to the _OSC regardless of the query flag"")Reviewed-by Mika Westerberg <[email protected]>Tested-by CUI Hao <[email protected]>Signed-off-by Mario Limonciello <[email protected]>---
v3->v4:
* Pick up tagsdrivers/acpi/bus.c | 11 +++++------ drivers/acpi/cppc_acpi.c | 4 +++- include/linux/acpi.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-)drivers/acpi/bus.c +5
-6@@ -298,7 +298,7 @@ EXPORT_SYMBOL_GPL(osc_cpc_flexible_adr_space_confirmed);bool osc_sb_native_usb4_support_confirmed;EXPORT_SYMBOL_GPL (osc_sb_native_usb4_support_confirmed); -bool osc_sb_cppc_not_supported; +bool osc_sb_cppc2_support_acked;static u8 sb_uuid_str[] ="0811B06E-4A27-44F9-8D60-3CBBC22E7B48" ;static void acpi_bus_osc_negotiate_platform_control (void )@@ -358,11 +358,6 @@ static void acpi_bus_osc_negotiate_platform_control(void)return ; } -#ifdef CONFIG_ACPI_CPPC_LIB - osc_sb_cppc_not_supported = !(capbuf_ret[OSC_SUPPORT_DWORD ] & - (OSC_SB_CPC_SUPPORT |OSC_SB_CPCV2_SUPPORT )); -#endif -/* * Now run _OSC again with query flag clear and with the caps * supported by both the OS and the platform. @@ -376,6 +371,10 @@ static void acpi_bus_osc_negotiate_platform_control(void) capbuf_ret = context.ret.pointer;if (context.ret.length >OSC_SUPPORT_DWORD ) { +#ifdef CONFIG_ACPI_CPPC_LIB + osc_sb_cppc2_support_acked = capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_CPCV2_SUPPORT ; +#endif + osc_sb_apei_support_acked = capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_APEI_SUPPORT ; osc_pc_lpi_support_confirmed =drivers/acpi/cppc_acpi.c +3
-1@@ -684,8 +684,10 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)acpi_status status;int ret = -ENODATA ; -if (osc_sb_cppc_not_supported) +if (!osc_sb_cppc2_support_acked) { +pr_debug ("CPPC v2 _OSC not acked\n" );return -ENODEV ; + }/* Parse the ACPI _CPC table for this CPU. */ status = acpi_evaluate_object_typed(handle, "_CPC", NULL, &output,include/linux/acpi.h +0
-0
include/linux/acpi.h acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);
Quoted 9 lines
include/linux/acpi.h +1
-2@@ -584,7 +584,7 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);extern bool osc_sb_apei_support_acked;extern bool osc_pc_lpi_support_confirmed;extern bool osc_sb_native_usb4_support_confirmed; -extern bool osc_sb_cppc_not_supported; +extern bool osc_sb_cppc2_support_acked;extern bool osc_cpc_flexible_adr_space_confirmed;/* USB4 Capabilities */ --
Applied along with the [2/2] as fixes for 5.19-rc, thanks!