[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240626042043.2410-2-mario.limonciello@amd.com>
Date: Tue, 25 Jun 2024 23:20:42 -0500
From: Mario Limonciello <mario.limonciello@....com>
To: Borislav Petkov <bp@...en8.de>, "Gautham R . Shenoy"
<gautham.shenoy@....com>, Perry Yuan <perry.yuan@....com>
CC: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
"Dave Hansen" <dave.hansen@...ux.intel.com>, "maintainer:X86 ARCHITECTURE
(32-BIT AND 64-BIT)" <x86@...nel.org>, "H . Peter Anvin" <hpa@...or.com>,
Huang Rui <ray.huang@....com>, Mario Limonciello <mario.limonciello@....com>,
"Rafael J . Wysocki" <rafael@...nel.org>, Viresh Kumar
<viresh.kumar@...aro.org>, Nikolay Borisov <nik.borisov@...e.com>, Peter
Zijlstra <peterz@...radead.org>, "open list:X86 ARCHITECTURE (32-BIT AND
64-BIT)" <linux-kernel@...r.kernel.org>, "open list:AMD PSTATE DRIVER"
<linux-pm@...r.kernel.org>
Subject: [PATCH 1/2] x86/cpu/amd: Clarify amd_get_highest_perf()
Rather than parsing through families and models as an if/else, use
cpu_feature_enabled() and switch/case.
Add definitions aligned with the amd-pstate definition for performance
levels. No intended functional changes.
Signed-off-by: Mario Limonciello <mario.limonciello@....com>
---
arch/x86/kernel/cpu/amd.c | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 44df3f11e731..8b730193d79e 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -29,6 +29,10 @@
#include "cpu.h"
+#define CPPC_HIGHEST_PERF_MAX 255
+#define CPPC_HIGHEST_PERF_PERFORMANCE 196
+#define CPPC_HIGHEST_PERF_DEFAULT 166
+
static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
{
u32 gprs[8] = { 0 };
@@ -1194,15 +1198,27 @@ u32 amd_get_highest_perf(void)
{
struct cpuinfo_x86 *c = &boot_cpu_data;
- if (c->x86 == 0x17 && ((c->x86_model >= 0x30 && c->x86_model < 0x40) ||
- (c->x86_model >= 0x70 && c->x86_model < 0x80)))
- return 166;
+ if (cpu_feature_enabled(X86_FEATURE_ZEN2)) {
+ switch (c->x86_model) {
+ case 0x30 ... 0x40:
+ case 0x70 ... 0x80:
+ return CPPC_HIGHEST_PERF_DEFAULT;
+ default:
+ return CPPC_HIGHEST_PERF_MAX;
+ }
+ }
- if (c->x86 == 0x19 && ((c->x86_model >= 0x20 && c->x86_model < 0x30) ||
- (c->x86_model >= 0x40 && c->x86_model < 0x70)))
- return 166;
+ if (cpu_feature_enabled(X86_FEATURE_ZEN3)) {
+ switch (c->x86_model) {
+ case 0x20 ... 0x30:
+ case 0x40 ... 0x70:
+ return CPPC_HIGHEST_PERF_DEFAULT;
+ default:
+ return CPPC_HIGHEST_PERF_MAX;
+ }
+ }
- return 255;
+ return CPPC_HIGHEST_PERF_MAX;
}
EXPORT_SYMBOL_GPL(amd_get_highest_perf);
--
2.43.0
Powered by blists - more mailing lists