diff options
Diffstat (limited to 'kernel/irq/spurious.c')
| -rw-r--r-- | kernel/irq/spurious.c | 162 |
1 files changed, 103 insertions, 59 deletions
diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c index c66d3f10e85..dd364c11e56 100644 --- a/kernel/irq/spurious.c +++ b/kernel/irq/spurious.c | |||
| @@ -12,83 +12,122 @@ | |||
| 12 | #include <linux/kallsyms.h> | 12 | #include <linux/kallsyms.h> |
| 13 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/moduleparam.h> | 14 | #include <linux/moduleparam.h> |
| 15 | #include <linux/timer.h> | ||
| 15 | 16 | ||
| 16 | static int irqfixup __read_mostly; | 17 | static int irqfixup __read_mostly; |
| 17 | 18 | ||
| 19 | #define POLL_SPURIOUS_IRQ_INTERVAL (HZ/10) | ||
| 20 | static void poll_spurious_irqs(unsigned long dummy); | ||
| 21 | static DEFINE_TIMER(poll_spurious_irq_timer, poll_spurious_irqs, 0, 0); | ||
| 22 | |||
| 18 | /* | 23 | /* |
| 19 | * Recovery handler for misrouted interrupts. | 24 | * Recovery handler for misrouted interrupts. |
| 20 | */ | 25 | */ |
| 21 | static int misrouted_irq(int irq) | 26 | static int try_one_irq(int irq, struct irq_desc *desc) |
| 22 | { | 27 | { |
| 23 | int i; | 28 | struct irqaction *action; |
| 24 | int ok = 0; | 29 | int ok = 0, work = 0; |
| 25 | int work = 0; /* Did we do work for a real IRQ */ | ||
| 26 | |||
| 27 | for (i = 1; i < NR_IRQS; i++) { | ||
| 28 | struct irq_desc *desc = irq_desc + i; | ||
| 29 | struct irqaction *action; | ||
| 30 | |||
| 31 | if (i == irq) /* Already tried */ | ||
| 32 | continue; | ||
| 33 | 30 | ||
| 34 | spin_lock(&desc->lock); | 31 | spin_lock(&desc->lock); |
| 35 | /* Already running on another processor */ | 32 | /* Already running on another processor */ |
| 36 | if (desc->status & IRQ_INPROGRESS) { | 33 | if (desc->status & IRQ_INPROGRESS) { |
| 37 | /* | 34 | /* |
| 38 | * Already running: If it is shared get the other | 35 | * Already running: If it is shared get the other |
| 39 | * CPU to go looking for our mystery interrupt too | 36 | * CPU to go looking for our mystery interrupt too |
| 40 | */ | 37 | */ |
| 41 | if (desc->action && (desc->action->flags & IRQF_SHARED)) | 38 | if (desc->action && (desc->action->flags & IRQF_SHARED)) |
| 42 | desc->status |= IRQ_PENDING; | 39 | desc->status |= IRQ_PENDING; |
| 43 | spin_unlock(&desc->lock); | ||
| 44 | continue; | ||
| 45 | } | ||
| 46 | /* Honour the normal IRQ locking */ | ||
| 47 | desc->status |= IRQ_INPROGRESS; | ||
| 48 | action = desc->action; | ||
| 49 | spin_unlock(&desc->lock); | 40 | spin_unlock(&desc->lock); |
| 41 | return ok; | ||
| 42 | } | ||
| 43 | /* Honour the normal IRQ locking */ | ||
| 44 | desc->status |= IRQ_INPROGRESS; | ||
| 45 | action = desc->action; | ||
| 46 | spin_unlock(&desc->lock); | ||
| 50 | 47 | ||
| 51 | while (action) { | 48 | while (action) { |
| 52 | /* Only shared IRQ handlers are safe to call */ | 49 | /* Only shared IRQ handlers are safe to call */ |
| 53 | if (action->flags & IRQF_SHARED) { | 50 | if (action->flags & IRQF_SHARED) { |
| 54 | if (action->handler(i, action->dev_id) == | 51 | if (action->handler(irq, action->dev_id) == |
| 55 | IRQ_HANDLED) | 52 | IRQ_HANDLED) |
| 56 | ok = 1; | 53 | ok = 1; |
| 57 | } | ||
| 58 | action = action->next; | ||
| 59 | } | 54 | } |
| 60 | local_irq_disable(); | 55 | action = action->next; |
| 61 | /* Now clean up the flags */ | 56 | } |
| 62 | spin_lock(&desc->lock); | 57 | local_irq_disable(); |
| 63 | action = desc->action; | 58 | /* Now clean up the flags */ |
| 59 | spin_lock(&desc->lock); | ||
| 60 | action = desc->action; | ||
| 64 | 61 | ||
| 62 | /* | ||
| 63 | * While we were looking for a fixup someone queued a real | ||
| 64 | * IRQ clashing with our walk: | ||
| 65 | */ | ||
| 66 | while ((desc->status & IRQ_PENDING) && action) { | ||
| 65 | /* | 67 | /* |
| 66 | * While we were looking for a fixup someone queued a real | 68 | * Perform real IRQ processing for the IRQ we deferred |
| 67 | * IRQ clashing with our walk: | ||
| 68 | */ | ||
| 69 | while ((desc->status & IRQ_PENDING) && action) { | ||
| 70 | /* | ||
| 71 | * Perform real IRQ processing for the IRQ we deferred | ||
| 72 | */ | ||
| 73 | work = 1; | ||
| 74 | spin_unlock(&desc->lock); | ||
| 75 | handle_IRQ_event(i, action); | ||
| 76 | spin_lock(&desc->lock); | ||
| 77 | desc->status &= ~IRQ_PENDING; | ||
| 78 | } | ||
| 79 | desc->status &= ~IRQ_INPROGRESS; | ||
| 80 | /* | ||
| 81 | * If we did actual work for the real IRQ line we must let the | ||
| 82 | * IRQ controller clean up too | ||
| 83 | */ | 69 | */ |
| 84 | if (work && desc->chip && desc->chip->end) | 70 | work = 1; |
| 85 | desc->chip->end(i); | ||
| 86 | spin_unlock(&desc->lock); | 71 | spin_unlock(&desc->lock); |
| 72 | handle_IRQ_event(irq, action); | ||
| 73 | spin_lock(&desc->lock); | ||
| 74 | desc->status &= ~IRQ_PENDING; | ||
| 75 | } | ||
| 76 | desc->status &= ~IRQ_INPROGRESS; | ||
| 77 | /* | ||
| 78 | * If we did actual work for the real IRQ line we must let the | ||
| 79 | * IRQ controller clean up too | ||
| 80 | */ | ||
| 81 | if (work && desc->chip && desc->chip->end) | ||
| 82 | desc->chip->end(irq); | ||
| 83 | spin_unlock(&desc->lock); | ||
| 84 | |||
| 85 | return ok; | ||
| 86 | } | ||
| 87 | |||
| 88 | static int misrouted_irq(int irq) | ||
| 89 | { | ||
| 90 | struct irq_desc *desc; | ||
| 91 | int i, ok = 0; | ||
| 92 | |||
| 93 | for_each_irq_desc(i, desc) { | ||
| 94 | if (!i) | ||
| 95 | continue; | ||
| 96 | |||
| 97 | if (i == irq) /* Already tried */ | ||
| 98 | continue; | ||
| 99 | |||
| 100 | if (try_one_irq(i, desc)) | ||
| 101 | ok = 1; | ||
| 87 | } | 102 | } |
| 88 | /* So the caller can adjust the irq error counts */ | 103 | /* So the caller can adjust the irq error counts */ |
| 89 | return ok; | 104 | return ok; |
| 90 | } | 105 | } |
| 91 | 106 | ||
| 107 | static void poll_spurious_irqs(unsigned long dummy) | ||
| 108 | { | ||
| 109 | struct irq_desc *desc; | ||
| 110 | int i; | ||
| 111 | |||
| 112 | for_each_irq_desc(i, desc) { | ||
| 113 | unsigned int status; | ||
| 114 | |||
| 115 | if (!i) | ||
| 116 | continue; | ||
| 117 | |||
| 118 | /* Racy but it doesn't matter */ | ||
| 119 | status = desc->status; | ||
| 120 | barrier(); | ||
| 121 | if (!(status & IRQ_SPURIOUS_DISABLED)) | ||
| 122 | continue; | ||
| 123 | |||
| 124 | try_one_irq(i, desc); | ||
| 125 | } | ||
| 126 | |||
| 127 | mod_timer(&poll_spurious_irq_timer, | ||
| 128 | jiffies + POLL_SPURIOUS_IRQ_INTERVAL); | ||
| 129 | } | ||
| 130 | |||
| 92 | /* | 131 | /* |
| 93 | * If 99,900 of the previous 100,000 interrupts have not been handled | 132 | * If 99,900 of the previous 100,000 interrupts have not been handled |
| 94 | * then assume that the IRQ is stuck in some manner. Drop a diagnostic | 133 | * then assume that the IRQ is stuck in some manner. Drop a diagnostic |
| @@ -137,7 +176,9 @@ report_bad_irq(unsigned int irq, struct irq_desc *desc, irqreturn_t action_ret) | |||
| 137 | } | 176 | } |
| 138 | } | 177 | } |
| 139 | 178 | ||
| 140 | static inline int try_misrouted_irq(unsigned int irq, struct irq_desc *desc, irqreturn_t action_ret) | 179 | static inline int |
| 180 | try_misrouted_irq(unsigned int irq, struct irq_desc *desc, | ||
| 181 | irqreturn_t action_ret) | ||
| 141 | { | 182 | { |
| 142 | struct irqaction *action; | 183 | struct irqaction *action; |
| 143 | 184 | ||
| @@ -212,6 +253,9 @@ void note_interrupt(unsigned int irq, struct irq_desc *desc, | |||
| 212 | desc->status |= IRQ_DISABLED | IRQ_SPURIOUS_DISABLED; | 253 | desc->status |= IRQ_DISABLED | IRQ_SPURIOUS_DISABLED; |
| 213 | desc->depth++; | 254 | desc->depth++; |
| 214 | desc->chip->disable(irq); | 255 | desc->chip->disable(irq); |
| 256 | |||
| 257 | mod_timer(&poll_spurious_irq_timer, | ||
| 258 | jiffies + POLL_SPURIOUS_IRQ_INTERVAL); | ||
| 215 | } | 259 | } |
| 216 | desc->irqs_unhandled = 0; | 260 | desc->irqs_unhandled = 0; |
| 217 | } | 261 | } |
| @@ -241,7 +285,7 @@ static int __init irqfixup_setup(char *str) | |||
| 241 | 285 | ||
| 242 | __setup("irqfixup", irqfixup_setup); | 286 | __setup("irqfixup", irqfixup_setup); |
| 243 | module_param(irqfixup, int, 0644); | 287 | module_param(irqfixup, int, 0644); |
| 244 | MODULE_PARM_DESC("irqfixup", "0: No fixup, 1: irqfixup mode 2: irqpoll mode"); | 288 | MODULE_PARM_DESC("irqfixup", "0: No fixup, 1: irqfixup mode, 2: irqpoll mode"); |
| 245 | 289 | ||
| 246 | static int __init irqpoll_setup(char *str) | 290 | static int __init irqpoll_setup(char *str) |
| 247 | { | 291 | { |
