[CPUFREQ][1/6] cpufreq: Add cpu number parameter to __cpufreq_driver_getavg()
authorvenkatesh.pallipadi@intel.com <venkatesh.pallipadi@intel.com>
Mon, 4 Aug 2008 18:59:07 +0000 (11:59 -0700)
committerDave Jones <davej@redhat.com>
Thu, 9 Oct 2008 17:52:43 +0000 (13:52 -0400)
Add a cpu parameter to __cpufreq_driver_getavg(). This is needed for software
cpufreq coordination where policy->cpu may not be same as the CPU on which we
want to getavg frequency.

A follow-on patch will use this parameter to getavg freq from all cpus
in policy->cpus.

Change since last patch. Fix the offline/online and suspend/resume
oops reported by Youquan Song <youquan.song@intel.com>

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Dave Jones <davej@redhat.com>
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
drivers/cpufreq/cpufreq.c
drivers/cpufreq/cpufreq_ondemand.c
include/linux/cpufreq.h

index 1def5b06fa4ab056ebe9d70e9935b319f9808ee6..c24c4a487b7cb05f8ec6ad73998a2e0e01439d32 100644 (file)
@@ -256,7 +256,8 @@ static u32 get_cur_val(const cpumask_t *mask)
  * 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(unsigned int cpu)
+static unsigned int get_measured_perf(struct cpufreq_policy *policy,
+                                     unsigned int cpu)
 {
        union {
                struct {
@@ -326,7 +327,7 @@ static unsigned int get_measured_perf(unsigned int cpu)
 
 #endif
 
-       retval = per_cpu(drv_data, cpu)->max_freq * perf_percent / 100;
+       retval = per_cpu(drv_data, policy->cpu)->max_freq * perf_percent / 100;
 
        put_cpu();
        set_cpus_allowed_ptr(current, &saved_mask);
index 9bbdc258624cc6310b65ed673f8ef0c9431db99c..31d6f535a79de51d322d8d76af3eccfd2bf11140 100644 (file)
@@ -1487,7 +1487,7 @@ no_policy:
 }
 EXPORT_SYMBOL_GPL(cpufreq_driver_target);
 
-int __cpufreq_driver_getavg(struct cpufreq_policy *policy)
+int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu)
 {
        int ret = 0;
 
@@ -1495,8 +1495,8 @@ int __cpufreq_driver_getavg(struct cpufreq_policy *policy)
        if (!policy)
                return -EINVAL;
 
-       if (cpu_online(policy->cpu) && cpufreq_driver->getavg)
-               ret = cpufreq_driver->getavg(policy->cpu);
+       if (cpu_online(cpu) && cpufreq_driver->getavg)
+               ret = cpufreq_driver->getavg(policycpu);
 
        cpufreq_cpu_put(policy);
        return ret;
index 67c9d4f9edc07ccd0d086e3c355cc21918444416..f56debd9a8d7ea8136defea16f751d8d5c2d7553 100644 (file)
@@ -415,7 +415,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
        if (load < (dbs_tuners_ins.up_threshold - 10)) {
                unsigned int freq_next, freq_cur;
 
-               freq_cur = __cpufreq_driver_getavg(policy);
+               freq_cur = __cpufreq_driver_getavg(policy, policy->cpu);
                if (!freq_cur)
                        freq_cur = policy->cur;
 
index 6fd5668aa572079f4cd81dc36326aa93a4faddde..1ee608fd7b77c35bee3639c449f6f6483de2bc7c 100644 (file)
@@ -187,7 +187,8 @@ extern int __cpufreq_driver_target(struct cpufreq_policy *policy,
                                   unsigned int relation);
 
 
-extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy);
+extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy,
+                                  unsigned int cpu);
 
 int cpufreq_register_governor(struct cpufreq_governor *governor);
 void cpufreq_unregister_governor(struct cpufreq_governor *governor);
@@ -226,7 +227,9 @@ struct cpufreq_driver {
        unsigned int    (*get)  (unsigned int cpu);
 
        /* optional */
-       unsigned int (*getavg)  (unsigned int cpu);
+       unsigned int (*getavg)  (struct cpufreq_policy *policy,
+                                unsigned int cpu);
+
        int     (*exit)         (struct cpufreq_policy *policy);
        int     (*suspend)      (struct cpufreq_policy *policy, pm_message_t pmsg);
        int     (*resume)       (struct cpufreq_policy *policy);