|
@@ -45,6 +45,7 @@
|
|
|
#include <asm/msr.h>
|
|
|
#include <asm/processor.h>
|
|
|
#include <asm/cpufeature.h>
|
|
|
+#include "mperf.h"
|
|
|
|
|
|
#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, \
|
|
|
"acpi-cpufreq", msg)
|
|
@@ -70,8 +71,6 @@ struct acpi_cpufreq_data {
|
|
|
|
|
|
static DEFINE_PER_CPU(struct acpi_cpufreq_data *, acfreq_data);
|
|
|
|
|
|
-static DEFINE_PER_CPU(struct aperfmperf, acfreq_old_perf);
|
|
|
-
|
|
|
/* acpi_perf_data is a pointer to percpu data. */
|
|
|
static struct acpi_processor_performance *acpi_perf_data;
|
|
|
|
|
@@ -239,45 +238,6 @@ static u32 get_cur_val(const struct cpumask *mask)
|
|
|
return cmd.val;
|
|
|
}
|
|
|
|
|
|
-/* Called via smp_call_function_single(), on the target CPU */
|
|
|
-static void read_measured_perf_ctrs(void *_cur)
|
|
|
-{
|
|
|
- struct aperfmperf *am = _cur;
|
|
|
-
|
|
|
- get_aperfmperf(am);
|
|
|
-}
|
|
|
-
|
|
|
-/*
|
|
|
- * Return the measured active (C0) frequency on this CPU since last call
|
|
|
- * to this function.
|
|
|
- * Input: cpu number
|
|
|
- * Return: Average CPU frequency in terms of max frequency (zero on error)
|
|
|
- *
|
|
|
- * We use IA32_MPERF and IA32_APERF MSRs to get the measured performance
|
|
|
- * over a period of time, while CPU is in C0 state.
|
|
|
- * IA32_MPERF counts at the rate of max advertised frequency
|
|
|
- * IA32_APERF counts at the rate of actual CPU frequency
|
|
|
- * Only IA32_APERF/IA32_MPERF ratio is architecturally defined and
|
|
|
- * no meaning should be associated with absolute values of these MSRs.
|
|
|
- */
|
|
|
-static unsigned int get_measured_perf(struct cpufreq_policy *policy,
|
|
|
- unsigned int cpu)
|
|
|
-{
|
|
|
- struct aperfmperf perf;
|
|
|
- unsigned long ratio;
|
|
|
- unsigned int retval;
|
|
|
-
|
|
|
- if (smp_call_function_single(cpu, read_measured_perf_ctrs, &perf, 1))
|
|
|
- return 0;
|
|
|
-
|
|
|
- ratio = calc_aperfmperf_ratio(&per_cpu(acfreq_old_perf, cpu), &perf);
|
|
|
- per_cpu(acfreq_old_perf, cpu) = perf;
|
|
|
-
|
|
|
- retval = (policy->cpuinfo.max_freq * ratio) >> APERFMPERF_SHIFT;
|
|
|
-
|
|
|
- return retval;
|
|
|
-}
|
|
|
-
|
|
|
static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
|
|
|
{
|
|
|
struct acpi_cpufreq_data *data = per_cpu(acfreq_data, cpu);
|
|
@@ -701,7 +661,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
|
|
|
|
|
|
/* Check for APERF/MPERF support in hardware */
|
|
|
if (cpu_has(c, X86_FEATURE_APERFMPERF))
|
|
|
- acpi_cpufreq_driver.getavg = get_measured_perf;
|
|
|
+ acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
|
|
|
|
|
|
dprintk("CPU%u - ACPI performance management activated.\n", cpu);
|
|
|
for (i = 0; i < perf->state_count; i++)
|