diff mbox series

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

Message ID 49c5a093d7ba1f20930c7433ed632e7c9bc7a2cb.1581496793.git.michal.simek@xilinx.com (mailing list archive)
State New, archived
Headers show
Series irqchip: xilinx: Switch to generic domain handler | expand

Commit Message

Michal Simek Feb. 12, 2020, 8:39 a.m. UTC
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.

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

 arch/microblaze/Kconfig           |  1 +
 arch/microblaze/kernel/irq.c      |  5 ----
 drivers/irqchip/irq-xilinx-intc.c | 44 +++++++++++--------------------
 3 files changed, 16 insertions(+), 34 deletions(-)

Comments

Marc Zyngier Feb. 21, 2020, 11:46 a.m. UTC | #1
On 2020-02-12 08:39, Michal Simek wrote:
> 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.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Stefan Asserhall <stefan.asserhall@xilinx.com>
> ---
> 
>  arch/microblaze/Kconfig           |  1 +
>  arch/microblaze/kernel/irq.c      |  5 ----
>  drivers/irqchip/irq-xilinx-intc.c | 44 +++++++++++--------------------
>  3 files changed, 16 insertions(+), 34 deletions(-)
> 
> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
> index 3a314aa2efa1..242f58ec086b 100644
> --- a/arch/microblaze/Kconfig
> +++ b/arch/microblaze/Kconfig
> @@ -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
> diff --git a/arch/microblaze/kernel/irq.c 
> b/arch/microblaze/kernel/irq.c
> index 1f8cb4c4f74f..0b37dde60a1e 100644
> --- a/arch/microblaze/kernel/irq.c
> +++ b/arch/microblaze/kernel/irq.c
> @@ -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();
>  }
> 
> diff --git a/drivers/irqchip/irq-xilinx-intc.c
> b/drivers/irqchip/irq-xilinx-intc.c
> index ad9e678c24ac..fa468e618762 100644
> --- a/drivers/irqchip/irq-xilinx-intc.c
> +++ b/drivers/irqchip/irq-xilinx-intc.c
> @@ -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;
> @@ -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);
> +			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.
Michal Simek Feb. 21, 2020, 11:49 a.m. UTC | #2
On 21. 02. 20 12:46, Marc Zyngier wrote:
> On 2020-02-12 08:39, Michal Simek wrote:
>> 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.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> Reviewed-by: Stefan Asserhall <stefan.asserhall@xilinx.com>
>> ---
>>
>>  arch/microblaze/Kconfig           |  1 +
>>  arch/microblaze/kernel/irq.c      |  5 ----
>>  drivers/irqchip/irq-xilinx-intc.c | 44 +++++++++++--------------------
>>  3 files changed, 16 insertions(+), 34 deletions(-)
>>
>> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
>> index 3a314aa2efa1..242f58ec086b 100644
>> --- a/arch/microblaze/Kconfig
>> +++ b/arch/microblaze/Kconfig
>> @@ -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
>> diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
>> index 1f8cb4c4f74f..0b37dde60a1e 100644
>> --- a/arch/microblaze/kernel/irq.c
>> +++ b/arch/microblaze/kernel/irq.c
>> @@ -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();
>>  }
>>
>> diff --git a/drivers/irqchip/irq-xilinx-intc.c
>> b/drivers/irqchip/irq-xilinx-intc.c
>> index ad9e678c24ac..fa468e618762 100644
>> --- a/drivers/irqchip/irq-xilinx-intc.c
>> +++ b/drivers/irqchip/irq-xilinx-intc.c
>> @@ -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;
>> @@ -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);
>> +            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
diff mbox series

Patch

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 3a314aa2efa1..242f58ec086b 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -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
diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
index 1f8cb4c4f74f..0b37dde60a1e 100644
--- a/arch/microblaze/kernel/irq.c
+++ b/arch/microblaze/kernel/irq.c
@@ -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();
 }
 
diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c
index ad9e678c24ac..fa468e618762 100644
--- a/drivers/irqchip/irq-xilinx-intc.c
+++ b/drivers/irqchip/irq-xilinx-intc.c
@@ -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;
@@ -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);
+			continue;
+		}
+
+		break;
+	} while (1);
 }
 
 static int __init xilinx_intc_of_init(struct device_node *intc,