2014-07-08 13:25:55

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 00/15] arm/arm64: fix use of irq_find_mapping outside of legal RCU context

A number of irqchip drivers are directly calling irq_find_mapping,
which may use a rcu_read_lock call when walking the radix tree.

Turns out that if you hit that point with CONFIG_PROVE_RCU enabled,
the kernel will shout at you, as using RCU in this context may be
illegal (specially if coming from the idle state, where RCU would be
in a quiescent state).

A possible fix would be to wrap calls to irq_find_mapping into a
RCU_NONIDLE macro, but that really looks ugly.

This patch series introduce another IRQ entry point on arm and arm64
(handle_domain_irq), which has the exact same behaviour as handle_IRQ,
except that it also takes a irq_domain pointer. This allows the
logical IRQ lookup to be done inside the irq_{enter,exit} section,
which contains a rcu_irq_{enter,exit}, making it safe.

A number of irqchips are then converted to this new entry point. I've
converted all the direct users of irq_find_mapping, except for the
cases where it was used as a chained handler (chained_irq_{enter,exit}
makes it safe). Users of irq_linear_revmap are safe as well.

I've given it some light testing on arm64. The series is also
available in my tree:

git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git handle_domain_irq

Marc Zyngier (15):
arm64: pass IRQ domain to the core IRQ handler
ARM: pass IRQ domain to the core IRQ handler
irqchip: GIC: convert to handle_domain_irq
irqchip: armada-370-xp: convert to handle_domain_irq
irqchip: clps711x: convert to handle_domain_irq
irqchip: mmp: convert to handle_domain_irq
irqchip: mxs: convert to handle_domain_irq
irqchip: orion: convert to handle_domain_irq
irqchip: s3c24xx: convert to handle_domain_irq
irqchip: sirfsoc: convert to handle_domain_irq
irqchip: sun4i: convert to handle_domain_irq
irqchip: versatile-fpga: convert to handle_domain_irq
irqchip: vic: convert to handle_domain_irq
irqchip: vt8500: convert to handle_domain_irq
irqchip: zevio: convert to handle_domain_irq

arch/arm/include/asm/irq.h | 2 ++
arch/arm/kernel/irq.c | 23 +++++++++++++++++++----
arch/arm64/include/asm/hardirq.h | 4 ++++
arch/arm64/kernel/irq.c | 23 ++++++++++++++++++++---
drivers/irqchip/irq-armada-370-xp.c | 19 ++++++++++---------
drivers/irqchip/irq-clps711x.c | 18 +++++++-----------
drivers/irqchip/irq-gic.c | 3 +--
drivers/irqchip/irq-mmp.c | 10 ++++------
drivers/irqchip/irq-mxs.c | 3 +--
drivers/irqchip/irq-orion.c | 5 ++---
drivers/irqchip/irq-s3c24xx.c | 4 +---
drivers/irqchip/irq-sirfsoc.c | 6 ++----
drivers/irqchip/irq-sun4i.c | 5 ++---
drivers/irqchip/irq-versatile-fpga.c | 2 +-
drivers/irqchip/irq-vic.c | 2 +-
drivers/irqchip/irq-vt8500.c | 5 ++---
drivers/irqchip/irq-zevio.c | 3 +--
17 files changed, 80 insertions(+), 57 deletions(-)

--
2.0.0


2014-07-08 13:21:15

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 11/15] irqchip: sun4i: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-sun4i.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-sun4i.c b/drivers/irqchip/irq-sun4i.c
index 6fcef4a..64155b6 100644
--- a/drivers/irqchip/irq-sun4i.c
+++ b/drivers/irqchip/irq-sun4i.c
@@ -136,7 +136,7 @@ IRQCHIP_DECLARE(allwinner_sun4i_ic, "allwinner,sun4i-a10-ic", sun4i_of_init);

