diff mbox series

[4/4] x86/amd: Move AMD core type identification code

Message ID 20241021175509.2079-5-mario.limonciello@amd.com (mailing list archive)
State New
Headers show
Series Adjustments for AMD heterogeneous designs | expand

Commit Message

Mario Limonciello Oct. 21, 2024, 5:55 p.m. UTC
The enum used for AMD core type identification is AMD specific so
it should only be in the definition for CONFIG_CPU_SUP_AMD.

Move the enum into this scope and adjust function return types since
enum amd_core_type won't be available in the non CONFIG_CPU_SUP_AMD
case.  Instead of a dedicated enum definition of no hetero support
use -EINVAL.

Suggested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 arch/x86/include/asm/processor.h | 15 +++++++--------
 arch/x86/kernel/acpi/cppc.c      |  2 +-
 arch/x86/kernel/cpu/amd.c        |  7 +++----
 3 files changed, 11 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index d81a6efa81bb0..5b772036f6e83 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -691,15 +691,14 @@  static inline u32 per_cpu_l2c_id(unsigned int cpu)
 	return per_cpu(cpu_info.topo.l2c_id, cpu);
 }
 
+#ifdef CONFIG_CPU_SUP_AMD
 /* defined by CPUID_Fn80000026_EBX BIT [31:28] */
 enum amd_core_type {
-	CPU_CORE_TYPE_NO_HETERO_SUP = -1,
-	CPU_CORE_TYPE_PERFORMANCE = 0,
-	CPU_CORE_TYPE_EFFICIENCY = 1,
-	CPU_CORE_TYPE_UNDEFINED = 2,
+	CPU_CORE_TYPE_PERFORMANCE,
+	CPU_CORE_TYPE_EFFICIENCY,
+	CPU_CORE_TYPE_UNDEFINED,
 };
 
-#ifdef CONFIG_CPU_SUP_AMD
 /*
  * Issue a DIV 0/1 insn to clear any division data from previous DIV
  * operations.
@@ -711,13 +710,13 @@  static __always_inline void amd_clear_divider(void)
 }
 
 extern void amd_check_microcode(void);
-extern enum amd_core_type amd_get_core_type(void);
+extern int amd_get_core_type(void);
 #else
 static inline void amd_clear_divider(void)		{ }
 static inline void amd_check_microcode(void)		{ }
-static inline enum amd_core_type amd_get_core_type(void)
+static inline int amd_get_core_type(void)
 {
-	return CPU_CORE_TYPE_NO_HETERO_SUP;
+	return -EINVAL;
 }
 #endif
 
diff --git a/arch/x86/kernel/acpi/cppc.c b/arch/x86/kernel/acpi/cppc.c
index ca289e6ec82c9..e25494212d964 100644
--- a/arch/x86/kernel/acpi/cppc.c
+++ b/arch/x86/kernel/acpi/cppc.c
@@ -273,7 +273,7 @@  int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator)
 	/* detect if running on heterogeneous design */
 	smp_call_function_single(cpu, amd_do_get_core_type, &core_type, 1);
 	switch (core_type) {
-	case CPU_CORE_TYPE_NO_HETERO_SUP:
+	case -EINVAL:
 		break;
 	case CPU_CORE_TYPE_PERFORMANCE:
 		/* use the max scale for performance cores */
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 0f533e6260d29..a0d17993d52ce 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -1211,10 +1211,9 @@  void amd_check_microcode(void)
  * Returns the CPU type [31:28] (i.e., performance or efficient) of
  * a CPU in the processor.
  *
- * If the processor has no core type support, returns
- * CPU_CORE_TYPE_NO_HETERO_SUP.
+ * If the processor has no core type support, returns -EINVAL.
  */
-enum amd_core_type amd_get_core_type(void)
+int amd_get_core_type(void)
 {
 	struct {
 		u32  num_processors             :16,
@@ -1224,7 +1223,7 @@  enum amd_core_type amd_get_core_type(void)
 	} props;
 
 	if (!cpu_feature_enabled(X86_FEATURE_AMD_HETEROGENEOUS_CORES))
-		return CPU_CORE_TYPE_NO_HETERO_SUP;
+		return -EINVAL;
 
 	cpuid_leaf_reg(0x80000026, CPUID_EBX, &props);
 	if (props.core_type >= CPU_CORE_TYPE_UNDEFINED)