genirq: Race condition in ONESHOT IRQ handler disabling IRQ forever
Hi,
I already sent this to <[email protected]> on Feb. 1, 2012 but did not get any response there. So resending to a wider audience with improved subject line:
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.
The following patch would solve the problem, but I'm not sure whether it's the Right Thing(TM) to do. Especially wrt. shared interrupts.
kernel/irq/handle.c +5 -0
@@ -146,6 +146,11 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)/* Fall through to add to randomness */ case IRQ_HANDLED : random |= action->flags; +/* unmask the IRQ that has been left masked +* due to race condition +*/ +if (res ==IRQ_HANDLED && (action->flags &IRQF_ONESHOT )) +unmask_irq (desc);break ;default :
Best regards,
Lothar Wassmann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
Quoted 33 lines · On 02/06/2012 09:14 AM, =?utf-8?Q?Lothar_Wa=C3=9Fmann?= wrote:
Hi,
I already sent this to <[email protected]> on Feb. 1, 2012 but did not get any response there. So resending to a wider audience with improved subject line:
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_HANDLEDinstead ofIRQ_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.
The following patch would solve the problem, but I'm not sure whether it's the Right Thing(TM) to do. Especially wrt. shared interrupts.
kernel/irq/handle.c +0
-0@@ -146,6 +146,11 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)/* Fall through to add to randomness */
kernel/irq/handle.c handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action) · line 156
Quoted 10 lines
kernel/irq/handle.c +5
-0case IRQ_HANDLED : random |= action->flags; +/* unmask the IRQ that has been left masked +* due to race condition +*/ +if (res ==IRQ_HANDLED && (action->flags &IRQF_ONESHOT )) +unmask_irq (desc);break ;default :
I think a better fix is to check the return value of handle_irq_event in handle_level_irq and if the IRQ_WAKE_THREADED bit is not set unmask the irq.
The same should probably also be done for handle_fasteoi_irq.
Quoted 13 lines · On Mon, Feb 06, 2012 at 09:14:47AM +0100, =?utf-8?Q?Lothar_Wa=C3=9Fmann?= wrote:
Hi,
I already sent this to <[email protected]> on Feb. 1, 2012 but did not get any response there. So resending to a wider audience with improved subject line:
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_HANDLEDinstead ofIRQ_WAKE_THREAD, meaning the soft-irq will not be called, the interrupt will remain masked forever.
Quoted 4 lines
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.
Isn't it the responsibility of the driver (say TSC2007)?
In this case, TSC2007 should return IRQ_WAKE_THREAD IMHO.
Thanks,
Yong
Quoted 46 lines
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.
The following patch would solve the problem, but I'm not sure whether it's the Right Thing(TM) to do. Especially wrt. shared interrupts.
kernel/irq/handle.c +5
-0@@ -146,6 +146,11 @@ handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)/* Fall through to add to randomness */ case IRQ_HANDLED : random |= action->flags; +/* unmask the IRQ that has been left masked +* due to race condition +*/ +if (res ==IRQ_HANDLED && (action->flags &IRQF_ONESHOT )) +unmask_irq (desc);break ;default :Best regards,
Lothar Wassmann
Signature · 15 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Signature · 1 line
Only stand for myself
Hi,
Quoted 14 lines · Lothar Wa?mann
Quoted 13 lines
Hi,
I already sent this to <[email protected]> on Feb. 1, 2012 but did not get any response there. So resending to a wider audience with improved subject line:
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_HANDLEDinstead ofIRQ_WAKE_THREAD, meaning the soft-irq will not be called, the interrupt will remain masked forever.
Quoted 9 lines
Quoted 4 lines
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.
Isn't it the responsibility of the driver (say TSC2007)?
In this case, TSC2007 should return
IRQ_WAKE_THREADIMHO.
That would mean it had to return IRQ_WAKE_THREAD unconditionally making the return code useless.
And it would cause an extra useless loop through the softirq handler.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
Quoted 21 lines · Lothar Wa?mann
Hi,
Quoted 19 lines · Lothar Wa?mann
Quoted 17 lines
Hi,
I already sent this to <[email protected]> on Feb. 1, 2012 but did not get any response there. So resending to a wider audience with improved subject line:
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_HANDLEDinstead ofIRQ_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.
Quoted 8 lines
Quoted 4 lines
Isn't it the responsibility of the driver (say TSC2007)?
In this case, TSC2007 should return
IRQ_WAKE_THREADIMHO.That would mean it had to return
IRQ_WAKE_THREADunconditionally making the return code useless.
And it would cause an extra useless loop through the softirq handler.
Yeah, it's the default behavior when we introduce 'theadirqs', and it's safe.
You know in your patch unmask_irq() is called locklessly and it will introduce other race.
Thanks,
Yong
Hi,
Quoted 26 lines · Yong Zhang
Quoted 25 lines · Lothar Wa?mann
Hi,
Quoted 23 lines · Lothar Wa?mann
Quoted 13 lines
Hi,
I already sent this to <[email protected]> on Feb. 1, 2012 but did not get any response there. So resending to a wider audience with improved subject line:
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_HANDLEDinstead ofIRQ_WAKE_THREAD, meaning the soft-irq will not be called, the interrupt will remain masked forever.Quoted 4 lines
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.
Isn't it the responsibility of the driver (say TSC2007)?
In this case, TSC2007 should return
IRQ_WAKE_THREADIMHO.
Quoted 8 lines
Quoted 4 lines
That would mean it had to return
IRQ_WAKE_THREADunconditionally making the return code useless.
And it would cause an extra useless loop through the softirq handler.Yeah, it's the default behavior when we introduce 'theadirqs', and it's safe.
So, the correct solution would be to remove the check for IRQ_WAKE_THREAD in handle_irq_event_percpu() and always invoke the softirq handler?
Note that this problem is not specific to the TSC2007 driver, but may occur with any hardware.
Or maybe do the unmasking in handle_irq_event() as proposed by Lars-Peter Clausen in <[email protected]>? Like that:
kernel/irq/chip.c +6 -2
@@ -343,6 +343,8 @@ EXPORT_SYMBOL_GPL(handle_simple_irq);void handle_level_irq (unsigned int irq,struct irq_desc *desc) { +int ret; +raw_spin_lock (&desc->lock);mask_ack_irq (desc);
@@ -360,10 +362,12 @@ 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); }
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
Quoted 51 lines · Lothar Waßmann
Hi,
Quoted 26 lines · Yong Zhang
Quoted 25 lines · Lothar Waßmann
Hi,
Quoted 23 lines · Lothar Waßmann
Quoted 13 lines
Hi,
I already sent this to <[email protected]> on Feb. 1, 2012 but did not get any response there. So resending to a wider audience with improved subject line:
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_HANDLEDinstead ofIRQ_WAKE_THREAD, meaning the soft-irq will not be called, the interrupt will remain masked forever.Quoted 4 lines
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.
Isn't it the responsibility of the driver (say TSC2007)?
In this case, TSC2007 should return
IRQ_WAKE_THREADIMHO.Quoted 8 lines
Quoted 4 lines
That would mean it had to return
IRQ_WAKE_THREADunconditionally making the return code useless.
And it would cause an extra useless loop through the softirq handler.Yeah, it's the default behavior when we introduce 'theadirqs', and it's safe.
So, the correct solution would be to remove the check for
IRQ_WAKE_THREADinhandle_irq_event_percpu()and always invoke the softirq handler?
Note that this problem is not specific to the TSC2007 driver, but may occur with any hardware.Or maybe do the unmasking in
handle_irq_event()as proposed by Lars-Peter Clausen in <[email protected]>? Like that:kernel/irq/chip.c +0
-0
kernel/irq/chip.c EXPORT_SYMBOL_GPL(handle_simple_irq); · line 346
Quoted 4 lines
kernel/irq/chip.c +1
-0@@ -343,6 +343,8 @@ EXPORT_SYMBOL_GPL(handle_simple_irq);void handle_level_irq (unsigned int irq,struct irq_desc *desc) { +int ret;
This should be irqreturn_t
Quoted 5 lines
kernel/irq/chip.c +1
-0+raw_spin_lock (&desc->lock);mask_ack_irq (desc);
kernel/irq/chip.c handle_level_irq(unsigned int irq, struct irq_desc *desc) · line 368
Quoted 9 lines
kernel/irq/chip.c +3
-2@@ -360,10 +362,12 @@ 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 ))
As I said, check for the bit, not for the value. This will ensure that will also work with shared interrupts. So something like this:
!((desc->istate & IRQS_ONESHOT) && (ret & IRQ_WAKE_THREAD)))
Quoted 8 lines
kernel/irq/chip.c +1
-0unmask_irq (desc); + out_unlock:raw_spin_unlock (&desc->lock); }Lothar Waßmann
PATCH 1/1 genirq: Fix race condition in ONESHOT irq handler
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.
--- kernel/irq/chip.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
kernel/irq/chip.c +7 -2
@@ -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); }
Signature · 1 line
1.7.2.5
Re: [PATCH] genirq: Fix race condition in ONESHOT irq handler
Quoted 5 lines · Lothar Wa?mann
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_HANDLEDinstead ofIRQ_WAKE_THREAD, meaning the soft-irq
Well, oneshot mode interrupts always had the semantics that the threaded handler needs to run unconditionally. In fact the oneshot mode was implemented to handle hardware which cannot do anything in hard interrupt context to avoid the ugliness of a primary handler calling disable_irq_nosync().
So it looks like driver developers decided that the oneshot mode might be interesting with a primary handler as well. I can see the reason why the tsc2007 driver uses it, but that does not make it a bug in the core code in the first place.
Though we should handle it and the problem not only arises with the IRQ_HANDLED return code, it also arises with IRQ_NONE.
Quoted 6 lines
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.
It should not return IRQ_HANDLED in that case, as the real thing is a spurious interrupt.
Quoted 5 lines
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.
This does not make sense. We acknowledge interrupts via mask_ack_irq() right on entry of handle_level_irq(). So either the interrupt controller is completely hosed or this explanation is bogus.
Quoted 19 lines
Signed-off-by Lothar Wa?mann <[email protected]>--- kernel/irq/chip.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)kernel/irq/chip.c +2
-0@@ -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);
kernel/irq/chip.c handle_level_irq(unsigned int irq, struct irq_desc *desc) · line 369
Quoted 10 lines
kernel/irq/chip.c +4
-2@@ -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 )))
Hmm, that looks ugly and it misses the same fixup for handle_fasteoi_irq() including proper comments.
The following patch should address both cases.
Thanks,
tglx
===================================================================
--- linux-3.2.orig/kernel/irq/chip.c +++ linux-3.2/kernel/irq/chip.c @@ -330,6 +330,24 @@ out_unlock: } EXPORT_SYMBOL_GPL(handle_simple_irq);
+/*
+ * Called unconditionally from handle_level_irq() and only for oneshot
+ * interrupts from handle_fasteoi_irq()
+ */
+static void cond_unmask_irq(struct irq_desc *desc)
+{
+ /*
+ * We need to unmask in the following cases:
+ * - Standard level irq (IRQF_ONESHOT is not set)
+ * - Oneshot irq which did not wake the thread (caused by a
+ * spurious interrupt or a primary handler handling it
+ * completely).
+ */
+ if (!irqd_irq_disabled(&desc->irq_data) &&
+ irqd_irq_masked(&desc->irq_data) && !desc->threads_oneshot)
+ unmask_irq(desc);
+}
+
/**
* handle_level_irq - Level type irq handler
* @irq: the interrupt number
@@ -362,8 +380,8 @@ handle_level_irq(unsigned int irq, struc
handle_irq_event(desc);
- if (!irqd_irq_disabled(&desc->irq_data) && !(desc->istate & IRQS_ONESHOT))
- unmask_irq(desc);
+ cond_unmask_irq(desc);
+
out_unlock:
raw_spin_unlock(&desc->lock);
}
@@ -417,6 +435,9 @@ handle_fasteoi_irq(unsigned int irq, str
preflow_handler(desc); handle_irq_event(desc);
+ if (desc->istate & IRQS_ONESHOT)
+ cond_unmask_irq(desc);
+
out_eoi:
desc->irq_data.chip->irq_eoi(&desc->irq_data);
out_unlock:
Re: [PATCH] genirq: Fix race condition in ONESHOT irq handler
Hi,
Quoted 14 lines · Thomas Gleixner
Quoted 5 lines · Lothar Wa?mann
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_HANDLEDinstead ofIRQ_WAKE_THREAD, meaning the soft-irqWell, oneshot mode interrupts always had the semantics that the threaded handler needs to run unconditionally. In fact the oneshot mode was implemented to handle hardware which cannot do anything in hard interrupt context to avoid the ugliness of a primary handler calling
disable_irq_nosync().
Quoted 5 lines
So it looks like driver developers decided that the oneshot mode might be interesting with a primary handler as well. I can see the reason why the tsc2007 driver uses it, but that does not make it a bug in the core code in the first place.
Then maybe the core code should not check the return value of the primary handler for IRQ_WAKE_THREAD but call the secondary handler unconditionally for ONESHOT interrupts.
Or it should be at least documented somewhere that primary handlers have to return IRQ_WAKE_THREAD in any case for oneshot interrupts.
Quoted 9 lines
Quoted 5 lines
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.
This does not make sense. We acknowledge interrupts via
mask_ack_irq()right on entry ofhandle_level_irq(). So either the interrupt
That's right. But at that point the IRQ line is still asserted and since it is a level IRQ this will not actually clear the interrupt status bit. Normally the IRQ status bit would self-clear when the IRQ line is being deasserted (in this case by removing the finger from the touch panel). But the i.MX28 leaves the IRQ status bit set and it takes another write to the IRQ status register to remove the bogus IRQ status.
Quoted 2 lines
controller is completely hosed or this explanation is bogus.
The first is the case.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
Re: [PATCH] genirq: Fix race condition in ONESHOT irq handler
Quoted 10 lines · Lothar Wa?mann
Quoted 5 lines
So it looks like driver developers decided that the oneshot mode might be interesting with a primary handler as well. I can see the reason why the tsc2007 driver uses it, but that does not make it a bug in the core code in the first place.
Then maybe the core code should not check the return value of the primary handler for
IRQ_WAKE_THREADbut call the secondary handler unconditionally for ONESHOT interrupts.
Or it should be at least documented somewhere that primary handlers have to returnIRQ_WAKE_THREADin any case for oneshot interrupts.
Well, you know how good we are with documentation :)
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
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.
This does not make sense. We acknowledge interrupts via
mask_ack_irq()right on entry ofhandle_level_irq(). So either the interrupt
Quoted 7 lines
That's right. But at that point the IRQ line is still asserted and since it is a level IRQ this will not actually clear the interrupt status bit. Normally the IRQ status bit would self-clear when the IRQ line is being deasserted (in this case by removing the finger from the touch panel). But the i.MX28 leaves the IRQ status bit set and it takes another write to the IRQ status register to remove the bogus IRQ status.
So the question is whether the imx irq chip implementation should write to the status register on unmask for level type irqs to avoid spurious interrupts being generated in the first place. This is not only an optimization for threaded interrupts, afaict this spurious effect should happen with non threaded interrupts as well.
Did my patch work for you ?
Thanks,
tglx
Re: [PATCH] genirq: Fix race condition in ONESHOT irq handler
Hi,
Quoted 18 lines · Thomas Gleixner
Quoted 9 lines · Lothar Wa?mann
Quoted 9 lines
Quoted 5 lines
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.
This does not make sense. We acknowledge interrupts via
mask_ack_irq()right on entry ofhandle_level_irq(). So either the interruptQuoted 7 lines
That's right. But at that point the IRQ line is still asserted and since it is a level IRQ this will not actually clear the interrupt status bit. Normally the IRQ status bit would self-clear when the IRQ line is being deasserted (in this case by removing the finger from the touch panel). But the i.MX28 leaves the IRQ status bit set and it takes another write to the IRQ status register to remove the bogus IRQ status.
Quoted 8 lines
So the question is whether the imx irq chip implementation should write to the status register on unmask for level type irqs to avoid spurious interrupts being generated in the first place. This is not only an optimization for threaded interrupts, afaict this spurious effect should happen with non threaded interrupts as well.
Did my patch work for you ?
Sorry, I couldn't test it earlier. Yes, it works.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________