static void __exception_irq_entry sun4i_handle_irq(struct pt_regs *regs)
{
- u32 irq, hwirq;
+ u32 hwirq;

/*
* hwirq == 0 can mean one of 3 things:
@@ -154,8 +154,7 @@ static void __exception_irq_entry sun4i_handle_irq(struct pt_regs *regs)
return;

do {
- irq = irq_find_mapping(sun4i_irq_domain, hwirq);
- handle_IRQ(irq, regs);
+ handle_domain_irq(sun4i_irq_domain, hwirq, regs);
hwirq = readl(sun4i_irq_base + SUN4I_IRQ_VECTOR_REG) >> 2;
} while (hwirq != 0);
}
--
2.0.0

2014-07-08 13:21:21

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 15/15] irqchip: zevio: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-zevio.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-zevio.c b/drivers/irqchip/irq-zevio.c
index ceb3a43..1b7c67d 100644
--- a/drivers/irqchip/irq-zevio.c
+++ b/drivers/irqchip/irq-zevio.c
@@ -56,8 +56,7 @@ static void __exception_irq_entry zevio_handle_irq(struct pt_regs *regs)

while (readl(zevio_irq_io + IO_STATUS)) {
irqnr = readl(zevio_irq_io + IO_CURRENT);
- irqnr = irq_find_mapping(zevio_irq_domain, irqnr);
- handle_IRQ(irqnr, regs);
+ handle_domain_IRQ(zevio_irq_domain, irqnr, regs);
};
}

--
2.0.0

2014-07-08 13:25:19

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 06/15] irqchip: mmp: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-mmp.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/irqchip/irq-mmp.c b/drivers/irqchip/irq-mmp.c
index 1c3e2c9..c0da57b 100644
--- a/drivers/irqchip/irq-mmp.c
+++ b/drivers/irqchip/irq-mmp.c
@@ -196,26 +196,24 @@ static struct mmp_intc_conf mmp2_conf = {

static void __exception_irq_entry mmp_handle_irq(struct pt_regs *regs)
{
- int irq, hwirq;
+ int hwirq;

hwirq = readl_relaxed(mmp_icu_base + PJ1_INT_SEL);
if (!(hwirq & SEL_INT_PENDING))
return;
hwirq &= SEL_INT_NUM_MASK;
- irq = irq_find_mapping(icu_data[0].domain, hwirq);
- handle_IRQ(irq, regs);
+ handle_domain_irq(icu_data[0].domain, hwirq, regs);
}

static void __exception_irq_entry mmp2_handle_irq(struct pt_regs *regs)
{
- int irq, hwirq;
+ int hwirq;

hwirq = readl_relaxed(mmp_icu_base + PJ4_INT_SEL);
if (!(hwirq & SEL_INT_PENDING))
return;
hwirq &= SEL_INT_NUM_MASK;
- irq = irq_find_mapping(icu_data[0].domain, hwirq);
- handle_IRQ(irq, regs);
+ handle_domain_irq(icu_data[0].domain, hwirq, regs);
}

/* MMP (ARMv5) */
--
2.0.0

2014-07-08 13:25:29

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 13/15] irqchip: vic: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-vic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-vic.c b/drivers/irqchip/irq-vic.c
index 7d35287..54089de 100644
--- a/drivers/irqchip/irq-vic.c
+++ b/drivers/irqchip/irq-vic.c
@@ -219,7 +219,7 @@ static int handle_one_vic(struct vic_device *vic, struct pt_regs *regs)

while ((stat = readl_relaxed(vic->base + VIC_IRQ_STATUS))) {
irq = ffs(stat) - 1;
- handle_IRQ(irq_find_mapping(vic->domain, irq), regs);
+ handle_domain_irq(vic->domain, irq, regs);
handled = 1;
}

--
2.0.0

