All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irqchip: xilinx: Enable generic irq multi handler
@ 2022-03-03 16:11 ` Michal Simek
  0 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2022-03-03 16:11 UTC (permalink / raw)
  To: linux-kernel, monstr, michal.simek, git
  Cc: Robert Hancock, Stefan Asserhall, Marc Zyngier, Thomas Gleixner,
	linux-arm-kernel

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

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Stefan Asserhall <stefan.asserhall@xilinx.com>
---

 arch/microblaze/Kconfig           |  2 ++
 arch/microblaze/include/asm/irq.h |  3 ---
 arch/microblaze/kernel/irq.c      | 16 +---------------
 drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++-
 4 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 59798e43cdb0..da568e981604 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -45,6 +45,8 @@ config MICROBLAZE
 	select SET_FS
 	select ZONE_DMA
 	select TRACE_IRQFLAGS_SUPPORT
+	select GENERIC_IRQ_MULTI_HANDLER
+	select HANDLE_DOMAIN_IRQ
 
 # Endianness selection
 choice
diff --git a/arch/microblaze/include/asm/irq.h b/arch/microblaze/include/asm/irq.h
index 0a28e80bbab0..cb6ab55d1d01 100644
--- a/arch/microblaze/include/asm/irq.h
+++ b/arch/microblaze/include/asm/irq.h
@@ -11,7 +11,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 */
diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
index 903dad822fad..1f8cb4c4f74f 100644
--- a/arch/microblaze/kernel/irq.c
+++ b/arch/microblaze/kernel/irq.c
@@ -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();
diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
index 356a59755d63..c6710190c152 100644
--- a/drivers/irqchip/irq-xilinx-intc.c
+++ b/drivers/irqchip/irq-xilinx-intc.c
@@ -110,7 +110,7 @@ static struct irq_chip intc_dev = {
 	.irq_mask_ack = intc_mask_ack,
 };
 
-unsigned int xintc_get_irq(void)
+static unsigned int xintc_get_irq(void)
 {
 	unsigned int irq = -1;
 	u32 hwirq;
@@ -164,6 +164,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)
 {
@@ -233,6 +252,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;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] irqchip: xilinx: Enable generic irq multi handler
@ 2022-03-03 16:11 ` Michal Simek
  0 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2022-03-03 16:11 UTC (permalink / raw)
  To: linux-kernel, monstr, michal.simek, git
  Cc: Robert Hancock, Stefan Asserhall, Marc Zyngier, Thomas Gleixner,
	linux-arm-kernel

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

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Stefan Asserhall <stefan.asserhall@xilinx.com>
---

 arch/microblaze/Kconfig           |  2 ++
 arch/microblaze/include/asm/irq.h |  3 ---
 arch/microblaze/kernel/irq.c      | 16 +---------------
 drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++-
 4 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 59798e43cdb0..da568e981604 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -45,6 +45,8 @@ config MICROBLAZE
 	select SET_FS
 	select ZONE_DMA
 	select TRACE_IRQFLAGS_SUPPORT
+	select GENERIC_IRQ_MULTI_HANDLER
+	select HANDLE_DOMAIN_IRQ
 
 # Endianness selection
 choice
diff --git a/arch/microblaze/include/asm/irq.h b/arch/microblaze/include/asm/irq.h
index 0a28e80bbab0..cb6ab55d1d01 100644
--- a/arch/microblaze/include/asm/irq.h
+++ b/arch/microblaze/include/asm/irq.h
@@ -11,7 +11,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 */
diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
index 903dad822fad..1f8cb4c4f74f 100644
--- a/arch/microblaze/kernel/irq.c
+++ b/arch/microblaze/kernel/irq.c
@@ -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();
diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
index 356a59755d63..c6710190c152 100644
--- a/drivers/irqchip/irq-xilinx-intc.c
+++ b/drivers/irqchip/irq-xilinx-intc.c
@@ -110,7 +110,7 @@ static struct irq_chip intc_dev = {
 	.irq_mask_ack = intc_mask_ack,
 };
 
