Skip to contentSkip to conversation

irqchip: xilinx: Switch to generic domain handler

PATCH Superseded Michal Simek 2 participants 8 messages Feb 12, 2020 – Feb 21, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover irqchip: xilinx: Switch to generic domain handler

Hi,

this series is based on cascade mode patch sent by Mubin
(https://lkml.org/lkml/2020/2/11/888 - v3 series).

The first patch is just fixing error patch. The second and the third are converting microblaze do_IRQ() to generic IRQ handler with appropriate changes in xilinx intc driver. I have done it in two steps to be visible how it was done.

The last patch removes concurrent_irq global variable which wasn't wired anywhere but it stores number of concurrent IRQs handled by one call. There is option to get it back if needed but I haven't seen it in other archs that's why I have removed it too.

Thanks,
Michal

Michal Simek (3):
irqchip: xilinx: Fill error code when irq domain registration fails
irqchip: xilinx: Enable generic irq multi handler
irqchip: xilinx: Use handle_domain_irq()

 arch/microblaze/Kconfig           |  2 ++
 arch/microblaze/include/asm/irq.h |  3 ---
 arch/microblaze/kernel/irq.c      | 21 +------------------
 drivers/irqchip/irq-xilinx-intc.c | 35 ++++++++++++++++++-------------
 4 files changed, 24 insertions(+), 37 deletions(-)
Signature · 1 line
2.25.0
#1 lore raw

PATCH 1/3 irqchip: xilinx: Fill error code when irq domain registration fails

There is no ret filled in case of irq_domain_add_linear() failure.

---

 drivers/irqchip/irq-xilinx-intc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/irqchip/irq-xilinx-intc.c +1 -0
index 51f461d2934f..cf1bb470d7b5 100644
@@ -230,6 +230,7 @@ static int __init xilinx_intc_of_init(struct device_node *intc,
 						  &xintc_irq_domain_ops, irqc);
 	if (!irqc->root_domain) {
 		pr_err("irq-xilinx: Unable to create IRQ domain\n");
+		ret = -EINVAL;
 		goto error;
 	}
 
Signature · 7 lines
2.25.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#2 lore raw

PATCH 2/3 irqchip: xilinx: Enable generic irq multi handler

In reply to Michal Simek

Register default arch handler via driver instead of directly pointing to xilinx intc controller. This patch makes architecture code more generic.

---

 arch/microblaze/Kconfig           |  1 +
 arch/microblaze/include/asm/irq.h |  3 ---
 arch/microblaze/kernel/irq.c      | 16 +---------------
 drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++-
 4 files changed, 23 insertions(+), 19 deletions(-)
arch/microblaze/Kconfig +1 -0
index 6a331bd57ea8..3a314aa2efa1 100644
@@ -47,6 +47,7 @@ config MICROBLAZE
 	select CPU_NO_EFFICIENT_FFS
 	select MMU_GATHER_NO_RANGE if MMU
 	select SPARSE_IRQ
+	select GENERIC_IRQ_MULTI_HANDLER
 
 # Endianness selection
 choice
arch/microblaze/include/asm/irq.h +0 -3
index eac2fb4b3fb9..5166f0893e2b 100644
@@ -14,7 +14,4 @@
 struct pt_regs;
 extern void do_IRQ(struct pt_regs *regs);
 
-/* should be defined in each interrupt controller driver */
-extern unsigned int xintc_get_irq(void);
-
 #endif /* _ASM_MICROBLAZE_IRQ_H */
arch/microblaze/kernel/irq.c +1 -15
index 903dad822fad..1f8cb4c4f74f 100644
@@ -20,27 +20,13 @@
 #include <linux/irqchip.h>
 #include <linux/of_irq.h>
 
-static u32 concurrent_irq;
-
 void __irq_entry do_IRQ(struct pt_regs *regs)
 {
-	unsigned int irq;
 	struct pt_regs *old_regs = set_irq_regs(regs);
 	trace_hardirqs_off();
 
 	irq_enter();
-	irq = xintc_get_irq();
-next_irq:
-	BUG_ON(!irq);
-	generic_handle_irq(irq);
-
-	irq = xintc_get_irq();
-	if (irq != -1U) {
-		pr_debug("next irq: %d\n", irq);
-		++concurrent_irq;
-		goto next_irq;
-	}
-
+	handle_arch_irq(regs);
 	irq_exit();
 	set_irq_regs(old_regs);
 	trace_hardirqs_on();
drivers/irqchip/irq-xilinx-intc.c +21 -1
index cf1bb470d7b5..ad9e678c24ac 100644
@@ -125,7 +125,7 @@ static unsigned int xintc_get_irq_local(struct xintc_irq_chip *irqc)
 	return irq;
 }
 
-unsigned int xintc_get_irq(void)
+static unsigned int xintc_get_irq(void)
 {
 	u32 hwirq;
 	unsigned int irq = -1;
@@ -178,6 +178,25 @@ static void xil_intc_irq_handler(struct irq_desc *desc)
 	chained_irq_exit(chip, desc);
 }
 
+static u32 concurrent_irq;
+
+static void xil_intc_handle_irq(struct pt_regs *regs)
+{
+	unsigned int irq;
+
+	irq = xintc_get_irq();
+next_irq:
+	BUG_ON(!irq);
+	generic_handle_irq(irq);
+
+	irq = xintc_get_irq();
+	if (irq != -1U) {
+		pr_debug("next irq: %d\n", irq);
+		++concurrent_irq;
+		goto next_irq;
+	}
+}
+
 static int __init xilinx_intc_of_init(struct device_node *intc,
 					     struct device_node *parent)
 {
@@ -248,6 +267,7 @@ static int __init xilinx_intc_of_init(struct device_node *intc,
 	} else {
 		primary_intc = irqc;
 		irq_set_default_host(primary_intc->root_domain);
+		set_handle_irq(xil_intc_handle_irq);
 	}
 
 	return 0;
Signature · 1 line
2.25.0
#3 lore raw

Re: [PATCH 2/3] irqchip: xilinx: Enable generic irq multi handler

Michal,

Quoted 60 lines · Michal Simek

Register default arch handler via driver instead of directly pointing to xilinx intc controller. This patch makes architecture code more generic.

---

 arch/microblaze/Kconfig           |  1 +
 arch/microblaze/include/asm/irq.h |  3 ---
 arch/microblaze/kernel/irq.c      | 16 +---------------
 drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++-
 4 files changed, 23 insertions(+), 19 deletions(-)
arch/microblaze/Kconfig +1 -0
index 6a331bd57ea8..3a314aa2efa1 100644
@@ -47,6 +47,7 @@ config MICROBLAZE
 	select CPU_NO_EFFICIENT_FFS
 	select MMU_GATHER_NO_RANGE if MMU
 	select SPARSE_IRQ
+	select GENERIC_IRQ_MULTI_HANDLER
 
 # Endianness selection
 choice
arch/microblaze/include/asm/irq.h +0 -3
index eac2fb4b3fb9..5166f0893e2b 100644
@@ -14,7 +14,4 @@
 struct pt_regs;
 extern void do_IRQ(struct pt_regs *regs);
 
-/* should be defined in each interrupt controller driver */
-extern unsigned int xintc_get_irq(void);
-
 #endif /* _ASM_MICROBLAZE_IRQ_H */
arch/microblaze/kernel/irq.c +0 -8
index 903dad822fad..1f8cb4c4f74f 100644
@@ -20,27 +20,13 @@
 #include <linux/irqchip.h>
 #include <linux/of_irq.h>
 
-static u32 concurrent_irq;
-
 void __irq_entry do_IRQ(struct pt_regs *regs)
 {
-	unsigned int irq;
 	struct pt_regs *old_regs = set_irq_regs(regs);
 	trace_hardirqs_off();
 
 	irq_enter();
-	irq = xintc_get_irq();
-next_irq:
-	BUG_ON(!irq);
-	generic_handle_irq(irq);
-

arch/microblaze/kernel/irq.c line 31

Quoted 10 lines
arch/microblaze/kernel/irq.c +1 -7
-	irq = xintc_get_irq();
-	if (irq != -1U) {
-		pr_debug("next irq: %d\n", irq);
-		++concurrent_irq;
-		goto next_irq;
-	}
-
+	handle_arch_irq(regs);
 	irq_exit();
 	set_irq_regs(old_regs);

If you're going to embrace common code, maybe you should do it fully, see below.

Quoted 20 lines
arch/microblaze/kernel/irq.c +0 -0
 	trace_hardirqs_on();
drivers/irqchip/irq-xilinx-intc.c +1 -1
index cf1bb470d7b5..ad9e678c24ac 100644
@@ -125,7 +125,7 @@ static unsigned int xintc_get_irq_local(struct
 xintc_irq_chip *irqc)
 	return irq;
 }
 
-unsigned int xintc_get_irq(void)
+static unsigned int xintc_get_irq(void)
 {
 	u32 hwirq;
drivers/irqchip/irq-xilinx-intc.c +0 -0
 	unsigned int irq = -1;
@@ -178,6 +178,25 @@ static void xil_intc_irq_handler(struct irq_desc 
 *desc)
 	chained_irq_exit(chip, desc);
 }

drivers/irqchip/irq-xilinx-intc.c static void xil_intc_irq_handler(struct irq_desc · line 190

Quoted 10 lines
drivers/irqchip/irq-xilinx-intc.c +9 -0
 
+static u32 concurrent_irq;
+
+static void xil_intc_handle_irq(struct pt_regs *regs)
+{
+	unsigned int irq;
+
+	irq = xintc_get_irq();
+next_irq:
+	BUG_ON(!irq);

Don't BUG_ON() for something that is probably a spurious interrupt. Handle it gracefully instead.

drivers/irqchip/irq-xilinx-intc.c static void xil_intc_irq_handler(struct irq_desc *desc) · line 194

Quoted 5 lines
drivers/irqchip/irq-xilinx-intc.c +5 -0
+	generic_handle_irq(irq);
+
+	irq = xintc_get_irq();
+	if (irq != -1U) {
+		pr_debug("next irq: %d\n", irq);

You already have debug information in xintc_get_irq(). Do you need more?

drivers/irqchip/irq-xilinx-intc.c static void xil_intc_irq_handler(struct irq_desc *desc) · line 195

Quoted 1 line
drivers/irqchip/irq-xilinx-intc.c +1 -0
+		++concurrent_irq;

What is the purpose of this "concurrent_irq"? It's not concurrent at all (it is actually broken in an SMP context), and nothing reads it.

drivers/irqchip/irq-xilinx-intc.c static void xil_intc_irq_handler(struct irq_desc · line 198

Quoted 2 lines
drivers/irqchip/irq-xilinx-intc.c +2 -0
+		goto next_irq;
+	}

Overall, this could be written in a much more elegant way:

        irq_hw_number_t hwirq;
        do {
                hwirq = xintc_read(IVR);
                if (likely(irq != -1UL))
                        handle_domain_irq(xintc_irqc->root_domain,
                                          hwirq, regs);
        } while (hwirq != -1UL);

and you can get rid of most of do_IRQ() (all the set_irq_regs, irq_enter logic is taken care of) as well as xintc_get_irq().

Quoted 13 lines
drivers/irqchip/irq-xilinx-intc.c +2 -0
+}
+
 static int __init xilinx_intc_of_init(struct device_node *intc,
 					     struct device_node *parent)

{

drivers/irqchip/irq-xilinx-intc.c +1 -0
@@ -248,6 +267,7 @@ static int __init xilinx_intc_of_init(struct
 device_node *intc,
 	} else {
 		primary_intc = irqc;
 		irq_set_default_host(primary_intc->root_domain);
+		set_handle_irq(xil_intc_handle_irq);
 	}
 
Quoted 1 line

return 0;

Thanks,

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#4 lore raw

PATCH 3/3 irqchip: xilinx: Use handle_domain_irq()

In reply to Michal Simek

Call generic domain specific irq handler which does the most of things self. Also get rid of concurrent_irq counting which hasn't been exported anywhere.
Based on this loop was also optimized by using do/while loop instead of goto loop.

---

 arch/microblaze/Kconfig           |  1 +
 arch/microblaze/kernel/irq.c      |  5 ----
 drivers/irqchip/irq-xilinx-intc.c | 44 +++++++++++--------------------
 3 files changed, 16 insertions(+), 34 deletions(-)
arch/microblaze/Kconfig +1 -0
index 3a314aa2efa1..242f58ec086b 100644
@@ -48,6 +48,7 @@ config MICROBLAZE
 	select MMU_GATHER_NO_RANGE if MMU
 	select SPARSE_IRQ
 	select GENERIC_IRQ_MULTI_HANDLER
+	select HANDLE_DOMAIN_IRQ
 
 # Endianness selection
 choice
arch/microblaze/kernel/irq.c +0 -5
index 1f8cb4c4f74f..0b37dde60a1e 100644
@@ -22,13 +22,8 @@
 
 void __irq_entry do_IRQ(struct pt_regs *regs)
 {
-	struct pt_regs *old_regs = set_irq_regs(regs);
 	trace_hardirqs_off();
-
-	irq_enter();
 	handle_arch_irq(regs);
-	irq_exit();
-	set_irq_regs(old_regs);
 	trace_hardirqs_on();
 }
 
drivers/irqchip/irq-xilinx-intc.c +15 -29

58 lines not on this page · raw message

Signature · 1 line
2.25.0
#5 lore raw

Re: [PATCH 3/3] irqchip: xilinx: Use handle_domain_irq()

Quoted 100 lines · Michal Simek

Call generic domain specific irq handler which does the most of things self. Also get rid of concurrent_irq counting which hasn't been exported anywhere.
Based on this loop was also optimized by using do/while loop instead of goto loop.

---

 arch/microblaze/Kconfig           |  1 +
 arch/microblaze/kernel/irq.c      |  5 ----
 drivers/irqchip/irq-xilinx-intc.c | 44 +++++++++++--------------------
 3 files changed, 16 insertions(+), 34 deletions(-)
arch/microblaze/Kconfig +1 -0
index 3a314aa2efa1..242f58ec086b 100644
@@ -48,6 +48,7 @@ config MICROBLAZE
 	select MMU_GATHER_NO_RANGE if MMU
 	select SPARSE_IRQ
 	select GENERIC_IRQ_MULTI_HANDLER
+	select HANDLE_DOMAIN_IRQ
 
 # Endianness selection
 choice
arch/microblaze/kernel/irq.c +0 -5
index 1f8cb4c4f74f..0b37dde60a1e 100644
@@ -22,13 +22,8 @@
 
 void __irq_entry do_IRQ(struct pt_regs *regs)
 {
-	struct pt_regs *old_regs = set_irq_regs(regs);
 	trace_hardirqs_off();
-
-	irq_enter();
 	handle_arch_irq(regs);
-	irq_exit();
-	set_irq_regs(old_regs);
 	trace_hardirqs_on();
 }
 
drivers/irqchip/irq-xilinx-intc.c +0 -14
index ad9e678c24ac..fa468e618762 100644
@@ -125,20 +125,6 @@ static unsigned int xintc_get_irq_local(struct
 xintc_irq_chip *irqc)
 	return irq;
 }
 
-static unsigned int xintc_get_irq(void)
-{
-	u32 hwirq;
-	unsigned int irq = -1;
-
-	hwirq = xintc_read(primary_intc, IVR);
-	if (hwirq != -1U)
-		irq = irq_find_mapping(primary_intc->root_domain, hwirq);
-
-	pr_debug("irq-xilinx: hwirq=%d, irq=%d\n", hwirq, irq);
-
-	return irq;
-}
-
 static int xintc_map(struct irq_domain *d, unsigned int irq,
 irq_hw_number_t hw)

{

drivers/irqchip/irq-xilinx-intc.c +5 -15
 	struct xintc_irq_chip *irqc = d->host_data;
@@ -178,23 +164,23 @@ static void xil_intc_irq_handler(struct irq_desc 
 *desc)
 	chained_irq_exit(chip, desc);
 }
 
-static u32 concurrent_irq;
-
 static void xil_intc_handle_irq(struct pt_regs *regs)
 {
-	unsigned int irq;
-
-	irq = xintc_get_irq();
-next_irq:
-	BUG_ON(!irq);
-	generic_handle_irq(irq);
-
-	irq = xintc_get_irq();
-	if (irq != -1U) {
-		pr_debug("next irq: %d\n", irq);
-		++concurrent_irq;
-		goto next_irq;
-	}
+	u32 hwirq;
+	struct xintc_irq_chip *irqc = primary_intc;
+
+	do {
+		hwirq = xintc_read(irqc, IVR);

drivers/irqchip/irq-xilinx-intc.c static void xil_intc_irq_handler(struct irq_desc · line 184

Quoted 10 lines
drivers/irqchip/irq-xilinx-intc.c +10 -0
+		if (hwirq != -1U) {
+			int ret;
+
+			ret = handle_domain_irq(irqc->root_domain, hwirq, regs);
+			WARN_ONCE(ret, "Unhandled HWIRQ %d\n", hwirq);
+			continue;
+		}
+
+		break;
+	} while (1);

OK, so this what I suggested already. Just squash the two patches in one, there is no point in keeping them separate.

Thanks,

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#6 lore raw

Re: [PATCH 3/3] irqchip: xilinx: Use handle_domain_irq()

Quoted 106 lines · Marc Zyngier
Quoted 105 lines · Michal Simek

Call generic domain specific irq handler which does the most of things self. Also get rid of concurrent_irq counting which hasn't been exported anywhere.
Based on this loop was also optimized by using do/while loop instead of goto loop.

---

 arch/microblaze/Kconfig           |  1 + arch/microblaze/kernel/irq.c      |  5 ---- drivers/irqchip/irq-xilinx-intc.c | 44 +++++++++++--------------------

 3 files changed, 16 insertions(+), 34 deletions(-)
arch/microblaze/Kconfig +0 -0
index 3a314aa2efa1..242f58ec086b 100644
@@ -48,6 +48,7 @@ config MICROBLAZE

     select MMU_GATHER_NO_RANGE if MMU
     select SPARSE_IRQ
     select GENERIC_IRQ_MULTI_HANDLER
+    select HANDLE_DOMAIN_IRQ

 # Endianness selection
 choice

arch/microblaze/kernel/irq.c +0 -5
index 1f8cb4c4f74f..0b37dde60a1e 100644
@@ -22,13 +22,8 @@
 
  void __irq_entry do_IRQ(struct pt_regs *regs)
  {
-    struct pt_regs *old_regs = set_irq_regs(regs);
      trace_hardirqs_off();
-
-    irq_enter();
      handle_arch_irq(regs);
-    irq_exit();
-    set_irq_regs(old_regs);
      trace_hardirqs_on();
  }
 
drivers/irqchip/irq-xilinx-intc.c +0 -14
index ad9e678c24ac..fa468e618762 100644
@@ -125,20 +125,6 @@ static unsigned int xintc_get_irq_local(struct
 xintc_irq_chip *irqc)
      return irq;
  }
 
-static unsigned int xintc_get_irq(void)
-{
-    u32 hwirq;
-    unsigned int irq = -1;
-
-    hwirq = xintc_read(primary_intc, IVR);
-    if (hwirq != -1U)
-        irq = irq_find_mapping(primary_intc->root_domain, hwirq);
-
-    pr_debug("irq-xilinx: hwirq=%d, irq=%d\n", hwirq, irq);
-
-    return irq;
-}
-
  static int xintc_map(struct irq_domain *d, unsigned int irq,
 irq_hw_number_t hw)

 {
     struct xintc_irq_chip *irqc = d->host_data;

drivers/irqchip/irq-xilinx-intc.c +10 -15
@@ -178,23 +164,23 @@ static void xil_intc_irq_handler(struct irq_desc
 *desc)
      chained_irq_exit(chip, desc);
  }
 
-static u32 concurrent_irq;
-
  static void xil_intc_handle_irq(struct pt_regs *regs)
  {
-    unsigned int irq;
-
-    irq = xintc_get_irq();
-next_irq:
-    BUG_ON(!irq);
-    generic_handle_irq(irq);
-
-    irq = xintc_get_irq();
-    if (irq != -1U) {
-        pr_debug("next irq: %d\n", irq);
-        ++concurrent_irq;
-        goto next_irq;
-    }
+    u32 hwirq;
+    struct xintc_irq_chip *irqc = primary_intc;
+
+    do {
+        hwirq = xintc_read(irqc, IVR);
+        if (hwirq != -1U) {
+            int ret;
+
+            ret = handle_domain_irq(irqc->root_domain, hwirq, regs);
+            WARN_ONCE(ret, "Unhandled HWIRQ %d\n", hwirq);
Quoted 8 lines

drivers/irqchip/irq-xilinx-intc.c static void xil_intc_irq_handler(struct irq_desc *desc) · line 183

Quoted 5 lines
drivers/irqchip/irq-xilinx-intc.c +5 -0
+            continue;
+        }
+
+        break;
+    } while (1);

OK, so this what I suggested already. Just squash the two patches in one, there is no point in keeping them separate.

I sent it exactly how I have done it originally. Not a problem with squashing that stuff together.

Thanks,
Michal

#7 lore raw
In reply to Michal Simek
Quoted 24 lines · Michal Simek

Hi,

this series is based on cascade mode patch sent by Mubin
(https://lkml.org/lkml/2020/2/11/888 - v3 series).

The first patch is just fixing error patch. The second and the third are converting microblaze do_IRQ() to generic IRQ handler with appropriate changes in xilinx intc driver. I have done it in two steps to be visible how it was done.

The last patch removes concurrent_irq global variable which wasn't wired anywhere but it stores number of concurrent IRQs handled by one call. There is option to get it back if needed but I haven't seen it in other archs that's why I have removed it too.

Thanks,
Michal

Michal Simek (3):
irqchip: xilinx: Fill error code when irq domain registration fails
irqchip: xilinx: Enable generic irq multi handler
irqchip: xilinx: Use handle_domain_irq()

Quoted 6 lines
 arch/microblaze/Kconfig           |  2 ++
 arch/microblaze/include/asm/irq.h |  3 ---
 arch/microblaze/kernel/irq.c      | 21 +------------------
 drivers/irqchip/irq-xilinx-intc.c | 35 ++++++++++++++++++-------------
 4 files changed, 24 insertions(+), 37 deletions(-)

Thomas/Marc: Can you please take a look at this series?

Thanks,
Michal