2014-07-08 13:25:32

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 09/15] irqchip: s3c24xx: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-s3c24xx.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c
index 78a6acc..c8d373f 100644
--- a/drivers/irqchip/irq-s3c24xx.c
+++ b/drivers/irqchip/irq-s3c24xx.c
@@ -339,7 +339,6 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc,
{
int pnd;
int offset;
- int irq;

pnd = __raw_readl(intc->reg_intpnd);
if (!pnd)
@@ -365,8 +364,7 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc,
if (!(pnd & (1 << offset)))
offset = __ffs(pnd);

- irq = irq_find_mapping(intc->domain, intc_offset + offset);
- handle_IRQ(irq, regs);
+ handle_domain_irq(intc->domain, intc_offset + offset, regs);
return true;
}

--
2.0.0

2014-07-08 13:25:38

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 02/15] ARM: pass IRQ domain to the core IRQ handler

Calling irq_find_mapping from outside a irq_{enter,exit} section is
unsafe and produces ugly messages if CONFIG_PROVE_RCU is enabled:
If coming from the idle state, the rcu_read_lock call in irq_find_mapping
will generate an an unpleasant warning.

A solution is to add a new handle_domain_irq entry point into
the arm code that the interrupt controller code can call.
This new function takes an irq_domain, and calls into irq_find_domain
inside the irq_{enter,exit} block.

Interrupt controllers can then be updated to use the new mechanism.

Signed-off-by: Marc Zyngier <[email protected]>
---
arch/arm/include/asm/irq.h | 2 ++
arch/arm/kernel/irq.c | 23 +++++++++++++++++++----
2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/arch/arm/include/asm/irq.h b/arch/arm/include/asm/irq.h
index 53c15de..8578811 100644
--- a/arch/arm/include/asm/irq.h
+++ b/arch/arm/include/asm/irq.h
@@ -24,10 +24,12 @@
#ifndef __ASSEMBLY__
struct irqaction;
struct pt_regs;
+struct irq_domain;
extern void migrate_irqs(void);

extern void asm_do_IRQ(unsigned int, struct pt_regs *);
void handle_IRQ(unsigned int, struct pt_regs *);
+void handle_domain_irq(struct irq_domain *, unsigned int, struct pt_regs *);
void init_IRQ(void);

