[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Thu, 6 Mar 2025 16:39:42 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=B6CnOecAYFlbYtAmXNZIM52L5jLL9etV56RibsihqlM=; b=eRgyBptrM7j1j77ja7PC/Lf4Zcko8U89t3ebdiGayTb1MU7h93/ECr5h9B8uCGzoosqN1itQs1vS2mI87SHl0FU9HNYhqhGMNuxaUR6dKdgPYlmX78/sKAqPcMR1Kst/zck9eo0nsew7OhNMo6exr3Vx9fOf/XrEhXgnuWMhzZ+F+CPYqlaDwP9UaSoUf6owGa/9jXZ4vU3nU8WQTTknKUEDh/5wzpnayr7bAnGh6XxgeKukvWUwEfKjgXV8QLdZ92/cZs+yJOsXSqkNW1lzKAmcPRi6PmrRK24EoqKhpGyx1NBAh62kgkOKCRQgkfXz4EO5YCnrGfDy9ztls/RskQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=woixVp+4Kvk9+vb1eLrU11Ai6jzi+fNyxt714VTRNWdx2cyUKHmdABMbtEdjiUEHxMtUfYPeEOmy+2qmM77DdPkDurgWzWAxNjTYBYWOSYjFcTG6+5zKEOjbWXsDkWcGEmMPpUJVDHVwhpzSy0vGfgGYP2ifskFljrTxLT17OjU6VwhZ3TrBO1sBh11AXYuIEEuMFxhFPmAob+/i4giZ9uTIvlxBRhVTNaFy5DH7lzSCEMsZKzUVjbSOhTqm1pXuBttasLRmiIYIleFUa5I04xJNl568j4Uo8+LRHVJjrCVEa3kIe54IZoWvbgLT27qiZzElu5NHfrjFGB5sMAOKtQ==
  • Cc: <ray.huang@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 06 Mar 2025 08:40:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxx>
---
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@xxxxxxx>
---
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 --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__ */
-- 
2.34.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.