diff mbox series

[v3,08/15] xen/amd: export processor max frequency value

Message ID 20250306083949.1503385-9-Penny.Zheng@amd.com (mailing list archive)
State New
Headers show
Series amd-cppc CPU Performance Scaling Driver | expand

Commit Message

Penny Zheng March 6, 2025, 8:39 a.m. UTC
When _CPC table could not provide processor frequency range
values for Xen governor, we need to read processor max frequency
as anchor point.

For AMD processors, we export max frequency value from amd_log_freq()

Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
---
v1 -> v2:
- new commit
---
xen/amd: export processor max frequency value

When _CPC table could not provide processor frequency range
values for Xen governor, we need to read processor max frequency
as anchor point.

For AMD processors, we export max frequency value from amd_log_freq()

Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
---
v1 -> v2:
- new commit
---
v2 -> v3:
- Replace per_cpu with this_cpu
- Add amd_ prefix for AMD-only variable
---
 xen/arch/x86/cpu/amd.c         | 10 +++++++++-
 xen/arch/x86/include/asm/amd.h |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index 7fb1d76798..6ab1cff3e5 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -56,6 +56,8 @@  bool __initdata amd_virt_spec_ctrl;
 
 static bool __read_mostly fam17_c6_disabled;
 
+DEFINE_PER_CPU_READ_MOSTLY(uint64_t, amd_max_freq_mhz);
+
 static inline int rdmsr_amd_safe(unsigned int msr, unsigned int *lo,
 				 unsigned int *hi)
 {
@@ -681,9 +683,15 @@  void amd_log_freq(const struct cpuinfo_x86 *c)
 		printk("CPU%u: %lu ... %lu MHz\n",
 		       smp_processor_id(),
 		       amd_parse_freq(c, lo), amd_parse_freq(c, hi));
-	else
+	else {
 		printk("CPU%u: %lu MHz\n", smp_processor_id(),
 		       amd_parse_freq(c, lo));
+		return;
+	}
+
+	/* Store max frequency for amd-cppc cpufreq driver */
+	if (hi >> 63)
+		this_cpu(amd_max_freq_mhz) = amd_parse_freq(c, hi);
 }
 
 void cf_check early_init_amd(struct cpuinfo_x86 *c)
diff --git a/xen/arch/x86/include/asm/amd.h b/xen/arch/x86/include/asm/amd.h
index 9c9599a622..cf9177c00a 100644
--- a/xen/arch/x86/include/asm/amd.h
+++ b/xen/arch/x86/include/asm/amd.h
@@ -174,4 +174,5 @@  bool amd_setup_legacy_ssbd(void);
 void amd_set_legacy_ssbd(bool enable);
 void amd_set_cpuid_user_dis(bool enable);
 
+DECLARE_PER_CPU(uint64_t, amd_max_freq_mhz);
 #endif /* __AMD_H__ */