Commit 38e1313f authored by Yang Li's avatar Yang Li Committed by Benjamin Herrenschmidt

powerpc/mpic: Fix problem that affinity is not updated

Since commit 57b150cc, desc->affinity
of an irq is changed after calling desc->chip->set_affinity.
Therefore we need to fix the irq_choose_cpu() not to depend on the
desc->affinity for new mask.
Signed-off-by: default avatarJiajun Wu <b06378@freescale.com>
Signed-off-by: default avatarLi Yang <leoli@freescale.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent a1128f8f
...@@ -567,13 +567,11 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic) ...@@ -567,13 +567,11 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic)
#endif /* CONFIG_MPIC_U3_HT_IRQS */ #endif /* CONFIG_MPIC_U3_HT_IRQS */
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
static int irq_choose_cpu(unsigned int virt_irq) static int irq_choose_cpu(const cpumask_t *mask)
{ {
cpumask_t mask;
int cpuid; int cpuid;
cpumask_copy(&mask, irq_to_desc(virt_irq)->affinity); if (cpumask_equal(mask, cpu_all_mask)) {
if (cpus_equal(mask, CPU_MASK_ALL)) {
static int irq_rover; static int irq_rover;
static DEFINE_SPINLOCK(irq_rover_lock); static DEFINE_SPINLOCK(irq_rover_lock);
unsigned long flags; unsigned long flags;
...@@ -594,20 +592,15 @@ static int irq_choose_cpu(unsigned int virt_irq) ...@@ -594,20 +592,15 @@ static int irq_choose_cpu(unsigned int virt_irq)
spin_unlock_irqrestore(&irq_rover_lock, flags); spin_unlock_irqrestore(&irq_rover_lock, flags);
} else { } else {
cpumask_t tmp; cpuid = cpumask_first_and(mask, cpu_online_mask);
if (cpuid >= nr_cpu_ids)
cpus_and(tmp, cpu_online_map, mask);
if (cpus_empty(tmp))
goto do_round_robin; goto do_round_robin;
cpuid = first_cpu(tmp);
} }
return get_hard_smp_processor_id(cpuid); return get_hard_smp_processor_id(cpuid);
} }
#else #else
static int irq_choose_cpu(unsigned int virt_irq) static int irq_choose_cpu(const cpumask_t *mask)
{ {
return hard_smp_processor_id(); return hard_smp_processor_id();
} }
...@@ -816,7 +809,7 @@ int mpic_set_affinity(unsigned int irq, const struct cpumask *cpumask) ...@@ -816,7 +809,7 @@ int mpic_set_affinity(unsigned int irq, const struct cpumask *cpumask)
unsigned int src = mpic_irq_to_hw(irq); unsigned int src = mpic_irq_to_hw(irq);
if (mpic->flags & MPIC_SINGLE_DEST_CPU) { if (mpic->flags & MPIC_SINGLE_DEST_CPU) {
int cpuid = irq_choose_cpu(irq); int cpuid = irq_choose_cpu(cpumask);
mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION), 1 << cpuid); mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION), 1 << cpuid);
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment