aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq/handle.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/irq/handle.c')
-rw-r--r--kernel/irq/handle.c58
1 files changed, 55 insertions, 3 deletions
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 9ebf77968871..26e08754744f 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -17,6 +17,7 @@
17#include <linux/kernel_stat.h> 17#include <linux/kernel_stat.h>
18#include <linux/rculist.h> 18#include <linux/rculist.h>
19#include <linux/hash.h> 19#include <linux/hash.h>
20#include <trace/irq.h>
20#include <linux/bootmem.h> 21#include <linux/bootmem.h>
21 22
22#include "internals.h" 23#include "internals.h"
@@ -338,6 +339,18 @@ irqreturn_t no_action(int cpl, void *dev_id)
338 return IRQ_NONE; 339 return IRQ_NONE;
339} 340}
340 341
342static void warn_no_thread(unsigned int irq, struct irqaction *action)
343{
344 if (test_and_set_bit(IRQTF_WARNED, &action->thread_flags))
345 return;
346
347 printk(KERN_WARNING "IRQ %d device %s returned IRQ_WAKE_THREAD "
348 "but no thread function available.", irq, action->name);
349}
350
351DEFINE_TRACE(irq_handler_entry);
352DEFINE_TRACE(irq_handler_exit);
353
341/** 354/**
342 * handle_IRQ_event - irq action chain handler 355 * handle_IRQ_event - irq action chain handler
343 * @irq: the interrupt number 356 * @irq: the interrupt number
@@ -350,15 +363,54 @@ irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action)
350 irqreturn_t ret, retval = IRQ_NONE; 363 irqreturn_t ret, retval = IRQ_NONE;
351 unsigned int status = 0; 364 unsigned int status = 0;
352 365
353 WARN_ONCE(!in_irq(), "BUG: IRQ handler called from non-hardirq context!");
354
355 if (!(action->flags & IRQF_DISABLED)) 366 if (!(action->flags & IRQF_DISABLED))
356 local_irq_enable_in_hardirq(); 367 local_irq_enable_in_hardirq();
357 368
358 do { 369 do {
370 trace_irq_handler_entry(irq, action);
359 ret = action->handler(irq, action->dev_id); 371 ret = action->handler(irq, action->dev_id);
360 if (ret == IRQ_HANDLED) 372 trace_irq_handler_exit(irq, action, ret);
373
374 switch (ret) {
375 case IRQ_WAKE_THREAD:
376 /*
377 * Set result to handled so the spurious check
378 * does not trigger.
379 */
380 ret = IRQ_HANDLED;
381
382 /*
383 * Catch drivers which return WAKE_THREAD but
384 * did not set up a thread function
385 */
386 if (unlikely(!action->thread_fn)) {
387 warn_no_thread(irq, action);
388 break;
389 }
390
391 /*
392 * Wake up the handler thread for this
393 * action. In case the thread crashed and was
394 * killed we just pretend that we handled the
395 * interrupt. The hardirq handler above has
396 * disabled the device interrupt, so no irq
397 * storm is lurking.
398 */
399 if (likely(!test_bit(IRQTF_DIED,
400 &action->thread_flags))) {
401 set_bit(IRQTF_RUNTHREAD, &action->thread_flags);
402 wake_up_process(action->thread);
403 }
404
405 /* Fall through to add to randomness */
406 case IRQ_HANDLED:
361 status |= action->flags; 407 status |= action->flags;
408 break;
409
410 default:
411 break;
412 }
413
362 retval |= ret; 414 retval |= ret;
363 action = action->next; 415 action = action->next;
364 } while (action); 416 } while (action);