Commit ea28cbc6 authored by Russell King's avatar Russell King

[ARM] Better handling of bad IRQ implementations.

There are edge triggered interrupt controllers around where the
"enable" control is before the edge detection.  This means that
we must keep the interrupts enabled, even when disable_irq() is
in effect, and mark such interrupts for later processing.

To make matters worse, some of these interrupt controllers do not
provide any method to re-trigger the interrupt.  We are unable
to call the handler direct from enable_irq() since we may be
in an IRQ-protected context.

Therefore, we add such interrupts to a list of pending interrupts,
which we process at the next hardware interrupt.
parent fb96b9c8
......@@ -218,7 +218,7 @@ static void sa1111_unmask_lowirq(unsigned int irq)
* be triggered. In fact, its very difficult, if not impossible to get
* INTSET to re-trigger the interrupt.
*/
static void sa1111_rerun_lowirq(unsigned int irq)
static int sa1111_retrigger_lowirq(unsigned int irq)
{
unsigned int mask = SA1111_IRQMASK_LO(irq);
int i;
......@@ -233,6 +233,7 @@ static void sa1111_rerun_lowirq(unsigned int irq)
if (i == 8)
printk(KERN_ERR "Danger Will Robinson: failed to "
"re-trigger IRQ%d\n", irq);
return i == 8 ? -1 : 0;
}
static int sa1111_type_lowirq(unsigned int irq, unsigned int flags)
......@@ -270,7 +271,7 @@ static struct irqchip sa1111_low_chip = {
.ack = sa1111_ack_irq,
.mask = sa1111_mask_lowirq,
.unmask = sa1111_unmask_lowirq,
.rerun = sa1111_rerun_lowirq,
.retrigger = sa1111_retrigger_lowirq,
.type = sa1111_type_lowirq,
.wake = sa1111_wake_lowirq,
};
......@@ -292,7 +293,7 @@ static void sa1111_unmask_highirq(unsigned int irq)
* be triggered. In fact, its very difficult, if not impossible to get
* INTSET to re-trigger the interrupt.
*/
static void sa1111_rerun_highirq(unsigned int irq)
static int sa1111_retrigger_highirq(unsigned int irq)
{
unsigned int mask = SA1111_IRQMASK_HI(irq);
int i;
......@@ -307,6 +308,7 @@ static void sa1111_rerun_highirq(unsigned int irq)
if (i == 8)
printk(KERN_ERR "Danger Will Robinson: failed to "
"re-trigger IRQ%d\n", irq);
return i == 8 ? -1 : 0;
}
static int sa1111_type_highirq(unsigned int irq, unsigned int flags)
......@@ -344,7 +346,7 @@ static struct irqchip sa1111_high_chip = {
.ack = sa1111_ack_irq,
.mask = sa1111_mask_highirq,
.unmask = sa1111_unmask_highirq,
.rerun = sa1111_rerun_highirq,
.retrigger = sa1111_retrigger_highirq,
.type = sa1111_type_highirq,
.wake = sa1111_wake_highirq,
};
......
......@@ -29,6 +29,7 @@
#include <linux/init.h>
#include <linux/seq_file.h>
#include <linux/errno.h>
#include <linux/list.h>
#include <asm/irq.h>
#include <asm/system.h>
......@@ -45,6 +46,7 @@
static volatile unsigned long irq_err_count;
static spinlock_t irq_controller_lock;
static LIST_HEAD(irq_pending);
struct irqdesc irq_desc[NR_IRQS];
void (*init_arch_irq)(void) __initdata = NULL;
......@@ -71,6 +73,7 @@ static struct irqchip bad_chip = {
static struct irqdesc bad_irq_desc = {
.chip = &bad_chip,
.handle = do_bad_IRQ,
.pend = LIST_HEAD_INIT(bad_irq_desc.pend),
.disable_depth = 1,
};
......@@ -90,6 +93,7 @@ void disable_irq(unsigned int irq)
spin_lock_irqsave(&irq_controller_lock, flags);
desc->disable_depth++;
list_del_init(&desc->pend);
spin_unlock_irqrestore(&irq_controller_lock, flags);
}
......@@ -122,9 +126,11 @@ void enable_irq(unsigned int irq)
* from here since the caller might be in an
* interrupt-protected region.
*/
if (desc->pending) {
if (desc->pending && list_empty(&desc->pend)) {
desc->pending = 0;
desc->chip->rerun(irq);
if (!desc->chip->retrigger ||
desc->chip->retrigger(irq))
list_add(&desc->pend, &irq_pending);
}
}
spin_unlock_irqrestore(&irq_controller_lock, flags);
......@@ -346,6 +352,40 @@ do_level_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
}
}
static void do_pending_irqs(struct pt_regs *regs)
{
struct list_head head, *l, *n;
do {
struct irqdesc *desc;
/*
* First, take the pending interrupts off the list.
* The act of calling the handlers may add some IRQs
* back onto the list.
*/
head = irq_pending;
INIT_LIST_HEAD(&irq_pending);
head.next->prev = &head;
head.prev->next = &head;
/*
* Now run each entry. We must delete it from our
* list before calling the handler.
*/
list_for_each_safe(l, n, &head) {
desc = list_entry(l, struct irqdesc, pend);
list_del_init(&desc->pend);
desc->handle(desc - irq_desc, desc, regs);
}
/*
* The list must be empty.
*/
BUG_ON(!list_empty(&head));
} while (!list_empty(&irq_pending));
}
/*
* do_IRQ handles all hardware IRQ's. Decoded IRQs should not
* come via this function. Instead, they should provide their
......@@ -365,6 +405,13 @@ asmlinkage void asm_do_IRQ(int irq, struct pt_regs *regs)
irq_enter();
spin_lock(&irq_controller_lock);
desc->handle(irq, desc, regs);
/*
* Now re-run any pending interrupts.
*/
if (!list_empty(&irq_pending))
do_pending_irqs(regs);
spin_unlock(&irq_controller_lock);
irq_exit();
}
......@@ -740,8 +787,10 @@ void __init init_IRQ(void)
extern void init_dma(void);
int irq;
for (irq = 0, desc = irq_desc; irq < NR_IRQS; irq++, desc++)
for (irq = 0, desc = irq_desc; irq < NR_IRQS; irq++, desc++) {
*desc = bad_irq_desc;
INIT_LIST_HEAD(&desc->pend);
}
init_arch_irq();
init_dma();
......
......@@ -15,6 +15,7 @@
* 16-Mar-1999 RMK Added autodetect of ISA PICs
*/
#include <linux/ioport.h>
#include <linux/list.h>
#include <linux/init.h>
#include <asm/mach/irq.h>
......
......@@ -16,6 +16,7 @@
*/
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/init.h>
#include <asm/mach/irq.h>
......
......@@ -15,6 +15,7 @@
*/
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <asm/mach/irq.h>
#include <asm/irq.h>
......
......@@ -15,6 +15,7 @@
* Fixes for various revision boards - DS
*/
#include <linux/init.h>
#include <linux/list.h>
#include <asm/irq.h>
#include <asm/mach/irq.h>
......
......@@ -11,6 +11,7 @@
* published by the Free Software Foundation.
*/
#include <linux/init.h>
#include <linux/list.h>
#include <asm/mach/irq.h>
#include <asm/irq.h>
......
......@@ -85,19 +85,6 @@ static int pxa_gpio_irq_type(unsigned int irq, unsigned int type)
return 0;
}
/*
* Since we can't actually physically mask edge triggered interrupts
* without the risk of missing transitions, we therefore logically mask
* them and defer their processing through tis function.
*/
static void pxa_manual_rerun(unsigned int irq)
{
struct pt_regs regs;
memset(&regs, 0, sizeof(regs));
irq_desc[irq].handle(irq, &irq_desc[irq], &regs);
}
/*
* GPIO IRQs must be acknoledged. This is for GPIO 0 and 1.
*/
......@@ -111,7 +98,6 @@ static struct irqchip pxa_low_gpio_chip = {
.ack = pxa_ack_low_gpio,
.mask = pxa_mask_irq,
.unmask = pxa_unmask_irq,
.rerun = pxa_manual_rerun,
.type = pxa_gpio_irq_type,
};
......
#include <linux/init.h>
#include <linux/list.h>
#include <asm/mach/irq.h>
#include <asm/hardware/iomd.h>
......
......@@ -13,6 +13,7 @@
#include <linux/module.h>
#include <linux/ioport.h>
#include <linux/ptrace.h>
#include <linux/device.h>
#include <asm/hardware.h>
#include <asm/irq.h>
......@@ -24,20 +25,12 @@
/*
* SA1100 GPIO edge detection for IRQs:
* IRQs are generated on Falling-Edge, Rising-Edge, or both.
* This must be called *before* the appropriate IRQ is registered.
* Use this instead of directly setting GRER/GFER.
*/
static int GPIO_IRQ_rising_edge;
static int GPIO_IRQ_falling_edge;
static int GPIO_IRQ_mask = (1 << 11) - 1;
static void sa1100_manual_rerun(unsigned int irq)
{
struct pt_regs regs;
memset(&regs, 0, sizeof(regs));
irq_desc[irq].handle(irq, &irq_desc[irq], &regs);
}
/*
* To get the GPIO number from an IRQ number
*/
......@@ -105,7 +98,6 @@ static struct irqchip sa1100_low_gpio_chip = {
.ack = sa1100_low_gpio_ack,
.mask = sa1100_low_gpio_mask,
.unmask = sa1100_low_gpio_unmask,
.rerun = sa1100_manual_rerun,
.type = sa1100_gpio_type,
.wake = sa1100_low_gpio_wake,
};
......@@ -189,7 +181,6 @@ static struct irqchip sa1100_high_gpio_chip = {
.ack = sa1100_high_gpio_ack,
.mask = sa1100_high_gpio_mask,
.unmask = sa1100_high_gpio_unmask,
.rerun = sa1100_manual_rerun,
.type = sa1100_gpio_type,
.wake = sa1100_high_gpio_wake,
};
......@@ -212,7 +203,6 @@ static struct irqchip sa1100_normal_chip = {
.ack = sa1100_mask_irq,
.mask = sa1100_mask_irq,
.unmask = sa1100_unmask_irq,
/* rerun should never be called */
};
static struct resource irq_resource = {
......@@ -267,10 +257,4 @@ void __init sa1100_init_irq(void)
*/
set_irq_chip(IRQ_GPIO11_27, &sa1100_normal_chip);
set_irq_chained_handler(IRQ_GPIO11_27, sa1100_high_gpio_handler);
/*
* We generally don't want the LCD IRQ being
* enabled as soon as we request it.
*/
set_irq_flags(IRQ_LCD, IRQF_VALID/* | IRQF_NOAUTOEN*/);
}
......@@ -33,9 +33,12 @@ struct irqchip {
*/
void (*unmask)(unsigned int);
/*
* Re-run the IRQ
* Ask the hardware to re-trigger the IRQ.
* Note: This method _must_ _not_ call the interrupt handler.
* If you are unable to retrigger the interrupt, do not
* provide a function, or if you do, return non-zero.
*/
void (*rerun)(unsigned int);
int (*retrigger)(unsigned int);
/*
* Set the type of the IRQ.
*/
......@@ -50,6 +53,7 @@ struct irqdesc {
irq_handler_t handle;
struct irqchip *chip;
struct irqaction *action;
struct list_head pend;
unsigned int disable_depth;
unsigned int triggered: 1; /* IRQ has occurred */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment