From: Ian Campbell <Ian.Campbell@citrix.com>
To: Julien Grall <julien.grall@linaro.org>
Cc: xen-devel@lists.xenproject.org, stefano.stabellini@citrix.com,
tim@xen.org, parth.dixit@linaro.org, christoffer.dall@linaro.org
Subject: Re: [PATCH v2 2/3] xen/arm: vgic: Keep track of vIRQ used by a domain
Date: Mon, 19 Jan 2015 16:28:56 +0000 [thread overview]
Message-ID: <1421684936.10440.142.camel@citrix.com> (raw)
In-Reply-To: <54BD2D7C.70204@linaro.org>
On Mon, 2015-01-19 at 16:14 +0000, Julien Grall wrote:
> >> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> >> index b272d86..1a8b3cd 100644
> >> --- a/xen/arch/arm/vgic.c
> >> +++ b/xen/arch/arm/vgic.c
> >> @@ -110,6 +110,15 @@ int domain_vgic_init(struct domain *d)
> >>
> >> d->arch.vgic.handler->domain_init(d);
> >>
> >> + d->arch.vgic.allocated_irqs =
> >> + xzalloc_array(unsigned long, BITS_TO_LONGS(vgic_num_irqs(d)));
> >> + if ( !d->arch.vgic.allocated_irqs )
> >> + return -ENOMEM;
> >> +
> >> + /* vIRQ0-15 (SGIs) are reserved */
> >> + for ( i = 0; i <= 15; i++ )
> >
> > ... ; i < NR_GIC_SGI; ...
>
> I don't really like the idea to use NR_GIC_SGI here. You are assuming
> that SGI is always start from 0.
I think that's pretty much architectural in the GIC.
> I will introduce GIC_SGI_FIRST, GIC_SGI_END and maybe the same for
> PPIs/SPIs.
If GICvN in the future doesn't have SGI_FIRST == 0 then having these
macros in place isn't going to appreciably reduce the amount of stuff
which needs doing, it'll the least of your worries I think..
> > In any case rather than goto can you use a while loop or some other
> > proper looping construct please, something like this ought to work:
> >
> > virq = first
> > while ( (virq = find_next...) < end )
> > {
> > if ( test_and_set... )
> > return virq;
> > first = virq; /* +1 ? */
> > }
> >
> > or perhaps:
> >
> > for ( virq = first ; virq = find... ; first = virq )
> > {
> > ....
> > }
> >
> > I think you might also be able combine virq and first into a single
> > variable? Unless always searching from the beginning is a feature?
>
> The goal was to avoid race condition with vgic_reserver_virq. In second
> though, we could also avoid to retry ad the raise condition would happen
> in very rare case.
If it is merely rare, rather than impossible, then the code should
handle the possibility not punt it to the caller.
Ian.
next prev parent reply other threads:[~2015-01-19 16:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-15 20:23 [PATCH v2 0/3] Find automatically a PPI for the DOM0 event channel IRQ Julien Grall
2015-01-15 20:23 ` [PATCH v2 1/3] xen/arm: vgic: Rename nr_lines into nr_spis Julien Grall
2015-01-19 17:00 ` Ian Campbell
2015-01-20 13:41 ` Julien Grall
2015-01-15 20:23 ` [PATCH v2 2/3] xen/arm: vgic: Keep track of vIRQ used by a domain Julien Grall
2015-01-19 15:55 ` Ian Campbell
2015-01-19 16:14 ` Julien Grall
2015-01-19 16:28 ` Ian Campbell [this message]
2015-01-15 20:23 ` [PATCH v2 3/3] xen/arm: Find automatically a PPI for the DOM0 event channel interrupt Julien Grall
2015-01-19 16:04 ` Ian Campbell
2015-01-19 16:19 ` Julien Grall
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=1421684936.10440.142.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=christoffer.dall@linaro.org \
--cc=julien.grall@linaro.org \
--cc=parth.dixit@linaro.org \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.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.