All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, android-virt@lists.cs.columbia.edu,
	patches@linaro.org
Subject: Re: [Qemu-devel] [Android-virt] [PATCH 02/12] arm: make the number of GIC interrupts configurable
Date: Fri, 27 Jan 2012 11:03:19 +1030	[thread overview]
Message-ID: <87vcnyc7cg.fsf@rustcorp.com.au> (raw)
In-Reply-To: <CAFEAcA_nymqH8waBR_01Dxz_BeE3OL7y5eTQ8_s24ekPp6uNFQ@mail.gmail.com>

On Wed, 25 Jan 2012 15:09:41 +0000, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 24 January 2012 08:42, Rusty Russell <rusty@rustcorp.com.au> wrote:
> > Reading through this, I see a lot of "- 32".  Trivial patch follows,
> > which applies to your rebasing branch:
> 
> (If you send patches as fresh new emails then they just apply
> with git am without needing manual cleanup, appear with sensible
> subjects in patchwork/patches.linaro, etc.)

Indeed, but it's so conversaionally gauche :(  I thought git am did the
Right Thing, but it doesn't, and --scissors doesn't help either (it gets
the wrong Subject line).  Oh well, I'll do it that way in future.

> > Subject: ARM: clean up GIC constants.
> > From: Rusty Russell <rusty@rustcorp.com.au>
> >
> > Interrupts numbers 0-31 are private to the processor interface, 32-1019 are
> > general interrups.  Add GIC_INTERNAL and substitute everywhere.
> >
> > Also, add a check that the total number of interrupts is divisible by
> > 32 (required for reporting interupt numbers, see gic_dist_readb(), and
> > is greater than 32.  And remove a single stray tab.
> 
> I agree with Avi that the presence of "Also" in a git
> commit message is generally a sign you should have submitted
> more than one patch :-)

Indeed, guilty as charged :)

> > Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> > ---
> >  hw/arm_gic.c |   48 ++++++++++++++++++++++++++----------------------
> >  1 files changed, 26 insertions(+), 22 deletions(-)
> >
> > diff --git a/hw/arm_gic.c b/hw/arm_gic.c
> > index cf582a5..a29eacb 100644
> > --- a/hw/arm_gic.c
> > +++ b/hw/arm_gic.c
> > @@ -13,6 +13,8 @@
> >
> >  /* Maximum number of possible interrupts, determined by the GIC architecture */
> >  #define GIC_MAXIRQ 1020
> > +/* First 32 are private to each CPU (SGIs and PPIs). */
> > +#define GIC_INTERNAL 32
> >  //#define DEBUG_GIC
> >
> >  #ifdef DEBUG_GIC
> > @@ -74,7 +76,7 @@ typedef struct gic_irq_state
> >  #define GIC_CLEAR_TRIGGER(irq) s->irq_state[irq].trigger = 0
> >  #define GIC_TEST_TRIGGER(irq) s->irq_state[irq].trigger
> >  #define GIC_GET_PRIORITY(irq, cpu) \
> > -  (((irq) < 32) ? s->priority1[irq][cpu] : s->priority2[(irq) - 32])
> > +  (((irq) < GIC_INTERNAL) ? s->priority1[irq][cpu] : s->priority2[(irq) - GIC_INTERNAL])
> 
> This line is now >80 characters and needs folding.
> (scripts/checkpatch.pl will catch this kind of nit.)

Will do.

