Skip to contentSkip to conversation

ACPI: processor: Move arch_init_invariance_cppc() call later

PATCH Applied Mario Limonciello 2 participants 4 messages Nov 2, 2024 – Nov 4, 2024

Subsystems (3)

v2 of 4 Applied Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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, push the call to the arch_init_invariance_cppc() macro to the end of acpi_processor_driver_init().

Fixes 279f838a61f9 ("x86/amd: Detect preferred cores in amd_get_boost_ratio_numerator()")

---
v1->v2:
* Fix LKP robot issue when CONFIG_ACPI_CPPC_LIB not defined

---
 arch/x86/include/asm/topology.h | 2 ++
 drivers/acpi/cppc_acpi.c        | 6 ------
 drivers/acpi/processor_driver.c | 1 +
 3 files changed, 3 insertions(+), 6 deletions(-)
arch/x86/include/asm/topology.h +2 -0
index abe3a8f22cbd..b04c5db7e945 100644
@@ -295,6 +295,8 @@ extern void arch_scale_freq_tick(void);
 #ifdef CONFIG_ACPI_CPPC_LIB
 void init_freq_invariance_cppc(void);
 #define arch_init_invariance_cppc init_freq_invariance_cppc
+#else
+static inline void arch_init_invariance_cppc(void) { }
 #endif
 
 #endif /* _ASM_X86_TOPOLOGY_H */
drivers/acpi/cppc_acpi.c +0 -6
index ed91dfd4fdca..9d48cd706659 100644
@@ -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 +1 -0
index cb52dd000b95..59620e7bc664 100644
@@ -270,6 +270,7 @@ static int __init acpi_processor_driver_init(void)
 				  NULL, acpi_soft_cpu_dead);
 
 	acpi_processor_throttling_init();
+	arch_init_invariance_cppc();
 	return 0;
 err:
 	driver_unregister(&acpi_processor_driver);
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 80 lines · Mario Limonciello

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, push the call to the arch_init_invariance_cppc() macro to the end of acpi_processor_driver_init().

Fixes 279f838a61f9 ("x86/amd: Detect preferred cores in amd_get_boost_ratio_numerator()")

---
v1->v2:
* Fix LKP robot issue when CONFIG_ACPI_CPPC_LIB not defined

---
 arch/x86/include/asm/topology.h | 2 ++
 drivers/acpi/cppc_acpi.c        | 6 ------
 drivers/acpi/processor_driver.c | 1 +
 3 files changed, 3 insertions(+), 6 deletions(-)
arch/x86/include/asm/topology.h +2 -0
index abe3a8f22cbd..b04c5db7e945 100644
@@ -295,6 +295,8 @@ extern void arch_scale_freq_tick(void);
 #ifdef CONFIG_ACPI_CPPC_LIB
 void init_freq_invariance_cppc(void);
 #define arch_init_invariance_cppc init_freq_invariance_cppc
+#else
+static inline void arch_init_invariance_cppc(void) { }
 #endif
 
 #endif /* _ASM_X86_TOPOLOGY_H */
drivers/acpi/cppc_acpi.c +0 -6
index ed91dfd4fdca..9d48cd706659 100644
@@ -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 +0 -0
index cb52dd000b95..59620e7bc664 100644

drivers/acpi/processor_driver.c static int __init acpi_processor_driver_init(void)

Quoted 8 lines
drivers/acpi/processor_driver.c +1 -1
@@ -270,6 +270,7 @@ static int __init acpi_processor_driver_init(void)
                                  NULL, acpi_soft_cpu_dead);
 
        acpi_processor_throttling_init();
+       arch_init_invariance_cppc();
        return 0;
 err:
        driver_unregister(&acpi_processor_driver);
--

Applied as a fix for 6.12-rc7.

However, it would be good to add a comment explaining why acpi_processor_driver_init() calls arch_init_invariance_cppc() at the end. The ACPI processor driver and CPPC are not otherwise related I think?

#2 lore raw
Quoted 92 lines · Rafael J. Wysocki
Quoted 80 lines · Mario Limonciello

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, push the call to the arch_init_invariance_cppc() macro to the end of acpi_processor_driver_init().

Fixes 279f838a61f9 ("x86/amd: Detect preferred cores in amd_get_boost_ratio_numerator()")

---
v1->v2:
* Fix LKP robot issue when CONFIG_ACPI_CPPC_LIB not defined

---
  arch/x86/include/asm/topology.h | 2 ++
  drivers/acpi/cppc_acpi.c        | 6 ------
  drivers/acpi/processor_driver.c | 1 +
  3 files changed, 3 insertions(+), 6 deletions(-)
