[PATCH 14/15 -tip] x86: Add cpufeature for performance frequencyAPERF/MPERF

From: Jaswinder Singh Rajput
Date: Mon May 11 2009 - 13:03:57 EST



X86_FEATURE_PERF_FREQ : Hardware Coordination Feedback Capability
(Presence of IA32_APERF, IA32_MPERF MSRs)

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@xxxxxxxxx>
---
arch/x86/include/asm/cpufeature.h | 1 +
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 9 ++-------
arch/x86/kernel/cpu/intel.c | 9 +++++++++
3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index aee0978..b91cb47 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -168,6 +168,7 @@
#define X86_FEATURE_SMM (7*32+ 13) /* System Management Mode */
#define X86_FEATURE_MM_CFG (7*32+ 14) /* MM configuration */
#define X86_FEATURE_BUS_CFG (7*32+ 15) /* Bus configuration */
+#define X86_FEATURE_PERF_FREQ (7*32+ 16) /* Performance frequency */

/* Virtualization flags: Linux defined */
#define X86_FEATURE_TPR_SHADOW (8*32+ 0) /* Intel TPR Shadow */
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
index 208ecf6..3811ca6 100644
--- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -60,7 +60,6 @@ enum {
};

#define INTEL_MSR_RANGE (0xffff)
-#define CPUID_6_ECX_APERFMPERF_CAPABILITY (0x1)

struct acpi_cpufreq_data {
struct acpi_processor_performance *acpi_data;
@@ -735,12 +734,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
acpi_processor_notify_smm(THIS_MODULE);

/* Check for APERF/MPERF support in hardware */
- if (c->x86_vendor == X86_VENDOR_INTEL && c->cpuid_level >= 6) {
- unsigned int ecx;
- ecx = cpuid_ecx(6);
- if (ecx & CPUID_6_ECX_APERFMPERF_CAPABILITY)
- acpi_cpufreq_driver.getavg = get_measured_perf;
- }
+ if (cpu_has(c, X86_FEATURE_PERF_FREQ))
+ acpi_cpufreq_driver.getavg = get_measured_perf;

dprintk("CPU%u - ACPI performance management activated.\n", cpu);
for (i = 0; i < perf->state_count; i++)
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 9c8f386..9c5169c 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -469,6 +469,15 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
break;
}
}
+ if (c->cpuid_level >= 6) {
+ /*
+ * Hardware Coordination Feedback Capability
+ * (Presence of IA32_APERF, IA32_MPERF MSRs)
+ */
+ l2 = cpuid_ecx(6);
+ if (l2 & 1)
+ set_cpu_cap(c, X86_FEATURE_PERF_FREQ);
+ }
}

#ifdef CONFIG_X86_32
--
1.6.0.6



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/