From: "Lothar Waßmann" <LW@KARO-electronics.de>
To: linux-kernel@vger.kernel.org
To: <linux-kernel@vger.kernel.org>
Cc: "Lothar Waßmann" <LW@KARO-electronics.de>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Yong Zhang" <yong.zhang0@gmail.com>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH] genirq: Fix race condition in ONESHOT irq handler
Date: Tue, 7 Feb 2012 14:38:41 +0100 [thread overview]
Message-ID: <1328621921-17404-1-git-send-email-LW@KARO-electronics.de> (raw)
In-Reply-To: <4F31220A.2050708@metafoo.de>
There is a race condition in the threaded IRQ handler code for oneshot
interrupts that may lead to disabling an IRQ indefinitely. IRQs are
masked before calling the hard-irq handler and are unmasked only after
the soft-irq handler has been run. Thus if the hard-irq handler
returns IRQ_HANDLED instead of IRQ_WAKE_THREAD, meaning the soft-irq
will not be called, the interrupt will remain masked forever.
This can happen due to a short pulse on the interrupt line, that
triggers the interrupt logic, but goes undetected by the hard-irq
handler. The problem can be reproduced with the TSC2007 touch
controller driver that uses ONESHOT interrupts.
The problem arises also with interrupt controllers that latch a level
triggered IRQ until it is acknowledged (like the i.MX28 does).
In this case the IRQ status bit will remain asserted after the
soft-irq finishes and retrigger the interrupt while the interrupt line
is already deasserted.
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
kernel/irq/chip.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index f7c543a..74fdef9 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -343,6 +343,8 @@ EXPORT_SYMBOL_GPL(handle_simple_irq);
void
handle_level_irq(unsigned int irq, struct irq_desc *desc)
{
+ irqreturn_t ret;
+
raw_spin_lock(&desc->lock);
mask_ack_irq(desc);
@@ -360,10 +362,13 @@ handle_level_irq(unsigned int irq, struct irq_desc *desc)
if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data)))
goto out_unlock;
- handle_irq_event(desc);
+ ret = handle_irq_event(desc);
- if (!irqd_irq_disabled(&desc->irq_data) && !(desc->istate & IRQS_ONESHOT))
+ if (!irqd_irq_disabled(&desc->irq_data) &&
+ (!(desc->istate & IRQS_ONESHOT) ||
+ !(ret & IRQ_WAKE_THREAD)))
unmask_irq(desc);
+
out_unlock:
raw_spin_unlock(&desc->lock);
}
--
1.7.2.5
next prev parent reply other threads:[~2012-02-07 13:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-06 8:14 [BUG] genirq: Race condition in ONESHOT IRQ handler disabling IRQ forever =?utf-8?Q?Lothar_Wa=C3=9Fmann?=
2012-02-06 10:42 ` Lars-Peter Clausen
2012-02-07 9:03 ` Yong Zhang
2012-02-07 10:01 ` Lothar Waßmann
2012-02-07 12:34 ` Yong Zhang
2012-02-07 12:52 ` Lothar Waßmann
2012-02-07 13:07 ` Lars-Peter Clausen
2012-02-07 13:38 ` Lothar Waßmann [this message]
2012-02-07 17:03 ` [PATCH] genirq: Fix race condition in ONESHOT irq handler Thomas Gleixner
2012-02-08 6:05 ` Lothar Waßmann
2012-02-08 10:38 ` Thomas Gleixner
2012-02-09 8:40 ` Lothar Waßmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1328621921-17404-1-git-send-email-LW@KARO-electronics.de \
--to=lw@karo-electronics.de \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=yong.zhang0@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®