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

[xen master] x86/cpufreq: Drop opencoded CPUID handling from powernow



commit 5d9974916bca25ce2d00b888f54b89e9eabdcc92
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Fri Nov 12 16:00:13 2021 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Mon Nov 29 13:53:05 2021 +0000

    x86/cpufreq: Drop opencoded CPUID handling from powernow
    
    Xen already collects CPUID.0x80000007.edx by default, meaning that we can
    refer to per-cpu data directly.  This also avoids the need IPI the onlining
    CPU to identify whether Core Performance Boost is available.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 tools/misc/xen-cpuid.c                      |  3 ++-
 xen/arch/x86/acpi/cpufreq/powernow.c        | 26 ++++----------------------
 xen/include/asm-x86/cpufeature.h            |  1 +
 xen/include/public/arch-x86/cpufeatureset.h |  2 ++
 4 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 37989e4a12..9b59fec263 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -139,7 +139,8 @@ static const char *const str_7c0[32] =
 
 static const char *const str_e7d[32] =
 {
-    [ 8] = "itsc",
+    /* 6 */                    [ 7] = "hw-pstate",
+    [ 8] = "itsc",             [ 9] = "cpb",
     [10] = "efro",
 };
 
diff --git a/xen/arch/x86/acpi/cpufreq/powernow.c 
b/xen/arch/x86/acpi/cpufreq/powernow.c
index 97a883e7a7..da8fc40b9a 100644
--- a/xen/arch/x86/acpi/cpufreq/powernow.c
+++ b/xen/arch/x86/acpi/cpufreq/powernow.c
@@ -32,9 +32,6 @@
 #include <acpi/acpi.h>
 #include <acpi/cpufreq/cpufreq.h>
 
-#define CPUID_FREQ_VOLT_CAPABILITIES    0x80000007
-#define CPB_CAPABLE             0x00000200
-#define USE_HW_PSTATE           0x00000080
 #define HW_PSTATE_MASK          0x00000007
 #define HW_PSTATE_VALID_MASK    0x80000000
 #define HW_PSTATE_MAX_MASK      0x000000f0
@@ -200,21 +197,6 @@ static int powernow_cpufreq_verify(struct cpufreq_policy 
*policy)
     return cpufreq_frequency_table_verify(policy, data->freq_table);
 }
 
-static void feature_detect(void *info)
-{
-    struct cpufreq_policy *policy = info;
-    unsigned int edx;
-
-    edx = cpuid_edx(CPUID_FREQ_VOLT_CAPABILITIES);
-    if ((edx & CPB_CAPABLE) == CPB_CAPABLE) {
-        policy->turbo = CPUFREQ_TURBO_ENABLED;
-        if (cpufreq_verbose)
-            printk(XENLOG_INFO
-                   "CPU%u: Core Boost/Turbo detected and enabled\n",
-                   smp_processor_id());
-    }
-}
-
 static int powernow_cpufreq_cpu_init(struct cpufreq_policy *policy)
 {
     unsigned int i;
@@ -300,9 +282,9 @@ static int powernow_cpufreq_cpu_init(struct cpufreq_policy 
*policy)
     if (result)
         goto err_freqfree;
 
-    if (c->cpuid_level >= 6)
-        on_selected_cpus(cpumask_of(cpu), feature_detect, policy, 1);
-      
+    if ( cpu_has(c, X86_FEATURE_CPB) )
+        policy->turbo = CPUFREQ_TURBO_ENABLED;
+
     /*
      * the first call to ->target() should result in us actually
      * writing something to the appropriate registers.
@@ -345,7 +327,7 @@ static const struct cpufreq_driver __initconstrel 
powernow_cpufreq_driver = {
 
 unsigned int __init powernow_register_driver(void)
 {
-    if ( !(cpuid_edx(CPUID_FREQ_VOLT_CAPABILITIES) & USE_HW_PSTATE) )
+    if ( !cpu_has_hw_pstate )
         return -ENODEV;
 
     return cpufreq_register_driver(&powernow_cpufreq_driver);
diff --git a/xen/include/asm-x86/cpufeature.h b/xen/include/asm-x86/cpufeature.h
index ba0fe7c0aa..4754940e23 100644
--- a/xen/include/asm-x86/cpufeature.h
+++ b/xen/include/asm-x86/cpufeature.h
@@ -122,6 +122,7 @@
 #define cpu_has_enqcmd          boot_cpu_has(X86_FEATURE_ENQCMD)
 
 /* CPUID level 0x80000007.edx */
+#define cpu_has_hw_pstate       boot_cpu_has(X86_FEATURE_HW_PSTATE)
 #define cpu_has_itsc            boot_cpu_has(X86_FEATURE_ITSC)
 
 /* CPUID level 0x80000008.ebx */
diff --git a/xen/include/public/arch-x86/cpufeatureset.h 
b/xen/include/public/arch-x86/cpufeatureset.h
index f11d5439ae..d6260c801a 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -247,7 +247,9 @@ XEN_CPUFEATURE(MOVDIR64B,     6*32+28) /*a  MOVDIR64B 
instruction */
 XEN_CPUFEATURE(ENQCMD,        6*32+29) /*   ENQCMD{,S} instructions */
 
 /* AMD-defined CPU features, CPUID level 0x80000007.edx, word 7 */
+XEN_CPUFEATURE(HW_PSTATE,     7*32+ 7) /*   Hardware Pstates */
 XEN_CPUFEATURE(ITSC,          7*32+ 8) /*a  Invariant TSC */
+XEN_CPUFEATURE(CPB,           7*32+ 9) /*   Core Performance Boost (Turbo) */
 XEN_CPUFEATURE(EFRO,          7*32+10) /*   APERF/MPERF Read Only interface */
 
 /* AMD-defined CPU features, CPUID level 0x80000008.ebx, word 8 */
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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