From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Jeremy Fitzhardinge <Jeremy.Fitzhardinge@citrix.com>,
"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH] xen: use PHYSDEVOP_get_free_pirq to implement find_unbound_pirq
Date: Mon, 22 Nov 2010 11:14:33 -0500 [thread overview]
Message-ID: <20101122161433.GC20383@dumpdata.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1011200115240.2373@kaball-desktop>
On Sat, Nov 20, 2010 at 01:19:31AM +0000, Stefano Stabellini wrote:
> On Fri, 19 Nov 2010, Konrad Rzeszutek Wilk wrote:
> > On Fri, Nov 19, 2010 at 01:58:03PM +0000, Stefano Stabellini wrote:
> > > Use PHYSDEVOP_get_free_pirq to implement find_unbound_pirq
> > >
> > > Use the new hypercall PHYSDEVOP_get_free_pirq to ask Xen to allocate a
> > > pirq. Remove the unsupported PHYSDEVOP_get_nr_pirqs hypercall to get the
> > > amount of pirq available.
> > >
> > > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > >
> > > diff --git a/drivers/xen/events.c b/drivers/xen/events.c
> > > index 321a0c8..ffd286e 100644
> > > --- a/drivers/xen/events.c
> > > +++ b/drivers/xen/events.c
> > > @@ -382,12 +382,17 @@ static int get_nr_hw_irqs(void)
> > > return ret;
> > > }
> > >
> > > -/* callers of this function should make sure that PHYSDEVOP_get_nr_pirqs
> > > - * succeeded otherwise nr_pirqs won't hold the right value */
> > > -static int find_unbound_pirq(void)
> > > +static int find_unbound_pirq(int type)
> > > {
> > > - int i;
> > > - for (i = nr_pirqs-1; i >= 0; i--) {
> > > + int rc, i;
> > > + struct physdev_get_free_pirq op_get_free_pirq;
> > > + op_get_free_pirq.type = type;
> > > +
> > > + rc = HYPERVISOR_physdev_op(PHYSDEVOP_get_free_pirq, &op_get_free_pirq);
> > > + if (!rc)
> > > + return op_get_free_pirq.pirq;
> > > +
> > > + for (i = 16; i <= nr_pirqs-1; i++) {
> >
> > 16? No no. Why not re-use the old loop, like so:
> >
> > for (i = nr_pirqs-1; i >= 0; i--) {
> >
>
> Because we don't know the real nr_pirqs anymore (PHYSDEVOP_get_nr_pirqs
> has been removed), so it is highly possible that starting from the top
> down would give us pirq numbers out of range in Xen. Therefore we need
> to start from the bottom up, and the bottom for Xen is 16.
Right, I forgot about the hypercall call. How about using LEGACY_IRQ instead then?
>
>
> > > if (pirq_to_irq[i] < 0)
> > > return i;
> > > }
> > > @@ -669,7 +674,7 @@ void xen_allocate_pirq_msi(char *name, int *irq, int *pirq)
> > > if (*irq == -1)
> > > goto out;
> > >
> > > - *pirq = find_unbound_pirq();
> > > + *pirq = find_unbound_pirq(MAP_PIRQ_TYPE_MSI);
> > > if (*pirq == -1)
> > > goto out;
> > >
> > > @@ -1504,23 +1509,12 @@ void xen_callback_vector(void) {}
> > > void __init xen_init_IRQ(void)
> > > {
> > > int i, rc;
> > > - struct physdev_nr_pirqs op_nr_pirqs;
> > >
> > > cpu_evtchn_mask_p = kcalloc(nr_cpu_ids, sizeof(struct cpu_evtchn_s),
> > > GFP_KERNEL);
> > > irq_info = kcalloc(nr_irqs, sizeof(*irq_info), GFP_KERNEL);
> > >
> > > - rc = HYPERVISOR_physdev_op(PHYSDEVOP_get_nr_pirqs, &op_nr_pirqs);
> > > - if (rc < 0) {
> > > - nr_pirqs = nr_irqs;
> > > - if (rc != -ENOSYS)
> > > - printk(KERN_WARNING "PHYSDEVOP_get_nr_pirqs returned rc=%d\n", rc);
> > > - } else {
> > > - if (xen_pv_domain() && !xen_initial_domain())
> > > - nr_pirqs = max((int)op_nr_pirqs.nr_pirqs, nr_irqs);
> > > - else
> > > - nr_pirqs = op_nr_pirqs.nr_pirqs;
> > > - }
> > > + nr_pirqs = nr_irqs;
> >
> > Why not just get rid of nr_pirgs altogether then? And use 'nr_irqs' instead?
> >
>
> Yeah, I guess we could do that. I kept it around just to make it more
> obvious that the max pirq number is different from nr_irqs and we don't
> know what the exact value is.
But with this change it is the same, is it not?
"nr_pirgs = nr_irqs;"
Or when you say "max pirq" you are referring to something else altogether?
next prev parent reply other threads:[~2010-11-22 16:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-19 13:58 [PATCH] xen: use PHYSDEVOP_get_free_pirq to implement find_unbound_pirq Stefano Stabellini
2010-11-19 16:23 ` Konrad Rzeszutek Wilk
2010-11-20 1:19 ` Stefano Stabellini
2010-11-22 16:14 ` Konrad Rzeszutek Wilk [this message]
2010-11-23 12:55 ` Stefano Stabellini
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=20101122161433.GC20383@dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=Jeremy.Fitzhardinge@citrix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/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