aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorChristian Krafft <krafft@de.ibm.com>2007-07-20 15:39:21 -0400
committerArnd Bergmann <arnd@klappe.arndb.de>2007-07-20 15:41:37 -0400
commit1e21fd5af3797a2c322e1723c69732e77aa74f48 (patch)
tree0d37951903078378586ff493991ecba7189a781b /arch
parente5ecc8719212e2566440818491ec5741689f3743 (diff)
[CELL] cbe_cpufreq: fix minor issues
Minor issues have been fixed: * added a missing call to of_node_put() * signedness of a function parameter * added some line breaks * changed global pmi_frequency_limit to a per node pmi_slow_mode_limit array Signed-off-by: Christian Krafft <krafft@de.ibm.com> Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/platforms/cell/cbe_cpufreq.c58
1 files changed, 40 insertions, 18 deletions
diff --git a/arch/powerpc/platforms/cell/cbe_cpufreq.c b/arch/powerpc/platforms/cell/cbe_cpufreq.c
index 3a26b3c115b9..a62562ee1461 100644
--- a/arch/powerpc/platforms/cell/cbe_cpufreq.c
+++ b/arch/powerpc/platforms/cell/cbe_cpufreq.c
@@ -67,7 +67,7 @@ static u64 MIC_Slow_Next_Timer_table[] = {
67 0x00003FC000000000ull, 67 0x00003FC000000000ull,
68}; 68};
69 69
70static unsigned int pmi_frequency_limit = 0; 70static u8 pmi_slow_mode_limit[MAX_BE];
71 71
72/* 72/*
73 * hardware specific functions 73 * hardware specific functions
@@ -169,35 +169,50 @@ static int set_pmode_reg(int cpu, unsigned int pmode)
169 169
170static int set_pmode(int cpu, unsigned int slow_mode) 170static int set_pmode(int cpu, unsigned int slow_mode)
171{ 171{
172 int rc;
172#ifdef CONFIG_PPC_PMI 173#ifdef CONFIG_PPC_PMI
173 if (cbe_cpufreq_has_pmi) 174 if (cbe_cpufreq_has_pmi)
174 return set_pmode_pmi(cpu, slow_mode); 175 rc = set_pmode_pmi(cpu, slow_mode);
176 else
175#endif 177#endif
176 return set_pmode_reg(cpu, slow_mode); 178 rc = set_pmode_reg(cpu, slow_mode);
179
180 pr_debug("register contains slow mode %d\n", get_pmode(cpu));
181
182 return rc;
177} 183}
178 184
179static void cbe_cpufreq_handle_pmi(pmi_message_t pmi_msg) 185static void cbe_cpufreq_handle_pmi(pmi_message_t pmi_msg)
180{ 186{
181 u8 cpu; 187 u8 node; slow_mode;
182 u8 cbe_pmode_new;
183 188
184 BUG_ON(pmi_msg.type != PMI_TYPE_FREQ_CHANGE); 189 BUG_ON(pmi_msg.type != PMI_TYPE_FREQ_CHANGE);
185 190
186 cpu = cbe_node_to_cpu(pmi_msg.data1); 191 node = pmi_msg.data1;
187 cbe_pmode_new = pmi_msg.data2; 192 slow_mode = pmi_msg.data2;
188 193
189 pmi_frequency_limit = cbe_freqs[cbe_pmode_new].frequency; 194 pmi_slow_mode_limit[node] = slow_mode;
190 195
191 pr_debug("cbe_handle_pmi: max freq=%d\n", pmi_frequency_limit); 196 pr_debug("cbe_handle_pmi: node: %d, max slow_mode=%d\n", slow_mode);
192} 197}
193 198
194static int pmi_notifier(struct notifier_block *nb, 199static int pmi_notifier(struct notifier_block *nb,
195 unsigned long event, void *data) 200 unsigned long event, void *data)
196{ 201{
197 struct cpufreq_policy *policy = data; 202 struct cpufreq_policy *policy = data;
203 u8 node;
204
205 node = cbe_cpu_to_node(policy->cpu);
206
207 pr_debug("got notified, event=%lu, node=%u\n", event, node);
198 208
199 if (pmi_frequency_limit) 209 if (pmi_slow_mode_limit[node] != 0) {
200 cpufreq_verify_within_limits(policy, 0, pmi_frequency_limit); 210 pr_debug("limiting node %d to slow mode %d\n",
211 node, pmi_slow_mode_limit[node]);
212
213 cpufreq_verify_within_limits(policy, 0,
214 cbe_freqs[pmi_slow_mode_limit[node]].frequency);
215 }
201 216
202 return 0; 217 return 0;
203} 218}
@@ -232,6 +247,8 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
232 247
233 max_freqp = of_get_property(cpu, "clock-frequency", NULL); 248 max_freqp = of_get_property(cpu, "clock-frequency", NULL);
234 249
250 of_node_put(cpu);
251
235 if (!max_freqp) 252 if (!max_freqp)
236 return -EINVAL; 253 return -EINVAL;
237 254
@@ -248,7 +265,9 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
248 } 265 }
249 266
250 policy->governor = CPUFREQ_DEFAULT_GOVERNOR; 267 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
251 /* if DEBUG is enabled set_pmode() measures the correct latency of a transition */ 268
269 /* if DEBUG is enabled set_pmode() measures the latency
270 * of a transition */
252 policy->cpuinfo.transition_latency = 25000; 271 policy->cpuinfo.transition_latency = 25000;
253 272
254 cur_pmode = get_pmode(policy->cpu); 273 cur_pmode = get_pmode(policy->cpu);
@@ -262,8 +281,8 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
262 281
263 cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu); 282 cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu);
264 283
265 284 /* this ensures that policy->cpuinfo_min
266 /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max are set correctly */ 285 * and policy->cpuinfo_max are set correctly */
267 return cpufreq_frequency_table_cpuinfo(policy, cbe_freqs); 286 return cpufreq_frequency_table_cpuinfo(policy, cbe_freqs);
268} 287}
269 288
@@ -279,12 +298,13 @@ static int cbe_cpufreq_verify(struct cpufreq_policy *policy)
279} 298}
280 299
281 300
282static int cbe_cpufreq_target(struct cpufreq_policy *policy, unsigned int target_freq, 301static int cbe_cpufreq_target(struct cpufreq_policy *policy,
283 unsigned int relation) 302 unsigned int target_freq,
303 unsigned int relation)
284{ 304{
285 int rc; 305 int rc;
286 struct cpufreq_freqs freqs; 306 struct cpufreq_freqs freqs;
287 int cbe_pmode_new; 307 unsigned int cbe_pmode_new;
288 308
289 cpufreq_frequency_table_target(policy, 309 cpufreq_frequency_table_target(policy,
290 cbe_freqs, 310 cbe_freqs,
@@ -299,12 +319,14 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy, unsigned int target
299 mutex_lock(&cbe_switch_mutex); 319 mutex_lock(&cbe_switch_mutex);
300 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 320 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
301 321
302 pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", 322 pr_debug("setting frequency for cpu %d to %d kHz, " \
323 "1/%d of max frequency\n",
303 policy->cpu, 324 policy->cpu,
304 cbe_freqs[cbe_pmode_new].frequency, 325 cbe_freqs[cbe_pmode_new].frequency,
305 cbe_freqs[cbe_pmode_new].index); 326 cbe_freqs[cbe_pmode_new].index);
306 327
307 rc = set_pmode(policy->cpu, cbe_pmode_new); 328 rc = set_pmode(policy->cpu, cbe_pmode_new);
329
308 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 330 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
309 mutex_unlock(&cbe_switch_mutex); 331 mutex_unlock(&cbe_switch_mutex);
310 332