Skip to contentSkip to conversation

AT91: Convert to fasteoi IRQ handler, and remove ARM irq_finish

PATCH Andrew Victor 5 participants 9 messages Apr 27, 2011 – Apr 29, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

The AT91's AIC interrupt controller will internally mask the current (and lower-priority) interrupts until software acknowledges that the interrupt was handled by writing to the AIC_EOICR register.

This matches the "fasteoi" IRQ flow-handler, so convert the AT91 to use handle_fasteoi_irq rather than handle_level_irq.

This also allows the irq_finish() call to be removed from the low-level ARM IRQ handler.

arch/arm/kernel/irq.c +0 -10
diff -urN -x CVS linux-2.6.38/arch/arm/kernel/irq.c linux-2.6/arch/arm/kernel/irq.c
@@ -42,13 +42,6 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 
-/*
- * No architecture-specific irq_finish function defined in arm/arch/irqs.h.
- */
-#ifndef irq_finish
-#define irq_finish(irq) do { } while (0)
-#endif
-
 unsigned long irq_err_count;
 
 int show_interrupts(struct seq_file *p, void *v)
@@ -135,9 +128,6 @@
 		generic_handle_irq(irq);
 	}
 
-	/* AT91 specific workaround */
-	irq_finish(irq);
-
 	irq_exit();
 	set_irq_regs(old_regs);
 }
arch/arm/mach-at91/gpio.c +2 -4
diff -urN -x CVS linux-2.6.38/arch/arm/mach-at91/gpio.c linux-2.6/arch/arm/mach-at91/gpio.c
@@ -392,8 +392,6 @@
 	at91_gpio = get_irq_chip_data(irq);
 	pio = at91_gpio->regbase;
 
-	/* temporarily mask (level sensitive) parent IRQ */
-	desc->irq_data.chip->irq_ack(&desc->irq_data);
 	for (;;) {
 		/* Reading ISR acks pending (edge triggered) GPIO interrupts.
 		 * When there none are pending, we're finished unless we need
@@ -429,8 +427,8 @@
 			isr >>= 1;
 		}
 	}
-	desc->irq_data.chip->irq_unmask(&desc->irq_data);
-	/* now it may re-trigger */
+	/* acknowledge interrupt - now it may re-trigger */
+	desc->irq_data.chip->irq_eoi(&desc->irq_data);
 }
 
 /*--------------------------------------------------------------------------*/
arch/arm/mach-at91/include/mach/irqs.h +0 -7
diff -urN -x CVS linux-2.6.38/arch/arm/mach-at91/include/mach/irqs.h linux-2.6/arch/arm/mach-at91/include/mach/irqs.h
@@ -28,13 +28,6 @@
 
 
 /*
- * Acknowledge interrupt with AIC after interrupt has been handled.
- *   (by kernel/irq.c)
- */
-#define irq_finish(irq) do { at91_sys_write(AT91_AIC_EOICR, 0); } while (0)
-
-
-/*
  * IRQ interrupt symbols are the AT91xxx_ID_* symbols
  * for IRQs handled directly through the AIC, or else the AT91_PIN_*
  * symbols in gpio.h for ones handled indirectly as GPIOs.
arch/arm/mach-at91/irq.c +8 -1
diff -urN -x CVS linux-2.6.38/arch/arm/mach-at91/irq.c linux-2.6/arch/arm/mach-at91/irq.c
@@ -46,6 +46,12 @@
 	at91_sys_write(AT91_AIC_IECR, 1 << d->irq);
 }
 
+static void at91_aic_eoi(struct irq_data *d)
+{
+	/* Acknowledge with AIC after interrupt has been handled */
+	at91_sys_write(AT91_AIC_EOICR, 0);	
+}
+
 unsigned int at91_extern_irq;
 
 #define is_extern_irq(irq) ((1 << (irq)) & at91_extern_irq)
@@ -122,6 +128,7 @@
 	.irq_ack	= at91_aic_mask_irq,
 	.irq_mask	= at91_aic_mask_irq,
 	.irq_unmask	= at91_aic_unmask_irq,
+	.irq_eoi	= at91_aic_eoi,
 	.irq_set_type	= at91_aic_set_type,
 	.irq_set_wake	= at91_aic_set_wake,
 };
@@ -144,7 +151,7 @@
 		at91_sys_write(AT91_AIC_SMR(i), AT91_AIC_SRCTYPE_LOW | priority[i]);
 
 		set_irq_chip(i, &at91_aic_chip);
-		set_irq_handler(i, handle_level_irq);
+		set_irq_handler(i, handle_fasteoi_irq);
 		set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
 
 		/* Perform 8 End Of Interrupt Command to make sure AIC will not Lock out nIRQ */
#1 lore raw
Quoted 4 lines · Andrew Victor

The AT91's AIC interrupt controller will internally mask the current (and lower-priority) interrupts until software acknowledges that the interrupt was handled by writing to the AIC_EOICR register.

Quoted 8 lines

This matches the "fasteoi" IRQ flow-handler, so convert the AT91 to use handle_fasteoi_irq rather than handle_level_irq.

