aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2009-03-02 04:53:57 -0500
committerIngo Molnar <mingo@elte.hu>2009-03-02 05:20:33 -0500
commit0edc0b324a37c4bf9e13f3194f2f45c677808792 (patch)
tree46dc183fd2cb4de30adb824c8a76723c62746636 /arch
parentc2b20cbd057b97e2f440fa3bc90b3df51de324fe (diff)
x86_32: apic/es7000_32, fix cpu_mask_to_apicid
Perform same-cluster checking even for masks with all (nr_cpu_ids) bits set and report BAD_APICID on failure. While at it, convert it to for_each_cpu. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/apic/es7000_32.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
index 9b9e86f3cfd..4d8830ffe48 100644
--- a/arch/x86/kernel/apic/es7000_32.c
+++ b/arch/x86/kernel/apic/es7000_32.c
@@ -577,32 +577,22 @@ static int es7000_check_phys_apicid_present(int cpu_physical_apicid)
577 577
578static unsigned int es7000_cpu_mask_to_apicid(const cpumask_t *cpumask) 578static unsigned int es7000_cpu_mask_to_apicid(const cpumask_t *cpumask)
579{ 579{
580 unsigned int cpu, num_bits_set, cpus_found = 0; 580 unsigned int round = 0;
581 int apicid; 581 int cpu, uninitialized_var(apicid);
582 582
583 num_bits_set = cpumask_weight(cpumask);
584 /* Return id to all */
585 if (num_bits_set == nr_cpu_ids)
586 return es7000_cpu_to_logical_apicid(0);
587 /* 583 /*
588 * The cpus in the mask must all be on the apic cluster. If are not 584 * The cpus in the mask must all be on the apic cluster.
589 * on the same apicid cluster return default value of target_cpus():
590 */ 585 */
591 cpu = cpumask_first(cpumask); 586 for_each_cpu(cpu, cpumask) {
592 apicid = es7000_cpu_to_logical_apicid(cpu); 587 int new_apicid = es7000_cpu_to_logical_apicid(cpu);
593 while (cpus_found < num_bits_set) {
594 if (cpumask_test_cpu(cpu, cpumask)) {
595 int new_apicid = es7000_cpu_to_logical_apicid(cpu);
596 588
597 if (APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) { 589 if (round && APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) {
598 WARN(1, "Not a valid mask!"); 590 WARN(1, "Not a valid mask!");
599 591
600 return es7000_cpu_to_logical_apicid(0); 592 return BAD_APICID;
601 }
602 apicid = new_apicid;
603 cpus_found++;
604 } 593 }
605 cpu++; 594 apicid = new_apicid;
595 round++;
606 } 596 }
607 return apicid; 597 return apicid;
608} 598}