Skip to content

Commit 3743d55

Browse files
huangruiIngo Molnar
authored andcommitted
x86, sched: Fix the AMD CPPC maximum performance value on certain AMD Ryzen generations
Some AMD Ryzen generations has different calculation method on maximum performance. 255 is not for all ASICs, some specific generations should use 166 as the maximum performance. Otherwise, it will report incorrect frequency value like below: ~ → lscpu | grep MHz CPU MHz: 3400.000 CPU max MHz: 7228.3198 CPU min MHz: 2200.0000 [ mingo: Tidied up whitespace use. ] [ Alexander Monakov <[email protected]>: fix 225 -> 255 typo. ] Fixes: 41ea667 ("x86, sched: Calculate frequency invariance for AMD systems") Fixes: 3c55e94 ("cpufreq: ACPI: Extend frequency tables to cover boost frequencies") Reported-by: Jason Bagavatsingham <[email protected]> Fixed-by: Alexander Monakov <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Huang Rui <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Tested-by: Jason Bagavatsingham <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=211791 Signed-off-by: Ingo Molnar <[email protected]>
1 parent 02dbb72 commit 3743d55

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

arch/x86/include/asm/processor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,10 @@ DECLARE_PER_CPU(u64, msr_misc_features_shadow);
787787

788788
#ifdef CONFIG_CPU_SUP_AMD
789789
extern u32 amd_get_nodes_per_socket(void);
790+
extern u32 amd_get_highest_perf(void);
790791
#else
791792
static inline u32 amd_get_nodes_per_socket(void) { return 0; }
793+
static inline u32 amd_get_highest_perf(void) { return 0; }
792794
#endif
793795

794796
static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)

arch/x86/kernel/cpu/amd.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,3 +1165,19 @@ void set_dr_addr_mask(unsigned long mask, int dr)
11651165
break;
11661166
}
11671167
}
1168+
1169+
u32 amd_get_highest_perf(void)
1170+
{
1171+
struct cpuinfo_x86 *c = &boot_cpu_data;
1172+
1173+
if (c->x86 == 0x17 && ((c->x86_model >= 0x30 && c->x86_model < 0x40) ||
1174+
(c->x86_model >= 0x70 && c->x86_model < 0x80)))
1175+
return 166;
1176+
1177+
if (c->x86 == 0x19 && ((c->x86_model >= 0x20 && c->x86_model < 0x30) ||
1178+
(c->x86_model >= 0x40 && c->x86_model < 0x70)))
1179+
return 166;
1180+
1181+
return 255;
1182+
}
1183+
EXPORT_SYMBOL_GPL(amd_get_highest_perf);

arch/x86/kernel/smpboot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,7 @@ static bool amd_set_max_freq_ratio(void)
20432043
return false;
20442044
}
20452045

2046-
highest_perf = perf_caps.highest_perf;
2046+
highest_perf = amd_get_highest_perf();
20472047
nominal_perf = perf_caps.nominal_perf;
20482048

20492049
if (!highest_perf || !nominal_perf) {

drivers/cpufreq/acpi-cpufreq.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,11 @@ static u64 get_max_boost_ratio(unsigned int cpu)
646646
return 0;
647647
}
648648

649-
highest_perf = perf_caps.highest_perf;
649+
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
650+
highest_perf = amd_get_highest_perf();
651+
else
652+
highest_perf = perf_caps.highest_perf;
653+
650654
nominal_perf = perf_caps.nominal_perf;
651655

652656
if (!highest_perf || !nominal_perf) {

0 commit comments

Comments
 (0)