aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/apic/summit_32.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
index 0a1135c5a6de..beda620bee86 100644
--- a/arch/x86/kernel/apic/summit_32.c
+++ b/arch/x86/kernel/apic/summit_32.c
@@ -291,33 +291,21 @@ static int summit_check_phys_apicid_present(int boot_cpu_physical_apicid)
291 291
292static unsigned int summit_cpu_mask_to_apicid(const cpumask_t *cpumask) 292static unsigned int summit_cpu_mask_to_apicid(const cpumask_t *cpumask)
293{ 293{
294 int cpus_found = 0; 294 unsigned int round = 0;
295 int num_bits_set; 295 int cpu, apicid = 0;
296 int apicid;
297 int cpu;
298 296
299 num_bits_set = cpus_weight(*cpumask);
300 if (num_bits_set >= nr_cpu_ids)
301 return BAD_APICID;
302 /* 297 /*
303 * The cpus in the mask must all be on the apic cluster. 298 * The cpus in the mask must all be on the apic cluster.
304 */ 299 */
305 cpu = first_cpu(*cpumask); 300 for_each_cpu(cpu, cpumask) {
306 apicid = summit_cpu_to_logical_apicid(cpu); 301 int new_apicid = summit_cpu_to_logical_apicid(cpu);
307
308 while (cpus_found < num_bits_set) {
309 if (cpu_isset(cpu, *cpumask)) {
310 int new_apicid = summit_cpu_to_logical_apicid(cpu);
311 302
312 if (APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) { 303 if (round && APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) {
313 printk("%s: Not a valid mask!\n", __func__); 304 printk("%s: Not a valid mask!\n", __func__);
314 305 return BAD_APICID;
315 return BAD_APICID;
316 }
317 apicid = apicid | new_apicid;
318 cpus_found++;
319 } 306 }
320 cpu++; 307 apicid |= new_apicid;
308 round++;
321 } 309 }
322 return apicid; 310 return apicid;
323} 311}