[PATCH v2 3/5] x86/cpufeature: add AMD Accumulated Power Mechanism feature flag

From: Huang Rui
Date: Wed Jan 13 2016 - 21:52:48 EST


AMD CPU family 15h model 0x60 introduces accumulated power mechanism.
It is used to report the processor power consumption and indicated by
CPUID Fn8000_0007_EDX[12].

Signed-off-by: Huang Rui <ray.huang@xxxxxxx>
---
arch/x86/include/asm/cpufeature.h | 2 +-
arch/x86/kernel/cpu/amd.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index f7ba9fb..0adce8f 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -85,7 +85,7 @@
#define X86_FEATURE_P4 ( 3*32+ 7) /* "" P4 */
#define X86_FEATURE_CONSTANT_TSC ( 3*32+ 8) /* TSC ticks at a constant rate */
#define X86_FEATURE_UP ( 3*32+ 9) /* smp kernel running on up */
-/* free, was #define X86_FEATURE_FXSAVE_LEAK ( 3*32+10) * "" FXSAVE leaks FOP/FIP/FOP */
+#define X86_FEATURE_ACC_POWER ( 3*32+10) /* AMD Accumulated Power Mechanism */
#define X86_FEATURE_ARCH_PERFMON ( 3*32+11) /* Intel Architectural PerfMon */
#define X86_FEATURE_PEBS ( 3*32+12) /* Precise-Event Based Sampling */
#define X86_FEATURE_BTS ( 3*32+13) /* Branch Trace Store */
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index d6e320f..97d4ce2 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -559,6 +559,10 @@ static void early_init_amd(struct cpuinfo_x86 *c)
set_sched_clock_stable();
}

+ /* Bit 12 of 8000_0007 edx is accumulated power mechanism. */
+ if (c->x86_power & BIT(12))
+ set_cpu_cap(c, X86_FEATURE_ACC_POWER);
+
#ifdef CONFIG_X86_64
set_cpu_cap(c, X86_FEATURE_SYSCALL32);
#else
--
1.9.1