This also allows the irq_finish() call to be removed from the low-level ARM IRQ handler.

Good for me

I put it in the next or you take Thomas?

Best Regards,
J.

#2 lore raw
In reply to Andrew Victor
Quoted 55 lines · Andrew Victor

The AT91's AIC interrupt controller will internally mask the current (and lower-priority) interrupts until software acknowledges that the interrupt was handled by writing to the AIC_EOICR register.

This matches the "fasteoi" IRQ flow-handler, so convert the AT91 to use handle_fasteoi_irq rather than handle_level_irq.

This also allows the irq_finish() call to be removed from the low-level ARM IRQ handler.

diff -urN -x CVS linux-2.6.38/arch/arm/kernel/irq.c linux-2.6/arch/arm/kernel/irq.c

arch/arm/kernel/irq.c +0 -10
@@ -42,13 +42,6 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 
-/*
- * No architecture-specific irq_finish function defined in arm/arch/irqs.h.
- */
-#ifndef irq_finish
-#define irq_finish(irq) do { } while (0)
-#endif
-
 unsigned long irq_err_count;
 
 int show_interrupts(struct seq_file *p, void *v)
@@ -135,9 +128,6 @@
 		generic_handle_irq(irq);
 	}
 
-	/* AT91 specific workaround */
-	irq_finish(irq);
-
 	irq_exit();
 	set_irq_regs(old_regs);
 }

diff -urN -x CVS linux-2.6.38/arch/arm/mach-at91/gpio.c linux-2.6/arch/arm/mach-at91/gpio.c

arch/arm/mach-at91/gpio.c +0 -2
@@ -392,8 +392,6 @@
 	at91_gpio = get_irq_chip_data(irq);
 	pio = at91_gpio->regbase;
 
-	/* temporarily mask (level sensitive) parent IRQ */
-	desc->irq_data.chip->irq_ack(&desc->irq_data);
 	for (;;) {
 		/* Reading ISR acks pending (edge triggered) GPIO interrupts.
 		 * When there none are pending, we're finished unless we need

arch/arm/mach-at91/gpio.c line 432

Quoted 8 lines
arch/arm/mach-at91/gpio.c +2 -2
@@ -429,8 +427,8 @@
 			isr >>= 1;
 		}
 	}
-	desc->irq_data.chip->irq_unmask(&desc->irq_data);
-	/* now it may re-trigger */
+	/* acknowledge interrupt - now it may re-trigger */
+	desc->irq_data.chip->irq_eoi(&desc->irq_data);
 }

why does this handler mess with the parent irq chip ? this looks pretty wrong to me.

Quoted 36 lines
arch/arm/mach-at91/gpio.c +0 -0
 /*--------------------------------------------------------------------------*/

diff -urN -x CVS linux-2.6.38/arch/arm/mach-at91/include/mach/irqs.h linux-2.6/arch/arm/mach-at91/include/mach/irqs.h

arch/arm/mach-at91/include/mach/irqs.h +0 -7
@@ -28,13 +28,6 @@
 
 
 /*
- * Acknowledge interrupt with AIC after interrupt has been handled.
- *   (by kernel/irq.c)
- */
-#define irq_finish(irq) do { at91_sys_write(AT91_AIC_EOICR, 0); } while (0)
-
-
-/*
  * IRQ interrupt symbols are the AT91xxx_ID_* symbols
  * for IRQs handled directly through the AIC, or else the AT91_PIN_*
  * symbols in gpio.h for ones handled indirectly as GPIOs.

diff -urN -x CVS linux-2.6.38/arch/arm/mach-at91/irq.c linux-2.6/arch/arm/mach-at91/irq.c

arch/arm/mach-at91/irq.c +6 -0
@@ -46,6 +46,12 @@
 	at91_sys_write(AT91_AIC_IECR, 1 << d->irq);
 }
 
+static void at91_aic_eoi(struct irq_data *d)
+{
+	/* Acknowledge with AIC after interrupt has been handled */
+	at91_sys_write(AT91_AIC_EOICR, 0);	
+}
+
 unsigned int at91_extern_irq;
 
 #define is_extern_irq(irq) ((1 << (irq)) & at91_extern_irq)

arch/arm/mach-at91/irq.c line 128

Quoted 1 line
arch/arm/mach-at91/irq.c +0 -0
@@ -122,6 +128,7 @@
 	.irq_ack	= at91_aic_mask_irq,

you should probably remove the ack. its just confusing.

Quoted 22 lines
arch/arm/mach-at91/irq.c +2 -1
 	.irq_mask	= at91_aic_mask_irq,
 	.irq_unmask	= at91_aic_unmask_irq,
+	.irq_eoi	= at91_aic_eoi,
 	.irq_set_type	= at91_aic_set_type,
 	.irq_set_wake	= at91_aic_set_wake,
 };
@@ -144,7 +151,7 @@
 		at91_sys_write(AT91_AIC_SMR(i), AT91_AIC_SRCTYPE_LOW | priority[i]);
 
 		set_irq_chip(i, &at91_aic_chip);