-unsigned int xintc_get_irq(void)
+static unsigned int xintc_get_irq(void)
 {
 	unsigned int irq = -1;
 	u32 hwirq;
@@ -164,6 +164,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)
 {
@@ -233,6 +252,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;
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] irqchip: xilinx: Enable generic irq multi handler
  2022-03-03 16:11 ` Michal Simek
@ 2022-03-03 17:01   ` Robert Hancock
  -1 siblings, 0 replies; 10+ messages in thread
From: Robert Hancock @ 2022-03-03 17:01 UTC (permalink / raw)
  To: linux-kernel, michal.simek, git, monstr
  Cc: maz, tglx, linux-arm-kernel, stefan.asserhall

On Thu, 2022-03-03 at 17:11 +0100, Michal Simek wrote:
> Register default arch handler via driver instead of directly pointing to
> xilinx intc controller. This patch makes architecture code more generic.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Stefan Asserhall <stefan.asserhall@xilinx.com>
> ---
> 
>  arch/microblaze/Kconfig           |  2 ++
>  arch/microblaze/include/asm/irq.h |  3 ---
>  arch/microblaze/kernel/irq.c      | 16 +---------------
>  drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++-
>  4 files changed, 24 insertions(+), 19 deletions(-)
> 
> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
> index 59798e43cdb0..da568e981604 100644
> --- a/arch/microblaze/Kconfig
> +++ b/arch/microblaze/Kconfig
> @@ -45,6 +45,8 @@ config MICROBLAZE
>  	select SET_FS
>  	select ZONE_DMA
>  	select TRACE_IRQFLAGS_SUPPORT
> +	select GENERIC_IRQ_MULTI_HANDLER
> +	select HANDLE_DOMAIN_IRQ
>  
>  # Endianness selection
>  choice
> diff --git a/arch/microblaze/include/asm/irq.h
> b/arch/microblaze/include/asm/irq.h
> index 0a28e80bbab0..cb6ab55d1d01 100644
> --- a/arch/microblaze/include/asm/irq.h
> +++ b/arch/microblaze/include/asm/irq.h
> @@ -11,7 +11,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 */
> diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
> index 903dad822fad..1f8cb4c4f74f 100644
> --- a/arch/microblaze/kernel/irq.c
> +++ b/arch/microblaze/kernel/irq.c
> @@ -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();
> diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-
> intc.c
> index 356a59755d63..c6710190c152 100644
> --- a/drivers/irqchip/irq-xilinx-intc.c
> +++ b/drivers/irqchip/irq-xilinx-intc.c
> @@ -110,7 +110,7 @@ static struct irq_chip intc_dev = {
>  	.irq_mask_ack = intc_mask_ack,
>  };
>  
> -unsigned int xintc_get_irq(void)
> +static unsigned int xintc_get_irq(void)
>  {
>  	unsigned int irq = -1;
>  	u32 hwirq;
> @@ -164,6 +164,25 @@ static void xil_intc_irq_handler(struct irq_desc *desc)
>  	chained_irq_exit(chip, desc);
>  }
>  
> +static u32 concurrent_irq;

Not sure what this variable is for? It seems to be incremented, but never read.

