powerpc: make irq_choose_cpu() available to all PIC drivers
authorStuart Yoder <stuart.yoder@freescale.com>
Thu, 19 May 2011 13:54:26 +0000 (08:54 -0500)
committerKumar Gala <galak@kernel.crashing.org>
Thu, 23 Jun 2011 02:44:59 +0000 (21:44 -0500)
Move irq_choose_cpu() into arch/powerpc/kernel/irq.c so that it can be used
by other PIC drivers.  The function is not MPIC-specific.

Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/include/asm/irq.h
arch/powerpc/kernel/irq.c
arch/powerpc/sysdev/mpic.c

index 1bff591f7f72a5f12c0ceebb2aabbf13810be01e..c57a28e52b6459322df4c2b7d407f27ecaa18ee3 100644 (file)
@@ -330,5 +330,7 @@ extern int call_handle_irq(int irq, void *p1,
                           struct thread_info *tp, void *func);
 extern void do_IRQ(struct pt_regs *regs);
 
+int irq_choose_cpu(const struct cpumask *mask);
+
 #endif /* _ASM_IRQ_H */
 #endif /* __KERNEL__ */
index 5b428e3086662bcc802f9ce5049ada0c92aefa63..38dd10e2841d85a58abd16f74fe42f7cf976880c 100644 (file)
@@ -882,6 +882,41 @@ unsigned int irq_find_mapping(struct irq_host *host,
 }
 EXPORT_SYMBOL_GPL(irq_find_mapping);
 
+#ifdef CONFIG_SMP
+int irq_choose_cpu(const struct cpumask *mask)
+{
+       int cpuid;
+
+       if (cpumask_equal(mask, cpu_all_mask)) {
+               static int irq_rover;
+               static DEFINE_RAW_SPINLOCK(irq_rover_lock);
+               unsigned long flags;
+
+               /* Round-robin distribution... */
+do_round_robin:
+               raw_spin_lock_irqsave(&irq_rover_lock, flags);
+
+               irq_rover = cpumask_next(irq_rover, cpu_online_mask);
+               if (irq_rover >= nr_cpu_ids)
+                       irq_rover = cpumask_first(cpu_online_mask);
+
+               cpuid = irq_rover;
+
+               raw_spin_unlock_irqrestore(&irq_rover_lock, flags);
+       } else {
+               cpuid = cpumask_first_and(mask, cpu_online_mask);
+               if (cpuid >= nr_cpu_ids)
+                       goto do_round_robin;
+       }
+
+       return get_hard_smp_processor_id(cpuid);
+}
+#else
+int irq_choose_cpu(const struct cpumask *mask)
+{
+       return hard_smp_processor_id();
+}
+#endif
 
 unsigned int irq_radix_revmap_lookup(struct irq_host *host,
                                     irq_hw_number_t hwirq)
index 3f995dcf95c915c3c44a8771cfcef211cd938bf4..d3bc7e595d0b7610f8196c83b8d437baf601239c 100644 (file)
@@ -597,42 +597,6 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic)
 
 #endif /* CONFIG_MPIC_U3_HT_IRQS */
 
-#ifdef CONFIG_SMP
-static int irq_choose_cpu(const struct cpumask *mask)
-{
-       int cpuid;
-
-       if (cpumask_equal(mask, cpu_all_mask)) {
-               static int irq_rover = 0;
-               static DEFINE_RAW_SPINLOCK(irq_rover_lock);
-               unsigned long flags;
-
-               /* Round-robin distribution... */
-       do_round_robin:
-               raw_spin_lock_irqsave(&irq_rover_lock, flags);
-
-               irq_rover = cpumask_next(irq_rover, cpu_online_mask);
-               if (irq_rover >= nr_cpu_ids)
-                       irq_rover = cpumask_first(cpu_online_mask);
-
-               cpuid = irq_rover;
-
-               raw_spin_unlock_irqrestore(&irq_rover_lock, flags);
-       } else {
-               cpuid = cpumask_first_and(mask, cpu_online_mask);
-               if (cpuid >= nr_cpu_ids)
-                       goto do_round_robin;
-       }
-
-       return get_hard_smp_processor_id(cpuid);
-}
-#else
-static int irq_choose_cpu(const struct cpumask *mask)
-{
-       return hard_smp_processor_id();
-}
-#endif
-
 /* Find an mpic associated with a given linux interrupt */
 static struct mpic *mpic_find(unsigned int irq)
 {