From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Nicolas DET <nd@bplan-gmbh.de>
Cc: linuxppc-dev@ozlabs.org, sl@bplan-gmbh.de, sha@pengutronix.de,
	linuxppc-embedded@ozlabs.org
Subject: Re: [PATCH 1/2] Add MPC52xx Interrupt controller support for ARCH=powerpc
Date: Tue, 31 Oct 2006 15:27:10 +1100	[thread overview]
Message-ID: <1162268830.25682.271.camel@localhost.localdomain> (raw)
In-Reply-To: <200610292310.k9TNAHXZ013852@post.webmailer.de>
On Mon, 2006-10-30 at 00:10 +0100, Nicolas DET wrote:
> +/*
> + * void call to be used for .ack in the irq_chip_ops
> + * indeed, some of our irq does noy need ack
> + * but the kernel call .ack if it's valid or not
> +*/
> +
> +static void mpc52xx_voidfunc(unsigned int virq)
> +{
> +#ifdef DEBUG
> +       int irq;
> +       int l2irq;
> +
> +       irq = irq_map[virq].hwirq;
> +       l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
> +
> +       pr_debug("%s: irq=%x, l2=%d\n", __func__, irq, l2irq);
> +#endif
> +}
As I said on IRC, we might be able to get away without that one, but
that's not urgent.
> +       irq = irq_map[virq].hwirq;
> +       l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
> +
> +       pr_debug("%s: irq=%x, l2=%d\n", __func__, irq, l2irq);
> +
> +       if (l2irq != 0)
> +               BUG();
Use BUG_ON(l2irq != 0); instead, generates better code (though I don't
think you really need to keep those checks once you've verified things
work fine).
> +       val = in_be32(&intr->ctrl);
> +       val &= ~(1 << 11);
> +       out_be32(&intr->ctrl, val);
> +}
>From the above, I deduce there is only one possible crit interrupt
right ? Also, it looks a lot, from the rest of the code that it's
basically just "main irq" 0, so why do you do two different L2's for
it ?
In fact, I'm a bit dubious of the way you differenciated "mainirq" and
"main" by giving them the same L2 number while they have different chips
and register sets... that seems to defeat the whole purpose of having
the L2 in the first place don't you think ?
I would have rather an L2 for CRIT + "IRQMAIN" thing (that is interrupts
using intr->ctrl bits 11 and below, I'll let you find a nice "name" for
it, maybe EXTIRQ ? (external irq), then a level for "MAIN" using
intr->main_mask etc... 
> +       case MPC52xx_IRQ_L1_CRIT:
> +               pr_debug("%s: Critical. l2=%x\n", __func__, l2irq);
> +
> +               if (l2irq != 0)
> +                       BUG();
> +
> +               type = mpc52xx_irqx_gettype(l2irq);
> +               good_irqchip = &mpc52xx_crit_irqchip;
> +               break;
> +
> +       case MPC52xx_IRQ_L1_MAIN:
> +               pr_debug("%s: Main IRQ[1-3] l2=%x\n", __func__, l2irq);
> +
> +               if ((l2irq >= 0) && (l2irq <= 3)) {
> +                       type = mpc52xx_irqx_gettype(l2irq);
> +                       good_irqchip = &mpc52xx_mainirq_irqchip;
> +               } else {
> +                       good_irqchip = &mpc52xx_main_irqchip;
> +               }
> +               break;
See my comment above... Also, the only ones that can be edge are the
ones using intr->ctrl, thus if you do things right, you don't need your
fake ack, just only provide an ack for these. For the others, provide an
ack&mask that just masks :) (Though it's debateable wether we should
make the generic ack&mask test for ack beeing NULL indeed, I'll talk to
thomas about it).
> +       case MPC52xx_IRQ_L1_PERP:
> +               pr_debug("%s: Peripherals. l2=%x\n", __func__, l2irq);
> +               good_irqchip = &mpc52xx_periph_irqchip;
> +               break;
> +
> +       case MPC52xx_IRQ_L1_SDMA:
> +               pr_debug("%s: SDMA. l2=%x\n", __func__, l2irq);
> +               good_irqchip = &mpc52xx_sdma_irqchip;
> +               break;
> +
> +       set_irq_chip_and_handler(virq, good_irqchip, good_handle);
> +       set_irq_type(virq, type);
set_irq_type() does nothing if you haven't hooked a set_type callback to
your irq_chip and none of yours does so just drop it for now and look at
how this is done in mpic or ipic. If you actually want to implement
proper set_type (which you might need to do if you want that code to
work without having the firmware pre-initialize interrupts with the
right type at boot), you probably want to set the handler in
set_irq_type().
next prev parent reply	other threads:[~2006-10-31  4:27 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-29 23:10 [PATCH 1/2] Add MPC52xx Interrupt controller support for ARCH=powerpc Nicolas DET
2006-10-30 17:37 ` Dale Farnsworth
2006-10-30 17:47 ` Dale Farnsworth
2006-10-30 23:18   ` Sylvain Munaut
2006-10-31  7:10   ` Nicolas DET
2006-10-30 22:25 ` Kumar Gala
2006-10-30 22:31   ` Benjamin Herrenschmidt
2006-10-30 23:15   ` Sylvain Munaut
2006-10-31  1:11     ` Kumar Gala
2006-10-31  6:59       ` Sylvain Munaut
2006-10-31  7:05         ` Benjamin Herrenschmidt
2006-10-31  7:14   ` Nicolas DET
2006-10-31  7:38     ` Benjamin Herrenschmidt
2006-10-31  8:25       ` Nicolas DET
2006-10-31  8:42         ` Benjamin Herrenschmidt
2006-10-31  9:08           ` Nicolas DET
2006-10-31 20:04             ` Nicolas DET
2006-10-31 21:59               ` Benjamin Herrenschmidt
2006-10-31 22:08                 ` Grant Likely
2006-10-31 22:11                   ` Benjamin Herrenschmidt
2006-10-31 23:08                     ` Grant Likely
2006-11-01  1:06                       ` Benjamin Herrenschmidt
2006-11-01  9:24                 ` Nicolas DET
2006-11-01 20:56                   ` Benjamin Herrenschmidt
2006-10-31 14:34           ` Kumar Gala
2006-10-31 16:24     ` Grant Likely
2006-10-31  4:27 ` Benjamin Herrenschmidt [this message]
2006-10-31  7:09   ` Nicolas DET
2006-10-31  7:21     ` Benjamin Herrenschmidt
2006-10-31  7:49       ` Nicolas DET
2006-10-31  7:58         ` Benjamin Herrenschmidt
2006-10-31  8:28           ` Nicolas DET
2006-10-31  8:44             ` Benjamin Herrenschmidt
2006-10-31  9:04               ` Nicolas DET
2006-10-31  9:07                 ` Benjamin Herrenschmidt
2006-10-31  9:46                   ` Nicolas DET
2006-10-31 20:29                     ` Benjamin Herrenschmidt
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=1162268830.25682.271.camel@localhost.localdomain \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=linuxppc-embedded@ozlabs.org \
    --cc=nd@bplan-gmbh.de \
    --cc=sha@pengutronix.de \
    --cc=sl@bplan-gmbh.de \
    /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).