Add APERF/MPERF support for AMD processors
Subsystems (2)
PATCH 1/1 Add APERF/MPERF support for AMD processors
Starting with model 10 of Family 0x10, AMD processors may have support for APERF/MPERF. Add support for identifying it and using it within cpufreq. Move the APERF/MPERF functions out of the acpi-cpufreq code and into their own file so they can easily be shared.
--- arch/x86/kernel/cpu/amd.c | 6 +++ arch/x86/kernel/cpu/cpufreq/Makefile | 4 +- arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 42 +----------------------- arch/x86/kernel/cpu/cpufreq/mperf.c | 50 ++++++++++++++++++++++++++++ arch/x86/kernel/cpu/cpufreq/mperf.h | 9 +++++ arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 4 ++- arch/x86/kernel/cpu/perf_event_amd.c | 2 +- 7 files changed, 72 insertions(+), 45 deletions(-) create mode 100644 arch/x86/kernel/cpu/cpufreq/mperf.c create mode 100644 arch/x86/kernel/cpu/cpufreq/mperf.h
arch/x86/kernel/cpu/amd.c +6 -0
@@ -537,6 +537,12 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)set_cpu_cap (c,X86_FEATURE_MFENCE_RDTSC ); } +if (c->cpuid_level >=6 ) { +unsigned ecx =cpuid_ecx (6 ); +if (ecx &0x01 ) +set_cpu_cap (c,X86_FEATURE_APERFMPERF ); + } +#ifdef CONFIG_X86_64 if (c->x86 ==0x10 ) {/* do this for boot cpu */
(quoted diff) +0 -0
b/arch/x86/kernel/cpu/cpufreq/Makefile
index 509296d..39cc160 100644
arch/x86/kernel/cpu/cpufreq/Makefile +2 -2
@@ -2,8 +2,8 @@ # K8 systems. ACPI is preferred to all other hardware-specific drivers. # speedstep-* is preferred over p4-clockmod. -obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o -obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o +obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o mperf.o +obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o mperf.o obj-$(CONFIG_X86_POWERNOW_K6) += powernow-k6.o obj-$(CONFIG_X86_POWERNOW_K7) += powernow-k7.o obj-$(CONFIG_X86_LONGHAUL) += longhaul.o
(quoted diff) +0 -0
b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
index 1b1920f..b3bd6b3 100644
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +1 -41
60 lines not on this page · raw message
(quoted diff) +0 -0
b/arch/x86/kernel/cpu/cpufreq/mperf.c
new file mode 100644
index 0000000..7a0a753
arch/x86/kernel/cpu/cpufreq/mperf.c new file +50 -0
50 lines not on this page · raw message
(quoted diff) +0 -0
b/arch/x86/kernel/cpu/cpufreq/mperf.h
new file mode 100644
index 0000000..67a7b64
arch/x86/kernel/cpu/cpufreq/mperf.h new file +9 -0
@@ -0,0 +1,9 @@ +/* +* (c) 2003-2006 Advanced Micro Devices, Inc. +* Your use of this code is subject to the terms and conditions of the +* GNU general public license version 2. See "COPYING" or +* http://www.gnu.org/licenses/gpl.html +*/ + +unsigned int get_measured_perf (struct cpufreq_policy *policy, +unsigned int cpu);
(quoted diff) +0 -0
b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
index 6e44519..ed9c4c2 100644
arch/x86/kernel/cpu/cpufreq/powernow-k8.c +1 -0
@@ -46,6 +46,7 @@#define PFX "powernow-k8: "#define VERSION "version 2.20.00"#include "powernow-k8.h" +#include "mperf.h" /* serialize freq changes */ static DEFINE_MUTEX (fidvid_mutex);
@@ -929,7 +930,8 @@ static int fill_powernow_table_pstate(struct
powernow_k8_data *data,
powernow_table[i].index = index;
/* Frequency may be rounded for these */
- if (boot_cpu_data.x86 == 0x10 || boot_cpu_data.x86 == 0x11) {
+ if ((boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model < 10)
+ || boot_cpu_data.x86 == 0x11) {
powernow_table[i].frequency =
freq_from_fid_did(lo & 0x3f, (lo >> 6) & 7);
} else
(quoted diff) +0 -0
b/arch/x86/kernel/cpu/perf_event_amd.c
index 6d28e08..8f3dbfd 100644
arch/x86/kernel/cpu/perf_event_amd.c +1 -1
@@ -1,6 +1,6 @@#ifdef CONFIG_CPU_SUP_AMD -static raw_spinlock_t amd_nb_lock; +static DEFINE_RAW_SPINLOCK (amd_nb_lock);static __initconst u64 amd_hw_cache_event_ids [PERF_COUNT_HW_CACHE_MAX ]
Signature · 2 lines
1.6.0.2 3