#ifdef CONFIG_MULTI_IRQ_HANDLER
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index 2c42576..d6af69f5 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -62,20 +62,30 @@ int arch_show_interrupts(struct seq_file *p, int prec)
* not come via this function. Instead, they should provide their
* own 'handler'. Used by platform code implementing C-based 1st
* level decoding.
+ *
+ * handle_domain_irq does the same thing, but also converts the HW
+ * interrupt number into a logical one using the provided domain. A
+ * NULL domain indicates that this conversion has already been done.
*/
-void handle_IRQ(unsigned int irq, struct pt_regs *regs)
+void handle_domain_irq(struct irq_domain *domain,
+ unsigned int hwirq, struct pt_regs *regs)
{
struct pt_regs *old_regs = set_irq_regs(regs);
+ unsigned int irq;

irq_enter();

+ if (domain)
+ irq = irq_find_mapping(domain, hwirq);
+ else
+ irq = hwirq;
+
/*
* Some hardware gives randomly wrong interrupts. Rather
* than crashing, do something sensible.
*/
- if (unlikely(irq >= nr_irqs)) {
- if (printk_ratelimit())
- printk(KERN_WARNING "Bad IRQ%u\n", irq);
+ if (unlikely(!irq || irq >= nr_irqs)) {
+ pr_warn_ratelimited("Bad IRQ%u (%u)\n", irq, hwirq);
ack_bad_irq(irq);
} else {
generic_handle_irq(irq);
@@ -85,6 +95,11 @@ void handle_IRQ(unsigned int irq, struct pt_regs *regs)
set_irq_regs(old_regs);
}

+void handle_IRQ(unsigned int irq, struct pt_regs *regs)
+{
+ handle_domain_irq(NULL, irq, regs);
+}
+
/*
* asm_do_IRQ is the interface to be used from assembly code.
*/
--
2.0.0

2014-07-08 13:25:43

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 10/15] irqchip: sirfsoc: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-sirfsoc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-sirfsoc.c b/drivers/irqchip/irq-sirfsoc.c
index 5e54f6d..a469355 100644
--- a/drivers/irqchip/irq-sirfsoc.c
+++ b/drivers/irqchip/irq-sirfsoc.c
@@ -50,12 +50,10 @@ sirfsoc_alloc_gc(void __iomem *base, unsigned int irq_start, unsigned int num)
static void __exception_irq_entry sirfsoc_handle_irq(struct pt_regs *regs)
{
void __iomem *base = sirfsoc_irqdomain->host_data;
- u32 irqstat, irqnr;
+ u32 irqstat;

irqstat = readl_relaxed(base + SIRFSOC_INIT_IRQ_ID);
- irqnr = irq_find_mapping(sirfsoc_irqdomain, irqstat & 0xff);
-
- handle_IRQ(irqnr, regs);
+ handle_domain_irq(sirfsoc_irqdomain, irqstat & 0xff, regs);
}

static int __init sirfsoc_irq_init(struct device_node *np,
--
2.0.0

2014-07-08 13:25:49

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 01/15] arm64: pass IRQ domain to the core IRQ handler

Calling irq_find_mapping from outside a irq_{enter,exit} section is
unsafe and produces ugly messages if CONFIG_PROVE_RCU is enabled:
If coming from the idle state, the rcu_read_lock call in irq_find_mapping
will generate an an unpleasant warning:

<quote>
===============================
[ INFO: suspicious RCU usage. ]
3.16.0-rc1+ #135 Not tainted
-------------------------------
include/linux/rcupdate.h:871 rcu_read_lock() used illegally while idle!

other info that might help us debug this:

RCU used illegally from idle CPU!
rcu_scheduler_active = 1, debug_locks = 0
RCU used illegally from extended quiescent state!
1 lock held by swapper/0/0:
#0: (rcu_read_lock){......}, at: [<ffffffc00010206c>]
irq_find_mapping+0x4c/0x198
</quote>

A solution is to add a new handle_domain_irq entry point into
the arm64 code that the interrupt controller code can call.
This new function takes an irq_domain, and calls into irq_find_domain
inside the irq_{enter,exit} block.

Interrupt controllers can then be updated to use the new mechanism.

Reported-by: Vladimir Murzin <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
---
arch/arm64/include/asm/hardirq.h | 4 ++++
arch/arm64/kernel/irq.c | 23 ++++++++++++++++++++---
2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/include/asm/hardirq.h b/arch/arm64/include/asm/hardirq.h
index 0be6782..fb3e318 100644
--- a/arch/arm64/include/asm/hardirq.h
+++ b/arch/arm64/include/asm/hardirq.h
@@ -49,6 +49,10 @@ static inline void ack_bad_irq(unsigned int irq)

extern void handle_IRQ(unsigned int, struct pt_regs *);

+struct irq_domain;
+extern void handle_domain_irq(struct irq_domain *,
+ unsigned int, struct pt_regs *);
+
/*
* No arch-specific IRQ flags.
*/
diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
index 0f08dfd..cb487ad 100644
--- a/arch/arm64/kernel/irq.c
+++ b/arch/arm64/kernel/irq.c
@@ -23,6 +23,7 @@

#include <linux/kernel_stat.h>
#include <linux/irq.h>
+#include <linux/irqdomain.h>
#include <linux/smp.h>
#include <linux/init.h>
#include <linux/irqchip.h>
@@ -45,19 +46,30 @@ int arch_show_interrupts(struct seq_file *p, int prec)
* not come via this function. Instead, they should provide their
* own 'handler'. Used by platform code implementing C-based 1st
* level decoding.
+ *
+ * handle_domain_irq does the same thing, but also converts the HW
+ * interrupt number into a logical one using the provided domain. A
+ * NULL domain indicates that this conversion has already been done.
*/
-void handle_IRQ(unsigned int irq, struct pt_regs *regs)
+void handle_domain_irq(struct irq_domain *domain,
+ unsigned int hwirq, struct pt_regs *regs)
{
struct pt_regs *old_regs = set_irq_regs(regs);
+ unsigned int irq;

irq_enter();

+ if (domain)
+ irq = irq_find_mapping(domain, hwirq);
+ else
+ irq = hwirq;
+
/*
* Some hardware gives randomly wrong interrupts. Rather
* than crashing, do something sensible.
*/
- if (unlikely(irq >= nr_irqs)) {
- pr_warn_ratelimited("Bad IRQ%u\n", irq);
+ if (unlikely(!irq || irq >= nr_irqs)) {
+ pr_warn_ratelimited("Bad IRQ%u (%u)\n", irq, hwirq);
ack_bad_irq(irq);
} else {
generic_handle_irq(irq);
@@ -67,6 +79,11 @@ void handle_IRQ(unsigned int irq, struct pt_regs *regs)
set_irq_regs(old_regs);
}

+void handle_IRQ(unsigned int irq, struct pt_regs *regs)
+{
+ handle_domain_irq(NULL, irq, regs);
+}
+
void __init set_handle_irq(void (*handle_irq)(struct pt_regs *))
{
if (handle_arch_irq)
--
2.0.0

2014-07-08 13:25:52

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 07/15] irqchip: mxs: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-mxs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-mxs.c b/drivers/irqchip/irq-mxs.c
index 4044ff2..e4acf1e 100644
--- a/drivers/irqchip/irq-mxs.c
+++ b/drivers/irqchip/irq-mxs.c
@@ -78,8 +78,7 @@ asmlinkage void __exception_irq_entry icoll_handle_irq(struct pt_regs *regs)

irqnr = __raw_readl(icoll_base + HW_ICOLL_STAT_OFFSET);
__raw_writel(irqnr, icoll_base + HW_ICOLL_VECTOR);
- irqnr = irq_find_mapping(icoll_domain, irqnr);
- handle_IRQ(irqnr, regs);
+ handle_domain_irq(icoll_domain, irqnr, regs);
}

static int icoll_irq_domain_map(struct irq_domain *d, unsigned int virq,
--
2.0.0

2014-07-08 13:26:03

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 12/15] irqchip: versatile-fpga: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-versatile-fpga.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-versatile-fpga.c b/drivers/irqchip/irq-versatile-fpga.c
index 3ae2bb8..73085b7 100644
--- a/drivers/irqchip/irq-versatile-fpga.c
+++ b/drivers/irqchip/irq-versatile-fpga.c
@@ -92,7 +92,7 @@ static int handle_one_fpga(struct fpga_irq_data *f, struct pt_regs *regs)

while ((status = readl(f->base + IRQ_STATUS))) {
irq = ffs(status) - 1;
- handle_IRQ(irq_find_mapping(f->domain, irq), regs);
+ handle_domain_irq(f->domain, irq, regs);
handled = 1;
}

--
2.0.0

2014-07-08 13:26:09

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 08/15] irqchip: orion: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-orion.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-orion.c b/drivers/irqchip/irq-orion.c
index 34d18b4..ad0c0f6 100644
--- a/drivers/irqchip/irq-orion.c
+++ b/drivers/irqchip/irq-orion.c
@@ -43,9 +43,8 @@ __exception_irq_entry orion_handle_irq(struct pt_regs *regs)
gc->mask_cache;
while (stat) {
u32 hwirq = __fls(stat);
- u32 irq = irq_find_mapping(orion_irq_domain,
- gc->irq_base + hwirq);
- handle_IRQ(irq, regs);
+ handle_domain_irq(orion_irq_domain,
+ gc->irq_base + hwirq, regs);
stat &= ~(1 << hwirq);
}
}
--
2.0.0