> +
> +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)
>  {
> @@ -233,6 +252,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;
-- 
Robert Hancock
Senior Hardware Designer, Calian Advanced Technologies
www.calian.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] irqchip: xilinx: Enable generic irq multi handler
@ 2022-03-03 17:01   ` Robert Hancock
  0 siblings, 0 replies; 10+ messages in thread
From: Robert Hancock @ 2022-03-03 17:01 UTC (permalink / raw)
  To: linux-kernel, michal.simek, git, monstr
  Cc: maz, tglx, linux-arm-kernel, stefan.asserhall

On Thu, 2022-03-03 at 17:11 +0100, Michal Simek wrote:
> Register default arch handler via driver instead of directly pointing to
> xilinx intc controller. This patch makes architecture code more generic.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Stefan Asserhall <stefan.asserhall@xilinx.com>
> ---
> 
>  arch/microblaze/Kconfig           |  2 ++
>  arch/microblaze/include/asm/irq.h |  3 ---
>  arch/microblaze/kernel/irq.c      | 16 +---------------
>  drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++-
>  4 files changed, 24 insertions(+), 19 deletions(-)
> 
> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
> index 59798e43cdb0..da568e981604 100644
> --- a/arch/microblaze/Kconfig
> +++ b/arch/microblaze/Kconfig
> @@ -45,6 +45,8 @@ config MICROBLAZE
>  	select SET_FS
>  	select ZONE_DMA
>  	select TRACE_IRQFLAGS_SUPPORT
> +	select GENERIC_IRQ_MULTI_HANDLER
> +	select HANDLE_DOMAIN_IRQ
>  
>  # Endianness selection
>  choice
> diff --git a/arch/microblaze/include/asm/irq.h
> b/arch/microblaze/include/asm/irq.h
> index 0a28e80bbab0..cb6ab55d1d01 100644
> --- a/arch/microblaze/include/asm/irq.h
> +++ b/arch/microblaze/include/asm/irq.h
> @@ -11,7 +11,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 */
> diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
> index 903dad822fad..1f8cb4c4f74f 100644
> --- a/arch/microblaze/kernel/irq.c
> +++ b/arch/microblaze/kernel/irq.c
> @@ -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();
> diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-
> intc.c
> index 356a59755d63..c6710190c152 100644
> --- a/drivers/irqchip/irq-xilinx-intc.c
> +++ b/drivers/irqchip/irq-xilinx-intc.c
> @@ -110,7 +110,7 @@ static struct irq_chip intc_dev = {
>  	.irq_mask_ack = intc_mask_ack,
>  };
>  
> -unsigned int xintc_get_irq(void)
> +static unsigned int xintc_get_irq(void)
>  {
>  	unsigned int irq = -1;
>  	u32 hwirq;
> @@ -164,6 +164,25 @@ static void xil_intc_irq_handler(struct irq_desc *desc)
>  	chained_irq_exit(chip, desc);
>  }
>  
> +static u32 concurrent_irq;

Not sure what this variable is for? It seems to be incremented, but never read.

> +
> +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)
>  {
> @@ -233,6 +252,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;
-- 
Robert Hancock
Senior Hardware Designer, Calian Advanced Technologies
www.calian.com
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] irqchip: xilinx: Enable generic irq multi handler
  2022-03-03 16:11 ` Michal Simek
@ 2022-03-03 17:24   ` Marc Zyngier
  -1 siblings, 0 replies; 10+ messages in thread
From: Marc Zyngier @ 2022-03-03 17:24 UTC (permalink / raw)
  To: Michal Simek
  Cc: linux-kernel, monstr, git, Robert Hancock, Stefan Asserhall,
	Thomas Gleixner, linux-arm-kernel

On Thu, 03 Mar 2022 16:11:39 +0000,
Michal Simek <michal.simek@xilinx.com> wrote:
> 
> Register default arch handler via driver instead of directly pointing to
> xilinx intc controller. This patch makes architecture code more generic.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Stefan Asserhall <stefan.asserhall@xilinx.com>
> ---
> 
>  arch/microblaze/Kconfig           |  2 ++
>  arch/microblaze/include/asm/irq.h |  3 ---
>  arch/microblaze/kernel/irq.c      | 16 +---------------
>  drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++-
>  4 files changed, 24 insertions(+), 19 deletions(-)
> 
> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
> index 59798e43cdb0..da568e981604 100644
> --- a/arch/microblaze/Kconfig
> +++ b/arch/microblaze/Kconfig
> @@ -45,6 +45,8 @@ config MICROBLAZE
>  	select SET_FS
>  	select ZONE_DMA
>  	select TRACE_IRQFLAGS_SUPPORT
> +	select GENERIC_IRQ_MULTI_HANDLER
> +	select HANDLE_DOMAIN_IRQ
>  
>  # Endianness selection
>  choice
> diff --git a/arch/microblaze/include/asm/irq.h b/arch/microblaze/include/asm/irq.h
> index 0a28e80bbab0..cb6ab55d1d01 100644
> --- a/arch/microblaze/include/asm/irq.h
> +++ b/arch/microblaze/include/asm/irq.h
> @@ -11,7 +11,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 */
> diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
> index 903dad822fad..1f8cb4c4f74f 100644
> --- a/arch/microblaze/kernel/irq.c
> +++ b/arch/microblaze/kernel/irq.c
> @@ -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();
> diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
> index 356a59755d63..c6710190c152 100644
> --- a/drivers/irqchip/irq-xilinx-intc.c
> +++ b/drivers/irqchip/irq-xilinx-intc.c
> @@ -110,7 +110,7 @@ static struct irq_chip intc_dev = {
>  	.irq_mask_ack = intc_mask_ack,
>  };
>  
> -unsigned int xintc_get_irq(void)
> +static unsigned int xintc_get_irq(void)
>  {
>  	unsigned int irq = -1;
>  	u32 hwirq;
> @@ -164,6 +164,25 @@ static void xil_intc_irq_handler(struct irq_desc *desc)
>  	chained_irq_exit(chip, desc);
>  }
>  
> +static u32 concurrent_irq;

Please kill this. It serves no purpose at all.

> +
> +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;
> +	}

How about writing this in (basic) C code, and use the exiting APIs?

diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
index 356a59755d63..18125bb841b2 100644
--- a/drivers/irqchip/irq-xilinx-intc.c
+++ b/drivers/irqchip/irq-xilinx-intc.c
@@ -110,18 +110,19 @@ static struct irq_chip intc_dev = {
 	.irq_mask_ack = intc_mask_ack,
 };
 
-unsigned int xintc_get_irq(void)
+#define SPURIOUS_IRQ	(-1U)
+
+static void xil_intc_handle_irq(struct pt_regs *regs)
 {
-	unsigned int irq = -1;
 	u32 hwirq;
 
-	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);
+	do {
+		hwirq = xintc_read(primary_intc, IVR);
+		if (unlikely(hwirq == SPURIOUS_IRQ))
+			break;
 
-	return irq;
+		generic_handle_domain_irq(primary_intc->root_domain, hwirq);
+	} while (true);
 }
 
 static int xintc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] irqchip: xilinx: Enable generic irq multi handler
@ 2022-03-03 17:24   ` Marc Zyngier
  0 siblings, 0 replies; 10+ messages in thread