-		set_irq_handler(i, handle_level_irq);
+		set_irq_handler(i, handle_fasteoi_irq);
 		set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
 
 		/* Perform 8 End Of Interrupt Command to make sure AIC will not Lock out nIRQ */

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

Signature · 1 line
torben Hohn
#3 lore raw

hi,

Quoted 8 lines
Quoted 5 lines

- ? ? desc->irq_data.chip->irq_unmask(&desc->irq_data);
- ? ? /* now it may re-trigger */
+ ? ? /* acknowledge interrupt - now it may re-trigger */
+ ? ? desc->irq_data.chip->irq_eoi(&desc->irq_data); ?}

why does this handler mess with the parent irq chip ? this looks pretty wrong to me.

This is a chained-handler, and without that line the end-of-interrupt doesn't seem to be signalled.

Regards,
Andrew Victor

#4 lore raw
Quoted 8 lines · * Andrew Victor | 2011-04-28 19:12:23 [+0200]:

hi,

Quoted 6 lines
Quoted 5 lines

- ? ? desc->irq_data.chip->irq_unmask(&desc->irq_data);
- ? ? /* now it may re-trigger */
+ ? ? /* acknowledge interrupt - now it may re-trigger */
+ ? ? desc->irq_data.chip->irq_eoi(&desc->irq_data); ?}

Quoted 5 lines
Quoted 2 lines

why does this handler mess with the parent irq chip ? this looks pretty wrong to me.

This is a chained-handler, and without that line the end-of-interrupt doesn't seem to be signalled.

Most chain handler don't mess with other irq chips. Why is the parent irq hanlder set level and not eoi? Wouldn't this make this superflous?

btw: tglx removed direct desc access so this patch won't apply.

Quoted 2 lines

Regards,
Andrew Victor

Sebastian

#5 lore raw
Quoted 13 lines · Sebastian Andrzej Siewior
Quoted 11 lines · * Andrew Victor | 2011-04-28 19:12:23 [+0200]:

hi,

Quoted 8 lines
Quoted 5 lines

- ? ? desc->irq_data.chip->irq_unmask(&desc->irq_data);
- ? ? /* now it may re-trigger */
+ ? ? /* acknowledge interrupt - now it may re-trigger */
+ ? ? desc->irq_data.chip->irq_eoi(&desc->irq_data); ?}

why does this handler mess with the parent irq chip ? this looks pretty wrong to me.

Quoted 7 lines
Quoted 2 lines

This is a chained-handler, and without that line the end-of-interrupt doesn't seem to be signalled.

Most chain handler don't mess with other irq chips. Why is the parent irq hanlder set level and not eoi? Wouldn't this make this superflous?

btw: tglx removed direct desc access so this patch won't apply.

It does, you still can access irq_data, but you should use the wrappers.

Thanks,

tglx

#6 lore raw
Quoted 11 lines · * Thomas Gleixner | 2011-04-28 21:48:52 [+0200]:
Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 6 lines · * Andrew Victor | 2011-04-28 19:12:23 [+0200]:

hi,

Quoted 4 lines
Quoted 4 lines

- ? ? desc->irq_data.chip->irq_unmask(&desc->irq_data);
- ? ? /* now it may re-trigger */
+ ? ? /* acknowledge interrupt - now it may re-trigger */
+ ? ? desc->irq_data.chip->irq_eoi(&desc->irq_data);

Quoted 4 lines
Quoted 1 line

btw: tglx removed direct desc access so this patch won't apply.

It does, you still can access irq_data, but you should use the wrappers.

commit ac93cdbd6e5e2547a031e2739e0dd445824bf1c8

Author: Thomas Gleixner <[email protected]>
Date:   Thu Mar 24 12:48:18 2011 +0100

arm: at91: Cleanup irq chip

This commit removed "desc->irq_data.chip->irq_unmask(&desc->irq_data);" among others so it does not apply anymore.

Quoted 3 lines

Thanks,

tglx

Sebastian

#7 lore raw
In reply to Sebastian Andrzej Siewior

hi Sebastian,

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

why does this handler mess with the parent irq chip ? this looks pretty wrong to me.

This is a chained-handler, and without that line the end-of-interrupt doesn't seem to be signalled.

Most chain handler don't mess with other irq chips. Why is the parent irq hanlder set level and not eoi? Wouldn't this make this superflous?

This patch changes the parent from level to eoi.

#8 lore raw
Quoted 1 line · * Andrew Victor | 2011-04-28 22:03:03 [+0200]:

hi Sebastian,

Hi Andrew,

Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

why does this handler mess with the parent irq chip ? this looks pretty wrong to me.

This is a chained-handler, and without that line the end-of-interrupt doesn't seem to be signalled.

Most chain handler don't mess with other irq chips. Why is the parent irq hanlder set level and not eoi? Wouldn't this make this superflous?

This patch changes the parent from level to eoi.

Yes. So why does your gpio chip still call ->irq_eoi() of the parent irq-chip? This is done by done the eoi-handler of the parent.

Sebastian