2014-07-08 13:27:07

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 04/15] irqchip: armada-370-xp: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-armada-370-xp.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index 574aba0..47144be 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -393,13 +393,15 @@ static void armada_370_xp_handle_msi_irq(struct pt_regs *regs, bool is_chained)
if (!(msimask & BIT(msinr)))
continue;

- irq = irq_find_mapping(armada_370_xp_msi_domain,
- msinr - 16);
-
- if (is_chained)
+ if (is_chained) {
+ irq = irq_find_mapping(armada_370_xp_msi_domain,
+ msinr - 16);
generic_handle_irq(irq);
- else
- handle_IRQ(irq, regs);
+ } else {
+ irq = msi - 16;
+ handle_domain_irq(armada_370_xp_msi_domain,
+ irq, regs);
+ }
}
}
#else
@@ -444,9 +446,8 @@ armada_370_xp_handle_irq(struct pt_regs *regs)
break;

if (irqnr > 1) {
- irqnr = irq_find_mapping(armada_370_xp_mpic_domain,
- irqnr);
- handle_IRQ(irqnr, regs);
+ handle_domain_irq(armada_370_xp_mpic_domain,
+ irqnr, regs);
continue;
}

--
2.0.0

2014-07-08 13:28:16

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 14/15] irqchip: vt8500: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-vt8500.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-vt8500.c b/drivers/irqchip/irq-vt8500.c
index eb6e91e..b7af816 100644
--- a/drivers/irqchip/irq-vt8500.c
+++ b/drivers/irqchip/irq-vt8500.c
@@ -181,7 +181,7 @@ static struct irq_domain_ops vt8500_irq_domain_ops = {
static void __exception_irq_entry vt8500_handle_irq(struct pt_regs *regs)
{
u32 stat, i;
- int irqnr, virq;
+ int irqnr;
void __iomem *base;

/* Loop through each active controller */
@@ -198,8 +198,7 @@ static void __exception_irq_entry vt8500_handle_irq(struct pt_regs *regs)
continue;
}

- virq = irq_find_mapping(intc[i].domain, irqnr);
- handle_IRQ(virq, regs);
+ handle_domain_irq(intc[i].domain, irqnr, regs);
}
}