From: Marc Zyngier @ 2022-03-03 17:24 UTC (permalink / raw)
  To: Michal Simek
  Cc: linux-kernel, monstr, git, Robert Hancock, Stefan Asserhall,
	Thomas Gleixner, linux-arm-kernel

On Thu, 03 Mar 2022 16:11:39 +0000,
Michal Simek <michal.simek@xilinx.com> wrote:
> 
> Register default arch handler via driver instead of directly pointing to
> xilinx intc controller. This patch makes architecture code more generic.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Stefan Asserhall <stefan.asserhall@xilinx.com>
> ---
> 
>  arch/microblaze/Kconfig           |  2 ++
>  arch/microblaze/include/asm/irq.h |  3 ---
>  arch/microblaze/kernel/irq.c      | 16 +---------------
>  drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++-
>  4 files changed, 24 insertions(+), 19 deletions(-)
> 
> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
> index 59798e43cdb0..da568e981604 100644
> --- a/arch/microblaze/Kconfig
> +++ b/arch/microblaze/Kconfig
> @@ -45,6 +45,8 @@ config MICROBLAZE
>  	select SET_FS
>  	select ZONE_DMA
>  	select TRACE_IRQFLAGS_SUPPORT
> +	select GENERIC_IRQ_MULTI_HANDLER
> +	select HANDLE_DOMAIN_IRQ
>  
>  # Endianness selection
>  choice
> diff --git a/arch/microblaze/include/asm/irq.h b/arch/microblaze/include/asm/irq.h
> index 0a28e80bbab0..cb6ab55d1d01 100644
> --- a/arch/microblaze/include/asm/irq.h
> +++ b/arch/microblaze/include/asm/irq.h
> @@ -11,7 +11,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 */
> diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
> index 903dad822fad..1f8cb4c4f74f 100644
> --- a/arch/microblaze/kernel/irq.c
> +++ b/arch/microblaze/kernel/irq.c
> @@ -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();
> diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
> index 356a59755d63..c6710190c152 100644
> --- a/drivers/irqchip/irq-xilinx-intc.c
> +++ b/drivers/irqchip/irq-xilinx-intc.c
> @@ -110,7 +110,7 @@ static struct irq_chip intc_dev = {
>  	.irq_mask_ack = intc_mask_ack,
>  };
>  
> -unsigned int xintc_get_irq(void)
> +static unsigned int xintc_get_irq(void)
>  {
>  	unsigned int irq = -1;
>  	u32 hwirq;
> @@ -164,6 +164,25 @@ static void xil_intc_irq_handler(struct irq_desc *desc)
>  	chained_irq_exit(chip, desc);
>  }
>  
> +static u32 concurrent_irq;

