diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2012-03-06 17:18:54 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-06 19:46:39 -0500 |
commit | 52abb700e16a9aa4cbc03f3d7f80206cbbc80680 (patch) | |
tree | f396df08518ff22039d2c4da153cba029f01ecd2 /kernel/irq/manage.c | |
parent | ce8fea7aa4ad9e3b40999a08622ef27c77159659 (diff) |
genirq: Clear action->thread_mask if IRQ_ONESHOT is not set
Xommit ac5637611(genirq: Unmask oneshot irqs when thread was not woken)
fails to unmask when a !IRQ_ONESHOT threaded handler is handled by
handle_level_irq.
This happens because thread_mask is or'ed unconditionally in
irq_wake_thread(), but for !IRQ_ONESHOT interrupts never cleared. So
the check for !desc->thread_active fails and keeps the interrupt
disabled.
Keep the thread_mask zero for !IRQ_ONESHOT interrupts.
Document the thread_mask magic while at it.
Reported-and-tested-by: Sven Joachim <svenjoac@gmx.de>
Reported-and-tested-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/irq/manage.c')
-rw-r--r-- | kernel/irq/manage.c | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 32313c084442..0f0d4704ddd8 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
@@ -985,6 +985,11 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
985 | 985 | ||
986 | /* add new interrupt at end of irq queue */ | 986 | /* add new interrupt at end of irq queue */ |
987 | do { | 987 | do { |
988 | /* | ||
989 | * Or all existing action->thread_mask bits, | ||
990 | * so we can find the next zero bit for this | ||
991 | * new action. | ||
992 | */ | ||
988 | thread_mask |= old->thread_mask; | 993 | thread_mask |= old->thread_mask; |
989 | old_ptr = &old->next; | 994 | old_ptr = &old->next; |
990 | old = *old_ptr; | 995 | old = *old_ptr; |
@@ -993,14 +998,41 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
993 | } | 998 | } |
994 | 999 | ||
995 | /* | 1000 | /* |
996 | * Setup the thread mask for this irqaction. Unlikely to have | 1001 | * Setup the thread mask for this irqaction for ONESHOT. For |
997 | * 32 resp 64 irqs sharing one line, but who knows. | 1002 | * !ONESHOT irqs the thread mask is 0 so we can avoid a |
1003 | * conditional in irq_wake_thread(). | ||
998 | */ | 1004 | */ |
999 | if (new->flags & IRQF_ONESHOT && thread_mask == ~0UL) { | 1005 | if (new->flags & IRQF_ONESHOT) { |
1000 | ret = -EBUSY; | 1006 | /* |
1001 | goto out_mask; | 1007 | * Unlikely to have 32 resp 64 irqs sharing one line, |
1008 | * but who knows. | ||
1009 | */ | ||
1010 | if (thread_mask == ~0UL) { | ||
1011 | ret = -EBUSY; | ||
1012 | goto out_mask; | ||
1013 | } | ||
1014 | /* | ||
1015 | * The thread_mask for the action is or'ed to | ||
1016 | * desc->thread_active to indicate that the | ||
1017 | * IRQF_ONESHOT thread handler has been woken, but not | ||
1018 | * yet finished. The bit is cleared when a thread | ||
1019 | * completes. When all threads of a shared interrupt | ||
1020 | * line have completed desc->threads_active becomes | ||
1021 | * zero and the interrupt line is unmasked. See | ||
1022 | * handle.c:irq_wake_thread() for further information. | ||
1023 | * | ||
1024 | * If no thread is woken by primary (hard irq context) | ||
1025 | * interrupt handlers, then desc->threads_active is | ||
1026 | * also checked for zero to unmask the irq line in the | ||
1027 | * affected hard irq flow handlers | ||
1028 | * (handle_[fasteoi|level]_irq). | ||
1029 | * | ||
1030 | * The new action gets the first zero bit of | ||
1031 | * thread_mask assigned. See the loop above which or's | ||
1032 | * all existing action->thread_mask bits. | ||
1033 | */ | ||
1034 | new->thread_mask = 1 << ffz(thread_mask); | ||
1002 | } | 1035 | } |
1003 | new->thread_mask = 1 << ffz(thread_mask); | ||
1004 | 1036 | ||
1005 | if (!shared) { | 1037 | if (!shared) { |
1006 | init_waitqueue_head(&desc->wait_for_threads); | 1038 | init_waitqueue_head(&desc->wait_for_threads); |