aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-01-10 18:51:06 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-10 18:51:06 -0500
commit0811a433c61e85f895018239c4466a36311cd5de (patch)
tree276933e518e5525d24ae37b02df2db9909679260 /arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
parentc299030765292434b73572f9bcfe84951ff06614 (diff)
parent3d14bdad40315b54470cb7812293d14c8af2bf7d (diff)
Merge branch 'linus' into core/iommu
Diffstat (limited to 'arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c')
-rw-r--r--arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
index f0ea6fa2f53..f08998278a3 100644
--- a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -458,11 +458,6 @@ static int centrino_verify (struct cpufreq_policy *policy)
458 * 458 *
459 * Sets a new CPUFreq policy. 459 * Sets a new CPUFreq policy.
460 */ 460 */
461struct allmasks {
462 cpumask_t saved_mask;
463 cpumask_t covered_cpus;
464};
465
466static int centrino_target (struct cpufreq_policy *policy, 461static int centrino_target (struct cpufreq_policy *policy,
467 unsigned int target_freq, 462 unsigned int target_freq,
468 unsigned int relation) 463 unsigned int relation)
@@ -472,12 +467,15 @@ static int centrino_target (struct cpufreq_policy *policy,
472 struct cpufreq_freqs freqs; 467 struct cpufreq_freqs freqs;
473 int retval = 0; 468 int retval = 0;
474 unsigned int j, k, first_cpu, tmp; 469 unsigned int j, k, first_cpu, tmp;
475 CPUMASK_ALLOC(allmasks); 470 cpumask_var_t saved_mask, covered_cpus;
476 CPUMASK_PTR(saved_mask, allmasks);
477 CPUMASK_PTR(covered_cpus, allmasks);
478 471
479 if (unlikely(allmasks == NULL)) 472 if (unlikely(!alloc_cpumask_var(&saved_mask, GFP_KERNEL)))
480 return -ENOMEM; 473 return -ENOMEM;
474 if (unlikely(!alloc_cpumask_var(&covered_cpus, GFP_KERNEL))) {
475 free_cpumask_var(saved_mask);
476 return -ENOMEM;
477 }
478 cpumask_copy(saved_mask, &current->cpus_allowed);
481 479
482 if (unlikely(per_cpu(centrino_model, cpu) == NULL)) { 480 if (unlikely(per_cpu(centrino_model, cpu) == NULL)) {
483 retval = -ENODEV; 481 retval = -ENODEV;
@@ -493,11 +491,9 @@ static int centrino_target (struct cpufreq_policy *policy,
493 goto out; 491 goto out;
494 } 492 }
495 493
496 *saved_mask = current->cpus_allowed;
497 first_cpu = 1; 494 first_cpu = 1;
498 cpus_clear(*covered_cpus); 495 for_each_cpu(j, policy->cpus) {
499 for_each_cpu_mask_nr(j, policy->cpus) { 496 const struct cpumask *mask;
500 const cpumask_t *mask;
501 497
502 /* cpufreq holds the hotplug lock, so we are safe here */ 498 /* cpufreq holds the hotplug lock, so we are safe here */
503 if (!cpu_online(j)) 499 if (!cpu_online(j))
@@ -508,9 +504,9 @@ static int centrino_target (struct cpufreq_policy *policy,
508 * Make sure we are running on CPU that wants to change freq 504 * Make sure we are running on CPU that wants to change freq
509 */ 505 */
510 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) 506 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
511 mask = &policy->cpus; 507 mask = policy->cpus;
512 else 508 else
513 mask = &cpumask_of_cpu(j); 509 mask = cpumask_of(j);
514 510
515 set_cpus_allowed_ptr(current, mask); 511 set_cpus_allowed_ptr(current, mask);
516 preempt_disable(); 512 preempt_disable();
@@ -542,7 +538,7 @@ static int centrino_target (struct cpufreq_policy *policy,
542 dprintk("target=%dkHz old=%d new=%d msr=%04x\n", 538 dprintk("target=%dkHz old=%d new=%d msr=%04x\n",
543 target_freq, freqs.old, freqs.new, msr); 539 target_freq, freqs.old, freqs.new, msr);
544 540
545 for_each_cpu_mask_nr(k, policy->cpus) { 541 for_each_cpu(k, policy->cpus) {
546 if (!cpu_online(k)) 542 if (!cpu_online(k))
547 continue; 543 continue;
548 freqs.cpu = k; 544 freqs.cpu = k;
@@ -567,7 +563,7 @@ static int centrino_target (struct cpufreq_policy *policy,
567 preempt_enable(); 563 preempt_enable();
568 } 564 }
569 565
570 for_each_cpu_mask_nr(k, policy->cpus) { 566 for_each_cpu(k, policy->cpus) {
571 if (!cpu_online(k)) 567 if (!cpu_online(k))
572 continue; 568 continue;
573 freqs.cpu = k; 569 freqs.cpu = k;
@@ -590,7 +586,7 @@ static int centrino_target (struct cpufreq_policy *policy,
590 tmp = freqs.new; 586 tmp = freqs.new;
591 freqs.new = freqs.old; 587 freqs.new = freqs.old;
592 freqs.old = tmp; 588 freqs.old = tmp;
593 for_each_cpu_mask_nr(j, policy->cpus) { 589 for_each_cpu(j, policy->cpus) {
594 if (!cpu_online(j)) 590 if (!cpu_online(j))
595 continue; 591 continue;
596 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 592 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
@@ -605,7 +601,8 @@ migrate_end:
605 preempt_enable(); 601 preempt_enable();
606 set_cpus_allowed_ptr(current, saved_mask); 602 set_cpus_allowed_ptr(current, saved_mask);
607out: 603out:
608 CPUMASK_FREE(allmasks); 604 free_cpumask_var(saved_mask);
605 free_cpumask_var(covered_cpus);
609 return retval; 606 return retval;
610} 607}
611 608