--
2.0.0

2014-07-08 13:25:17

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 03/15] irqchip: GIC: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-gic.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 7e11c9d..f1f09a7 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -294,8 +294,7 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)
irqnr = irqstat & GICC_IAR_INT_ID_MASK;

if (likely(irqnr > 15 && irqnr < 1021)) {
- irqnr = irq_find_mapping(gic->domain, irqnr);
- handle_IRQ(irqnr, regs);
+ handle_domain_irq(gic->domain, irqnr, regs);
continue;
}
if (irqnr < 16) {
--
2.0.0

2014-07-08 13:29:05

by Marc Zyngier

[permalink] [raw]
Subject: [PATCH 05/15] irqchip: clps711x: convert to handle_domain_irq

Use the new handle_domain_irq method to handle interrupts.

Signed-off-by: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-clps711x.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/irqchip/irq-clps711x.c b/drivers/irqchip/irq-clps711x.c
index 33340dc..33127f1 100644
--- a/drivers/irqchip/irq-clps711x.c
+++ b/drivers/irqchip/irq-clps711x.c
@@ -76,24 +76,20 @@ static struct {

static asmlinkage void __exception_irq_entry clps711x_irqh(struct pt_regs *regs)
{
- u32 irqnr, irqstat;
+ u32 irqstat;

do {
irqstat = readw_relaxed(clps711x_intc->intmr[0]) &
readw_relaxed(clps711x_intc->intsr[0]);
- if (irqstat) {
- irqnr = irq_find_mapping(clps711x_intc->domain,
- fls(irqstat) - 1);
- handle_IRQ(irqnr, regs);
- }
+ if (irqstat)
+ handle_domain_irq(clps711x_intc->domain,
+ fls(irqstat) - 1, regs);

irqstat = readw_relaxed(clps711x_intc->intmr[1]) &
readw_relaxed(clps711x_intc->intsr[1]);
- if (irqstat) {
- irqnr = irq_find_mapping(clps711x_intc->domain,
- fls(irqstat) - 1 + 16);
- handle_IRQ(irqnr, regs);
- }
+ if (irqstat)
+ handle_domain_irq(clps711x_intc->domain,
+ fls(irqstat) - 1 + 16, regs);
} while (irqstat);
}

--
2.0.0

2014-07-11 20:38:44

by Christopher Covington

[permalink] [raw]
Subject: Re: [PATCH 00/15] arm/arm64: fix use of irq_find_mapping outside of legal RCU context

Hi Mark,

On 07/08/2014 09:10 AM, Marc Zyngier wrote:
> A number of irqchip drivers are directly calling irq_find_mapping,
> which may use a rcu_read_lock call when walking the radix tree.

If this happens to be easy for you to determine: do direct callers of
irq_find_host such as irq_create_of_mapping have a similar problem with
irq_domain_mutex?

Thanks,
Christopher

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by the Linux Foundation.

2014-07-15 09:18:17

by Antoine Tenart

[permalink] [raw]
Subject: Re: [PATCH 11/15] irqchip: sun4i: convert to handle_domain_irq

Hi Marc,

On Tue, Jul 08, 2014 at 02:10:34PM +0100, Marc Zyngier wrote:
> Use the new handle_domain_irq method to handle interrupts.
>
> Signed-off-by: Marc Zyngier <[email protected]>

I tested this one on an A13 olinuxino. It worked well. I also tested
with CONFIG_PROVE_RCU enabled.

Antoine

> ---
> drivers/irqchip/irq-sun4i.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/irqchip/irq-sun4i.c b/drivers/irqchip/irq-sun4i.c
> index 6fcef4a..64155b6 100644
> --- a/drivers/irqchip/irq-sun4i.c
> +++ b/drivers/irqchip/irq-sun4i.c
> @@ -136,7 +136,7 @@ IRQCHIP_DECLARE(allwinner_sun4i_ic, "allwinner,sun4i-a10-ic", sun4i_of_init);
>
> static void __exception_irq_entry sun4i_handle_irq(struct pt_regs *regs)
> {
> - u32 irq, hwirq;
> + u32 hwirq;
>
> /*
> * hwirq == 0 can mean one of 3 things:
> @@ -154,8 +154,7 @@ static void __exception_irq_entry sun4i_handle_irq(struct pt_regs *regs)
> return;
>
> do {
> - irq = irq_find_mapping(sun4i_irq_domain, hwirq);
> - handle_IRQ(irq, regs);
> + handle_domain_irq(sun4i_irq_domain, hwirq, regs);
> hwirq = readl(sun4i_irq_base + SUN4I_IRQ_VECTOR_REG) >> 2;
> } while (hwirq != 0);
> }
> --
> 2.0.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

--
Antoine T?nart, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

2014-07-29 14:28:36

by Marc Zyngier

[permalink] [raw]
Subject: Re: [PATCH 00/15] arm/arm64: fix use of irq_find_mapping outside of legal RCU context

On Fri, Jul 11 2014 at 9:38:22 pm BST, Christopher Covington <[email protected]> wrote:
> Hi Mark,
>
> On 07/08/2014 09:10 AM, Marc Zyngier wrote:
>> A number of irqchip drivers are directly calling irq_find_mapping,
>> which may use a rcu_read_lock call when walking the radix tree.
>
> If this happens to be easy for you to determine: do direct callers of
> irq_find_host such as irq_create_of_mapping have a similar problem with
> irq_domain_mutex?

Definitely not from this problem. irq_find_host doesn't use RCU at all,
so it shouldn't be an issue.

Thanks,

M.
--
Jazz is not dead. It just smells funny.