@@ -568,28 +568,24 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic)
568568#endif /* CONFIG_MPIC_U3_HT_IRQS */
569569
570570#ifdef CONFIG_SMP
571- static int irq_choose_cpu (const cpumask_t * mask )
571+ static int irq_choose_cpu (const struct cpumask * mask )
572572{
573573 int cpuid ;
574574
575575 if (cpumask_equal (mask , cpu_all_mask )) {
576- static int irq_rover ;
576+ static int irq_rover = 0 ;
577577 static DEFINE_RAW_SPINLOCK (irq_rover_lock );
578578 unsigned long flags ;
579579
580580 /* Round-robin distribution... */
581581 do_round_robin :
582582 raw_spin_lock_irqsave (& irq_rover_lock , flags );
583583
584- while (! cpu_online ( irq_rover )) {
585- if (++ irq_rover >= NR_CPUS )
586- irq_rover = 0 ;
587- }
584+ irq_rover = cpumask_next ( irq_rover , cpu_online_mask );
585+ if (irq_rover >= nr_cpu_ids )
586+ irq_rover = cpumask_first ( cpu_online_mask ) ;
587+
588588 cpuid = irq_rover ;
589- do {
590- if (++ irq_rover >= NR_CPUS )
591- irq_rover = 0 ;
592- } while (!cpu_online (irq_rover ));
593589
594590 raw_spin_unlock_irqrestore (& irq_rover_lock , flags );
595591 } else {
@@ -601,7 +597,7 @@ static int irq_choose_cpu(const cpumask_t *mask)
601597 return get_hard_smp_processor_id (cpuid );
602598}
603599#else
604- static int irq_choose_cpu (const cpumask_t * mask )
600+ static int irq_choose_cpu (const struct cpumask * mask )
605601{
606602 return hard_smp_processor_id ();
607603}
@@ -814,12 +810,16 @@ int mpic_set_affinity(unsigned int irq, const struct cpumask *cpumask)
814810
815811 mpic_irq_write (src , MPIC_INFO (IRQ_DESTINATION ), 1 << cpuid );
816812 } else {
817- cpumask_t tmp ;
813+ cpumask_var_t tmp ;
818814
819- cpumask_and (& tmp , cpumask , cpu_online_mask );
815+ alloc_cpumask_var (& tmp , GFP_KERNEL );
816+
817+ cpumask_and (tmp , cpumask , cpu_online_mask );
820818
821819 mpic_irq_write (src , MPIC_INFO (IRQ_DESTINATION ),
822- mpic_physmask (cpus_addr (tmp )[0 ]));
820+ mpic_physmask (cpumask_bits (tmp )[0 ]));
821+
822+ free_cpumask_var (tmp );
823823 }
824824
825825 return 0 ;
@@ -1479,21 +1479,6 @@ void mpic_teardown_this_cpu(int secondary)
14791479}
14801480
14811481
1482- void mpic_send_ipi (unsigned int ipi_no , unsigned int cpu_mask )
1483- {
1484- struct mpic * mpic = mpic_primary ;
1485-
1486- BUG_ON (mpic == NULL );
1487-
1488- #ifdef DEBUG_IPI
1489- DBG ("%s: send_ipi(ipi_no: %d)\n" , mpic -> name , ipi_no );
1490- #endif
1491-
1492- mpic_cpu_write (MPIC_INFO (CPU_IPI_DISPATCH_0 ) +
1493- ipi_no * MPIC_INFO (CPU_IPI_DISPATCH_STRIDE ),
1494- mpic_physmask (cpu_mask & cpus_addr (cpu_online_map )[0 ]));
1495- }
1496-
14971482static unsigned int _mpic_get_one_irq (struct mpic * mpic , int reg )
14981483{
14991484 u32 src ;
@@ -1589,8 +1574,25 @@ void mpic_request_ipis(void)
15891574 }
15901575}
15911576
1577+ static void mpic_send_ipi (unsigned int ipi_no , const struct cpumask * cpu_mask )
1578+ {
1579+ struct mpic * mpic = mpic_primary ;
1580+
1581+ BUG_ON (mpic == NULL );
1582+
1583+ #ifdef DEBUG_IPI
1584+ DBG ("%s: send_ipi(ipi_no: %d)\n" , mpic -> name , ipi_no );
1585+ #endif
1586+
1587+ mpic_cpu_write (MPIC_INFO (CPU_IPI_DISPATCH_0 ) +
1588+ ipi_no * MPIC_INFO (CPU_IPI_DISPATCH_STRIDE ),
1589+ mpic_physmask (cpumask_bits (cpu_mask )[0 ]));
1590+ }
1591+
15921592void smp_mpic_message_pass (int target , int msg )
15931593{
1594+ cpumask_var_t tmp ;
1595+
15941596 /* make sure we're sending something that translates to an IPI */
15951597 if ((unsigned int )msg > 3 ) {
15961598 printk ("SMP %d: smp_message_pass: unknown msg %d\n" ,
@@ -1599,13 +1601,17 @@ void smp_mpic_message_pass(int target, int msg)
15991601 }
16001602 switch (target ) {
16011603 case MSG_ALL :
1602- mpic_send_ipi (msg , 0xffffffff );
1604+ mpic_send_ipi (msg , cpu_online_mask );
16031605 break ;
16041606 case MSG_ALL_BUT_SELF :
1605- mpic_send_ipi (msg , 0xffffffff & ~(1 << smp_processor_id ()));
1607+ alloc_cpumask_var (& tmp , GFP_NOWAIT );
1608+ cpumask_andnot (tmp , cpu_online_mask ,
1609+ cpumask_of (smp_processor_id ()));
1610+ mpic_send_ipi (msg , tmp );
1611+ free_cpumask_var (tmp );
16061612 break ;
16071613 default :
1608- mpic_send_ipi (msg , 1 << target );
1614+ mpic_send_ipi (msg , cpumask_of ( target ) );
16091615 break ;
16101616 }
16111617}
@@ -1616,7 +1622,7 @@ int __init smp_mpic_probe(void)
16161622
16171623 DBG ("smp_mpic_probe()...\n" );
16181624
1619- nr_cpus = cpus_weight ( cpu_possible_map );
1625+ nr_cpus = cpumask_weight ( cpu_possible_mask );
16201626
16211627 DBG ("nr_cpus: %d\n" , nr_cpus );
16221628
0 commit comments