diff options
author | Stuart Yoder <stuart.yoder@freescale.com> | 2011-05-19 09:54:26 -0400 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2011-06-22 22:44:59 -0400 |
commit | 6ec36b5848a8336d3a0010727b9365c3254d2d2e (patch) | |
tree | 7876f705354d8b6e73a6079b5bd6561f0b8e2cbd /arch | |
parent | 47fe819e7555b31d24f8a11d9b2568d8f5de8b01 (diff) |
powerpc: make irq_choose_cpu() available to all PIC drivers
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/include/asm/irq.h | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/irq.c | 35 | ||||
-rw-r--r-- | arch/powerpc/sysdev/mpic.c | 36 |
3 files changed, 37 insertions, 36 deletions
diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h index 1bff591f7f72..c57a28e52b64 100644 --- a/arch/powerpc/include/asm/irq.h +++ b/arch/powerpc/include/asm/irq.h | |||
@@ -330,5 +330,7 @@ extern int call_handle_irq(int irq, void *p1, | |||
330 | struct thread_info *tp, void *func); | 330 | struct thread_info *tp, void *func); |
331 | extern void do_IRQ(struct pt_regs *regs); | 331 | extern void do_IRQ(struct pt_regs *regs); |
332 | 332 | ||
333 | int irq_choose_cpu(const struct cpumask *mask); | ||
334 | |||
333 | #endif /* _ASM_IRQ_H */ | 335 | #endif /* _ASM_IRQ_H */ |
334 | #endif /* __KERNEL__ */ | 336 | #endif /* __KERNEL__ */ |
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index 5b428e308666..38dd10e2841d 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c | |||
@@ -882,6 +882,41 @@ unsigned int irq_find_mapping(struct irq_host *host, | |||
882 | } | 882 | } |
883 | EXPORT_SYMBOL_GPL(irq_find_mapping); | 883 | EXPORT_SYMBOL_GPL(irq_find_mapping); |
884 | 884 | ||
885 | #ifdef CONFIG_SMP | ||
886 | int irq_choose_cpu(const struct cpumask *mask) | ||
887 | { | ||
888 | int cpuid; | ||
889 | |||
890 | if (cpumask_equal(mask, cpu_all_mask)) { | ||
891 | static int irq_rover; | ||
892 | static DEFINE_RAW_SPINLOCK(irq_rover_lock); | ||
893 | unsigned long flags; | ||
894 | |||
895 | /* Round-robin distribution... */ | ||
896 | do_round_robin: | ||
897 | raw_spin_lock_irqsave(&irq_rover_lock, flags); | ||
898 | |||
899 | irq_rover = cpumask_next(irq_rover, cpu_online_mask); | ||
900 | if (irq_rover >= nr_cpu_ids) | ||
901 | irq_rover = cpumask_first(cpu_online_mask); | ||
902 | |||
903 | cpuid = irq_rover; | ||
904 | |||
905 | raw_spin_unlock_irqrestore(&irq_rover_lock, flags); | ||
906 | } else { | ||
907 | cpuid = cpumask_first_and(mask, cpu_online_mask); | ||
908 | if (cpuid >= nr_cpu_ids) | ||
909 | goto do_round_robin; | ||
910 | } | ||
911 | |||
912 | return get_hard_smp_processor_id(cpuid); | ||
913 | } | ||
914 | #else | ||
915 | int irq_choose_cpu(const struct cpumask *mask) | ||
916 | { | ||
917 | return hard_smp_processor_id(); | ||
918 | } | ||
919 | #endif | ||
885 | 920 | ||
886 | unsigned int irq_radix_revmap_lookup(struct irq_host *host, | 921 | unsigned int irq_radix_revmap_lookup(struct irq_host *host, |
887 | irq_hw_number_t hwirq) | 922 | irq_hw_number_t hwirq) |
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c index 3f995dcf95c9..d3bc7e595d0b 100644 --- a/arch/powerpc/sysdev/mpic.c +++ b/arch/powerpc/sysdev/mpic.c | |||
@@ -597,42 +597,6 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic) | |||
597 | 597 | ||
598 | #endif /* CONFIG_MPIC_U3_HT_IRQS */ | 598 | #endif /* CONFIG_MPIC_U3_HT_IRQS */ |
599 | 599 | ||
600 | #ifdef CONFIG_SMP | ||
601 | static int irq_choose_cpu(const struct cpumask *mask) | ||
602 | { | ||
603 | int cpuid; | ||
604 | |||
605 | if (cpumask_equal(mask, cpu_all_mask)) { | ||
606 | static int irq_rover = 0; | ||
607 | static DEFINE_RAW_SPINLOCK(irq_rover_lock); | ||
608 | unsigned long flags; | ||
609 | |||
610 | /* Round-robin distribution... */ | ||
611 | do_round_robin: | ||
612 | raw_spin_lock_irqsave(&irq_rover_lock, flags); | ||
613 | |||
614 | irq_rover = cpumask_next(irq_rover, cpu_online_mask); | ||
615 | if (irq_rover >= nr_cpu_ids) | ||
616 | irq_rover = cpumask_first(cpu_online_mask); | ||
617 | |||
618 | cpuid = irq_rover; | ||
619 | |||
620 | raw_spin_unlock_irqrestore(&irq_rover_lock, flags); | ||
621 | } else { | ||
622 | cpuid = cpumask_first_and(mask, cpu_online_mask); | ||
623 | if (cpuid >= nr_cpu_ids) | ||
624 | goto do_round_robin; | ||
625 | } | ||
626 | |||
627 | return get_hard_smp_processor_id(cpuid); | ||
628 | } | ||
629 | #else | ||
630 | static int irq_choose_cpu(const struct cpumask *mask) | ||
631 | { | ||
632 | return hard_smp_processor_id(); | ||
633 | } | ||
634 | #endif | ||
635 | |||
636 | /* Find an mpic associated with a given linux interrupt */ | 600 | /* Find an mpic associated with a given linux interrupt */ |
637 | static struct mpic *mpic_find(unsigned int irq) | 601 | static struct mpic *mpic_find(unsigned int irq) |
638 | { | 602 | { |