aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2013-03-24 02:26:43 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-04-02 09:24:00 -0400
commitb43a7ffbf33be7e4d3b10b7714ee663ea2c52fe2 (patch)
tree7d3ac2733d76a785be12bfba75bfe244a5a31460 /arch
parentfd143b4d6fb763183ef6e46d1ab84a42c59079af (diff)
cpufreq: Notify all policy->cpus in cpufreq_notify_transition()
policy->cpus contains all online cpus that have single shared clock line. And their frequencies are always updated together. Many SMP system's cpufreq drivers take care of this in individual drivers but the best place for this code is in cpufreq core. This patch modifies cpufreq_notify_transition() to notify frequency change for all cpus in policy->cpus and hence updates all users of this API. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Stephen Warren <swarren@nvidia.com> Tested-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-davinci/cpufreq.c5
-rw-r--r--arch/arm/mach-imx/cpufreq.c5
-rw-r--r--arch/arm/mach-integrator/cpu.c6
-rw-r--r--arch/arm/mach-pxa/cpufreq-pxa2xx.c5
-rw-r--r--arch/arm/mach-pxa/cpufreq-pxa3xx.c5
-rw-r--r--arch/arm/mach-s3c24xx/cpufreq.c8
-rw-r--r--arch/arm/mach-sa1100/cpu-sa1100.c5
-rw-r--r--arch/arm/mach-sa1100/cpu-sa1110.c5
-rw-r--r--arch/arm/mach-tegra/cpu-tegra.c15
-rw-r--r--arch/avr32/mach-at32ap/cpufreq.c5
-rw-r--r--arch/blackfin/mach-common/cpufreq.c79
-rw-r--r--arch/cris/arch-v32/mach-a3/cpufreq.c20
-rw-r--r--arch/cris/arch-v32/mach-fs/cpufreq.c17
-rw-r--r--arch/ia64/kernel/cpufreq/acpi-cpufreq.c22
-rw-r--r--arch/mips/kernel/cpufreq/loongson2_cpufreq.c5
-rw-r--r--arch/powerpc/platforms/cell/cbe_cpufreq.c5
-rw-r--r--arch/powerpc/platforms/pasemi/cpufreq.c5
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_32.c14
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_64.c5
-rw-r--r--arch/sh/kernel/cpufreq.c5
-rw-r--r--arch/sparc/kernel/us2e_cpufreq.c13
-rw-r--r--arch/sparc/kernel/us3_cpufreq.c13
-rw-r--r--arch/unicore32/kernel/cpu-ucv2.c5
23 files changed, 119 insertions, 153 deletions
diff --git a/arch/arm/mach-davinci/cpufreq.c b/arch/arm/mach-davinci/cpufreq.c
index 4729eaab0f40..55eb8703043d 100644
--- a/arch/arm/mach-davinci/cpufreq.c
+++ b/arch/arm/mach-davinci/cpufreq.c
@@ -90,7 +90,6 @@ static int davinci_target(struct cpufreq_policy *policy,
90 90
91 freqs.old = davinci_getspeed(0); 91 freqs.old = davinci_getspeed(0);
92 freqs.new = clk_round_rate(armclk, target_freq * 1000) / 1000; 92 freqs.new = clk_round_rate(armclk, target_freq * 1000) / 1000;
93 freqs.cpu = 0;
94 93
95 if (freqs.old == freqs.new) 94 if (freqs.old == freqs.new)
96 return ret; 95 return ret;
@@ -102,7 +101,7 @@ static int davinci_target(struct cpufreq_policy *policy,
102 if (ret) 101 if (ret)
103 return -EINVAL; 102 return -EINVAL;
104 103
105 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 104 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
106 105
107 /* if moving to higher frequency, up the voltage beforehand */ 106 /* if moving to higher frequency, up the voltage beforehand */
108 if (pdata->set_voltage && freqs.new > freqs.old) { 107 if (pdata->set_voltage && freqs.new > freqs.old) {
@@ -126,7 +125,7 @@ static int davinci_target(struct cpufreq_policy *policy,
126 pdata->set_voltage(idx); 125 pdata->set_voltage(idx);
127 126
128out: 127out:
129 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 128 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
130 129
131 return ret; 130 return ret;
132} 131}
diff --git a/arch/arm/mach-imx/cpufreq.c b/arch/arm/mach-imx/cpufreq.c
index d8c75c3c925d..cfce5e3f67f5 100644
--- a/arch/arm/mach-imx/cpufreq.c
+++ b/arch/arm/mach-imx/cpufreq.c
@@ -87,13 +87,12 @@ static int mxc_set_target(struct cpufreq_policy *policy,
87 87
88 freqs.old = clk_get_rate(cpu_clk) / 1000; 88 freqs.old = clk_get_rate(cpu_clk) / 1000;
89 freqs.new = freq_Hz / 1000; 89 freqs.new = freq_Hz / 1000;
90 freqs.cpu = 0;
91 freqs.flags = 0; 90 freqs.flags = 0;
92 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 91 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
93 92
94 ret = set_cpu_freq(freq_Hz); 93 ret = set_cpu_freq(freq_Hz);
95 94
96 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 95 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
97 96
98 return ret; 97 return ret;
99} 98}
diff --git a/arch/arm/mach-integrator/cpu.c b/arch/arm/mach-integrator/cpu.c
index 590c192cdf4d..df863c30771c 100644
--- a/arch/arm/mach-integrator/cpu.c
+++ b/arch/arm/mach-integrator/cpu.c
@@ -123,14 +123,12 @@ static int integrator_set_target(struct cpufreq_policy *policy,
123 vco = icst_hz_to_vco(&cclk_params, target_freq * 1000); 123 vco = icst_hz_to_vco(&cclk_params, target_freq * 1000);
124 freqs.new = icst_hz(&cclk_params, vco) / 1000; 124 freqs.new = icst_hz(&cclk_params, vco) / 1000;
125 125
126 freqs.cpu = policy->cpu;
127
128 if (freqs.old == freqs.new) { 126 if (freqs.old == freqs.new) {
129 set_cpus_allowed(current, cpus_allowed); 127 set_cpus_allowed(current, cpus_allowed);
130 return 0; 128 return 0;
131 } 129 }
132 130
133 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 131 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
134 132
135 cm_osc = __raw_readl(CM_OSC); 133 cm_osc = __raw_readl(CM_OSC);
136 134
@@ -151,7 +149,7 @@ static int integrator_set_target(struct cpufreq_policy *policy,
151 */ 149 */
152 set_cpus_allowed(current, cpus_allowed); 150 set_cpus_allowed(current, cpus_allowed);
153 151
154 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 152 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
155 153
156 return 0; 154 return 0;
157} 155}
diff --git a/arch/arm/mach-pxa/cpufreq-pxa2xx.c b/arch/arm/mach-pxa/cpufreq-pxa2xx.c
index 6a7aeab42f6c..f1ca4daa1ad6 100644
--- a/arch/arm/mach-pxa/cpufreq-pxa2xx.c
+++ b/arch/arm/mach-pxa/cpufreq-pxa2xx.c
@@ -311,7 +311,6 @@ static int pxa_set_target(struct cpufreq_policy *policy,
311 new_freq_mem = pxa_freq_settings[idx].membus; 311 new_freq_mem = pxa_freq_settings[idx].membus;
312 freqs.old = policy->cur; 312 freqs.old = policy->cur;
313 freqs.new = new_freq_cpu; 313 freqs.new = new_freq_cpu;
314 freqs.cpu = policy->cpu;
315 314
316 if (freq_debug) 315 if (freq_debug)
317 pr_debug("Changing CPU frequency to %d Mhz, (SDRAM %d Mhz)\n", 316 pr_debug("Changing CPU frequency to %d Mhz, (SDRAM %d Mhz)\n",
@@ -327,7 +326,7 @@ static int pxa_set_target(struct cpufreq_policy *policy,
327 * you should add a notify client with any platform specific 326 * you should add a notify client with any platform specific
328 * Vcc changing capability 327 * Vcc changing capability
329 */ 328 */
330 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 329 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
331 330
332 /* Calculate the next MDREFR. If we're slowing down the SDRAM clock 331 /* Calculate the next MDREFR. If we're slowing down the SDRAM clock
333 * we need to preset the smaller DRI before the change. If we're 332 * we need to preset the smaller DRI before the change. If we're
@@ -382,7 +381,7 @@ static int pxa_set_target(struct cpufreq_policy *policy,
382 * you should add a notify client with any platform specific 381 * you should add a notify client with any platform specific
383 * SDRAM refresh timer adjustments 382 * SDRAM refresh timer adjustments
384 */ 383 */
385 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 384 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
386 385
387 /* 386 /*
388 * Even if voltage setting fails, we don't report it, as the frequency 387 * Even if voltage setting fails, we don't report it, as the frequency
diff --git a/arch/arm/mach-pxa/cpufreq-pxa3xx.c b/arch/arm/mach-pxa/cpufreq-pxa3xx.c
index b85b4ab7aac6..8c45b2b926a7 100644
--- a/arch/arm/mach-pxa/cpufreq-pxa3xx.c
+++ b/arch/arm/mach-pxa/cpufreq-pxa3xx.c
@@ -184,7 +184,6 @@ static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy,
184 184
185 freqs.old = policy->cur; 185 freqs.old = policy->cur;
186 freqs.new = next->cpufreq_mhz * 1000; 186 freqs.new = next->cpufreq_mhz * 1000;
187 freqs.cpu = policy->cpu;
188 187
189 pr_debug("CPU frequency from %d MHz to %d MHz%s\n", 188 pr_debug("CPU frequency from %d MHz to %d MHz%s\n",
190 freqs.old / 1000, freqs.new / 1000, 189 freqs.old / 1000, freqs.new / 1000,
@@ -193,14 +192,14 @@ static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy,
193 if (freqs.old == target_freq) 192 if (freqs.old == target_freq)
194 return 0; 193 return 0;
195 194
196 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 195 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
197 196
198 local_irq_save(flags); 197 local_irq_save(flags);
199 __update_core_freq(next); 198 __update_core_freq(next);
200 __update_bus_freq(next); 199 __update_bus_freq(next);
201 local_irq_restore(flags); 200 local_irq_restore(flags);
202 201
203 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 202 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
204 203
205 return 0; 204 return 0;
206} 205}
diff --git a/arch/arm/mach-s3c24xx/cpufreq.c b/arch/arm/mach-s3c24xx/cpufreq.c
index 5f181e733eee..3c0e78ede0da 100644
--- a/arch/arm/mach-s3c24xx/cpufreq.c
+++ b/arch/arm/mach-s3c24xx/cpufreq.c
@@ -204,7 +204,6 @@ static int s3c_cpufreq_settarget(struct cpufreq_policy *policy,
204 freqs.old = cpu_cur.freq; 204 freqs.old = cpu_cur.freq;
205 freqs.new = cpu_new.freq; 205 freqs.new = cpu_new.freq;
206 206
207 freqs.freqs.cpu = 0;
208 freqs.freqs.old = cpu_cur.freq.armclk / 1000; 207 freqs.freqs.old = cpu_cur.freq.armclk / 1000;
209 freqs.freqs.new = cpu_new.freq.armclk / 1000; 208 freqs.freqs.new = cpu_new.freq.armclk / 1000;
210 209
@@ -218,9 +217,7 @@ static int s3c_cpufreq_settarget(struct cpufreq_policy *policy,
218 s3c_cpufreq_updateclk(clk_pclk, cpu_new.freq.pclk); 217 s3c_cpufreq_updateclk(clk_pclk, cpu_new.freq.pclk);
219 218
220 /* start the frequency change */ 219 /* start the frequency change */
221 220 cpufreq_notify_transition(policy, &freqs.freqs, CPUFREQ_PRECHANGE);
222 if (policy)
223 cpufreq_notify_transition(&freqs.freqs, CPUFREQ_PRECHANGE);
224 221
225 /* If hclk is staying the same, then we do not need to 222 /* If hclk is staying the same, then we do not need to
226 * re-write the IO or the refresh timings whilst we are changing 223 * re-write the IO or the refresh timings whilst we are changing
@@ -264,8 +261,7 @@ static int s3c_cpufreq_settarget(struct cpufreq_policy *policy,
264 local_irq_restore(flags); 261 local_irq_restore(flags);
265 262
266 /* notify everyone we've done this */ 263 /* notify everyone we've done this */
267 if (policy) 264 cpufreq_notify_transition(policy, &freqs.freqs, CPUFREQ_POSTCHANGE);
268 cpufreq_notify_transition(&freqs.freqs, CPUFREQ_POSTCHANGE);
269 265
270 s3c_freq_dbg("%s: finished\n", __func__); 266 s3c_freq_dbg("%s: finished\n", __func__);
271 return 0; 267 return 0;
diff --git a/arch/arm/mach-sa1100/cpu-sa1100.c b/arch/arm/mach-sa1100/cpu-sa1100.c
index e8f4d1e19233..32687617c7a5 100644
--- a/arch/arm/mach-sa1100/cpu-sa1100.c
+++ b/arch/arm/mach-sa1100/cpu-sa1100.c
@@ -201,9 +201,8 @@ static int sa1100_target(struct cpufreq_policy *policy,
201 201
202 freqs.old = cur; 202 freqs.old = cur;
203 freqs.new = sa11x0_ppcr_to_freq(new_ppcr); 203 freqs.new = sa11x0_ppcr_to_freq(new_ppcr);
204 freqs.cpu = 0;
205 204
206 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 205 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
207 206
208 if (freqs.new > cur) 207 if (freqs.new > cur)
209 sa1100_update_dram_timings(cur, freqs.new); 208 sa1100_update_dram_timings(cur, freqs.new);
@@ -213,7 +212,7 @@ static int sa1100_target(struct cpufreq_policy *policy,
213 if (freqs.new < cur) 212 if (freqs.new < cur)
214 sa1100_update_dram_timings(cur, freqs.new); 213 sa1100_update_dram_timings(cur, freqs.new);
215 214
216 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 215 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
217 216
218 return 0; 217 return 0;
219} 218}
diff --git a/arch/arm/mach-sa1100/cpu-sa1110.c b/arch/arm/mach-sa1100/cpu-sa1110.c
index 48c45b0c92bb..38a77330dc16 100644
--- a/arch/arm/mach-sa1100/cpu-sa1110.c
+++ b/arch/arm/mach-sa1100/cpu-sa1110.c
@@ -258,7 +258,6 @@ static int sa1110_target(struct cpufreq_policy *policy,
258 258
259 freqs.old = sa11x0_getspeed(0); 259 freqs.old = sa11x0_getspeed(0);
260 freqs.new = sa11x0_ppcr_to_freq(ppcr); 260 freqs.new = sa11x0_ppcr_to_freq(ppcr);
261 freqs.cpu = 0;
262 261
263 sdram_calculate_timing(&sd, freqs.new, sdram); 262 sdram_calculate_timing(&sd, freqs.new, sdram);
264 263
@@ -279,7 +278,7 @@ static int sa1110_target(struct cpufreq_policy *policy,
279 sd.mdcas[2] = 0xaaaaaaaa; 278 sd.mdcas[2] = 0xaaaaaaaa;
280#endif 279#endif
281 280
282 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 281 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
283 282
284 /* 283 /*
285 * The clock could be going away for some time. Set the SDRAMs 284 * The clock could be going away for some time. Set the SDRAMs
@@ -327,7 +326,7 @@ static int sa1110_target(struct cpufreq_policy *policy,
327 */ 326 */
328 sdram_update_refresh(freqs.new, sdram); 327 sdram_update_refresh(freqs.new, sdram);
329 328
330 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 329 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
331 330
332 return 0; 331 return 0;
333} 332}
diff --git a/arch/arm/mach-tegra/cpu-tegra.c b/arch/arm/mach-tegra/cpu-tegra.c
index e3d6e15ff188..11ca730970f8 100644
--- a/arch/arm/mach-tegra/cpu-tegra.c
+++ b/arch/arm/mach-tegra/cpu-tegra.c
@@ -106,7 +106,8 @@ out:
106 return ret; 106 return ret;
107} 107}
108 108
109static int tegra_update_cpu_speed(unsigned long rate) 109static int tegra_update_cpu_speed(struct cpufreq_policy *policy,
110 unsigned long rate)
110{ 111{
111 int ret = 0; 112 int ret = 0;
112 struct cpufreq_freqs freqs; 113 struct cpufreq_freqs freqs;
@@ -128,8 +129,7 @@ static int tegra_update_cpu_speed(unsigned long rate)
128 else 129 else
129 clk_set_rate(emc_clk, 100000000); /* emc 50Mhz */ 130 clk_set_rate(emc_clk, 100000000); /* emc 50Mhz */
130 131
131 for_each_online_cpu(freqs.cpu) 132 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
132 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
133 133
134#ifdef CONFIG_CPU_FREQ_DEBUG 134#ifdef CONFIG_CPU_FREQ_DEBUG
135 printk(KERN_DEBUG "cpufreq-tegra: transition: %u --> %u\n", 135 printk(KERN_DEBUG "cpufreq-tegra: transition: %u --> %u\n",
@@ -143,8 +143,7 @@ static int tegra_update_cpu_speed(unsigned long rate)
143 return ret; 143 return ret;
144 } 144 }
145 145
146 for_each_online_cpu(freqs.cpu) 146 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
147 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
148 147
149 return 0; 148 return 0;
150} 149}
@@ -181,7 +180,7 @@ static int tegra_target(struct cpufreq_policy *policy,
181 180
182 target_cpu_speed[policy->cpu] = freq; 181 target_cpu_speed[policy->cpu] = freq;
183 182
184 ret = tegra_update_cpu_speed(tegra_cpu_highest_speed()); 183 ret = tegra_update_cpu_speed(policy, tegra_cpu_highest_speed());
185 184
186out: 185out:
187 mutex_unlock(&tegra_cpu_lock); 186 mutex_unlock(&tegra_cpu_lock);
@@ -193,10 +192,12 @@ static int tegra_pm_notify(struct notifier_block *nb, unsigned long event,
193{ 192{
194 mutex_lock(&tegra_cpu_lock); 193 mutex_lock(&tegra_cpu_lock);
195 if (event == PM_SUSPEND_PREPARE) { 194 if (event == PM_SUSPEND_PREPARE) {
195 struct cpufreq_policy *policy = cpufreq_cpu_get(0);
196 is_suspended = true; 196 is_suspended = true;
197 pr_info("Tegra cpufreq suspend: setting frequency to %d kHz\n", 197 pr_info("Tegra cpufreq suspend: setting frequency to %d kHz\n",
198 freq_table[0].frequency); 198 freq_table[0].frequency);
199 tegra_update_cpu_speed(freq_table[0].frequency); 199 tegra_update_cpu_speed(policy, freq_table[0].frequency);
200 cpufreq_cpu_put(policy);
200 } else if (event == PM_POST_SUSPEND) { 201 } else if (event == PM_POST_SUSPEND) {
201 is_suspended = false; 202 is_suspended = false;
202 } 203 }
diff --git a/arch/avr32/mach-at32ap/cpufreq.c b/arch/avr32/mach-at32ap/cpufreq.c
index 18b765629a0c..654488723cb5 100644
--- a/arch/avr32/mach-at32ap/cpufreq.c
+++ b/arch/avr32/mach-at32ap/cpufreq.c
@@ -61,7 +61,6 @@ static int at32_set_target(struct cpufreq_policy *policy,
61 61
62 freqs.old = at32_get_speed(0); 62 freqs.old = at32_get_speed(0);
63 freqs.new = (freq + 500) / 1000; 63 freqs.new = (freq + 500) / 1000;
64 freqs.cpu = 0;
65 freqs.flags = 0; 64 freqs.flags = 0;
66 65
67 if (!ref_freq) { 66 if (!ref_freq) {
@@ -69,7 +68,7 @@ static int at32_set_target(struct cpufreq_policy *policy,
69 loops_per_jiffy_ref = boot_cpu_data.loops_per_jiffy; 68 loops_per_jiffy_ref = boot_cpu_data.loops_per_jiffy;
70 } 69 }
71 70
72 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 71 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
73 if (freqs.old < freqs.new) 72 if (freqs.old < freqs.new)
74 boot_cpu_data.loops_per_jiffy = cpufreq_scale( 73 boot_cpu_data.loops_per_jiffy = cpufreq_scale(
75 loops_per_jiffy_ref, ref_freq, freqs.new); 74 loops_per_jiffy_ref, ref_freq, freqs.new);
@@ -77,7 +76,7 @@ static int at32_set_target(struct cpufreq_policy *policy,
77 if (freqs.new < freqs.old) 76 if (freqs.new < freqs.old)
78 boot_cpu_data.loops_per_jiffy = cpufreq_scale( 77 boot_cpu_data.loops_per_jiffy = cpufreq_scale(
79 loops_per_jiffy_ref, ref_freq, freqs.new); 78 loops_per_jiffy_ref, ref_freq, freqs.new);
80 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 79 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
81 80
82 pr_debug("cpufreq: set frequency %lu Hz\n", freq); 81 pr_debug("cpufreq: set frequency %lu Hz\n", freq);
83 82
diff --git a/arch/blackfin/mach-common/cpufreq.c b/arch/blackfin/mach-common/cpufreq.c
index d88bd31319e6..995511e80bef 100644
--- a/arch/blackfin/mach-common/cpufreq.c
+++ b/arch/blackfin/mach-common/cpufreq.c
@@ -127,13 +127,13 @@ unsigned long cpu_set_cclk(int cpu, unsigned long new)
127} 127}
128#endif 128#endif
129 129
130static int bfin_target(struct cpufreq_policy *poli, 130static int bfin_target(struct cpufreq_policy *policy,
131 unsigned int target_freq, unsigned int relation) 131 unsigned int target_freq, unsigned int relation)
132{ 132{
133#ifndef CONFIG_BF60x 133#ifndef CONFIG_BF60x
134 unsigned int plldiv; 134 unsigned int plldiv;
135#endif 135#endif
136 unsigned int index, cpu; 136 unsigned int index;
137 unsigned long cclk_hz; 137 unsigned long cclk_hz;
138 struct cpufreq_freqs freqs; 138 struct cpufreq_freqs freqs;
139 static unsigned long lpj_ref; 139 static unsigned long lpj_ref;
@@ -144,59 +144,48 @@ static int bfin_target(struct cpufreq_policy *poli,
144 cycles_t cycles; 144 cycles_t cycles;
145#endif 145#endif
146 146
147 for_each_online_cpu(cpu) { 147 if (cpufreq_frequency_table_target(policy, bfin_freq_table, target_freq,
148 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); 148 relation, &index))
149 return -EINVAL;
149 150
150 if (!policy) 151 cclk_hz = bfin_freq_table[index].frequency;
151 continue;
152 152
153 if (cpufreq_frequency_table_target(policy, bfin_freq_table, 153 freqs.old = bfin_getfreq_khz(0);
154 target_freq, relation, &index)) 154 freqs.new = cclk_hz;
155 return -EINVAL;
156 155
157 cclk_hz = bfin_freq_table[index].frequency; 156 pr_debug("cpufreq: changing cclk to %lu; target = %u, oldfreq = %u\n",
157 cclk_hz, target_freq, freqs.old);
158 158
159 freqs.old = bfin_getfreq_khz(0); 159 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
160 freqs.new = cclk_hz;
161 freqs.cpu = cpu;
162
163 pr_debug("cpufreq: changing cclk to %lu; target = %u, oldfreq = %u\n",
164 cclk_hz, target_freq, freqs.old);
165
166 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
167 if (cpu == CPUFREQ_CPU) {
168#ifndef CONFIG_BF60x 160#ifndef CONFIG_BF60x
169 plldiv = (bfin_read_PLL_DIV() & SSEL) | 161 plldiv = (bfin_read_PLL_DIV() & SSEL) | dpm_state_table[index].csel;
170 dpm_state_table[index].csel; 162 bfin_write_PLL_DIV(plldiv);
171 bfin_write_PLL_DIV(plldiv);
172#else 163#else
173 ret = cpu_set_cclk(cpu, freqs.new * 1000); 164 ret = cpu_set_cclk(policy->cpu, freqs.new * 1000);
174 if (ret != 0) { 165 if (ret != 0) {
175 WARN_ONCE(ret, "cpufreq set freq failed %d\n", ret); 166 WARN_ONCE(ret, "cpufreq set freq failed %d\n", ret);
176 break; 167 return ret;
177 } 168 }
178#endif 169#endif
179 on_each_cpu(bfin_adjust_core_timer, &index, 1); 170 on_each_cpu(bfin_adjust_core_timer, &index, 1);
180#if defined(CONFIG_CYCLES_CLOCKSOURCE) 171#if defined(CONFIG_CYCLES_CLOCKSOURCE)
181 cycles = get_cycles(); 172 cycles = get_cycles();
182 SSYNC(); 173 SSYNC();
183 cycles += 10; /* ~10 cycles we lose after get_cycles() */ 174 cycles += 10; /* ~10 cycles we lose after get_cycles() */
184 __bfin_cycles_off += 175 __bfin_cycles_off += (cycles << __bfin_cycles_mod) - (cycles << index);
185 (cycles << __bfin_cycles_mod) - (cycles << index); 176 __bfin_cycles_mod = index;
186 __bfin_cycles_mod = index;
187#endif 177#endif
188 if (!lpj_ref_freq) { 178 if (!lpj_ref_freq) {
189 lpj_ref = loops_per_jiffy; 179 lpj_ref = loops_per_jiffy;
190 lpj_ref_freq = freqs.old; 180 lpj_ref_freq = freqs.old;
191 }
192 if (freqs.new != freqs.old) {
193 loops_per_jiffy = cpufreq_scale(lpj_ref,
194 lpj_ref_freq, freqs.new);
195 }
196 }
197 /* TODO: just test case for cycles clock source, remove later */
198 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
199 } 181 }
182 if (freqs.new != freqs.old) {
183 loops_per_jiffy = cpufreq_scale(lpj_ref,
184 lpj_ref_freq, freqs.new);
185 }
186
187 /* TODO: just test case for cycles clock source, remove later */
188 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
200 189
201 pr_debug("cpufreq: done\n"); 190 pr_debug("cpufreq: done\n");
202 return ret; 191 return ret;
diff --git a/arch/cris/arch-v32/mach-a3/cpufreq.c b/arch/cris/arch-v32/mach-a3/cpufreq.c
index ee391ecb5bc9..ee142c490575 100644
--- a/arch/cris/arch-v32/mach-a3/cpufreq.c
+++ b/arch/cris/arch-v32/mach-a3/cpufreq.c
@@ -27,23 +27,17 @@ static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu)
27 return clk_ctrl.pll ? 200000 : 6000; 27 return clk_ctrl.pll ? 200000 : 6000;
28} 28}
29 29
30static void cris_freq_set_cpu_state(unsigned int state) 30static void cris_freq_set_cpu_state(struct cpufreq_policy *policy,
31 unsigned int state)
31{ 32{
32 int i = 0;
33 struct cpufreq_freqs freqs; 33 struct cpufreq_freqs freqs;
34 reg_clkgen_rw_clk_ctrl clk_ctrl; 34 reg_clkgen_rw_clk_ctrl clk_ctrl;
35 clk_ctrl = REG_RD(clkgen, regi_clkgen, rw_clk_ctrl); 35 clk_ctrl = REG_RD(clkgen, regi_clkgen, rw_clk_ctrl);
36 36
37#ifdef CONFIG_SMP 37 freqs.old = cris_freq_get_cpu_frequency(policy->cpu);
38 for_each_present_cpu(i) 38 freqs.new = cris_freq_table[state].frequency;
39#endif
40 {
41 freqs.old = cris_freq_get_cpu_frequency(i);
42 freqs.new = cris_freq_table[state].frequency;
43 freqs.cpu = i;
44 }
45 39
46 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 40 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
47 41
48 local_irq_disable(); 42 local_irq_disable();
49 43
@@ -57,7 +51,7 @@ static void cris_freq_set_cpu_state(unsigned int state)
57 51
58 local_irq_enable(); 52 local_irq_enable();
59 53
60 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 54 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
61}; 55};
62 56
63static int cris_freq_verify(struct cpufreq_policy *policy) 57static int cris_freq_verify(struct cpufreq_policy *policy)
@@ -75,7 +69,7 @@ static int cris_freq_target(struct cpufreq_policy *policy,
75 target_freq, relation, &newstate)) 69 target_freq, relation, &newstate))
76 return -EINVAL; 70 return -EINVAL;
77 71
78 cris_freq_set_cpu_state(newstate); 72 cris_freq_set_cpu_state(policy, newstate);
79 73
80 return 0; 74 return 0;
81} 75}
diff --git a/arch/cris/arch-v32/mach-fs/cpufreq.c b/arch/cris/arch-v32/mach-fs/cpufreq.c
index d92cf70d1cbe..12952235d5db 100644
--- a/arch/cris/arch-v32/mach-fs/cpufreq.c
+++ b/arch/cris/arch-v32/mach-fs/cpufreq.c
@@ -27,20 +27,17 @@ static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu)
27 return clk_ctrl.pll ? 200000 : 6000; 27 return clk_ctrl.pll ? 200000 : 6000;
28} 28}
29 29
30static void cris_freq_set_cpu_state(unsigned int state) 30static void cris_freq_set_cpu_state(struct cpufreq_policy *policy,
31 unsigned int state)
31{ 32{
32 int i;
33 struct cpufreq_freqs freqs; 33 struct cpufreq_freqs freqs;
34 reg_config_rw_clk_ctrl clk_ctrl; 34 reg_config_rw_clk_ctrl clk_ctrl;
35 clk_ctrl = REG_RD(config, regi_config, rw_clk_ctrl); 35 clk_ctrl = REG_RD(config, regi_config, rw_clk_ctrl);
36 36
37 for_each_possible_cpu(i) { 37 freqs.old = cris_freq_get_cpu_frequency(policy->cpu);
38 freqs.old = cris_freq_get_cpu_frequency(i); 38 freqs.new = cris_freq_table[state].frequency;
39 freqs.new = cris_freq_table[state].frequency;
40 freqs.cpu = i;
41 }
42 39
43 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 40 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
44 41
45 local_irq_disable(); 42 local_irq_disable();
46 43
@@ -54,7 +51,7 @@ static void cris_freq_set_cpu_state(unsigned int state)
54 51
55 local_irq_enable(); 52 local_irq_enable();
56 53
57 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 54 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
58}; 55};
59 56
60static int cris_freq_verify(struct cpufreq_policy *policy) 57static int cris_freq_verify(struct cpufreq_policy *policy)
@@ -71,7 +68,7 @@ static int cris_freq_target(struct cpufreq_policy *policy,
71 (policy, cris_freq_table, target_freq, relation, &newstate)) 68 (policy, cris_freq_table, target_freq, relation, &newstate))
72 return -EINVAL; 69 return -EINVAL;
73 70
74 cris_freq_set_cpu_state(newstate); 71 cris_freq_set_cpu_state(policy, newstate);
75 72
76 return 0; 73 return 0;
77} 74}
diff --git a/arch/ia64/kernel/cpufreq/acpi-cpufreq.c b/arch/ia64/kernel/cpufreq/acpi-cpufreq.c
index f09b174244d5..4700fef8d1fa 100644
--- a/arch/ia64/kernel/cpufreq/acpi-cpufreq.c
+++ b/arch/ia64/kernel/cpufreq/acpi-cpufreq.c
@@ -137,7 +137,7 @@ migrate_end:
137static int 137static int
138processor_set_freq ( 138processor_set_freq (
139 struct cpufreq_acpi_io *data, 139 struct cpufreq_acpi_io *data,
140 unsigned int cpu, 140 struct cpufreq_policy *policy,
141 int state) 141 int state)
142{ 142{
143 int ret = 0; 143 int ret = 0;
@@ -149,8 +149,8 @@ processor_set_freq (
149 pr_debug("processor_set_freq\n"); 149 pr_debug("processor_set_freq\n");
150 150
151 saved_mask = current->cpus_allowed; 151 saved_mask = current->cpus_allowed;
152 set_cpus_allowed_ptr(current, cpumask_of(cpu)); 152 set_cpus_allowed_ptr(current, cpumask_of(policy->cpu));
153 if (smp_processor_id() != cpu) { 153 if (smp_processor_id() != policy->cpu) {
154 retval = -EAGAIN; 154 retval = -EAGAIN;
155 goto migrate_end; 155 goto migrate_end;
156 } 156 }
@@ -170,12 +170,11 @@ processor_set_freq (
170 data->acpi_data.state, state); 170 data->acpi_data.state, state);
171 171
172 /* cpufreq frequency struct */ 172 /* cpufreq frequency struct */
173 cpufreq_freqs.cpu = cpu;
174 cpufreq_freqs.old = data->freq_table[data->acpi_data.state].frequency; 173 cpufreq_freqs.old = data->freq_table[data->acpi_data.state].frequency;
175 cpufreq_freqs.new = data->freq_table[state].frequency; 174 cpufreq_freqs.new = data->freq_table[state].frequency;
176 175
177 /* notify cpufreq */ 176 /* notify cpufreq */
178 cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_PRECHANGE); 177 cpufreq_notify_transition(policy, &cpufreq_freqs, CPUFREQ_PRECHANGE);
179 178
180 /* 179 /*
181 * First we write the target state's 'control' value to the 180 * First we write the target state's 'control' value to the
@@ -189,17 +188,20 @@ processor_set_freq (
189 ret = processor_set_pstate(value); 188 ret = processor_set_pstate(value);
190 if (ret) { 189 if (ret) {
191 unsigned int tmp = cpufreq_freqs.new; 190 unsigned int tmp = cpufreq_freqs.new;
192 cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE); 191 cpufreq_notify_transition(policy, &cpufreq_freqs,
192 CPUFREQ_POSTCHANGE);
193 cpufreq_freqs.new = cpufreq_freqs.old; 193 cpufreq_freqs.new = cpufreq_freqs.old;
194 cpufreq_freqs.old = tmp; 194 cpufreq_freqs.old = tmp;
195 cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_PRECHANGE); 195 cpufreq_notify_transition(policy, &cpufreq_freqs,
196 cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE); 196 CPUFREQ_PRECHANGE);
197 cpufreq_notify_transition(policy, &cpufreq_freqs,
198 CPUFREQ_POSTCHANGE);
197 printk(KERN_WARNING "Transition failed with error %d\n", ret); 199 printk(KERN_WARNING "Transition failed with error %d\n", ret);
198 retval = -ENODEV; 200 retval = -ENODEV;
199 goto migrate_end; 201 goto migrate_end;
200 } 202 }
201 203
202 cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE); 204 cpufreq_notify_transition(policy, &cpufreq_freqs, CPUFREQ_POSTCHANGE);
203 205
204 data->acpi_data.state = state; 206 data->acpi_data.state = state;
205 207
@@ -240,7 +242,7 @@ acpi_cpufreq_target (
240 if (result) 242 if (result)
241 return (result); 243 return (result);
242 244
243 result = processor_set_freq(data, policy->cpu, next_state); 245 result = processor_set_freq(data, policy, next_state);
244 246
245 return (result); 247 return (result);
246} 248}
diff --git a/arch/mips/kernel/cpufreq/loongson2_cpufreq.c b/arch/mips/kernel/cpufreq/loongson2_cpufreq.c
index 3237c5235f9c..bafda7063f03 100644
--- a/arch/mips/kernel/cpufreq/loongson2_cpufreq.c
+++ b/arch/mips/kernel/cpufreq/loongson2_cpufreq.c
@@ -80,7 +80,6 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
80 80
81 pr_debug("cpufreq: requested frequency %u Hz\n", target_freq * 1000); 81 pr_debug("cpufreq: requested frequency %u Hz\n", target_freq * 1000);
82 82
83 freqs.cpu = cpu;
84 freqs.old = loongson2_cpufreq_get(cpu); 83 freqs.old = loongson2_cpufreq_get(cpu);
85 freqs.new = freq; 84 freqs.new = freq;
86 freqs.flags = 0; 85 freqs.flags = 0;
@@ -89,7 +88,7 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
89 return 0; 88 return 0;
90 89
91 /* notifiers */ 90 /* notifiers */
92 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 91 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
93 92
94 set_cpus_allowed_ptr(current, &cpus_allowed); 93 set_cpus_allowed_ptr(current, &cpus_allowed);
95 94
@@ -97,7 +96,7 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
97 clk_set_rate(cpuclk, freq); 96 clk_set_rate(cpuclk, freq);
98 97
99 /* notifiers */ 98 /* notifiers */
100 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 99 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
101 100
102 pr_debug("cpufreq: set frequency %u kHz\n", freq); 101 pr_debug("cpufreq: set frequency %u kHz\n", freq);
103 102
diff --git a/arch/powerpc/platforms/cell/cbe_cpufreq.c b/arch/powerpc/platforms/cell/cbe_cpufreq.c
index d4c39e32f147..718c6a33023d 100644
--- a/arch/powerpc/platforms/cell/cbe_cpufreq.c
+++ b/arch/powerpc/platforms/cell/cbe_cpufreq.c
@@ -156,10 +156,9 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy,
156 156
157 freqs.old = policy->cur; 157 freqs.old = policy->cur;
158 freqs.new = cbe_freqs[cbe_pmode_new].frequency; 158 freqs.new = cbe_freqs[cbe_pmode_new].frequency;
159 freqs.cpu = policy->cpu;
160 159
161 mutex_lock(&cbe_switch_mutex); 160 mutex_lock(&cbe_switch_mutex);
162 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 161 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
163 162
164 pr_debug("setting frequency for cpu %d to %d kHz, " \ 163 pr_debug("setting frequency for cpu %d to %d kHz, " \
165 "1/%d of max frequency\n", 164 "1/%d of max frequency\n",
@@ -169,7 +168,7 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy,
169 168
170 rc = set_pmode(policy->cpu, cbe_pmode_new); 169 rc = set_pmode(policy->cpu, cbe_pmode_new);
171 170
172 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 171 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
173 mutex_unlock(&cbe_switch_mutex); 172 mutex_unlock(&cbe_switch_mutex);
174 173
175 return rc; 174 return rc;
diff --git a/arch/powerpc/platforms/pasemi/cpufreq.c b/arch/powerpc/platforms/pasemi/cpufreq.c
index 890f30e70f98..be1e7958909e 100644
--- a/arch/powerpc/platforms/pasemi/cpufreq.c
+++ b/arch/powerpc/platforms/pasemi/cpufreq.c
@@ -273,10 +273,9 @@ static int pas_cpufreq_target(struct cpufreq_policy *policy,
273 273
274 freqs.old = policy->cur; 274 freqs.old = policy->cur;
275 freqs.new = pas_freqs[pas_astate_new].frequency; 275 freqs.new = pas_freqs[pas_astate_new].frequency;
276 freqs.cpu = policy->cpu;
277 276
278 mutex_lock(&pas_switch_mutex); 277 mutex_lock(&pas_switch_mutex);
279 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 278 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
280 279
281 pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", 280 pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n",
282 policy->cpu, 281 policy->cpu,
@@ -288,7 +287,7 @@ static int pas_cpufreq_target(struct cpufreq_policy *policy,
288 for_each_online_cpu(i) 287 for_each_online_cpu(i)
289 set_astate(i, pas_astate_new); 288 set_astate(i, pas_astate_new);
290 289
291 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 290 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
292 mutex_unlock(&pas_switch_mutex); 291 mutex_unlock(&pas_switch_mutex);
293 292
294 ppc_proc_freq = freqs.new * 1000ul; 293 ppc_proc_freq = freqs.new * 1000ul;
diff --git a/arch/powerpc/platforms/powermac/cpufreq_32.c b/arch/powerpc/platforms/powermac/cpufreq_32.c
index 311b804353b1..3104fad82480 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_32.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_32.c
@@ -335,7 +335,8 @@ static int pmu_set_cpu_speed(int low_speed)
335 return 0; 335 return 0;
336} 336}
337 337
338static int do_set_cpu_speed(int speed_mode, int notify) 338static int do_set_cpu_speed(struct cpufreq_policy *policy, int speed_mode,
339 int notify)
339{ 340{
340 struct cpufreq_freqs freqs; 341 struct cpufreq_freqs freqs;
341 unsigned long l3cr; 342 unsigned long l3cr;
@@ -343,13 +344,12 @@ static int do_set_cpu_speed(int speed_mode, int notify)
343 344
344 freqs.old = cur_freq; 345 freqs.old = cur_freq;
345 freqs.new = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq; 346 freqs.new = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq;
346 freqs.cpu = smp_processor_id();
347 347
348 if (freqs.old == freqs.new) 348 if (freqs.old == freqs.new)
349 return 0; 349 return 0;
350 350
351 if (notify) 351 if (notify)
352 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 352 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
353 if (speed_mode == CPUFREQ_LOW && 353 if (speed_mode == CPUFREQ_LOW &&
354 cpu_has_feature(CPU_FTR_L3CR)) { 354 cpu_has_feature(CPU_FTR_L3CR)) {
355 l3cr = _get_L3CR(); 355 l3cr = _get_L3CR();
@@ -366,7 +366,7 @@ static int do_set_cpu_speed(int speed_mode, int notify)
366 _set_L3CR(prev_l3cr); 366 _set_L3CR(prev_l3cr);
367 } 367 }
368 if (notify) 368 if (notify)
369 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 369 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
370 cur_freq = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq; 370 cur_freq = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq;
371 371
372 return 0; 372 return 0;
@@ -393,7 +393,7 @@ static int pmac_cpufreq_target( struct cpufreq_policy *policy,
393 target_freq, relation, &newstate)) 393 target_freq, relation, &newstate))
394 return -EINVAL; 394 return -EINVAL;
395 395
396 rc = do_set_cpu_speed(newstate, 1); 396 rc = do_set_cpu_speed(policy, newstate, 1);
397 397
398 ppc_proc_freq = cur_freq * 1000ul; 398 ppc_proc_freq = cur_freq * 1000ul;
399 return rc; 399 return rc;
@@ -442,7 +442,7 @@ static int pmac_cpufreq_suspend(struct cpufreq_policy *policy)
442 no_schedule = 1; 442 no_schedule = 1;
443 sleep_freq = cur_freq; 443 sleep_freq = cur_freq;
444 if (cur_freq == low_freq && !is_pmu_based) 444 if (cur_freq == low_freq && !is_pmu_based)
445 do_set_cpu_speed(CPUFREQ_HIGH, 0); 445 do_set_cpu_speed(policy, CPUFREQ_HIGH, 0);
446 return 0; 446 return 0;
447} 447}
448 448
@@ -458,7 +458,7 @@ static int pmac_cpufreq_resume(struct cpufreq_policy *policy)
458 * is that we force a switch to whatever it was, which is 458 * is that we force a switch to whatever it was, which is
459 * probably high speed due to our suspend() routine 459 * probably high speed due to our suspend() routine
460 */ 460 */
461 do_set_cpu_speed(sleep_freq == low_freq ? 461 do_set_cpu_speed(policy, sleep_freq == low_freq ?
462 CPUFREQ_LOW : CPUFREQ_HIGH, 0); 462 CPUFREQ_LOW : CPUFREQ_HIGH, 0);
463 463
464 ppc_proc_freq = cur_freq * 1000ul; 464 ppc_proc_freq = cur_freq * 1000ul;
diff --git a/arch/powerpc/platforms/powermac/cpufreq_64.c b/arch/powerpc/platforms/powermac/cpufreq_64.c
index 9650c6029c82..7ba423431cfe 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_64.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_64.c
@@ -339,11 +339,10 @@ static int g5_cpufreq_target(struct cpufreq_policy *policy,
339 339
340 freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency; 340 freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency;
341 freqs.new = g5_cpu_freqs[newstate].frequency; 341 freqs.new = g5_cpu_freqs[newstate].frequency;
342 freqs.cpu = 0;
343 342
344 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 343 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
345 rc = g5_switch_freq(newstate); 344 rc = g5_switch_freq(newstate);
346 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 345 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
347 346
348 mutex_unlock(&g5_switch_mutex); 347 mutex_unlock(&g5_switch_mutex);
349 348
diff --git a/arch/sh/kernel/cpufreq.c b/arch/sh/kernel/cpufreq.c
index e68b45b6f3f9..2c7bd94f95ee 100644
--- a/arch/sh/kernel/cpufreq.c
+++ b/arch/sh/kernel/cpufreq.c
@@ -69,15 +69,14 @@ static int sh_cpufreq_target(struct cpufreq_policy *policy,
69 69
70 dev_dbg(dev, "requested frequency %u Hz\n", target_freq * 1000); 70 dev_dbg(dev, "requested frequency %u Hz\n", target_freq * 1000);
71 71
72 freqs.cpu = cpu;
73 freqs.old = sh_cpufreq_get(cpu); 72 freqs.old = sh_cpufreq_get(cpu);
74 freqs.new = (freq + 500) / 1000; 73 freqs.new = (freq + 500) / 1000;
75 freqs.flags = 0; 74 freqs.flags = 0;
76 75
77 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 76 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
78 set_cpus_allowed_ptr(current, &cpus_allowed); 77 set_cpus_allowed_ptr(current, &cpus_allowed);
79 clk_set_rate(cpuclk, freq); 78 clk_set_rate(cpuclk, freq);
80 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 79 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
81 80
82 dev_dbg(dev, "set frequency %lu Hz\n", freq); 81 dev_dbg(dev, "set frequency %lu Hz\n", freq);
83 82
diff --git a/arch/sparc/kernel/us2e_cpufreq.c b/arch/sparc/kernel/us2e_cpufreq.c
index 489fc15f3194..abe963d7b87c 100644
--- a/arch/sparc/kernel/us2e_cpufreq.c
+++ b/arch/sparc/kernel/us2e_cpufreq.c
@@ -248,8 +248,10 @@ static unsigned int us2e_freq_get(unsigned int cpu)
248 return clock_tick / estar_to_divisor(estar); 248 return clock_tick / estar_to_divisor(estar);
249} 249}
250 250
251static void us2e_set_cpu_divider_index(unsigned int cpu, unsigned int index) 251static void us2e_set_cpu_divider_index(struct cpufreq_policy *policy,
252 unsigned int index)
252{ 253{
254 unsigned int cpu = policy->cpu;
253 unsigned long new_bits, new_freq; 255 unsigned long new_bits, new_freq;
254 unsigned long clock_tick, divisor, old_divisor, estar; 256 unsigned long clock_tick, divisor, old_divisor, estar;
255 cpumask_t cpus_allowed; 257 cpumask_t cpus_allowed;
@@ -272,14 +274,13 @@ static void us2e_set_cpu_divider_index(unsigned int cpu, unsigned int index)
272 274
273 freqs.old = clock_tick / old_divisor; 275 freqs.old = clock_tick / old_divisor;
274 freqs.new = new_freq; 276 freqs.new = new_freq;
275 freqs.cpu = cpu; 277 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
276 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
277 278
278 if (old_divisor != divisor) 279 if (old_divisor != divisor)
279 us2e_transition(estar, new_bits, clock_tick * 1000, 280 us2e_transition(estar, new_bits, clock_tick * 1000,
280 old_divisor, divisor); 281 old_divisor, divisor);
281 282
282 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 283 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
283 284
284 set_cpus_allowed_ptr(current, &cpus_allowed); 285 set_cpus_allowed_ptr(current, &cpus_allowed);
285} 286}
@@ -295,7 +296,7 @@ static int us2e_freq_target(struct cpufreq_policy *policy,
295 target_freq, relation, &new_index)) 296 target_freq, relation, &new_index))
296 return -EINVAL; 297 return -EINVAL;
297 298
298 us2e_set_cpu_divider_index(policy->cpu, new_index); 299 us2e_set_cpu_divider_index(policy, new_index);
299 300
300 return 0; 301 return 0;
301} 302}
@@ -335,7 +336,7 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
335static int us2e_freq_cpu_exit(struct cpufreq_policy *policy) 336static int us2e_freq_cpu_exit(struct cpufreq_policy *policy)
336{ 337{
337 if (cpufreq_us2e_driver) 338 if (cpufreq_us2e_driver)
338 us2e_set_cpu_divider_index(policy->cpu, 0); 339 us2e_set_cpu_divider_index(policy, 0);
339 340
340 return 0; 341 return 0;
341} 342}
diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
index eb1624b931d9..7ceb9c8458f0 100644
--- a/arch/sparc/kernel/us3_cpufreq.c
+++ b/arch/sparc/kernel/us3_cpufreq.c
@@ -96,8 +96,10 @@ static unsigned int us3_freq_get(unsigned int cpu)
96 return ret; 96 return ret;
97} 97}
98 98
99static void us3_set_cpu_divider_index(unsigned int cpu, unsigned int index) 99static void us3_set_cpu_divider_index(struct cpufreq_policy *policy,
100 unsigned int index)
100{ 101{
102 unsigned int cpu = policy->cpu;
101 unsigned long new_bits, new_freq, reg; 103 unsigned long new_bits, new_freq, reg;
102 cpumask_t cpus_allowed; 104 cpumask_t cpus_allowed;
103 struct cpufreq_freqs freqs; 105 struct cpufreq_freqs freqs;
@@ -131,14 +133,13 @@ static void us3_set_cpu_divider_index(unsigned int cpu, unsigned int index)
131 133
132 freqs.old = get_current_freq(cpu, reg); 134 freqs.old = get_current_freq(cpu, reg);
133 freqs.new = new_freq; 135 freqs.new = new_freq;
134 freqs.cpu = cpu; 136 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
135 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
136 137
137 reg &= ~SAFARI_CFG_DIV_MASK; 138 reg &= ~SAFARI_CFG_DIV_MASK;
138 reg |= new_bits; 139 reg |= new_bits;
139 write_safari_cfg(reg); 140 write_safari_cfg(reg);
140 141
141 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 142 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
142 143
143 set_cpus_allowed_ptr(current, &cpus_allowed); 144 set_cpus_allowed_ptr(current, &cpus_allowed);
144} 145}
@@ -156,7 +157,7 @@ static int us3_freq_target(struct cpufreq_policy *policy,
156 &new_index)) 157 &new_index))
157 return -EINVAL; 158 return -EINVAL;
158 159
159 us3_set_cpu_divider_index(policy->cpu, new_index); 160 us3_set_cpu_divider_index(policy, new_index);
160 161
161 return 0; 162 return 0;
162} 163}
@@ -192,7 +193,7 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
192static int us3_freq_cpu_exit(struct cpufreq_policy *policy) 193static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
193{ 194{
194 if (cpufreq_us3_driver) 195 if (cpufreq_us3_driver)
195 us3_set_cpu_divider_index(policy->cpu, 0); 196 us3_set_cpu_divider_index(policy, 0);
196 197
197 return 0; 198 return 0;
198} 199}
diff --git a/arch/unicore32/kernel/cpu-ucv2.c b/arch/unicore32/kernel/cpu-ucv2.c
index 4a99f62584c7..ba5a71ce2d71 100644
--- a/arch/unicore32/kernel/cpu-ucv2.c
+++ b/arch/unicore32/kernel/cpu-ucv2.c
@@ -52,15 +52,14 @@ static int ucv2_target(struct cpufreq_policy *policy,
52 struct cpufreq_freqs freqs; 52 struct cpufreq_freqs freqs;
53 struct clk *mclk = clk_get(NULL, "MAIN_CLK"); 53 struct clk *mclk = clk_get(NULL, "MAIN_CLK");
54 54
55 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 55 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
56 56
57 if (!clk_set_rate(mclk, target_freq * 1000)) { 57 if (!clk_set_rate(mclk, target_freq * 1000)) {
58 freqs.old = cur; 58 freqs.old = cur;
59 freqs.new = target_freq; 59 freqs.new = target_freq;
60 freqs.cpu = 0;
61 } 60 }
62 61
63 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 62 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
64 63
65 return 0; 64 return 0;
66} 65}