]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - kernel/irq/spurious.c
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 */
27 for(i
= 1; i
< NR_IRQS
; i
++) {
28 struct irqaction
*action
;
30 if (i
== irq
) /* Already tried */
33 spin_lock(&desc
->lock
);
34 action
= desc
->action
;
35 /* Already running on another processor */
36 if (desc
->status
& IRQ_INPROGRESS
) {
38 * Already running: If it is shared get the other
39 * CPU to go looking for our mystery interrupt too
41 if (desc
->action
&& (desc
->action
->flags
& SA_SHIRQ
))
42 desc
->status
|= IRQ_PENDING
;
43 spin_unlock(&desc
->lock
);
46 /* Honour the normal IRQ locking */
47 desc
->status
|= IRQ_INPROGRESS
;
48 spin_unlock(&desc
->lock
);
50 /* Only shared IRQ handlers are safe to call */
51 if (action
->flags
& SA_SHIRQ
) {
52 if (action
->handler(i
, action
->dev_id
, regs
) ==
56 action
= action
->next
;
59 /* Now clean up the flags */
60 spin_lock(&desc
->lock
);
61 action
= desc
->action
;
64 * While we were looking for a fixup someone queued a real
65 * IRQ clashing with our walk
68 while ((desc
->status
& IRQ_PENDING
) && action
) {
70 * Perform real IRQ processing for the IRQ we deferred
73 spin_unlock(&desc
->lock
);
74 handle_IRQ_event(i
, regs
, action
);
75 spin_lock(&desc
->lock
);
76 desc
->status
&= ~IRQ_PENDING
;
78 desc
->status
&= ~IRQ_INPROGRESS
;
80 * If we did actual work for the real IRQ line we must let the
81 * IRQ controller clean up too
84 desc
->handler
->end(i
);
85 spin_unlock(&desc
->lock
);
87 /* So the caller can adjust the irq error counts */
92 * If 99,900 of the previous 100,000 interrupts have not been handled
93 * then assume that the IRQ is stuck in some manner. Drop a diagnostic
94 * and try to turn the IRQ off.
96 * (The other 100-of-100,000 interrupts may have been a correctly
97 * functioning device sharing an IRQ with the failing one)
99 * Called under desc->lock
103 __report_bad_irq(unsigned int irq
, irq_desc_t
*desc
, irqreturn_t action_ret
)
105 struct irqaction
*action
;
107 if (action_ret
!= IRQ_HANDLED
&& action_ret
!= IRQ_NONE
) {
108 printk(KERN_ERR
"irq event %d: bogus return value %x\n",
111 printk(KERN_ERR
"irq %d: nobody cared (try booting with "
112 "the \"irqpoll\" option)\n", irq
);
115 printk(KERN_ERR
"handlers:\n");
116 action
= desc
->action
;
118 printk(KERN_ERR
"[<%p>]", action
->handler
);
119 print_symbol(" (%s)",
120 (unsigned long)action
->handler
);
122 action
= action
->next
;
126 static void report_bad_irq(unsigned int irq
, irq_desc_t
*desc
, irqreturn_t action_ret
)
128 static int count
= 100;
132 __report_bad_irq(irq
, desc
, action_ret
);
136 void note_interrupt(unsigned int irq
, irq_desc_t
*desc
, irqreturn_t action_ret
,
137 struct pt_regs
*regs
)
139 if (action_ret
!= IRQ_HANDLED
) {
140 desc
->irqs_unhandled
++;
141 if (action_ret
!= IRQ_NONE
)
142 report_bad_irq(irq
, desc
, action_ret
);
145 if (unlikely(irqfixup
)) {
146 /* Don't punish working computers */
147 if ((irqfixup
== 2 && irq
== 0) || action_ret
== IRQ_NONE
) {
148 int ok
= misrouted_irq(irq
, regs
);
149 if (action_ret
== IRQ_NONE
)
150 desc
->irqs_unhandled
-= ok
;
155 if (desc
->irq_count
< 100000)
159 if (desc
->irqs_unhandled
> 99900) {
161 * The interrupt is stuck
163 __report_bad_irq(irq
, desc
, action_ret
);
167 printk(KERN_EMERG
"Disabling IRQ #%d\n", irq
);
168 desc
->status
|= IRQ_DISABLED
;
169 desc
->handler
->disable(irq
);
171 desc
->irqs_unhandled
= 0;
176 int __init
noirqdebug_setup(char *str
)
179 printk(KERN_INFO
"IRQ lockup detection disabled\n");
183 __setup("noirqdebug", noirqdebug_setup
);
185 static int __init
irqfixup_setup(char *str
)
188 printk(KERN_WARNING
"Misrouted IRQ fixup support enabled.\n");
189 printk(KERN_WARNING
"This may impact system performance.\n");
193 __setup("irqfixup", irqfixup_setup
);
195 static int __init
irqpoll_setup(char *str
)
198 printk(KERN_WARNING
"Misrouted IRQ fixup and polling support "
200 printk(KERN_WARNING
"This may significantly impact system "
205 __setup("irqpoll", irqpoll_setup
);