|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 3/3] 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>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
I don't think the printk() is very helpful. I could be talked into retaining
it as a prink_once(), but (irrespective of cpufreq_verbose), it doesn't want
repeating on each CPU because it will either be all or none of them.
---
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 37989e4a12f0..9b59fec26371 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 82d7827e17c1..c39af2e23d1a 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.
@@ -348,7 +330,7 @@ unsigned int __init powernow_register_driver(void)
if ( !(boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
return -ENODEV;
- 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 ba0fe7c0aa5f..4754940e23f3 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 f11d5439aef7..d6260c801ab5 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 */
--
2.11.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |