From: tglx@linutronix.de (Thomas Gleixner)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] genirq: Add support for priority-drop/deactivate interrupt controllers
Date: Tue, 28 Oct 2014 21:14:40 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.11.1410282054490.5308@nanos> (raw)
In-Reply-To: <544FF183.9030705@arm.com>
On Tue, 28 Oct 2014, Marc Zyngier wrote:
> On 28/10/14 15:32, Thomas Gleixner wrote:
> > Let me make a few assumptions and correct me if I'm wrong as usual.
> >
> > 1) The startup/shutdown procedure for such an interrupt is the
> > expensive mask/unmask which you want to avoid for the actual
> > handling case
>
> Indeed.
>
> > 2) In case of an actual interrupt the flow (ignoring locking) is:
> >
> > handle_xxx_irq()
> >
> > mask_irq(); /* chip->irq_mask() maps to EOI */
> >
> > if (!action || irq_disabled())
> > return;
> >
> > handle_actions();
> >
> > if (irq_threads_active() || irq_disabled())
> > return;
> >
> > unmask_irq(); /* chip->irq_unmask() maps to DIR */
> >
> > So that is handle_level_irq() with the chip callbacks being:
> >
> > irq_startup = gic_unmask
> > irq_shutdown = gic_mask
> > irq_unmask = gic_dir
> > irq_mask = gic_eoi
>
> So while this works really well for the interrupt handling part, it will
> break [un]mask_irq(). This is because you can only write to EOI for an
> interrupt that you have ACKed just before (anything else and the GIC
> state machine goes crazy). Basically, any use for EOI/DIR outside of the
> interrupt context itself (hardirq or thread) is really dangerous.
I really doubt that the DIR invocation is dangerous outside of
interrupt context. Otherwise your threaded scheme would not work at
all as the DIR invocation happens in thread context.
The nice thing about the lazy irq disable code is that the irq_mask(),
i.e. EOI, invocation actually happens always in hard interrupt
context. We should never invoke irq_mask() from any other context if
you supply a startup/shutdown function.
> If we had a flag like IRQCHIP_UNMASK_IS_STARTUP, we could distinguish
> this particular case, but that's borderline ugly.
Indeed. But I don't think it is required. See also below.
> > 4) In the lazy irq disable case if the interrupt fires mask_irq()
> > [EOI] is good enough to silence it.
> >
> > Though in the enable_irq() case you cannot rely on the automatic
> > resend of the interrupt when you unmask [DIR]. So we need to make
> > sure that even in the level case (dunno whether that's supported in
> > that mode) we end up calling the irq_retrigger() callback. But
> > that's rather simple to achieve with a new chip flag.
>
> I think this one breaks for the same reason as above. And an interrupt
> masked with EOI cannot easily be restarted without clearing the ACTIVE
> bit (and everything becomes even more of a complete madness).
So we already established that irq_mask()/EOI will only be called from
the actual interrupt context and irq_unmask()/DIR must be safe to be
called from any context in order to make the EOI/DIR based threaded
optimization work.
So the only interesting code path is enable_irq() which invokes
irq_enable() and then the resend/retrigger machinery.
irq_enable() calls chip->irq_unmask(), i.e. DIR. So that clears the
ACTIVE bit and then the IRQ either gets resent by hardware (in case of
level as the device interrupt is still active) or retriggered by the
irq_retrigger() callback.
I might be wrong as usual, but if there is any restriction on DIR
versus the invocation context, your whole optimization scheme is hosed
anyway.
Thanks
tglx
next prev parent reply other threads:[~2014-10-28 20:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-25 11:06 [PATCH 0/3] genirq: Add support for "split-EOI" irqchips Marc Zyngier
2014-10-25 11:06 ` [PATCH 1/3] genirq: Add support for priority-drop/deactivate interrupt controllers Marc Zyngier
2014-10-25 20:27 ` Thomas Gleixner
2014-10-25 20:40 ` Thomas Gleixner
2014-10-27 15:42 ` Marc Zyngier
2014-10-28 15:32 ` Thomas Gleixner
2014-10-28 19:41 ` Marc Zyngier
2014-10-28 20:14 ` Thomas Gleixner [this message]
2014-10-29 10:11 ` Marc Zyngier
2014-10-29 10:26 ` Thomas Gleixner
2014-10-30 14:15 ` Marc Zyngier
2014-10-30 15:59 ` Thomas Gleixner
2014-10-25 11:06 ` [PATCH 2/3] irqchip: GIC: Convert to EOImode == 1 Marc Zyngier
2014-10-25 11:06 ` [PATCH 3/3] irqchip: GICv3: " Marc Zyngier
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.DEB.2.11.1410282054490.5308@nanos \
--to=tglx@linutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
/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