aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVenkatesh Pallipadi <venkatesh.pallipadi@intel.com>2006-10-03 15:35:23 -0400
committerDave Jones <davej@redhat.com>2006-10-15 19:57:10 -0400
commit64be7eedb2fd0d41614739b265b22708aa81734c (patch)
tree50df83e84eee613571f6869c51c62aab7b57cd1b
parent83d0515bbb10c7a3e52eee697d1032e447291eda (diff)
[CPUFREQ][5/8] acpi-cpufreq: lindent acpi-cpufreq.c
Lindent acpi-cpufreq. Additional changes replacing "return (..)" by "return ..". No functionality changes in this patch. Signed-off-by: Denis Sadykov <denis.m.sadykov@intel.com> Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> Signed-off-by: Dave Jones <davej@redhat.com>
-rw-r--r--arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c299
1 files changed, 139 insertions, 160 deletions
diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 07fd97ba4c7a..385f17aca06b 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -51,7 +51,6 @@ MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski");
51MODULE_DESCRIPTION("ACPI Processor P-States Driver"); 51MODULE_DESCRIPTION("ACPI Processor P-States Driver");
52MODULE_LICENSE("GPL"); 52MODULE_LICENSE("GPL");
53 53
54
55enum { 54enum {
56 UNDEFINED_CAPABLE = 0, 55 UNDEFINED_CAPABLE = 0,
57 SYSTEM_INTEL_MSR_CAPABLE, 56 SYSTEM_INTEL_MSR_CAPABLE,
@@ -61,36 +60,34 @@ enum {
61#define INTEL_MSR_RANGE (0xffff) 60#define INTEL_MSR_RANGE (0xffff)
62 61
63struct acpi_cpufreq_data { 62struct acpi_cpufreq_data {
64 struct acpi_processor_performance *acpi_data; 63 struct acpi_processor_performance *acpi_data;
65 struct cpufreq_frequency_table *freq_table; 64 struct cpufreq_frequency_table *freq_table;
66 unsigned int resume; 65 unsigned int resume;
67 unsigned int cpu_feature; 66 unsigned int cpu_feature;
68}; 67};
69 68
70static struct acpi_cpufreq_data *drv_data[NR_CPUS]; 69static struct acpi_cpufreq_data *drv_data[NR_CPUS];
71static struct acpi_processor_performance *acpi_perf_data[NR_CPUS]; 70static struct acpi_processor_performance *acpi_perf_data[NR_CPUS];
72 71
73static struct cpufreq_driver acpi_cpufreq_driver; 72static struct cpufreq_driver acpi_cpufreq_driver;
74 73
75static unsigned int acpi_pstate_strict; 74static unsigned int acpi_pstate_strict;
76 75
77
78static int check_est_cpu(unsigned int cpuid) 76static int check_est_cpu(unsigned int cpuid)
79{ 77{
80 struct cpuinfo_x86 *cpu = &cpu_data[cpuid]; 78 struct cpuinfo_x86 *cpu = &cpu_data[cpuid];
81 79
82 if (cpu->x86_vendor != X86_VENDOR_INTEL || 80 if (cpu->x86_vendor != X86_VENDOR_INTEL ||
83 !cpu_has(cpu, X86_FEATURE_EST)) 81 !cpu_has(cpu, X86_FEATURE_EST))
84 return 0; 82 return 0;
85 83
86 return 1; 84 return 1;
87} 85}
88 86
89
90static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data) 87static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data)
91{ 88{
92 struct acpi_processor_performance *perf; 89 struct acpi_processor_performance *perf;
93 int i; 90 int i;
94 91
95 perf = data->acpi_data; 92 perf = data->acpi_data;
96 93
@@ -101,7 +98,6 @@ static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data)
101 return 0; 98 return 0;
102} 99}
103 100
104
105static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data) 101static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
106{ 102{
107 int i; 103 int i;
@@ -114,15 +110,14 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
114 return data->freq_table[0].frequency; 110 return data->freq_table[0].frequency;
115} 111}
116 112
117
118static unsigned extract_freq(u32 val, struct acpi_cpufreq_data *data) 113static unsigned extract_freq(u32 val, struct acpi_cpufreq_data *data)
119{ 114{
120 switch (data->cpu_feature) { 115 switch (data->cpu_feature) {
121 case SYSTEM_INTEL_MSR_CAPABLE: 116 case SYSTEM_INTEL_MSR_CAPABLE:
122 return extract_msr(val, data); 117 return extract_msr(val, data);
123 case SYSTEM_IO_CAPABLE: 118 case SYSTEM_IO_CAPABLE:
124 return extract_io(val, data); 119 return extract_io(val, data);
125 default: 120 default:
126 return 0; 121 return 0;
127 } 122 }
128} 123}
@@ -138,7 +133,7 @@ static void wrport(u16 port, u8 bit_width, u32 value)
138 } 133 }
139} 134}
140 135
141static void rdport(u16 port, u8 bit_width, u32 *ret) 136static void rdport(u16 port, u8 bit_width, u32 * ret)
142{ 137{
143 *ret = 0; 138 *ret = 0;
144 if (bit_width <= 8) { 139 if (bit_width <= 8) {
@@ -176,13 +171,13 @@ static void do_drv_read(struct drv_cmd *cmd)
176 u32 h; 171 u32 h;
177 172
178 switch (cmd->type) { 173 switch (cmd->type) {
179 case SYSTEM_INTEL_MSR_CAPABLE: 174 case SYSTEM_INTEL_MSR_CAPABLE:
180 rdmsr(cmd->addr.msr.reg, cmd->val, h); 175 rdmsr(cmd->addr.msr.reg, cmd->val, h);
181 break; 176 break;
182 case SYSTEM_IO_CAPABLE: 177 case SYSTEM_IO_CAPABLE:
183 rdport(cmd->addr.io.port, cmd->addr.io.bit_width, &cmd->val); 178 rdport(cmd->addr.io.port, cmd->addr.io.bit_width, &cmd->val);
184 break; 179 break;
185 default: 180 default:
186 break; 181 break;
187 } 182 }
188} 183}
@@ -192,20 +187,20 @@ static void do_drv_write(struct drv_cmd *cmd)
192 u32 h = 0; 187 u32 h = 0;
193 188
194 switch (cmd->type) { 189 switch (cmd->type) {
195 case SYSTEM_INTEL_MSR_CAPABLE: 190 case SYSTEM_INTEL_MSR_CAPABLE:
196 wrmsr(cmd->addr.msr.reg, cmd->val, h); 191 wrmsr(cmd->addr.msr.reg, cmd->val, h);
197 break; 192 break;
198 case SYSTEM_IO_CAPABLE: 193 case SYSTEM_IO_CAPABLE:
199 wrport(cmd->addr.io.port, cmd->addr.io.bit_width, cmd->val); 194 wrport(cmd->addr.io.port, cmd->addr.io.bit_width, cmd->val);
200 break; 195 break;
201 default: 196 default:
202 break; 197 break;
203 } 198 }
204} 199}
205 200
206static inline void drv_read(struct drv_cmd *cmd) 201static inline void drv_read(struct drv_cmd *cmd)
207{ 202{
208 cpumask_t saved_mask = current->cpus_allowed; 203 cpumask_t saved_mask = current->cpus_allowed;
209 cmd->val = 0; 204 cmd->val = 0;
210 205
211 set_cpus_allowed(current, cmd->mask); 206 set_cpus_allowed(current, cmd->mask);
@@ -216,8 +211,8 @@ static inline void drv_read(struct drv_cmd *cmd)
216 211
217static void drv_write(struct drv_cmd *cmd) 212static void drv_write(struct drv_cmd *cmd)
218{ 213{
219 cpumask_t saved_mask = current->cpus_allowed; 214 cpumask_t saved_mask = current->cpus_allowed;
220 unsigned int i; 215 unsigned int i;
221 216
222 for_each_cpu_mask(i, cmd->mask) { 217 for_each_cpu_mask(i, cmd->mask) {
223 set_cpus_allowed(current, cpumask_of_cpu(i)); 218 set_cpus_allowed(current, cpumask_of_cpu(i));
@@ -230,8 +225,8 @@ static void drv_write(struct drv_cmd *cmd)
230 225
231static u32 get_cur_val(cpumask_t mask) 226static u32 get_cur_val(cpumask_t mask)
232{ 227{
233 struct acpi_processor_performance *perf; 228 struct acpi_processor_performance *perf;
234 struct drv_cmd cmd; 229 struct drv_cmd cmd;
235 230
236 if (unlikely(cpus_empty(mask))) 231 if (unlikely(cpus_empty(mask)))
237 return 0; 232 return 0;
@@ -262,14 +257,13 @@ static u32 get_cur_val(cpumask_t mask)
262 257
263static unsigned int get_cur_freq_on_cpu(unsigned int cpu) 258static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
264{ 259{
265 struct acpi_cpufreq_data *data = drv_data[cpu]; 260 struct acpi_cpufreq_data *data = drv_data[cpu];
266 unsigned int freq; 261 unsigned int freq;
267 262
268 dprintk("get_cur_freq_on_cpu (%d)\n", cpu); 263 dprintk("get_cur_freq_on_cpu (%d)\n", cpu);
269 264
270 if (unlikely(data == NULL || 265 if (unlikely(data == NULL ||
271 data->acpi_data == NULL || 266 data->acpi_data == NULL || data->freq_table == NULL)) {
272 data->freq_table == NULL)) {
273 return 0; 267 return 0;
274 } 268 }
275 269
@@ -280,10 +274,10 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
280} 274}
281 275
282static unsigned int check_freqs(cpumask_t mask, unsigned int freq, 276static unsigned int check_freqs(cpumask_t mask, unsigned int freq,
283 struct acpi_cpufreq_data *data) 277 struct acpi_cpufreq_data *data)
284{ 278{
285 unsigned int cur_freq; 279 unsigned int cur_freq;
286 unsigned int i; 280 unsigned int i;
287 281
288 for (i = 0; i < 100; i++) { 282 for (i = 0; i < 100; i++) {
289 cur_freq = extract_freq(get_cur_val(mask), data); 283 cur_freq = extract_freq(get_cur_val(mask), data);
@@ -295,34 +289,31 @@ static unsigned int check_freqs(cpumask_t mask, unsigned int freq,
295} 289}
296 290
297static int acpi_cpufreq_target(struct cpufreq_policy *policy, 291static int acpi_cpufreq_target(struct cpufreq_policy *policy,
298 unsigned int target_freq, 292 unsigned int target_freq, unsigned int relation)
299 unsigned int relation)
300{ 293{
301 struct acpi_cpufreq_data *data = drv_data[policy->cpu]; 294 struct acpi_cpufreq_data *data = drv_data[policy->cpu];
302 struct acpi_processor_performance *perf; 295 struct acpi_processor_performance *perf;
303 struct cpufreq_freqs freqs; 296 struct cpufreq_freqs freqs;
304 cpumask_t online_policy_cpus; 297 cpumask_t online_policy_cpus;
305 struct drv_cmd cmd; 298 struct drv_cmd cmd;
306 unsigned int msr; 299 unsigned int msr;
307 unsigned int next_state = 0; 300 unsigned int next_state = 0;
308 unsigned int next_perf_state = 0; 301 unsigned int next_perf_state = 0;
309 unsigned int i; 302 unsigned int i;
310 int result = 0; 303 int result = 0;
311 304
312 dprintk("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu); 305 dprintk("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu);
313 306
314 if (unlikely(data == NULL || 307 if (unlikely(data == NULL ||
315 data->acpi_data == NULL || 308 data->acpi_data == NULL || data->freq_table == NULL)) {
316 data->freq_table == NULL)) {
317 return -ENODEV; 309 return -ENODEV;
318 } 310 }
319 311
320 perf = data->acpi_data; 312 perf = data->acpi_data;
321 result = cpufreq_frequency_table_target(policy, 313 result = cpufreq_frequency_table_target(policy,
322 data->freq_table, 314 data->freq_table,
323 target_freq, 315 target_freq,
324 relation, 316 relation, &next_state);
325 &next_state);
326 if (unlikely(result)) 317 if (unlikely(result))
327 return -ENODEV; 318 return -ENODEV;
328 319
@@ -339,30 +330,34 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
339 next_perf_state = data->freq_table[next_state].index; 330 next_perf_state = data->freq_table[next_state].index;
340 if (freqs.new == freqs.old) { 331 if (freqs.new == freqs.old) {
341 if (unlikely(data->resume)) { 332 if (unlikely(data->resume)) {
342 dprintk("Called after resume, resetting to P%d\n", next_perf_state); 333 dprintk("Called after resume, resetting to P%d\n",
334 next_perf_state);
343 data->resume = 0; 335 data->resume = 0;
344 } else { 336 } else {
345 dprintk("Already at target state (P%d)\n", next_perf_state); 337 dprintk("Already at target state (P%d)\n",
338 next_perf_state);
346 return 0; 339 return 0;
347 } 340 }
348 } 341 }
349 342
350 switch (data->cpu_feature) { 343 switch (data->cpu_feature) {
351 case SYSTEM_INTEL_MSR_CAPABLE: 344 case SYSTEM_INTEL_MSR_CAPABLE:
352 cmd.type = SYSTEM_INTEL_MSR_CAPABLE; 345 cmd.type = SYSTEM_INTEL_MSR_CAPABLE;
353 cmd.addr.msr.reg = MSR_IA32_PERF_CTL; 346 cmd.addr.msr.reg = MSR_IA32_PERF_CTL;
354 msr = (u32) perf->states[next_perf_state].control & INTEL_MSR_RANGE; 347 msr =
355 cmd.val = (cmd.val & ~INTEL_MSR_RANGE) | msr; 348 (u32) perf->states[next_perf_state].
356 break; 349 control & INTEL_MSR_RANGE;
357 case SYSTEM_IO_CAPABLE: 350 cmd.val = (cmd.val & ~INTEL_MSR_RANGE) | msr;
358 cmd.type = SYSTEM_IO_CAPABLE; 351 break;
359 cmd.addr.io.port = perf->control_register.address; 352 case SYSTEM_IO_CAPABLE:
360 cmd.addr.io.bit_width = perf->control_register.bit_width; 353 cmd.type = SYSTEM_IO_CAPABLE;
361 cmd.val = (u32) perf->states[next_perf_state].control; 354 cmd.addr.io.port = perf->control_register.address;
362 break; 355 cmd.addr.io.bit_width = perf->control_register.bit_width;
363 default: 356 cmd.val = (u32) perf->states[next_perf_state].control;
364 return -ENODEV; 357 break;
365 } 358 default:
359 return -ENODEV;
360 }
366 361
367 cpus_clear(cmd.mask); 362 cpus_clear(cmd.mask);
368 363
@@ -381,7 +376,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
381 if (acpi_pstate_strict) { 376 if (acpi_pstate_strict) {
382 if (!check_freqs(cmd.mask, freqs.new, data)) { 377 if (!check_freqs(cmd.mask, freqs.new, data)) {
383 dprintk("acpi_cpufreq_target failed (%d)\n", 378 dprintk("acpi_cpufreq_target failed (%d)\n",
384 policy->cpu); 379 policy->cpu);
385 return -EAGAIN; 380 return -EAGAIN;
386 } 381 }
387 } 382 }
@@ -395,10 +390,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
395 return result; 390 return result;
396} 391}
397 392
398 393static int acpi_cpufreq_verify(struct cpufreq_policy *policy)
399static int
400acpi_cpufreq_verify (
401 struct cpufreq_policy *policy)
402{ 394{
403 struct acpi_cpufreq_data *data = drv_data[policy->cpu]; 395 struct acpi_cpufreq_data *data = drv_data[policy->cpu];
404 396
@@ -407,13 +399,10 @@ acpi_cpufreq_verify (
407 return cpufreq_frequency_table_verify(policy, data->freq_table); 399 return cpufreq_frequency_table_verify(policy, data->freq_table);
408} 400}
409 401
410
411static unsigned long 402static unsigned long
412acpi_cpufreq_guess_freq ( 403acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
413 struct acpi_cpufreq_data *data,
414 unsigned int cpu)
415{ 404{
416 struct acpi_processor_performance *perf = data->acpi_data; 405 struct acpi_processor_performance *perf = data->acpi_data;
417 406
418 if (cpu_khz) { 407 if (cpu_khz) {
419 /* search the closest match to cpu_khz */ 408 /* search the closest match to cpu_khz */
@@ -423,14 +412,14 @@ acpi_cpufreq_guess_freq (
423 412
424 for (i = 0; i < (perf->state_count - 1); i++) { 413 for (i = 0; i < (perf->state_count - 1); i++) {
425 freq = freqn; 414 freq = freqn;
426 freqn = perf->states[i+1].core_frequency * 1000; 415 freqn = perf->states[i + 1].core_frequency * 1000;
427 if ((2 * cpu_khz) > (freqn + freq)) { 416 if ((2 * cpu_khz) > (freqn + freq)) {
428 perf->state = i; 417 perf->state = i;
429 return (freq); 418 return freq;
430 } 419 }
431 } 420 }
432 perf->state = perf->state_count - 1; 421 perf->state = perf->state_count - 1;
433 return (freqn); 422 return freqn;
434 } else { 423 } else {
435 /* assume CPU is at P0... */ 424 /* assume CPU is at P0... */
436 perf->state = 0; 425 perf->state = 0;
@@ -438,7 +427,6 @@ acpi_cpufreq_guess_freq (
438 } 427 }
439} 428}
440 429
441
442/* 430/*
443 * acpi_cpufreq_early_init - initialize ACPI P-States library 431 * acpi_cpufreq_early_init - initialize ACPI P-States library
444 * 432 *
@@ -449,21 +437,21 @@ acpi_cpufreq_guess_freq (
449 */ 437 */
450static int acpi_cpufreq_early_init(void) 438static int acpi_cpufreq_early_init(void)
451{ 439{
452 struct acpi_processor_performance *data; 440 struct acpi_processor_performance *data;
453 cpumask_t covered; 441 cpumask_t covered;
454 unsigned int i, j; 442 unsigned int i, j;
455 443
456 dprintk("acpi_cpufreq_early_init\n"); 444 dprintk("acpi_cpufreq_early_init\n");
457 445
458 for_each_possible_cpu(i) { 446 for_each_possible_cpu(i) {
459 data = kzalloc(sizeof(struct acpi_processor_performance), 447 data = kzalloc(sizeof(struct acpi_processor_performance),
460 GFP_KERNEL); 448 GFP_KERNEL);
461 if (!data) { 449 if (!data) {
462 for_each_cpu_mask(j, covered) { 450 for_each_cpu_mask(j, covered) {
463 kfree(acpi_perf_data[j]); 451 kfree(acpi_perf_data[j]);
464 acpi_perf_data[j] = NULL; 452 acpi_perf_data[j] = NULL;
465 } 453 }
466 return (-ENOMEM); 454 return -ENOMEM;
467 } 455 }
468 acpi_perf_data[i] = data; 456 acpi_perf_data[i] = data;
469 cpu_set(i, covered); 457 cpu_set(i, covered);
@@ -501,27 +489,25 @@ static struct dmi_system_id sw_any_bug_dmi_table[] = {
501 { } 489 { }
502}; 490};
503 491
504static int 492static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
505acpi_cpufreq_cpu_init (
506 struct cpufreq_policy *policy)
507{ 493{
508 unsigned int i; 494 unsigned int i;
509 unsigned int valid_states = 0; 495 unsigned int valid_states = 0;
510 unsigned int cpu = policy->cpu; 496 unsigned int cpu = policy->cpu;
511 struct acpi_cpufreq_data *data; 497 struct acpi_cpufreq_data *data;
512 unsigned int l, h; 498 unsigned int l, h;
513 unsigned int result = 0; 499 unsigned int result = 0;
514 struct cpuinfo_x86 *c = &cpu_data[policy->cpu]; 500 struct cpuinfo_x86 *c = &cpu_data[policy->cpu];
515 struct acpi_processor_performance *perf; 501 struct acpi_processor_performance *perf;
516 502
517 dprintk("acpi_cpufreq_cpu_init\n"); 503 dprintk("acpi_cpufreq_cpu_init\n");
518 504
519 if (!acpi_perf_data[cpu]) 505 if (!acpi_perf_data[cpu])
520 return (-ENODEV); 506 return -ENODEV;
521 507
522 data = kzalloc(sizeof(struct acpi_cpufreq_data), GFP_KERNEL); 508 data = kzalloc(sizeof(struct acpi_cpufreq_data), GFP_KERNEL);
523 if (!data) 509 if (!data)
524 return (-ENOMEM); 510 return -ENOMEM;
525 511
526 data->acpi_data = acpi_perf_data[cpu]; 512 data->acpi_data = acpi_perf_data[cpu];
527 drv_data[cpu] = data; 513 drv_data[cpu] = data;
@@ -566,11 +552,11 @@ acpi_cpufreq_cpu_init (
566 } 552 }
567 553
568 switch (perf->control_register.space_id) { 554 switch (perf->control_register.space_id) {
569 case ACPI_ADR_SPACE_SYSTEM_IO: 555 case ACPI_ADR_SPACE_SYSTEM_IO:
570 dprintk("SYSTEM IO addr space\n"); 556 dprintk("SYSTEM IO addr space\n");
571 data->cpu_feature = SYSTEM_IO_CAPABLE; 557 data->cpu_feature = SYSTEM_IO_CAPABLE;
572 break; 558 break;
573 case ACPI_ADR_SPACE_FIXED_HARDWARE: 559 case ACPI_ADR_SPACE_FIXED_HARDWARE:
574 dprintk("HARDWARE addr space\n"); 560 dprintk("HARDWARE addr space\n");
575 if (!check_est_cpu(cpu)) { 561 if (!check_est_cpu(cpu)) {
576 result = -ENODEV; 562 result = -ENODEV;
@@ -578,14 +564,16 @@ acpi_cpufreq_cpu_init (
578 } 564 }
579 data->cpu_feature = SYSTEM_INTEL_MSR_CAPABLE; 565 data->cpu_feature = SYSTEM_INTEL_MSR_CAPABLE;
580 break; 566 break;
581 default: 567 default:
582 dprintk("Unknown addr space %d\n", 568 dprintk("Unknown addr space %d\n",
583 (u32) (perf->control_register.space_id)); 569 (u32) (perf->control_register.space_id));
584 result = -ENODEV; 570 result = -ENODEV;
585 goto err_unreg; 571 goto err_unreg;
586 } 572 }
587 573
588 data->freq_table = kmalloc(sizeof(struct cpufreq_frequency_table) * (perf->state_count + 1), GFP_KERNEL); 574 data->freq_table =
575 kmalloc(sizeof(struct cpufreq_frequency_table) *
576 (perf->state_count + 1), GFP_KERNEL);
589 if (!data->freq_table) { 577 if (!data->freq_table) {
590 result = -ENOMEM; 578 result = -ENOMEM;
591 goto err_unreg; 579 goto err_unreg;
@@ -593,22 +581,23 @@ acpi_cpufreq_cpu_init (
593 581
594 /* detect transition latency */ 582 /* detect transition latency */
595 policy->cpuinfo.transition_latency = 0; 583 policy->cpuinfo.transition_latency = 0;
596 for (i=0; i<perf->state_count; i++) { 584 for (i = 0; i < perf->state_count; i++) {
597 if ((perf->states[i].transition_latency * 1000) > policy->cpuinfo.transition_latency) 585 if ((perf->states[i].transition_latency * 1000) >
598 policy->cpuinfo.transition_latency = perf->states[i].transition_latency * 1000; 586 policy->cpuinfo.transition_latency)
587 policy->cpuinfo.transition_latency =
588 perf->states[i].transition_latency * 1000;
599 } 589 }
600 policy->governor = CPUFREQ_DEFAULT_GOVERNOR; 590 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
601 591
602 /* table init */ 592 /* table init */
603 for (i=0; i<perf->state_count; i++) 593 for (i = 0; i < perf->state_count; i++) {
604 { 594 if (i > 0 && perf->states[i].core_frequency ==
605 if ( i > 0 && perf->states[i].core_frequency == 595 perf->states[i - 1].core_frequency)
606 perf->states[i - 1].core_frequency)
607 continue; 596 continue;
608 597
609 data->freq_table[valid_states].index = i; 598 data->freq_table[valid_states].index = i;
610 data->freq_table[valid_states].frequency = 599 data->freq_table[valid_states].frequency =
611 perf->states[i].core_frequency * 1000; 600 perf->states[i].core_frequency * 1000;
612 valid_states++; 601 valid_states++;
613 } 602 }
614 data->freq_table[perf->state_count].frequency = CPUFREQ_TABLE_END; 603 data->freq_table[perf->state_count].frequency = CPUFREQ_TABLE_END;
@@ -619,14 +608,14 @@ acpi_cpufreq_cpu_init (
619 } 608 }
620 609
621 switch (data->cpu_feature) { 610 switch (data->cpu_feature) {
622 case ACPI_ADR_SPACE_SYSTEM_IO: 611 case ACPI_ADR_SPACE_SYSTEM_IO:
623 /* Current speed is unknown and not detectable by IO port */ 612 /* Current speed is unknown and not detectable by IO port */
624 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu); 613 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
625 break; 614 break;
626 case ACPI_ADR_SPACE_FIXED_HARDWARE: 615 case ACPI_ADR_SPACE_FIXED_HARDWARE:
627 get_cur_freq_on_cpu(cpu); 616 get_cur_freq_on_cpu(cpu);
628 break; 617 break;
629 default: 618 default:
630 break; 619 break;
631 } 620 }
632 621
@@ -636,100 +625,89 @@ acpi_cpufreq_cpu_init (
636 dprintk("CPU%u - ACPI performance management activated.\n", cpu); 625 dprintk("CPU%u - ACPI performance management activated.\n", cpu);
637 for (i = 0; i < perf->state_count; i++) 626 for (i = 0; i < perf->state_count; i++)
638 dprintk(" %cP%d: %d MHz, %d mW, %d uS\n", 627 dprintk(" %cP%d: %d MHz, %d mW, %d uS\n",
639 (i == perf->state?'*':' '), i, 628 (i == perf->state ? '*' : ' '), i,
640 (u32) perf->states[i].core_frequency, 629 (u32) perf->states[i].core_frequency,
641 (u32) perf->states[i].power, 630 (u32) perf->states[i].power,
642 (u32) perf->states[i].transition_latency); 631 (u32) perf->states[i].transition_latency);
643 632
644 cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu); 633 cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu);
645 634
646 /* 635 /*
647 * the first call to ->target() should result in us actually 636 * the first call to ->target() should result in us actually
648 * writing something to the appropriate registers. 637 * writing something to the appropriate registers.
649 */ 638 */
650 data->resume = 1; 639 data->resume = 1;
651 640
652 return result; 641 return result;
653 642
654 err_freqfree: 643 err_freqfree:
655 kfree(data->freq_table); 644 kfree(data->freq_table);
656 err_unreg: 645 err_unreg:
657 acpi_processor_unregister_performance(perf, cpu); 646 acpi_processor_unregister_performance(perf, cpu);
658 err_free: 647 err_free:
659 kfree(data); 648 kfree(data);
660 drv_data[cpu] = NULL; 649 drv_data[cpu] = NULL;
661 650
662 return (result); 651 return result;
663} 652}
664 653
665 654static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
666static int
667acpi_cpufreq_cpu_exit (
668 struct cpufreq_policy *policy)
669{ 655{
670 struct acpi_cpufreq_data *data = drv_data[policy->cpu]; 656 struct acpi_cpufreq_data *data = drv_data[policy->cpu];
671 657
672
673 dprintk("acpi_cpufreq_cpu_exit\n"); 658 dprintk("acpi_cpufreq_cpu_exit\n");
674 659
675 if (data) { 660 if (data) {
676 cpufreq_frequency_table_put_attr(policy->cpu); 661 cpufreq_frequency_table_put_attr(policy->cpu);
677 drv_data[policy->cpu] = NULL; 662 drv_data[policy->cpu] = NULL;
678 acpi_processor_unregister_performance(data->acpi_data, policy->cpu); 663 acpi_processor_unregister_performance(data->acpi_data,
664 policy->cpu);
679 kfree(data); 665 kfree(data);
680 } 666 }
681 667
682 return (0); 668 return 0;
683} 669}
684 670
685static int 671static int acpi_cpufreq_resume(struct cpufreq_policy *policy)
686acpi_cpufreq_resume (
687 struct cpufreq_policy *policy)
688{ 672{
689 struct acpi_cpufreq_data *data = drv_data[policy->cpu]; 673 struct acpi_cpufreq_data *data = drv_data[policy->cpu];
690 674
691
692 dprintk("acpi_cpufreq_resume\n"); 675 dprintk("acpi_cpufreq_resume\n");
693 676
694 data->resume = 1; 677 data->resume = 1;
695 678
696 return (0); 679 return 0;
697} 680}
698 681
699 682static struct freq_attr *acpi_cpufreq_attr[] = {
700static struct freq_attr* acpi_cpufreq_attr[] = {
701 &cpufreq_freq_attr_scaling_available_freqs, 683 &cpufreq_freq_attr_scaling_available_freqs,
702 NULL, 684 NULL,
703}; 685};
704 686
705static struct cpufreq_driver acpi_cpufreq_driver = { 687static struct cpufreq_driver acpi_cpufreq_driver = {
706 .verify = acpi_cpufreq_verify, 688 .verify = acpi_cpufreq_verify,
707 .target = acpi_cpufreq_target, 689 .target = acpi_cpufreq_target,
708 .get = get_cur_freq_on_cpu, 690 .get = get_cur_freq_on_cpu,
709 .init = acpi_cpufreq_cpu_init, 691 .init = acpi_cpufreq_cpu_init,
710 .exit = acpi_cpufreq_cpu_exit, 692 .exit = acpi_cpufreq_cpu_exit,
711 .resume = acpi_cpufreq_resume, 693 .resume = acpi_cpufreq_resume,
712 .name = "acpi-cpufreq", 694 .name = "acpi-cpufreq",
713 .owner = THIS_MODULE, 695 .owner = THIS_MODULE,
714 .attr = acpi_cpufreq_attr, 696 .attr = acpi_cpufreq_attr,
715}; 697};
716 698
717 699static int __init acpi_cpufreq_init(void)
718static int __init
719acpi_cpufreq_init (void)
720{ 700{
721 dprintk("acpi_cpufreq_init\n"); 701 dprintk("acpi_cpufreq_init\n");
722 702
723 acpi_cpufreq_early_init(); 703 acpi_cpufreq_early_init();
724 704
725 return cpufreq_register_driver(&acpi_cpufreq_driver); 705 return cpufreq_register_driver(&acpi_cpufreq_driver);
726} 706}
727 707
728 708static void __exit acpi_cpufreq_exit(void)
729static void __exit
730acpi_cpufreq_exit (void)
731{ 709{
732 unsigned int i; 710 unsigned int i;
733 dprintk("acpi_cpufreq_exit\n"); 711 dprintk("acpi_cpufreq_exit\n");
734 712
735 cpufreq_unregister_driver(&acpi_cpufreq_driver); 713 cpufreq_unregister_driver(&acpi_cpufreq_driver);
@@ -742,7 +720,8 @@ acpi_cpufreq_exit (void)
742} 720}
743 721
744module_param(acpi_pstate_strict, uint, 0644); 722module_param(acpi_pstate_strict, uint, 0644);
745MODULE_PARM_DESC(acpi_pstate_strict, "value 0 or non-zero. non-zero -> strict ACPI checks are performed during frequency changes."); 723MODULE_PARM_DESC(acpi_pstate_strict,
724 "value 0 or non-zero. non-zero -> strict ACPI checks are performed during frequency changes.");
746 725
747late_initcall(acpi_cpufreq_init); 726late_initcall(acpi_cpufreq_init);
748module_exit(acpi_cpufreq_exit); 727module_exit(acpi_cpufreq_exit);