2 * linux/kernel/irq/spurious.c
4 * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar
6 * This file contains spurious interrupt handling.
9 <<<<<<< HEAD
:kernel
/irq
/spurious
.c
11 #include <linux/jiffies.h>
12 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:kernel
/irq
/spurious
.c
13 #include <linux/irq.h>
14 #include <linux/module.h>
15 #include <linux/kallsyms.h>
16 #include <linux/interrupt.h>
17 #include <linux/moduleparam.h>
19 static int irqfixup __read_mostly
;
22 * Recovery handler for misrouted interrupts.
24 static int misrouted_irq(int irq
)
28 int work
= 0; /* Did we do work for a real IRQ */
30 for (i
= 1; i
< NR_IRQS
; i
++) {
31 struct irq_desc
*desc
= irq_desc
+ i
;
32 struct irqaction
*action
;
34 if (i
== irq
) /* Already tried */
37 spin_lock(&desc
->lock
);
38 /* Already running on another processor */
39 if (desc
->status
& IRQ_INPROGRESS
) {
41 * Already running: If it is shared get the other
42 * CPU to go looking for our mystery interrupt too
44 if (desc
->action
&& (desc
->action
->flags
& IRQF_SHARED
))
45 desc
->status
|= IRQ_PENDING
;
46 spin_unlock(&desc
->lock
);
49 /* Honour the normal IRQ locking */
50 desc
->status
|= IRQ_INPROGRESS
;
51 action
= desc
->action
;
52 spin_unlock(&desc
->lock
);
55 /* Only shared IRQ handlers are safe to call */
56 if (action
->flags
& IRQF_SHARED
) {
57 if (action
->handler(i
, action
->dev_id
) ==
61 action
= action
->next
;
64 /* Now clean up the flags */
65 spin_lock(&desc
->lock
);
66 action
= desc
->action
;
69 * While we were looking for a fixup someone queued a real
70 * IRQ clashing with our walk:
72 while ((desc
->status
& IRQ_PENDING
) && action
) {
74 * Perform real IRQ processing for the IRQ we deferred
77 spin_unlock(&desc
->lock
);
78 handle_IRQ_event(i
, action
);
79 spin_lock(&desc
->lock
);
80 desc
->status
&= ~IRQ_PENDING
;
82 desc
->status
&= ~IRQ_INPROGRESS
;
84 * If we did actual work for the real IRQ line we must let the
85 * IRQ controller clean up too
87 if (work
&& desc
->chip
&& desc
->chip
->end
)
89 spin_unlock(&desc
->lock
);
91 /* So the caller can adjust the irq error counts */
96 * If 99,900 of the previous 100,000 interrupts have not been handled
97 * then assume that the IRQ is stuck in some manner. Drop a diagnostic
98 * and try to turn the IRQ off.
100 * (The other 100-of-100,000 interrupts may have been a correctly
101 * functioning device sharing an IRQ with the failing one)
103 * Called under desc->lock
107 __report_bad_irq(unsigned int irq
, struct irq_desc
*desc
,
108 irqreturn_t action_ret
)
110 struct irqaction
*action
;
112 if (action_ret
!= IRQ_HANDLED
&& action_ret
!= IRQ_NONE
) {
113 printk(KERN_ERR
"irq event %d: bogus return value %x\n",
116 printk(KERN_ERR
"irq %d: nobody cared (try booting with "
117 "the \"irqpoll\" option)\n", irq
);
120 printk(KERN_ERR
"handlers:\n");
122 action
= desc
->action
;
124 printk(KERN_ERR
"[<%p>]", action
->handler
);
125 print_symbol(" (%s)",
126 (unsigned long)action
->handler
);
128 action
= action
->next
;
133 report_bad_irq(unsigned int irq
, struct irq_desc
*desc
, irqreturn_t action_ret
)
135 static int count
= 100;
139 __report_bad_irq(irq
, desc
, action_ret
);
143 static inline int try_misrouted_irq(unsigned int irq
, struct irq_desc
*desc
, irqreturn_t action_ret
)
145 struct irqaction
*action
;
150 /* We didn't actually handle the IRQ - see if it was misrouted? */
151 if (action_ret
== IRQ_NONE
)
155 * But for 'irqfixup == 2' we also do it for handled interrupts if
156 * they are marked as IRQF_IRQPOLL (or for irq zero, which is the
157 * traditional PC timer interrupt.. Legacy)
166 * Since we don't get the descriptor lock, "action" can
167 * change under us. We don't really care, but we don't
168 * want to follow a NULL pointer. So tell the compiler to
169 * just load it once by using a barrier.
171 action
= desc
->action
;
173 return action
&& (action
->flags
& IRQF_IRQPOLL
);
176 void note_interrupt(unsigned int irq
, struct irq_desc
*desc
,
177 irqreturn_t action_ret
)
179 if (unlikely(action_ret
!= IRQ_HANDLED
)) {
181 * If we are seeing only the odd spurious IRQ caused by
182 * bus asynchronicity then don't eventually trigger an error,
183 * otherwise the couter becomes a doomsday timer for otherwise
186 <<<<<<< HEAD
:kernel
/irq
/spurious
.c
187 if (jiffies
- desc
->last_unhandled
> HZ
/10)
189 if (time_after(jiffies
, desc
->last_unhandled
+ HZ
/10))
190 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:kernel
/irq
/spurious
.c
191 desc
->irqs_unhandled
= 1;
193 desc
->irqs_unhandled
++;
194 desc
->last_unhandled
= jiffies
;
195 if (unlikely(action_ret
!= IRQ_NONE
))
196 report_bad_irq(irq
, desc
, action_ret
);
199 if (unlikely(try_misrouted_irq(irq
, desc
, action_ret
))) {
200 int ok
= misrouted_irq(irq
);
201 if (action_ret
== IRQ_NONE
)
202 desc
->irqs_unhandled
-= ok
;
206 if (likely(desc
->irq_count
< 100000))
210 if (unlikely(desc
->irqs_unhandled
> 99900)) {
212 * The interrupt is stuck
214 __report_bad_irq(irq
, desc
, action_ret
);
218 printk(KERN_EMERG
"Disabling IRQ #%d\n", irq
);
219 desc
->status
|= IRQ_DISABLED
;
221 desc
->chip
->disable(irq
);
223 desc
->irqs_unhandled
= 0;
226 int noirqdebug __read_mostly
;
228 int noirqdebug_setup(char *str
)
231 printk(KERN_INFO
"IRQ lockup detection disabled\n");
236 __setup("noirqdebug", noirqdebug_setup
);
237 module_param(noirqdebug
, bool, 0644);
238 MODULE_PARM_DESC(noirqdebug
, "Disable irq lockup detection when true");
240 static int __init
irqfixup_setup(char *str
)
243 printk(KERN_WARNING
"Misrouted IRQ fixup support enabled.\n");
244 printk(KERN_WARNING
"This may impact system performance.\n");
249 __setup("irqfixup", irqfixup_setup
);
250 module_param(irqfixup
, int, 0644);
251 MODULE_PARM_DESC("irqfixup", "0: No fixup, 1: irqfixup mode 2: irqpoll mode");
253 static int __init
irqpoll_setup(char *str
)
256 printk(KERN_WARNING
"Misrouted IRQ fixup and polling support "
258 printk(KERN_WARNING
"This may significantly impact system "
263 __setup("irqpoll", irqpoll_setup
);