Please kill this. It serves no purpose at all.

> +
> +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;
> +	}

How about writing this in (basic) C code, and use the exiting APIs?

diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
index 356a59755d63..18125bb841b2 100644
--- a/drivers/irqchip/irq-xilinx-intc.c
+++ b/drivers/irqchip/irq-xilinx-intc.c
@@ -110,18 +110,19 @@ static struct irq_chip intc_dev = {
 	.irq_mask_ack = intc_mask_ack,
 };
 
-unsigned int xintc_get_irq(void)
+#define SPURIOUS_IRQ	(-1U)
+
+static void xil_intc_handle_irq(struct pt_regs *regs)
 {
-	unsigned int irq = -1;
 	u32 hwirq;
 
-	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);
+	do {
+		hwirq = xintc_read(primary_intc, IVR);
+		if (unlikely(hwirq == SPURIOUS_IRQ))
+			break;
 
-	return irq;
+		generic_handle_domain_irq(primary_intc->root_domain, hwirq);
+	} while (true);
 }
 
 static int xintc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] irqchip: xilinx: Enable generic irq multi handler
  2022-03-03 17:01   ` Robert Hancock
@ 2022-03-04  6:58     ` Michal Simek
  -1 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2022-03-04  6:58 UTC (permalink / raw)
  To: Robert Hancock, linux-kernel, michal.simek, git, monstr
  Cc: maz, tglx, linux-arm-kernel, stefan.asserhall



On 3/3/22 18:01, Robert Hancock wrote:
> On Thu, 2022-03-03 at 17:11 +0100, Michal Simek wrote:
>> Register default arch handler via driver instead of directly pointing to
>> xilinx intc controller. This patch makes architecture code more generic.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> Reviewed-by: Stefan Asserhall <stefan.asserhall@xilinx.com>
>> ---
>>
>>   arch/microblaze/Kconfig           |  2 ++
>>   arch/microblaze/include/asm/irq.h |  3 ---
>>   arch/microblaze/kernel/irq.c      | 16 +---------------
>>   drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++-
>>   4 files changed, 24 insertions(+), 19 deletions(-)
>>
>> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
>> index 59798e43cdb0..da568e981604 100644
>> --- a/arch/microblaze/Kconfig
>> +++ b/arch/microblaze/Kconfig
>> @@ -45,6 +45,8 @@ config MICROBLAZE
>>   	select SET_FS
>>   	select ZONE_DMA
>>   	select TRACE_IRQFLAGS_SUPPORT
>> +	select GENERIC_IRQ_MULTI_HANDLER
>> +	select HANDLE_DOMAIN_IRQ
>>   
>>   # Endianness selection
>>   choice
>> diff --git a/arch/microblaze/include/asm/irq.h
>> b/arch/microblaze/include/asm/irq.h
>> index 0a28e80bbab0..cb6ab55d1d01 100644
>> --- a/arch/microblaze/include/asm/irq.h
>> +++ b/arch/microblaze/include/asm/irq.h
>> @@ -11,7 +11,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 */
>> diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
>> index 903dad822fad..1f8cb4c4f74f 100644
>> --- a/arch/microblaze/kernel/irq.c
>> +++ b/arch/microblaze/kernel/irq.c
>> @@ -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();
>> diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-
>> intc.c
>> index 356a59755d63..c6710190c152 100644
>> --- a/drivers/irqchip/irq-xilinx-intc.c
>> +++ b/drivers/irqchip/irq-xilinx-intc.c
>> @@ -110,7 +110,7 @@ static struct irq_chip intc_dev = {
>>   	.irq_mask_ack = intc_mask_ack,
>>   };
>>   
>> -unsigned int xintc_get_irq(void)
>> +static unsigned int xintc_get_irq(void)
>>   {
>>   	unsigned int irq = -1;
>>   	u32 hwirq;
>> @@ -164,6 +164,25 @@ static void xil_intc_irq_handler(struct irq_desc *desc)
>>   	chained_irq_exit(chip, desc);
>>   }
>>   
>> +static u32 concurrent_irq;
> 
> Not sure what this variable is for? It seems to be incremented, but never read.