arch/x86/include/asm/topology.h +2 -0
index abe3a8f22cbd..b04c5db7e945 100644
@@ -295,6 +295,8 @@ extern void arch_scale_freq_tick(void);
  #ifdef CONFIG_ACPI_CPPC_LIB
  void init_freq_invariance_cppc(void);
  #define arch_init_invariance_cppc init_freq_invariance_cppc
+#else
+static inline void arch_init_invariance_cppc(void) { }
  #endif
 
  #endif /* _ASM_X86_TOPOLOGY_H */
drivers/acpi/cppc_acpi.c +0 -6
index ed91dfd4fdca..9d48cd706659 100644
@@ -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 +0 -0
index cb52dd000b95..59620e7bc664 100644

drivers/acpi/processor_driver.c static int __init acpi_processor_driver_init(void)

Quoted 8 lines
drivers/acpi/processor_driver.c +1 -1
@@ -270,6 +270,7 @@ static int __init acpi_processor_driver_init(void)
                                   NULL, acpi_soft_cpu_dead);
 
         acpi_processor_throttling_init();
+       arch_init_invariance_cppc();
         return 0;
  err:
         driver_unregister(&acpi_processor_driver);
--

Applied as a fix for 6.12-rc7.

Quoted 4 lines

However, it would be good to add a comment explaining why acpi_processor_driver_init() calls arch_init_invariance_cppc() at the end. The ACPI processor driver and CPPC are not otherwise related I think?

Sure, I'm thinking a comment like this.

/*
* Frequency invariance calculations on AMD platforms can't be run until
* _CPC has been evaluated on all processors which will only happen
* after probing is complete.
*/

If that sounds good do you want to squash it in? Or if you would prefer another commit tacked on that's no problem I'll do that.

#3 lore raw
Quoted 99 lines · Mario Limonciello
Quoted 92 lines · Rafael J. Wysocki
Quoted 80 lines · Mario Limonciello

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, push the call to the arch_init_invariance_cppc() macro to the end of acpi_processor_driver_init().

Fixes 279f838a61f9 ("x86/amd: Detect preferred cores in amd_get_boost_ratio_numerator()")

---
v1->v2:
* Fix LKP robot issue when CONFIG_ACPI_CPPC_LIB not defined

---
  arch/x86/include/asm/topology.h | 2 ++
  drivers/acpi/cppc_acpi.c        | 6 ------
  drivers/acpi/processor_driver.c | 1 +
  3 files changed, 3 insertions(+), 6 deletions(-)
arch/x86/include/asm/topology.h +2 -0
index abe3a8f22cbd..b04c5db7e945 100644
@@ -295,6 +295,8 @@ extern void arch_scale_freq_tick(void);
  #ifdef CONFIG_ACPI_CPPC_LIB
  void init_freq_invariance_cppc(void);
  #define arch_init_invariance_cppc init_freq_invariance_cppc
+#else
+static inline void arch_init_invariance_cppc(void) { }
  #endif
 
  #endif /* _ASM_X86_TOPOLOGY_H */
drivers/acpi/cppc_acpi.c +0 -6
index ed91dfd4fdca..9d48cd706659 100644
@@ -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 +0 -0
index cb52dd000b95..59620e7bc664 100644

drivers/acpi/processor_driver.c static int __init acpi_processor_driver_init(void)

Quoted 8 lines
drivers/acpi/processor_driver.c +1 -1
@@ -270,6 +270,7 @@ static int __init acpi_processor_driver_init(void)
                                   NULL, acpi_soft_cpu_dead);
 
         acpi_processor_throttling_init();
+       arch_init_invariance_cppc();
         return 0;
  err:
         driver_unregister(&acpi_processor_driver);
--

Applied as a fix for 6.12-rc7.

Quoted 4 lines

However, it would be good to add a comment explaining why acpi_processor_driver_init() calls arch_init_invariance_cppc() at the end. The ACPI processor driver and CPPC are not otherwise related I think?

Quoted 7 lines

Sure, I'm thinking a comment like this.

/*
* Frequency invariance calculations on AMD platforms can't be run until
* _CPC has been evaluated on all processors which will only happen
* after probing is complete.
*/

It would be more precise to say "after acpi_cppc_processor_probe() has been called for all online CPUs".

Which among other things means that the ordering of this call with respect to acpi_processor_throttling_init() does not matter.

Quoted 2 lines

If that sounds good do you want to squash it in? Or if you would prefer another commit tacked on that's no problem I'll do that.

IMV a separate patch for 6.13 will be fine.