From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Laurent Pinchart <laurentp@cse-semaphore.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: Interrupt handling documentation
Date: Tue, 18 Mar 2008 07:44:05 +1100 [thread overview]
Message-ID: <1205786645.26869.178.camel@pasglop> (raw)
In-Reply-To: <200803171713.51671.laurentp@cse-semaphore.com>
On Mon, 2008-03-17 at 17:13 +0100, Laurent Pinchart wrote:
> The PIC I am working with is linked to a falling-edge external irq on the
> CPM2. When the first PIC interrupt was generated the kernel called the PIC
> chained irq handler endlessly.
>
> After some investigation it turned out the external interrupt bit in the CPM2
> interrupt pending register never got cleared. set_irq_chained_handler()
> registers the chained irq handler at the lowest level in the irq stack,
> bypassing all the interrupt acknowledgement/masking logic.
Yes, exactly. To answer a previous question in the thread, the reason
there are two approaches to cascades is just that:
- The "easy" approach using setup_irq(). The normal interrupt handling
is done for the cascade, it's masked/acked/whatever-is-needed as any
other interrupt before the second interrupt is fetched. This results
is slightly more kernel stack usage and overhead in getting to the
second interrupt, among other things, but is easier.
- The "fast" approach using a chained handler. This, as you noticed,
bypass pretty much the whole stack and calls the chain handler directly.
That means that your chain handler is responsible to perform all the
necessary things to ensure the cascade interrupt is properly ack'ed
etc...
> The fix was easy, all I had to do was to call desc->chip->ack(irq) at the
> beginning on the chained irq handler and desc->chip->eoi(irq) at the end.
For an edge cascade, that would do, I suppose. But beware that if you
are only calling ack() and not mask(), then a subsequent chain interrupt
from the same cascade can (and will) potentially happen while you are
calling the handler as the cascade itself has been ack'ed and not
masked. In the case of cpm2, that also probably means you don't need to
call end().
That might be fine though, but it increases the chances of having of
stack overflows caused by interrupts stacking up.
> However, I'm wondering if this really belongs in the PIC code, or if PICs
> shouldn't be registered at a higher level (setup_irq or even request_irq) so
> that they would reuse the handle_*_irq handlers. Any opinion on this ?
They can. The chain handling mechanism is an optimisation. It avoids a
spinlock and other bits & pieces which improve performance & latency of
handling cascaded interrupts, at the expense of that added complexity.
Ben.
prev parent reply other threads:[~2008-03-17 20:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-11 10:58 Interrupt handling documentation Laurent Pinchart
2008-03-12 0:51 ` Michael Ellerman
2008-03-13 13:56 ` Laurent Pinchart
2008-03-17 16:13 ` Laurent Pinchart
2008-03-17 20:44 ` Benjamin Herrenschmidt [this message]
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=1205786645.26869.178.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=laurentp@cse-semaphore.com \
--cc=linuxppc-dev@ozlabs.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;
as well as URLs for NNTP newsgroup(s).