ACPI: processor: Move arch_init_invariance_cppc() call later
Subsystems (7)
PATCH v4 1/1 ACPI: processor: Move arch_init_invariance_cppc() call later
From: Mario Limonciello <[email protected]>
arch_init_invariance_cppc() is called at the end of acpi_cppc_processor_probe() in order to configure frequency invariance based upon the values from _CPC.
This however doesn't work on AMD CPPC shared memory designs that have AMD preferred cores enabled because _CPC needs to be analyzed from all cores to judge if preferred cores are enabled.
This issue manifests to users as a warning since commit 21fb59ab4b97 ("ACPI: CPPC: Adjust debug messages in amd_set_max_freq_ratio() to warn"):
``` Could not retrieve highest performance (-19) ```
However the warning isn't the cause of this, it was actually commit 279f838a61f9 ("x86/amd: Detect preferred cores in amd_get_boost_ratio_numerator()") which exposed the issue.
To fix this problem, change arch_init_invariance_cppc() into a new weak symbol that is called at the end of acpi_processor_driver_init(). Each architecture that supports it can declare the symbol to override the weak one.
---
v4:
* Drop macros and only use symbols
v3:
* Weak symbol instead of macro to help riscv build failure
* Update commit message
* Add comment
--- arch/arm64/include/asm/topology.h | 4 ---- arch/x86/include/asm/topology.h | 5 ----- arch/x86/kernel/acpi/cppc.c | 7 ++++++- drivers/acpi/cppc_acpi.c | 6 ------ drivers/acpi/processor_driver.c | 9 +++++++++ drivers/base/arch_topology.c | 6 +++++- include/acpi/processor.h | 2 ++ include/linux/arch_topology.h | 4 ---- 8 files changed, 22 insertions(+), 21 deletions(-)
arch/arm64/include/asm/topology.h +0 -4
@@ -26,10 +26,6 @@ void update_freq_counters_refs(void);#define arch_scale_freq_invariant topology_scale_freq_invariant#define arch_scale_freq_ref topology_get_freq_ref -#ifdef CONFIG_ACPI_CPPC_LIB -#define arch_init_invariance_cppc topology_init_cpu_capacity_cppc -#endif -/* Replace task scheduler's default cpu-invariant accounting */ #define arch_scale_cpu_capacity topology_get_cpu_scale
arch/x86/include/asm/topology.h +0 -5
@@ -305,9 +305,4 @@ static inline void freq_invariance_set_perf_ratio(u64 ratio, bool turbo_disabledextern void arch_scale_freq_tick (void );#define arch_scale_freq_tick arch_scale_freq_tick -#ifdef CONFIG_ACPI_CPPC_LIB -void init_freq_invariance_cppc (void ); -#define arch_init_invariance_cppc init_freq_invariance_cppc -#endif -#endif /* _ASM_X86_TOPOLOGY_H */
arch/x86/kernel/acpi/cppc.c +6 -1
@@ -110,7 +110,7 @@ static void amd_set_max_freq_ratio(void)static DEFINE_MUTEX (freq_invariance_lock); -void init_freq_invariance_cppc (void ) +static inline void init_freq_invariance_cppc (void ) {static bool init_done;
@@ -127,6 +127,11 @@ void init_freq_invariance_cppc(void)mutex_unlock (&freq_invariance_lock); } +void acpi_processor_init_invariance_cppc (void ) +{ +init_freq_invariance_cppc (); +} +/* * Get the highest performance register value. * @cpu: CPU from which to get highest performance.
drivers/acpi/cppc_acpi.c +0 -6
@@ -671,10 +671,6 @@ static int pcc_data_alloc(int pcc_ss_id)* ) */ -#ifndef arch_init_invariance_cppc -static inline void arch_init_invariance_cppc (void ) { } -#endif -/** * acpi_cppc_processor_probe - Search for per CPU _CPC objects. * @pr: Ptr to acpi_processor containing this CPU's logical ID.
@@ -905,8 +901,6 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) goto out_free; } -arch_init_invariance_cppc (); -kfree (output.pointer);return 0 ;
drivers/acpi/processor_driver.c +9 -0
@@ -237,6 +237,9 @@ static struct notifier_block acpi_processor_notifier_block = { .notifier_call = acpi_processor_notifier, }; +void __weak acpi_processor_init_invariance_cppc (void ) +{ } +/* * We keep the driver loaded even when ACPI is not running. * This is needed for the powernow-k8 driver, that works even without
@@ -270,6 +273,12 @@ static int __init acpi_processor_driver_init(void) NULL, acpi_soft_cpu_dead);acpi_processor_throttling_init (); + +/* +* Frequency invariance calculations on AMD platforms can't be run until +* after acpi_cppc_processor_probe() has been called for all online CPUs +*/ +acpi_processor_init_invariance_cppc ();return 0 ; err:driver_unregister (&acpi_processor_driver);
drivers/base/arch_topology.c +5 -1
@@ -366,7 +366,7 @@ void __weak freq_inv_set_max_ratio(int cpu, u64 max_rate)#ifdef CONFIG_ACPI_CPPC_LIB #include <acpi/cppc_acpi.h> -void topology_init_cpu_capacity_cppc (void ) +static inline void topology_init_cpu_capacity_cppc (void ) {u64 capacity, capacity_scale =0 ;struct cppc_perf_caps perf_caps;
@@ -417,6 +417,10 @@ void topology_init_cpu_capacity_cppc(void) exit: free_raw_capacity(); } +void acpi_processor_init_invariance_cppc (void ) +{ +topology_init_cpu_capacity_cppc (); +}#endif #ifdef CONFIG_CPU_FREQ
include/acpi/processor.h +2 -0
@@ -465,4 +465,6 @@ extern int acpi_processor_ffh_lpi_probe(unsigned int cpu);extern int acpi_processor_ffh_lpi_enter (struct acpi_lpi_state *lpi);#endif +void acpi_processor_init_invariance_cppc (void ); +#endif
include/linux/arch_topology.h +0 -4
@@ -11,10 +11,6 @@void topology_normalize_cpu_scale (void );int topology_update_cpu_topology (void ); -#ifdef CONFIG_ACPI_CPPC_LIB -void topology_init_cpu_capacity_cppc (void ); -#endif -struct device_node ;bool topology_parse_cpu_capacity (struct device_node *cpu_node,int cpu);
base-commit: 6db936d4ac0fe281af48b4d1ebf69b1523bbac31
Signature · 1 line
2.43.0
Rafael J. Wysocki
maintainerQuoted 17 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
arch_init_invariance_cppc()is called at the end ofacpi_cppc_processor_probe()in order to configure frequency invariance based upon the values from_CPC.This however doesn't work on AMD CPPC shared memory designs that have AMD preferred cores enabled because
_CPCneeds to be analyzed from all cores to judge if preferred cores are enabled.This issue manifests to users as a warning since commit
21fb59ab4b97("ACPI: CPPC: Adjust debug messages inamd_set_max_freq_ratio()to warn"):``` Could not retrieve highest performance (-19) ```
Quoted 8 lines
However the warning isn't the cause of this, it was actually commit
279f838a61f9("x86/amd: Detect preferred cores inamd_get_boost_ratio_numerator()") which exposed the issue.To fix this problem, change
arch_init_invariance_cppc()into a new weak symbol that is called at the end ofacpi_processor_driver_init(). Each architecture that supports it can declare the symbol to override the weak one.
"Define it for x86, in arch/x86/kernel/acpi/cppc.c, and for all of the architectures using the generic arch_topology.c code."
Quoted 183 lines
Fixes 279f838a61f9 ("x86/amd: Detect preferred cores in amd_get_boost_ratio_numerator()")Reported-by Ivan Shapovalov <[email protected]>Tested-by Oleksandr Natalenko <[email protected]>Signed-off-by Mario Limonciello <[email protected]>---
v4:
* Drop macros and only use symbols
v3:
* Weak symbol instead of macro to help riscv build failure
* Update commit message
* Add comment--- arch/arm64/include/asm/topology.h | 4 ---- arch/x86/include/asm/topology.h | 5 ----- arch/x86/kernel/acpi/cppc.c | 7 ++++++- drivers/acpi/cppc_acpi.c | 6 ------ drivers/acpi/processor_driver.c | 9 +++++++++ drivers/base/arch_topology.c | 6 +++++- include/acpi/processor.h | 2 ++ include/linux/arch_topology.h | 4 ---- 8 files changed, 22 insertions(+), 21 deletions(-)arch/arm64/include/asm/topology.h +0
-4@@ -26,10 +26,6 @@ void update_freq_counters_refs(void);#define arch_scale_freq_invariant topology_scale_freq_invariant#define arch_scale_freq_ref topology_get_freq_ref -#ifdef CONFIG_ACPI_CPPC_LIB -#define arch_init_invariance_cppc topology_init_cpu_capacity_cppc -#endif -/* Replace task scheduler's default cpu-invariant accounting */ #define arch_scale_cpu_capacity topology_get_cpu_scalearch/x86/include/asm/topology.h +0
-5@@ -305,9 +305,4 @@ static inline void freq_invariance_set_perf_ratio(u64 ratio, bool turbo_disabledextern void arch_scale_freq_tick (void );#define arch_scale_freq_tick arch_scale_freq_tick -#ifdef CONFIG_ACPI_CPPC_LIB -void init_freq_invariance_cppc (void ); -#define arch_init_invariance_cppc init_freq_invariance_cppc -#endif -#endif /* _ASM_X86_TOPOLOGY_H */ arch/x86/kernel/acpi/cppc.c +6
-1@@ -110,7 +110,7 @@ static void amd_set_max_freq_ratio(void)static DEFINE_MUTEX (freq_invariance_lock); -void init_freq_invariance_cppc (void ) +static inline void init_freq_invariance_cppc (void ) {static bool init_done;@@ -127,6 +127,11 @@ void init_freq_invariance_cppc(void)mutex_unlock (&freq_invariance_lock); } +void acpi_processor_init_invariance_cppc (void ) +{ +init_freq_invariance_cppc (); +} +/* * Get the highest performance register value. * @cpu: CPU from which to get highest performance. drivers/acpi/cppc_acpi.c +0
-6@@ -671,10 +671,6 @@ static int pcc_data_alloc(int pcc_ss_id)* ) */ -#ifndef arch_init_invariance_cppc -static inline void arch_init_invariance_cppc (void ) { } -#endif -/** * acpi_cppc_processor_probe - Search for per CPU _CPC objects. * @pr: Ptr to acpi_processor containing this CPU's logical ID. @@ -905,8 +901,6 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) goto out_free; } -arch_init_invariance_cppc (); -kfree (output.pointer);return 0 ;drivers/acpi/processor_driver.c +9
-0@@ -237,6 +237,9 @@ static struct notifier_block acpi_processor_notifier_block = { .notifier_call = acpi_processor_notifier, }; +void __weak acpi_processor_init_invariance_cppc (void ) +{ } +/* * We keep the driver loaded even when ACPI is not running. * This is needed for the powernow-k8 driver, that works even without @@ -270,6 +273,12 @@ static int __init acpi_processor_driver_init(void) NULL, acpi_soft_cpu_dead);acpi_processor_throttling_init (); + +/* +* Frequency invariance calculations on AMD platforms can't be run until +* after acpi_cppc_processor_probe() has been called for all online CPUs +*/ +acpi_processor_init_invariance_cppc ();return 0 ; err:driver_unregister (&acpi_processor_driver);drivers/base/arch_topology.c +5
-1@@ -366,7 +366,7 @@ void __weak freq_inv_set_max_ratio(int cpu, u64 max_rate)#ifdef CONFIG_ACPI_CPPC_LIB #include <acpi/cppc_acpi.h> -void topology_init_cpu_capacity_cppc (void ) +static inline void topology_init_cpu_capacity_cppc (void ) {u64 capacity, capacity_scale =0 ;struct cppc_perf_caps perf_caps;@@ -417,6 +417,10 @@ void topology_init_cpu_capacity_cppc(void) exit: free_raw_capacity(); } +void acpi_processor_init_invariance_cppc (void ) +{ +topology_init_cpu_capacity_cppc (); +}#endif #ifdef CONFIG_CPU_FREQ include/acpi/processor.h +2
-0@@ -465,4 +465,6 @@ extern int acpi_processor_ffh_lpi_probe(unsigned int cpu);extern int acpi_processor_ffh_lpi_enter (struct acpi_lpi_state *lpi);#endif +void acpi_processor_init_invariance_cppc (void ); +#endif include/linux/arch_topology.h +0
-4@@ -11,10 +11,6 @@void topology_normalize_cpu_scale (void );int topology_update_cpu_topology (void ); -#ifdef CONFIG_ACPI_CPPC_LIB -void topology_init_cpu_capacity_cppc (void ); -#endif -struct device_node ;bool topology_parse_cpu_capacity (struct device_node *cpu_node,int cpu);base-commit:
6db936d4ac0fe281af48b4d1ebf69b1523bbac31--
2.43.0
Rafael J. Wysocki
maintainerQuoted 23 lines · Rafael J. Wysocki
Quoted 21 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
arch_init_invariance_cppc()is called at the end ofacpi_cppc_processor_probe()in order to configure frequency invariance based upon the values from_CPC.This however doesn't work on AMD CPPC shared memory designs that have AMD preferred cores enabled because
_CPCneeds to be analyzed from all cores to judge if preferred cores are enabled.This issue manifests to users as a warning since commit
21fb59ab4b97("ACPI: CPPC: Adjust debug messages inamd_set_max_freq_ratio()to warn"):``` Could not retrieve highest performance (-19) ```However the warning isn't the cause of this, it was actually commit
279f838a61f9("x86/amd: Detect preferred cores inamd_get_boost_ratio_numerator()") which exposed the issue.
Quoted 7 lines
Quoted 4 lines
To fix this problem, change
arch_init_invariance_cppc()into a new weak symbol that is called at the end ofacpi_processor_driver_init(). Each architecture that supports it can declare the symbol to override the weak one."Define it for x86, in
arch/x86/kernel/acpi/cppc.c, and for all of the architectures using the genericarch_topology.ccode."
I've added this to the patch changelog and queued it up as a 6.12 fix.
Thanks!
Quoted 29 lines · Rafael J. Wysocki
Quoted 28 lines · Rafael J. Wysocki
Quoted 25 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
arch_init_invariance_cppc()is called at the end ofacpi_cppc_processor_probe()in order to configure frequency invariance based upon the values from_CPC.This however doesn't work on AMD CPPC shared memory designs that have AMD preferred cores enabled because
_CPCneeds to be analyzed from all cores to judge if preferred cores are enabled.This issue manifests to users as a warning since commit
21fb59ab4b97("ACPI: CPPC: Adjust debug messages inamd_set_max_freq_ratio()to warn"):``` Could not retrieve highest performance (-19) ```However the warning isn't the cause of this, it was actually commit
279f838a61f9("x86/amd: Detect preferred cores inamd_get_boost_ratio_numerator()") which exposed the issue.To fix this problem, change
arch_init_invariance_cppc()into a new weak symbol that is called at the end ofacpi_processor_driver_init(). Each architecture that supports it can declare the symbol to override the weak one.
Quoted 6 lines
Quoted 2 lines
"Define it for x86, in
arch/x86/kernel/acpi/cppc.c, and for all of the architectures using the genericarch_topology.ccode."I've added this to the patch changelog and queued it up as a 6.12 fix.
Thanks!
Thanks!