From: Mario Limonciello <mario.limonciello@amd.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, "H . Peter Anvin" <hpa@zytor.com>,
"Rafael J . Wysocki" <rafael@kernel.org>,
"Gautham R . Shenoy" <gautham.shenoy@amd.com>,
Mario Limonciello <mario.limonciello@amd.com>,
Perry Yuan <perry.yuan@amd.com>,
Brijesh Singh <brijesh.singh@amd.com>,
Peter Zijlstra <peterz@infradead.org>,
Li RongQing <lirongqing@baidu.com>,
"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<linux-kernel@vger.kernel.org>,
"open list:ACPI" <linux-acpi@vger.kernel.org>,
"open list:AMD PSTATE DRIVER" <linux-pm@vger.kernel.org>
Subject: [PATCH 4/4] x86/amd: Move AMD core type identification code
Date: Mon, 21 Oct 2024 12:55:09 -0500 [thread overview]
Message-ID: <20241021175509.2079-5-mario.limonciello@amd.com> (raw)
In-Reply-To: <20241021175509.2079-1-mario.limonciello@amd.com>
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 --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)
--
2.43.0
prev parent reply other threads:[~2024-10-21 17:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-21 17:55 [PATCH 0/4] Adjustments for AMD heterogeneous designs Mario Limonciello
2024-10-21 17:55 ` [PATCH 1/4] x86/cpufeatures: Rename X86_FEATURE_FAST_CPPC to have AMD prefix Mario Limonciello
2024-10-21 17:55 ` [PATCH 2/4] x86/cpufeatures: Rename X86_FEATURE_HETERO_CORE_TOPOLOGY to X86_FEATURE_AMD_HETEROGENEOUS_CORES Mario Limonciello
2024-10-21 18:17 ` Mario Limonciello
2024-10-21 17:55 ` [PATCH 3/4] x86/cpu: Enable SD_ASYM_PACKING for PKG Domain on AMD Processors Mario Limonciello
2024-10-21 17:55 ` Mario Limonciello [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241021175509.2079-5-mario.limonciello@amd.com \
--to=mario.limonciello@amd.com \
--cc=bp@alien8.de \
--cc=brijesh.singh@amd.com \
--cc=dave.hansen@linux.intel.com \
--cc=gautham.shenoy@amd.com \
--cc=hpa@zytor.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=mingo@redhat.com \
--cc=perry.yuan@amd.com \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®