From: Greg Kurz <groug@kaod.org>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: David Gibson <david@gibson.dropbear.id.au>,
qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
qemu-s390x@nongnu.org, Alexey Kardashevskiy <aik@ozlabs.ru>,
Michael Roth <mdroth@linux.vnet.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
David Hildenbrand <david@redhat.com>,
Cornelia Huck <cohuck@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Dmitry Fleytman <dmitry.fleytman@gmail.com>,
Thomas Huth <thuth@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 05/19] spapr: Set irq type in a dedicated function
Date: Sun, 20 Jan 2019 15:31:21 +0100 [thread overview]
Message-ID: <20190120153121.1af80747@bahia.lan> (raw)
In-Reply-To: <161148b8-e998-2551-4c7e-20be1b245aab@kaod.org>
On Fri, 18 Jan 2019 13:34:39 +0100
Cédric Le Goater <clg@kaod.org> wrote:
> On 1/17/19 6:14 PM, Greg Kurz wrote:
> > PHB hotplug will need to set the type of all LSIs at machine init.
> >
> > Prepare for that by moving the behaviour of setting the type from
> > spapr_irq_claim() to a separate spapr_irq_set_type() function. Have
> > all the callers of spapr_irq_claim() to also call the new function.
> >
> > There's no such need of separating allocation and type setting for
> > MSIs, so this introduces a convenient spapr_irq_claim_msi() function
> > for MSI users.
>
> I would make LSI the special case instead.
>
Well... LSI is the special case in the sense it calls two distinct
functions to have the job done instead of one for MSI. :)
But anyway I'm likely to try another approach in v4.
> C.
>
>
> > Wire all this to the existing backends.
> >
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > ---
> > hw/ppc/spapr_events.c | 4 +--
> > hw/ppc/spapr_irq.c | 59 ++++++++++++++++++++++++++++++++++++--------
> > hw/ppc/spapr_pci.c | 5 ++--
> > hw/ppc/spapr_vio.c | 2 +
> > include/hw/ppc/spapr_irq.h | 7 ++++-
> > 5 files changed, 59 insertions(+), 18 deletions(-)
> >
> > diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
> > index b9c7ecb9e987..777a70842acc 100644
> > --- a/hw/ppc/spapr_events.c
> > +++ b/hw/ppc/spapr_events.c
> > @@ -713,7 +713,7 @@ void spapr_events_init(sPAPRMachineState *spapr)
> > epow_irq = spapr_irq_findone(spapr, &error_fatal);
> > }
> >
> > - spapr_irq_claim(spapr, epow_irq, false, &error_fatal);
> > + spapr_irq_claim(spapr, epow_irq, &error_fatal);
> >
> > QTAILQ_INIT(&spapr->pending_events);
> >
> > @@ -737,7 +737,7 @@ void spapr_events_init(sPAPRMachineState *spapr)
> > hp_irq = spapr_irq_findone(spapr, &error_fatal);
> > }
> >
> > - spapr_irq_claim(spapr, hp_irq, false, &error_fatal);
> > + spapr_irq_claim_msi(spapr, hp_irq, &error_fatal);
> >
> > spapr_event_sources_register(spapr->event_sources, EVENT_CLASS_HOT_PLUG,
> > hp_irq);
> > diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
> > index bcd816c5a5fb..396dd09bdbe0 100644
> > --- a/hw/ppc/spapr_irq.c
> > +++ b/hw/ppc/spapr_irq.c
> > @@ -125,8 +125,7 @@ error:
> > error_propagate(errp, local_err);
> > }
> >
> > -static int spapr_irq_claim_xics(sPAPRMachineState *spapr, int irq, bool lsi,
> > - Error **errp)
> > +static int spapr_irq_claim_xics(sPAPRMachineState *spapr, int irq, Error **errp)
> > {
> > ICSState *ics = spapr->ics;
> >
> > @@ -142,11 +141,20 @@ static int spapr_irq_claim_xics(sPAPRMachineState *spapr, int irq, bool lsi,
> > return -1;
> > }
> >
> > - ics_set_irq_type(ics, irq - ics->offset, lsi);
> > ics_claim_irq(ics, irq - ics->offset);
> > return 0;
> > }
> >
> > +static void spapr_irq_set_type_xics(sPAPRMachineState *spapr, int irq, bool lsi)
> > +{
> > + ICSState *ics = spapr->ics;
> > +
> > + assert(ics);
> > + assert(ics_valid_irq(ics, irq));
> > +
> > + ics_set_irq_type(ics, irq - ics->offset, lsi);
> > +}
> > +
> > static void spapr_irq_free_xics(sPAPRMachineState *spapr, int irq, int num)
> > {
> > ICSState *ics = spapr->ics;
> > @@ -245,6 +253,7 @@ sPAPRIrq spapr_irq_xics = {
> >
> > .init = spapr_irq_init_xics,
> > .claim = spapr_irq_claim_xics,
> > + .set_type = spapr_irq_set_type_xics,
> > .free = spapr_irq_free_xics,
> > .qirq = spapr_qirq_xics,
> > .print_info = spapr_irq_print_info_xics,
> > @@ -292,17 +301,20 @@ static void spapr_irq_init_xive(sPAPRMachineState *spapr, Error **errp)
> > spapr_xive_hcall_init(spapr);
> > }
> >
> > -static int spapr_irq_claim_xive(sPAPRMachineState *spapr, int irq, bool lsi,
> > - Error **errp)
> > +static int spapr_irq_claim_xive(sPAPRMachineState *spapr, int irq, Error **errp)
> > {
> > if (!spapr_xive_irq_claim(spapr->xive, irq)) {
> > error_setg(errp, "IRQ %d is invalid", irq);
> > return -1;
> > }
> > - xive_source_irq_set(&spapr->xive->source, irq, lsi);
> > return 0;
> > }
> >
> > +static void spapr_irq_set_type_xive(sPAPRMachineState *spapr, int irq, bool lsi)
> > +{
> > + xive_source_irq_set(&spapr->xive->source, irq, lsi);
> > +}
> > +
> > static void spapr_irq_free_xive(sPAPRMachineState *spapr, int irq, int num)
> > {
> > int i;
> > @@ -403,6 +415,7 @@ sPAPRIrq spapr_irq_xive = {
> >
> > .init = spapr_irq_init_xive,
> > .claim = spapr_irq_claim_xive,
> > + .set_type = spapr_irq_set_type_xive,
> > .free = spapr_irq_free_xive,
> > .qirq = spapr_qirq_xive,
> > .print_info = spapr_irq_print_info_xive,
> > @@ -466,19 +479,19 @@ static void spapr_irq_init_dual(sPAPRMachineState *spapr, Error **errp)
> > }
> > }
> >
> > -static int spapr_irq_claim_dual(sPAPRMachineState *spapr, int irq, bool lsi,
> > +static int spapr_irq_claim_dual(sPAPRMachineState *spapr, int irq,
> > Error **errp)
> > {
> > Error *local_err = NULL;
> > int ret;
> >
> > - ret = spapr_irq_xics.claim(spapr, irq, lsi, &local_err);
> > + ret = spapr_irq_xics.claim(spapr, irq, &local_err);
> > if (local_err) {
> > error_propagate(errp, local_err);
> > return ret;
> > }
> >
> > - ret = spapr_irq_xive.claim(spapr, irq, lsi, &local_err);
> > + ret = spapr_irq_xive.claim(spapr, irq, &local_err);
> > if (local_err) {
> > error_propagate(errp, local_err);
> > return ret;
> > @@ -487,6 +500,12 @@ static int spapr_irq_claim_dual(sPAPRMachineState *spapr, int irq, bool lsi,
> > return ret;
> > }
> >
> > +static void spapr_irq_set_type_dual(sPAPRMachineState *spapr, int irq, bool lsi)
> > +{
> > + spapr_irq_xics.set_type(spapr, irq, lsi);
> > + spapr_irq_xive.set_type(spapr, irq, lsi);
> > +}
> > +
> > static void spapr_irq_free_dual(sPAPRMachineState *spapr, int irq, int num)
> > {
> > spapr_irq_xics.free(spapr, irq, num);
> > @@ -582,6 +601,7 @@ sPAPRIrq spapr_irq_dual = {
> >
> > .init = spapr_irq_init_dual,
> > .claim = spapr_irq_claim_dual,
> > + .set_type = spapr_irq_set_type_dual,
> > .free = spapr_irq_free_dual,
> > .qirq = spapr_qirq_dual,
> > .print_info = spapr_irq_print_info_dual,
> > @@ -608,9 +628,25 @@ void spapr_irq_init(sPAPRMachineState *spapr, Error **errp)
> > spapr->irq->nr_irqs);
> > }
> >
> > -int spapr_irq_claim(sPAPRMachineState *spapr, int irq, bool lsi, Error **errp)
> > +int spapr_irq_claim(sPAPRMachineState *spapr, int irq, Error **errp)
> > +{
> > + return spapr->irq->claim(spapr, irq, errp);
> > +}
> > +
> > +void spapr_irq_set_type(sPAPRMachineState *spapr, int irq, bool lsi)
> > {
> > - return spapr->irq->claim(spapr, irq, lsi, errp);
> > + return spapr->irq->set_type(spapr, irq, lsi);
> > +}
> > +
> > +int spapr_irq_claim_msi(sPAPRMachineState *spapr, int irq, Error **errp)
> > +{
> > + int ret = spapr_irq_claim(spapr, irq, errp);
> > +
> > + if (!ret) {
> > + spapr_irq_set_type(spapr, irq, false);
> > + }
> > +
> > + return ret;
> > }
> >
> > void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num)
> > @@ -699,6 +735,7 @@ sPAPRIrq spapr_irq_xics_legacy = {
> >
> > .init = spapr_irq_init_xics,
> > .claim = spapr_irq_claim_xics,
> > + .set_type = spapr_irq_set_type_xics,
> > .free = spapr_irq_free_xics,
> > .qirq = spapr_qirq_xics,
> > .print_info = spapr_irq_print_info_xics,
> > diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> > index ccdaf2c9a606..ec9d4d28004c 100644
> > --- a/hw/ppc/spapr_pci.c
> > +++ b/hw/ppc/spapr_pci.c
> > @@ -391,7 +391,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr,
> > }
> >
> > for (i = 0; i < req_num; i++) {
> > - spapr_irq_claim(spapr, irq + i, false, &err);
> > + spapr_irq_claim_msi(spapr, irq + i, &err);
> > if (err) {
> > error_reportf_err(err, "Can't allocate MSIs for device %x: ",
> > config_addr);
> > @@ -1738,11 +1738,12 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
> > }
> > }
> >
> > - spapr_irq_claim(spapr, irq, true, &local_err);
> > + spapr_irq_claim(spapr, irq, &local_err);
> > if (local_err) {
> > error_propagate_prepend(errp, local_err, "can't allocate LSIs: ");
> > return;
> > }
> > + spapr_irq_set_type(spapr, irq, true);
> >
> > sphb->lsi_table[i].irq = irq;
> > }
> > diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
> > index f80b70a39c46..9ae4351d4414 100644
> > --- a/hw/ppc/spapr_vio.c
> > +++ b/hw/ppc/spapr_vio.c
> > @@ -546,7 +546,7 @@ static void spapr_vio_busdev_realize(DeviceState *qdev, Error **errp)
> > }
> > }
> >
> > - spapr_irq_claim(spapr, dev->irq, false, &local_err);
> > + spapr_irq_claim_msi(spapr, dev->irq, &local_err);
> > if (local_err) {
> > error_propagate(errp, local_err);
> > return;
> > diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h
> > index 14b02c3aca33..42b325eb51ba 100644
> > --- a/include/hw/ppc/spapr_irq.h
> > +++ b/include/hw/ppc/spapr_irq.h
> > @@ -36,7 +36,8 @@ typedef struct sPAPRIrq {
> > uint8_t ov5;
> >
> > void (*init)(sPAPRMachineState *spapr, Error **errp);
> > - int (*claim)(sPAPRMachineState *spapr, int irq, bool lsi, Error **errp);
> > + int (*claim)(sPAPRMachineState *spapr, int irq, Error **errp);
> > + void (*set_type)(sPAPRMachineState *spapr, int irq, bool lsi);
> > void (*free)(sPAPRMachineState *spapr, int irq, int num);
> > qemu_irq (*qirq)(sPAPRMachineState *spapr, int irq);
> > void (*print_info)(sPAPRMachineState *spapr, Monitor *mon);
> > @@ -55,7 +56,9 @@ extern sPAPRIrq spapr_irq_xive;
> > extern sPAPRIrq spapr_irq_dual;
> >
> > void spapr_irq_init(sPAPRMachineState *spapr, Error **errp);
> > -int spapr_irq_claim(sPAPRMachineState *spapr, int irq, bool lsi, Error **errp);
> > +int spapr_irq_claim(sPAPRMachineState *spapr, int irq, Error **errp);
> > +void spapr_irq_set_type(sPAPRMachineState *spapr, int irq, bool lsi);
> > +int spapr_irq_claim_msi(sPAPRMachineState *spapr, int irq, Error **errp);
> > void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num);
> > qemu_irq spapr_qirq(sPAPRMachineState *spapr, int irq);
> > int spapr_irq_post_load(sPAPRMachineState *spapr, int version_id);
> >
>
next prev parent reply other threads:[~2019-01-20 14:31 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-17 17:14 [Qemu-devel] [PATCH v3 00/19] spapr: Add support for PHB hotplug Greg Kurz
2019-01-17 17:14 ` [Qemu-devel] [PATCH v3 01/19] ppc: Move spapr-related prototypes from xics.h into a seperate header file Greg Kurz
2019-01-17 17:14 ` [Qemu-devel] [PATCH v3 02/19] spapr: Rename xics to intc in interrupt controller agnostic code Greg Kurz
2019-01-18 13:56 ` Cédric Le Goater
2019-01-20 14:22 ` Greg Kurz
2019-02-05 6:03 ` David Gibson
2019-01-17 17:14 ` [Qemu-devel] [PATCH v3 03/19] xics: Disintricate allocation and type setting of interrupts Greg Kurz
2019-01-18 11:47 ` Greg Kurz
2019-01-18 12:26 ` Cédric Le Goater
2019-01-20 14:24 ` Greg Kurz
2019-02-05 6:13 ` David Gibson
2019-02-05 14:59 ` Greg Kurz
2019-02-06 1:47 ` David Gibson
2019-01-17 17:14 ` [Qemu-devel] [PATCH v3 04/19] spapr/xive: Don't set irq type in spapr_xive_irq_claim() Greg Kurz
2019-01-18 12:27 ` Cédric Le Goater
2019-01-17 17:14 ` [Qemu-devel] [PATCH v3 05/19] spapr: Set irq type in a dedicated function Greg Kurz
2019-01-18 12:34 ` Cédric Le Goater
2019-01-20 14:31 ` Greg Kurz [this message]
2019-01-17 17:15 ` [Qemu-devel] [PATCH v3 06/19] spapr: Identify LSIs of all possible PHBs at machine init Greg Kurz
2019-01-18 12:38 ` Cédric Le Goater
2019-01-20 14:37 ` Greg Kurz
2019-01-17 17:15 ` [Qemu-devel] [PATCH v3 07/19] spapr_pci: add PHB unrealize Greg Kurz
2019-01-18 11:54 ` Greg Kurz
2019-01-17 17:15 ` [Qemu-devel] [PATCH v3 08/19] spapr: create DR connectors for PHBs Greg Kurz
2019-01-17 17:15 ` [Qemu-devel] [PATCH v3 09/19] spapr: populate PHB DRC entries for root DT node Greg Kurz
2019-01-17 17:15 ` [Qemu-devel] [PATCH v3 10/19] spapr_events: add support for phb hotplug events Greg Kurz
2019-01-17 17:15 ` [Qemu-devel] [PATCH v3 11/19] qdev: pass an Object * to qbus_set_hotplug_handler() Greg Kurz
2019-01-17 17:15 ` [Qemu-devel] [PATCH v3 12/19] spapr_pci: provide node start offset via spapr_populate_pci_dt() Greg Kurz
2019-01-17 17:15 ` [Qemu-devel] [PATCH v3 13/19] spapr_pci: add ibm, my-drc-index property for PHB hotplug Greg Kurz
2019-01-17 17:15 ` [Qemu-devel] [PATCH v3 14/19] spapr: Factor out setting of "phandle" DT property to sPAPR irq frontend Greg Kurz
2019-01-18 12:45 ` Cédric Le Goater
2019-01-20 15:41 ` Greg Kurz
2019-01-17 17:16 ` [Qemu-devel] [PATCH v3 15/19] spapr_xive: Cache device tree nodename in sPAPRXive Greg Kurz
2019-01-18 13:38 ` Cédric Le Goater
2019-01-22 13:27 ` Greg Kurz
2019-01-22 14:26 ` Cédric Le Goater
2019-01-22 14:35 ` Greg Kurz
2019-01-17 17:16 ` [Qemu-devel] [PATCH v3 16/19] spapr: Expose the name of the interrupt controller node Greg Kurz
2019-01-18 13:44 ` Cédric Le Goater
2019-01-17 17:16 ` [Qemu-devel] [PATCH v3 17/19] spapr_irq: Expose the phandle of the interrupt controller Greg Kurz
2019-01-18 13:46 ` Cédric Le Goater
2019-01-22 13:32 ` Greg Kurz
2019-01-17 17:16 ` [Qemu-devel] [PATCH v3 18/19] spapr: add hotplug hooks for PHB hotplug Greg Kurz
2019-01-18 13:55 ` Cédric Le Goater
2019-01-17 17:16 ` [Qemu-devel] [PATCH v3 19/19] spapr: enable PHB hotplug for default pseries machine type Greg Kurz
2019-01-22 5:44 ` [Qemu-devel] [PATCH v3 00/19] spapr: Add support for PHB hotplug Alexey Kardashevskiy
2019-01-22 7:22 ` Greg Kurz
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=20190120153121.1af80747@bahia.lan \
--to=groug@kaod.org \
--cc=aik@ozlabs.ru \
--cc=clg@kaod.org \
--cc=cohuck@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=david@redhat.com \
--cc=dmitry.fleytman@gmail.com \
--cc=ehabkost@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcel@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=thuth@redhat.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;
as well as URLs for NNTP newsgroup(s).