All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: "Lothar Waßmann" <LW@KARO-electronics.de>
Cc: linux-kernel@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>,
	Yong Zhang <yong.zhang0@gmail.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] genirq: Fix race condition in ONESHOT irq handler
Date: Wed, 8 Feb 2012 11:38:18 +0100 (CET)	[thread overview]
Message-ID: <alpine.LFD.2.02.1202081123390.2794@ionos> (raw)
In-Reply-To: <20274.4237.63380.338503@ipc1.ka-ro>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1956 bytes --]

On Wed, 8 Feb 2012, Lothar Waßmann wrote:
> > 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.

Well, you know how good we are with documentation :)
 
> > > 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
> > 
> 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

WARNING: multiple messages have this Message-ID (diff)
From: tglx@linutronix.de (Thomas Gleixner)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] genirq: Fix race condition in ONESHOT irq handler
Date: Wed, 8 Feb 2012 11:38:18 +0100 (CET)	[thread overview]
Message-ID: <alpine.LFD.2.02.1202081123390.2794@ionos> (raw)
In-Reply-To: <20274.4237.63380.338503@ipc1.ka-ro>

On Wed, 8 Feb 2012, Lothar Wa?mann wrote:
> > 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.

Well, you know how good we are with documentation :)
 
> > > 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
> > 
> 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

  reply	other threads:[~2012-02-08 10:38 UTC|newest]

Thread overview: 24+ 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  8:14 ` =?utf-8?Q?Lothar_Wa=C3=9Fmann?=
2012-02-06 10:42 ` Lars-Peter Clausen
2012-02-06 10:42   ` Lars-Peter Clausen
2012-02-07  9:03 ` Yong Zhang
2012-02-07  9:03   ` Yong Zhang
2012-02-07 10:01   ` Lothar Waßmann
2012-02-07 10:01     ` Lothar Waßmann
2012-02-07 12:34     ` Yong Zhang
2012-02-07 12:34       ` Yong Zhang
2012-02-07 12:52       ` Lothar Waßmann
2012-02-07 12:52         ` Lothar Waßmann
2012-02-07 13:07         ` Lars-Peter Clausen
2012-02-07 13:07           ` Lars-Peter Clausen
2012-02-07 13:38           ` [PATCH] genirq: Fix race condition in ONESHOT irq handler Lothar Waßmann
2012-02-07 13:38             ` Lothar Waßmann
2012-02-07 17:03             ` Thomas Gleixner
2012-02-07 17:03               ` Thomas Gleixner
2012-02-08  6:05               ` Lothar Waßmann
2012-02-08  6:05                 ` Lothar Waßmann
2012-02-08 10:38                 ` Thomas Gleixner [this message]
2012-02-08 10:38                   ` Thomas Gleixner
2012-02-09  8:40                   ` Lothar Waßmann
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=alpine.LFD.2.02.1202081123390.2794@ionos \
    --to=tglx@linutronix.de \
    --cc=LW@KARO-electronics.de \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.