> > @@ -812,11 +814,13 @@ static void gic_init(gic_state *s, int num_irq)
> >     s->num_cpu = num_cpu;
> >  #endif
> >     s->num_irq = num_irq + GIC_BASE_IRQ;
> > -    if (s->num_irq > GIC_MAXIRQ) {
> > -        hw_error("requested %u interrupt lines exceeds GIC maximum %d\n",
> > -                 num_irq, GIC_MAXIRQ);
> > +    if (s->num_irq > GIC_MAXIRQ
> > +        || s->num_irq < GIC_INTERNAL
> > +        || (s->num_irq % 32) != 0) {
> 
> So I guess our implementation isn't likely to work properly for a
> non-multiple-of-32 number of IRQs, but this isn't an architectural GIC
> restriction. (In fact the GIC architecture spec allows the supported
> interrupt IDs to not even be in a contiguous range, which we certainly
> don't support...)

Yes, I intuited it from here:

static uint32_t gic_dist_readb(void *opaque, target_phys_addr_t offset)
{
...
        if (offset == 4)
            return ((s->num_irq / 32) - 1) | ((NUM_CPU(s) - 1) << 5);

If want want to support non-32-divisible # irqs, we need at least:

        ((s->num_irq + 31) / 32 - 1)

Seemed easier to have an initialization-time assert than check
everywhere else for overflows.

> I also think it's architecturally permitted that not all the internal
> (SPI/PPI) interrupts are implemented, ie that s->num_irq < 32 (you
> have to read the GIC architecture manually quite closely to deduce
> this, though).

This made me read that part of the manual... interesting.

> Anyway, if we would otherwise die horribly later on we should
> catch these cases, but it would be good to have at least a comment
> saying that these are implementation limitations rather than
> architectural ones.

Good point.  If we add an "supported" bit to each irq, we could do weird
things, but presumably ->num_irq would still correspond to
ITLinesNumber.

I don't want to put too much of an essay in there.  How's this:

        /* ITLinesNumber is represented as (N - 32) / 1.  See
          gic_dist_readb. */
        if (s->num_irq < 32 || (s->num_irq % 32)) {
                hw_error("%u interrupt lines unsupported: not divisible by 32\n",
                         num_irq);
                

> Beefing up the parameter check should be a separate patch.

Thanks, coming soon.

I should be getting access to git.linaro.org RSN, so I can post there
for easier merging.

Thanks,
Rusty.

  reply	other threads:[~2012-01-27  0:34 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-13 20:52 [Qemu-devel] [PATCH 00/12] Add support for Cortex-A15 and vexpress-a15 Peter Maydell
2012-01-13 20:52 ` [Qemu-devel] [PATCH 01/12] vexpress, realview: Add (dummy) L2 cache controller Peter Maydell
2012-01-13 20:52 ` [Qemu-devel] [PATCH 02/12] arm: make the number of GIC interrupts configurable Peter Maydell
2012-01-24  8:42   ` [Qemu-devel] [Android-virt] " Rusty Russell
2012-01-25 15:09     ` Peter Maydell
2012-01-27  0:33       ` Rusty Russell [this message]
2012-01-27  9:01         ` Peter Maydell
2012-02-19 23:06         ` [Qemu-devel] [PATCH 1/2] arm: clean up GIC constants Rusty Russell
2012-02-20 17:27           ` Peter Maydell
2012-02-21  2:33             ` Rusty Russell
2012-02-21 12:42               ` Peter Maydell
2012-02-19 23:07         ` [Qemu-devel] [PATCH] arm: make sure that number of irqs can be represented in GICD_TYPER Rusty Russell
2012-02-19 23:40           ` [Qemu-devel] [Android-virt] " Christoffer Dall
2012-02-20  3:52             ` Rusty Russell
2012-02-20  3:53             ` [Qemu-devel] [PATCH 3/2] " Rusty Russell
2012-02-21  2:33   ` [Qemu-devel] [PATCH 2/2] " Rusty Russell
2012-02-21 12:42     ` Peter Maydell
2012-01-13 20:52 ` [Qemu-devel] [PATCH 03/12] hw/arm_boot.c: Make SMP boards specify address to poll in bootup loop Peter Maydell
2012-01-16  1:56   ` [Qemu-devel] [Android-virt] " Alexander Graf
2012-01-16  8:31     ` Peter Maydell
2012-01-16 23:31       ` andrzej zaborowski
2012-01-16 23:41         ` Peter Maydell
2012-01-17  1:16   ` [Qemu-devel] " andrzej zaborowski
2012-01-13 20:52 ` [Qemu-devel] [PATCH 04/12] hw/vexpress.c: Make motherboard peripheral memory map table-driven Peter Maydell
2012-01-13 20:52 ` [Qemu-devel] [PATCH 05/12] hw/vexpress.c: Move secondary CPU boot code to SRAM Peter Maydell
2012-01-13 20:52 ` [Qemu-devel] [PATCH 06/12] hw/vexpress.c: Factor out daughterboard-specific initialization Peter Maydell
2012-01-13 20:52 ` [Qemu-devel] [PATCH 07/12] hw/vexpress.c: Instantiate the motherboard CLCD Peter Maydell
2012-01-13 20:52 ` [Qemu-devel] [PATCH 08/12] hw/a15mpcore.c: Add Cortex-A15 private peripheral model Peter Maydell
2012-01-13 20:52 ` [Qemu-devel] [PATCH 09/12] Add dummy implementation of generic timer cp15 registers Peter Maydell
2012-01-13 20:52 ` [Qemu-devel] [PATCH 10/12] Add Cortex-A15 CPU definition Peter Maydell
2012-01-23 18:12   ` [Qemu-devel] [Android-virt] " Peter Maydell
2012-01-24  7:59   ` [Qemu-devel] " Andreas Färber
2012-01-24  8:33     ` Peter Maydell
2012-01-13 20:52 ` [Qemu-devel] [PATCH 11/12] arm_boot: Pass base address of GIC CPU interface, not whole GIC Peter Maydell
2012-01-13 20:52 ` [Qemu-devel] [PATCH 12/12] hw/vexpress.c: Add vexpress-a15 machine Peter Maydell
2012-01-13 20:57 ` [Qemu-devel] [PATCH 00/12] Add support for Cortex-A15 and vexpress-a15 Peter Maydell
2012-01-15 22:56   ` [Qemu-devel] [Android-virt] " Christoffer Dall
2012-01-17 19:08     ` Peter Maydell
2012-01-27 10:28       ` 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=87vcnyc7cg.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=android-virt@lists.cs.columbia.edu \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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 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.