aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/irq/handle.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2009-03-23 13:28:15 -0400
committerThomas Gleixner <tglx@linutronix.de>2009-03-24 07:15:23 -0400
commit3aa551c9b4c40018f0e261a178e3d25478dc04a9 (patch)
tree2a696109273fcc421d774cc8fefa4180331a85ad /kernel/irq/handle.c
parent80c5520811d3805adcb15c570ea5e2d489fa5d0b (diff)
genirq: add threaded interrupt handler support
Add support for threaded interrupt handlers: A device driver can request that its main interrupt handler runs in a thread. To achive this the device driver requests the interrupt with request_threaded_irq() and provides additionally to the handler a thread function. The handler function is called in hard interrupt context and needs to check whether the interrupt originated from the device. If the interrupt originated from the device then the handler can either return IRQ_HANDLED or IRQ_WAKE_THREAD. IRQ_HANDLED is returned when no further action is required. IRQ_WAKE_THREAD causes the genirq code to invoke the threaded (main) handler. When IRQ_WAKE_THREAD is returned handler must have disabled the interrupt on the device level. This is mandatory for shared interrupt handlers, but we need to do it as well for obscure x86 hardware where disabling an interrupt on the IO_APIC level redirects the interrupt to the legacy PIC interrupt lines. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/irq/handle.c')
-rw-r--r--kernel/irq/handle.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 9ebf77968871..fe8f45374e86 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -357,8 +357,37 @@ irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action)
357 357
358 do { 358 do {
359 ret = action->handler(irq, action->dev_id); 359 ret = action->handler(irq, action->dev_id);
360 if (ret == IRQ_HANDLED) 360
361 switch (ret) {
362 case IRQ_WAKE_THREAD:
363 /*
364 * Wake up the handler thread for this
365 * action. In case the thread crashed and was
366 * killed we just pretend that we handled the
367 * interrupt. The hardirq handler above has
368 * disabled the device interrupt, so no irq
369 * storm is lurking.
370 */
371 if (likely(!test_bit(IRQTF_DIED,
372 &action->thread_flags))) {
373 set_bit(IRQTF_RUNTHREAD, &action->thread_flags);
374 wake_up_process(action->thread);
375 }
376
377 /*
378 * Set it to handled so the spurious check
379 * does not trigger.
380 */
381 ret = IRQ_HANDLED;
382 /* Fall through to add to randomness */
383 case IRQ_HANDLED:
361 status |= action->flags; 384 status |= action->flags;
385 break;
386
387 default:
388 break;
389 }
390
362 retval |= ret; 391 retval |= ret;
363 action = action->next; 392 action = action->next;
364 } while (action); 393 } while (action);