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

[PATCH v1 04/11] xen/x86: get processor max speed from DMI table


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Tue, 3 Dec 2024 16:11:04 +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=z0U8rdCyjQTujNhBIGlymmnhb0TRmAlHR3r/R+Vaoss=; b=jmwnFeEddpbPpWfiLDgpU6bE7AztxkU/+ojDLAOMIsUPerQpkmPXIxd6UQ2kEmEKt7jctl8Ep+sE6Rq/VYQPjekGGkfeLvHAdAgdLVU+/K1oMq11jm/F3pEnyJjHaSQ+RU0OFopWgokeJaNz+1glgk+0urCciJG9Yh4t7t/oUuZCG0+Jq+LgMt3WeWFhAXSHV55YxgRVw2AU1MjNm/vfgFdGnWbRfL5wZORmYxkSBw8I35f4MsHgr+Ql6Lk04nzmBsBA6ZxVweHx+TxxVhc7MglnNc1O8O2Zt88eKF7oWWSHv9jfg/1muvO1M8Ekh7WZAoFwAutap5rDsE03jJT8wg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RzRVv/8MQzO1pA2BcmN8CA7FPWGJDSWWIecgf1+X1DD2pNvTcDi+OTFpGLMBxps+XEBL3Q/JMHv8cXQpHD6Oap0KadkkOBOet0WqPrP8XWN2gyVkscLS/k+N3wSip8ouCiPzvIAOeLhl4oQEC8fXAiAP5ZXcrshQY/Hk9CRWX0/s0sWlLVTni0Js4MYBStw8wuK9Z7N6wc4gr8oLHSb7LVImITKzsemGlm4Yrv3jS1sslqvisyPzGXywTiHkxhWn9KOfIPA4UUVIhRYi3x2d+sVu5xwwtj2+m7cQqRZLeGwxsokKltI8rWlTm5A18+EZID3spKhDt7O9uAV4ZwEohw==
  • Cc: <stefano.stabellini@xxxxxxx>, <Ray.Huang@xxxxxxx>, <Xenia.Ragiadakou@xxxxxxx>, <Jason.Andryuk@xxxxxxx>, <penny.zheng@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, "Andrew Cooper" <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Tue, 03 Dec 2024 08:22:09 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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

For AMD processors, we rely on parsing DMI table to get processor
max speed.

Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
---
 xen/arch/x86/dmi_scan.c            | 19 +++++++++++++++++++
 xen/include/acpi/cpufreq/cpufreq.h |  2 ++
 xen/include/xen/dmi.h              |  5 +++++
 3 files changed, 26 insertions(+)

diff --git a/xen/arch/x86/dmi_scan.c b/xen/arch/x86/dmi_scan.c
index 2fcc485295..ec9073c04b 100644
--- a/xen/arch/x86/dmi_scan.c
+++ b/xen/arch/x86/dmi_scan.c
@@ -10,6 +10,8 @@
 #include <xen/efi.h>
 #include <xen/pci.h>
 #include <xen/pci_regs.h>
+#include <xen/unaligned.h>
+#include <acpi/cpufreq/cpufreq.h>
 
 #define memcpy_fromio    memcpy
 #define alloc_bootmem(l) xmalloc_bytes(l)
@@ -680,6 +682,23 @@ static void __init cf_check dmi_decode(const struct 
dmi_header *dm)
                                dmi_string(dm, data[6])));
                        dmi_save_ident(dm, DMI_BOARD_VERSION, 6);
                        break;
+               case DMI_ENTRY_PROCESSOR:
+                       dmi_max_speed_mhz = 0;
+                       if ( dm->length >= DMI_ENTRY_PROCESSOR_MIN_LENGTH )
+                       {
+                               dmi_max_speed_mhz = 
(uint16_t)get_unaligned((const uint16_t *)
+                                               (dm + 
DMI_PROCESSOR_MAX_SPEED_OFFSET));
+                               if ( !dmi_max_speed_mhz )
+                                       dmi_printk(("Warnning: read zero value 
for Processor Max Speed\n"));
+                       }
+                       /*
+                        * Real stupid fallback value, just in case there is no
+                        * actual value set.
+                        */
+                       dmi_max_speed_mhz = dmi_max_speed_mhz ? : 1;
+
+                       dmi_printk(("Processor Max Speed: %u\n", 
dmi_max_speed));
+                       break;
        }
 }
 
diff --git a/xen/include/acpi/cpufreq/cpufreq.h 
b/xen/include/acpi/cpufreq/cpufreq.h
index 71e8ca91f0..acf133430b 100644
--- a/xen/include/acpi/cpufreq/cpufreq.h
+++ b/xen/include/acpi/cpufreq/cpufreq.h
@@ -271,4 +271,6 @@ int acpi_cpufreq_register(void);
 int amd_pstate_cmdline_parse(const char *s, const char *e);
 int amd_pstate_register_driver(void);
 
+extern uint16_t dmi_max_speed_mhz;
+
 #endif /* __XEN_CPUFREQ_PM_H__ */
diff --git a/xen/include/xen/dmi.h b/xen/include/xen/dmi.h
index ed6ffda315..158bb6228a 100644
--- a/xen/include/xen/dmi.h
+++ b/xen/include/xen/dmi.h
@@ -1,6 +1,11 @@
 #ifndef __DMI_H__
 #define __DMI_H__
 
+/* Minimum struct length needed for the DMI processor entry we want */
+#define DMI_ENTRY_PROCESSOR_MIN_LENGTH  48
+/* Offset in the DMI processor entry for the max frequency */
+#define DMI_PROCESSOR_MAX_SPEED_OFFSET  0x14
+
 enum dmi_field {
        DMI_NONE,
        DMI_BIOS_VENDOR,
-- 
2.34.1




 


Rackspace

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