From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>,
Gregory CLEMENT <gregory.clement@free-electrons.com>,
Jason Cooper <jason@lakedaemon.net>
Subject: [patch 5/5] irqchip: armanda: Sanitize set_irq_affinity()
Date: Tue, 04 Mar 2014 20:43:41 -0000 [thread overview]
Message-ID: <20140304203101.088889302@linutronix.de> (raw)
In-Reply-To: 20140304202425.102779779@linutronix.de
[-- Attachment #1: irqchip-armanda-sanitize-irq-affinity-logic.patch --]
[-- Type: text/plain, Size: 2980 bytes --]
The set_irq_affinity() function has two issues:
1) It has no protection against selecting an offline cpu from the
given mask.
2) It pointlessly restricts the affinity masks to have a single cpu
set. This collides with the irq migration code of arm.
irq affinity is set to core 3
core 3 goes offline
migration code sets mask to cpu_online_mask and calls the
irq_set_affinity() callback of the irq_chip which fails due to bit
0,1,2 set.
So instead of doing silly for_each_cpu() loops just pick any bit of
the mask which intersects with the online mask.
The read back of the routing register is pointless as well. We can
simply write the new mask as the bits in this register reflect one
core.
Get rid of fiddling with the default_irq_affinity as well.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: Jason Cooper <jason@lakedaemon.net>
---
drivers/irqchip/irq-armada-370-xp.c | 38 ++++--------------------------------
1 file changed, 5 insertions(+), 33 deletions(-)
Index: tip/drivers/irqchip/irq-armada-370-xp.c
===================================================================
--- tip.orig/drivers/irqchip/irq-armada-370-xp.c
+++ tip/drivers/irqchip/irq-armada-370-xp.c
@@ -244,35 +244,16 @@ static DEFINE_RAW_SPINLOCK(irq_controlle
static int armada_xp_set_affinity(struct irq_data *d,
const struct cpumask *mask_val, bool force)
{
- unsigned long reg;
- unsigned long new_mask = 0;
- unsigned long online_mask = 0;
- unsigned long count = 0;
irq_hw_number_t hwirq = irqd_to_hwirq(d);
+ unsigned long mask;
int cpu;
- for_each_cpu(cpu, mask_val) {
- new_mask |= 1 << cpu_logical_map(cpu);
- count++;
- }
-
- /*
- * Forbid mutlicore interrupt affinity
- * This is required since the MPIC HW doesn't limit
- * several CPUs from acknowledging the same interrupt.
- */
- if (count > 1)
- return -EINVAL;
-
- for_each_cpu(cpu, cpu_online_mask)
- online_mask |= 1 << cpu_logical_map(cpu);
+ /* Select a single core from the affinity mask which is online */
+ cpu = cpumask_any_and(mask_val, cpu_online_mask);
+ mask = 1UL << cpu_logical_map(cpu);
raw_spin_lock(&irq_controller_lock);
-
- reg = readl(main_int_base + ARMADA_370_XP_INT_SOURCE_CTL(hwirq));
- reg = (reg & (~online_mask)) | new_mask;
- writel(reg, main_int_base + ARMADA_370_XP_INT_SOURCE_CTL(hwirq));
-
+ writel(mask, main_int_base + ARMADA_370_XP_INT_SOURCE_CTL(hwirq));
raw_spin_unlock(&irq_controller_lock);
return 0;
@@ -494,15 +475,6 @@ static int __init armada_370_xp_mpic_of_
#ifdef CONFIG_SMP
armada_xp_mpic_smp_cpu_init();
-
- /*
- * Set the default affinity from all CPUs to the boot cpu.
- * This is required since the MPIC doesn't limit several CPUs
- * from acknowledging the same interrupt.
- */
- cpumask_clear(irq_default_affinity);
- cpumask_set_cpu(smp_processor_id(), irq_default_affinity);
-
#endif
armada_370_xp_msi_init(node, main_int_res.start);
next prev parent reply other threads:[~2014-03-04 20:43 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-04 20:43 [patch 0/5] genirq: Sanitize irq_set_affinity callbacks Thomas Gleixner
2014-03-04 20:43 ` [patch 1/5] ia64: Validate online cpus in irq_set_affinity() callbacks Thomas Gleixner
2014-03-04 20:43 ` Thomas Gleixner
2014-03-12 12:15 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-12 12:15 ` tip-bot for Thomas Gleixner
2014-03-04 20:43 ` [patch 2/5] mips: " Thomas Gleixner
2014-03-05 11:20 ` Peter Zijlstra
2014-03-05 14:54 ` Thomas Gleixner
2014-03-12 12:15 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-04 20:43 ` [patch 4/5] xen: Validate online cpus in set_affinity Thomas Gleixner
2014-03-04 20:43 ` Thomas Gleixner
2014-03-05 10:36 ` David Vrabel
2014-03-05 10:36 ` David Vrabel
2014-03-12 12:15 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-12 12:15 ` tip-bot for Thomas Gleixner
2014-03-04 20:43 ` [patch 3/5] parisc: Validate online cpus in irq_set_affinity() callbacks Thomas Gleixner
2014-03-12 12:16 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-04 20:43 ` Thomas Gleixner [this message]
2014-03-06 19:05 ` [patch 5/5] irqchip: armanda: Sanitize set_irq_affinity() Jason Cooper
2014-03-07 16:02 ` Gregory CLEMENT
2014-03-07 17:17 ` Thomas Gleixner
2014-03-18 14:06 ` Gregory CLEMENT
2014-03-18 20:55 ` Thomas Gleixner
2014-03-18 21:04 ` Gregory CLEMENT
2014-04-24 16:04 ` Gregory CLEMENT
2014-04-25 11:15 ` Jason Cooper
2014-04-28 19:05 ` Thomas Gleixner
2014-04-28 19:33 ` [tip:irq/urgent] " tip-bot for Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140304203101.088889302@linutronix.de \
--to=tglx@linutronix.de \
--cc=gregory.clement@free-electrons.com \
--cc=jason@lakedaemon.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.