I used this when I was checking how irqs are working and how many concurrent_irq 
I am getting. It was read via debugger not via any linux interface.

Thanks,
Michal


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] irqchip: xilinx: Enable generic irq multi handler
@ 2022-03-04  6:58     ` Michal Simek
  0 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2022-03-04  6:58 UTC (permalink / raw)
  To: Robert Hancock, linux-kernel, michal.simek, git, monstr
  Cc: maz, tglx, linux-arm-kernel, stefan.asserhall



On 3/3/22 18:01, Robert Hancock wrote:
> On Thu, 2022-03-03 at 17:11 +0100, Michal Simek wrote:
>> Register default arch handler via driver instead of directly pointing to
>> xilinx intc controller. This patch makes architecture code more generic.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> Reviewed-by: Stefan Asserhall <stefan.asserhall@xilinx.com>
>> ---
>>
>>   arch/microblaze/Kconfig           |  2 ++
>>   arch/microblaze/include/asm/irq.h |  3 ---
>>   arch/microblaze/kernel/irq.c      | 16 +---------------
>>   drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++-
>>   4 files changed, 24 insertions(+), 19 deletions(-)
>>
>> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
>> index 59798e43cdb0..da568e981604 100644
>> --- a/arch/microblaze/Kconfig
>> +++ b/arch/microblaze/Kconfig
>> @@ -45,6 +45,8 @@ config MICROBLAZE
>>   	select SET_FS
>>   	select ZONE_DMA
>>   	select TRACE_IRQFLAGS_SUPPORT
>> +	select GENERIC_IRQ_MULTI_HANDLER
>> +	select HANDLE_DOMAIN_IRQ
>>   
>>   # Endianness selection
>>   choice
>> diff --git a/arch/microblaze/include/asm/irq.h
>> b/arch/microblaze/include/asm/irq.h
>> index 0a28e80bbab0..cb6ab55d1d01 100644
>> --- a/arch/microblaze/include/asm/irq.h
>> +++ b/arch/microblaze/include/asm/irq.h
>> @@ -11,7 +11,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 */
>> diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
>> index 903dad822fad..1f8cb4c4f74f 100644
>> --- a/arch/microblaze/kernel/irq.c
>> +++ b/arch/microblaze/kernel/irq.c
>> @@ -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();
>> diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-
>> intc.c
>> index 356a59755d63..c6710190c152 100644
>> --- a/drivers/irqchip/irq-xilinx-intc.c
>> +++ b/drivers/irqchip/irq-xilinx-intc.c
>> @@ -110,7 +110,7 @@ static struct irq_chip intc_dev = {
>>   	.irq_mask_ack = intc_mask_ack,
>>   };
>>   
>> -unsigned int xintc_get_irq(void)
>> +static unsigned int xintc_get_irq(void)
>>   {
>>   	unsigned int irq = -1;
>>   	u32 hwirq;
>> @@ -164,6 +164,25 @@ static void xil_intc_irq_handler(struct irq_desc *desc)
>>   	chained_irq_exit(chip, desc);
>>   }
>>   
>> +static u32 concurrent_irq;
> 
> Not sure what this variable is for? It seems to be incremented, but never read.

I used this when I was checking how irqs are working and how many concurrent_irq 
I am getting. It was read via debugger not via any linux interface.

Thanks,
Michal


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] irqchip: xilinx: Enable generic irq multi handler
  2022-03-03 17:24   ` Marc Zyngier
