2 * linux/kernel/irq/spurious.c
4 * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar
6 * This file contains spurious interrupt handling.
10 #include <linux/module.h>
11 #include <linux/kallsyms.h>
12 #include <linux/interrupt.h>
17 * Recovery handler for misrouted interrupts.
20 static int misrouted_irq(int irq, struct pt_regs *regs)
25 int work = 0; /* Did we do work for a real IRQ */
26 for(i = 1; i < NR_IRQS; i++)
28 struct irqaction *action;
29 if(i == irq) /* Already tried */
32 spin_lock(&desc->lock);
33 action = desc->action;
34 /* Already running on another processor */
35 if(desc->status & IRQ_INPROGRESS)
37 /* Already running: If it is shared get the other
38 CPU to go looking for our mystery interrupt too */
39 if(desc->action && (desc->action->flags & SA_SHIRQ))
40 desc->status |= IRQ_PENDING;
41 spin_unlock(&desc->lock);
44 /* Honour the normal IRQ locking */
45 desc->status |= IRQ_INPROGRESS;
46 spin_unlock(&desc->lock);
49 /* Only shared IRQ handlers are safe to call */
50 if(action->flags & SA_SHIRQ)
52 if(action->handler(i, action->dev_id, regs) == IRQ_HANDLED)
55 action = action->next;
58 /* Now clean up the flags */
59 spin_lock(&desc->lock);
60 action = desc->action;
62 /* While we were looking for a fixup someone queued a real
63 IRQ clashing with our walk */
65 while((desc->status & IRQ_PENDING) && action)
67 /* Perform real IRQ processing for the IRQ we deferred */
69 spin_unlock(&desc->lock);
70 handle_IRQ_event(i, regs, action);
71 spin_lock(&desc->lock);
72 desc->status &= ~IRQ_PENDING;
74 desc->status &= ~IRQ_INPROGRESS;
75 /* If we did actual work for the real IRQ line we must
76 let the IRQ controller clean up too */
78 desc->handler->end(i);
79 spin_unlock(&desc->lock);
81 /* So the caller can adjust the irq error counts */
86 * If 99,900 of the previous 100,000 interrupts have not been handled
87 * then assume that the IRQ is stuck in some manner. Drop a diagnostic
88 * and try to turn the IRQ off.
90 * (The other 100-of-100,000 interrupts may have been a correctly
91 * functioning device sharing an IRQ with the failing one)
93 * Called under desc->lock
97 __report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret)
99 struct irqaction *action;
101 if (action_ret != IRQ_HANDLED && action_ret != IRQ_NONE) {
102 printk(KERN_ERR "irq event %d: bogus return value %x\n",
105 printk(KERN_ERR "irq %d: nobody cared (try booting with the \"irqpoll\" option.\n", irq);
108 printk(KERN_ERR "handlers:\n");
109 action = desc->action;
111 printk(KERN_ERR "[<%p>]", action->handler);
112 print_symbol(" (%s)",
113 (unsigned long)action->handler);
115 action = action->next;
119 void report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret)
121 static int count = 100;
125 __report_bad_irq(irq, desc, action_ret);
129 void note_interrupt(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret, struct pt_regs *regs)
131 if (action_ret != IRQ_HANDLED) {
132 desc->irqs_unhandled++;
133 if (action_ret != IRQ_NONE)
134 report_bad_irq(irq, desc, action_ret);
137 if(unlikely(irqfixup)) { /* Don't punish working computers */
138 if((irqfixup == 2 && irq == 0) || action_ret == IRQ_NONE) {
140 ok = misrouted_irq(irq, regs);
141 if(action_ret == IRQ_NONE)
142 desc->irqs_unhandled -= ok;
147 if (desc->irq_count < 100000)
151 if (desc->irqs_unhandled > 99900) {
153 * The interrupt is stuck
155 __report_bad_irq(irq, desc, action_ret);
159 printk(KERN_EMERG "Disabling IRQ #%d\n", irq);
160 desc->status |= IRQ_DISABLED;
161 desc->handler->disable(irq);
163 desc->irqs_unhandled = 0;
168 int __init noirqdebug_setup(char *str)
171 printk(KERN_INFO "IRQ lockup detection disabled\n");
175 __setup("noirqdebug", noirqdebug_setup);
177 static int __init irqfixup_setup(char *str)
180 printk(KERN_WARNING "Misrouted IRQ fixup support enabled.\n");
181 printk(KERN_WARNING "This may impact system performance.\n");
185 __setup("irqfixup", irqfixup_setup);
187 static int __init irqpoll_setup(char *str)
190 printk(KERN_WARNING "Misrouted IRQ fixup and polling support enabled.\n");
191 printk(KERN_WARNING "This may significantly impact system performance.\n");
195 __setup("irqpoll", irqpoll_setup);