@ 2022-03-04  7:51     ` Michal Simek
  -1 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2022-03-04  7:51 UTC (permalink / raw)
  To: Marc Zyngier, Michal Simek
  Cc: linux-kernel, monstr, git, Robert Hancock, Stefan Asserhall,
	Thomas Gleixner, linux-arm-kernel



On 3/3/22 18:24, Marc Zyngier wrote:
> On Thu, 03 Mar 2022 16:11:39 +0000,
> Michal Simek <michal.simek@xilinx.com> wrote:
>>
>> Register default arch handler via driver instead of directly pointing to
>> xilinx intc controller. This patch makes architecture code more generic.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> Reviewed-by: Stefan Asserhall <stefan.asserhall@xilinx.com>
>> ---
>>
>>   arch/microblaze/Kconfig           |  2 ++
>>   arch/microblaze/include/asm/irq.h |  3 ---
>>   arch/microblaze/kernel/irq.c      | 16 +---------------
>>   drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++-
>>   4 files changed, 24 insertions(+), 19 deletions(-)
>>
>> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
>> index 59798e43cdb0..da568e981604 100644
>> --- a/arch/microblaze/Kconfig
>> +++ b/arch/microblaze/Kconfig
>> @@ -45,6 +45,8 @@ config MICROBLAZE
>>   	select SET_FS
>>   	select ZONE_DMA
>>   	select TRACE_IRQFLAGS_SUPPORT
>> +	select GENERIC_IRQ_MULTI_HANDLER
>> +	select HANDLE_DOMAIN_IRQ
>>   
>>   # Endianness selection
>>   choice
>> diff --git a/arch/microblaze/include/asm/irq.h b/arch/microblaze/include/asm/irq.h
>> index 0a28e80bbab0..cb6ab55d1d01 100644
>> --- a/arch/microblaze/include/asm/irq.h
>> +++ b/arch/microblaze/include/asm/irq.h
>> @@ -11,7 +11,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 */
>> diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
>> index 903dad822fad..1f8cb4c4f74f 100644
>> --- a/arch/microblaze/kernel/irq.c
>> +++ b/arch/microblaze/kernel/irq.c
>> @@ -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();
>> diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
>> index 356a59755d63..c6710190c152 100644
>> --- a/drivers/irqchip/irq-xilinx-intc.c
>> +++ b/drivers/irqchip/irq-xilinx-intc.c
>> @@ -110,7 +110,7 @@ static struct irq_chip intc_dev = {
>>   	.irq_mask_ack = intc_mask_ack,
>>   };
>>   
>> -unsigned int xintc_get_irq(void)
>> +static unsigned int xintc_get_irq(void)
>>   {
>>   	unsigned int irq = -1;
>>   	u32 hwirq;
>> @@ -164,6 +164,25 @@ static void xil_intc_irq_handler(struct irq_desc *desc)
>>   	chained_irq_exit(chip, desc);
>>   }
>>   
>> +static u32 concurrent_irq;
> 
> Please kill this. It serves no purpose at all.
> 
>> +
>> +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;
>> +	}
> 
> How about writing this in (basic) C code, and use the exiting APIs?
> 
> diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
> index 356a59755d63..18125bb841b2 100644
> --- a/drivers/irqchip/irq-xilinx-intc.c
> +++ b/drivers/irqchip/irq-xilinx-intc.c
> @@ -110,18 +110,19 @@ static struct irq_chip intc_dev = {
>   	.irq_mask_ack = intc_mask_ack,
>   };
>   
> -unsigned int xintc_get_irq(void)
> +#define SPURIOUS_IRQ	(-1U)
> +
> +static void xil_intc_handle_irq(struct pt_regs *regs)
>   {
> -	unsigned int irq = -1;
>   	u32 hwirq;
>   
> -	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);
> +	do {
> +		hwirq = xintc_read(primary_intc, IVR);
> +		if (unlikely(hwirq == SPURIOUS_IRQ))
> +			break;
>   
> -	return irq;
> +		generic_handle_domain_irq(primary_intc->root_domain, hwirq);
> +	} while (true);
>   }
>   
>   static int xintc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)
> 
> 	M.
> 

That works. Sent v2.

Thanks,
Michal

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] irqchip: xilinx: Enable generic irq multi handler
@ 2022-03-04  7:51     ` Michal Simek
  0 siblings, 0 replies; 10+ messages in thread
From: Michal Simek @ 2022-03-04  7:51 UTC (permalink / raw)
  To: Marc Zyngier, Michal Simek
  Cc: linux-kernel, monstr, git, Robert Hancock, Stefan Asserhall,
	Thomas Gleixner, linux-arm-kernel



On 3/3/22 18:24, Marc Zyngier wrote:
> On Thu, 03 Mar 2022 16:11:39 +0000,
> Michal Simek <michal.simek@xilinx.com> wrote:
>>
>> Register default arch handler via driver instead of directly pointing to
>> xilinx intc controller. This patch makes architecture code more generic.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> Reviewed-by: Stefan Asserhall <stefan.asserhall@xilinx.com>
>> ---
>>
>>   arch/microblaze/Kconfig           |  2 ++
>>   arch/microblaze/include/asm/irq.h |  3 ---
>>   arch/microblaze/kernel/irq.c      | 16 +---------------
>>   drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++-
>>   4 files changed, 24 insertions(+), 19 deletions(-)
>>
>> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
>> index 59798e43cdb0..da568e981604 100644
>> --- a/arch/microblaze/Kconfig
>> +++ b/arch/microblaze/Kconfig
>> @@ -45,6 +45,8 @@ config MICROBLAZE
>>   	select SET_FS
>>   	select ZONE_DMA
>>   	select TRACE_IRQFLAGS_SUPPORT
>> +	select GENERIC_IRQ_MULTI_HANDLER
>> +	select HANDLE_DOMAIN_IRQ
>>   
>>   # Endianness selection
>>   choice
>> diff --git a/arch/microblaze/include/asm/irq.h b/arch/microblaze/include/asm/irq.h
>> index 0a28e80bbab0..cb6ab55d1d01 100644
>> --- a/arch/microblaze/include/asm/irq.h
>> +++ b/arch/microblaze/include/asm/irq.h
>> @@ -11,7 +11,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 */
>> diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
>> index 903dad822fad..1f8cb4c4f74f 100644
>> --- a/arch/microblaze/kernel/irq.c
>> +++ b/arch/microblaze/kernel/irq.c
>> @@ -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();
>> diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
>> index 356a59755d63..c6710190c152 100644
>> --- a/drivers/irqchip/irq-xilinx-intc.c
>> +++ b/drivers/irqchip/irq-xilinx-intc.c
>> @@ -110,7 +110,7 @@ static struct irq_chip intc_dev = {
>>   	.irq_mask_ack = intc_mask_ack,
>>   };
>>   
>> -unsigned int xintc_get_irq(void)
>> +static unsigned int xintc_get_irq(void)
>>   {
>>   	unsigned int irq = -1;
>>   	u32 hwirq;
>> @@ -164,6 +164,25 @@ static void xil_intc_irq_handler(struct irq_desc *desc)
>>   	chained_irq_exit(chip, desc);
>>   }
>>   
>> +static u32 concurrent_irq;
> 
> Please kill this. It serves no purpose at all.
> 
>> +
>> +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;
>> +	}
> 
> How about writing this in (basic) C code, and use the exiting APIs?
> 
> diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
> index 356a59755d63..18125bb841b2 100644
> --- a/drivers/irqchip/irq-xilinx-intc.c
> +++ b/drivers/irqchip/irq-xilinx-intc.c
> @@ -110,18 +110,19 @@ static struct irq_chip intc_dev = {
>   	.irq_mask_ack = intc_mask_ack,
>   };
>   
> -unsigned int xintc_get_irq(void)
> +#define SPURIOUS_IRQ	(-1U)
> +
> +static void xil_intc_handle_irq(struct pt_regs *regs)
>   {
> -	unsigned int irq = -1;
>   	u32 hwirq;
>   
> -	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);
> +	do {
> +		hwirq = xintc_read(primary_intc, IVR);
> +		if (unlikely(hwirq == SPURIOUS_IRQ))
> +			break;
>   
> -	return irq;
> +		generic_handle_domain_irq(primary_intc->root_domain, hwirq);
> +	} while (true);
>   }
>   
>   static int xintc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)
> 
> 	M.
> 

That works. Sent v2.

Thanks,
Michal

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-03-04  7:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03 16:11 [PATCH] irqchip: xilinx: Enable generic irq multi handler Michal Simek
2022-03-03 16:11 ` Michal Simek
2022-03-03 17:01 ` Robert Hancock
2022-03-03 17:01   ` Robert Hancock
2022-03-04  6:58   ` Michal Simek
2022-03-04  6:58     ` Michal Simek
2022-03-03 17:24 ` Marc Zyngier
2022-03-03 17:24   ` Marc Zyngier
2022-03-04  7:51   ` Michal Simek
2022-03-04  7:51     ` Michal Simek

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.