qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 v2 10/13] spapr_irq: Expose the phandle of the interrupt controller
Date: Mon, 14 Jan 2019 11:03:36 +0100	[thread overview]
Message-ID: <20190114110336.1dce0527@bahia.lan> (raw)
In-Reply-To: <08695a23-c67a-938d-b13e-be04e6fa09c3@kaod.org>

On Mon, 14 Jan 2019 09:11:47 +0100
Cédric Le Goater <clg@kaod.org> wrote:

> On 1/11/19 10:04 PM, Greg Kurz wrote:
> > This will be used by PHB hotplug in order to create the "interrupt-map"
> > property of the PHB node.
> > 
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > ---
> >  hw/intc/spapr_xive.c        |   34 ++++++++++++++++++++++++++++++++--
> >  hw/intc/xics_spapr.c        |   28 +++++++++++++++++++++++++++-
> >  hw/ppc/spapr_irq.c          |   13 ++++++++++++-
> >  include/hw/ppc/spapr_irq.h  |    1 +
> >  include/hw/ppc/spapr_xive.h |    2 ++
> >  include/hw/ppc/xics_spapr.h |    2 ++
> >  6 files changed, 76 insertions(+), 4 deletions(-)
> > 
> > diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
> > index d391177ab81f..ffae680024d7 100644
> > --- a/hw/intc/spapr_xive.c
> > +++ b/hw/intc/spapr_xive.c
> > @@ -1414,6 +1414,12 @@ void spapr_xive_hcall_init(sPAPRMachineState *spapr)
> >      spapr_register_hypercall(H_INT_RESET, h_int_reset);
> >  }
> >  
> > +static gchar *xive_nodename(sPAPRXive *xive)
> > +{
> > +    return g_strdup_printf("interrupt-controller@%" PRIx64,
> > +                           xive->tm_base + XIVE_TM_USER_PAGE * (1 << TM_SHIFT));
> > +}
> > +
> >  void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
> >                     uint32_t phandle)
> >  {
> > @@ -1450,8 +1456,7 @@ void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
> >                             XIVE_TM_OS_PAGE * (1ull << TM_SHIFT));
> >      timas[3] = cpu_to_be64(1ull << TM_SHIFT);
> >  
> > -    nodename = g_strdup_printf("interrupt-controller@%" PRIx64,
> > -                           xive->tm_base + XIVE_TM_USER_PAGE * (1 << TM_SHIFT));
> > +    nodename = xive_nodename(xive);
> >      _FDT(node = fdt_add_subnode(fdt, 0, nodename));
> >      g_free(nodename);
> >  
> > @@ -1479,3 +1484,28 @@ void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
> >      _FDT(fdt_setprop(fdt, 0, "ibm,plat-res-int-priorities",
> >                       plat_res_int_priorities, sizeof(plat_res_int_priorities)));
> >  }
> > +
> > +uint32_t spapr_get_phandle_xive(sPAPRMachineState *spapr, void *fdt,
> > +                                Error **errp)
> > +{
> > +    gchar *nodename = xive_nodename(spapr->xive);
> > +    int phandle = -1, offset;
> > +
> > +    offset = fdt_subnode_offset(fdt, 0, nodename);
> > +    if (offset < 0) {
> > +        error_setg(errp, "Can't find node \"%s\": %s", nodename,
> > +                   fdt_strerror(offset));
> > +        goto out;
> > +    }
> > +
> > +    phandle = fdt_get_phandle(spapr->fdt_blob, offset);
> > +    if (phandle < 0) {
> > +        error_setg(errp, "Can't get phandle of node \"%s\": %s",
> > +                   nodename, fdt_strerror(phandle));
> > +        goto out;
> > +    }
> > +
> > +out:
> > +    g_free(nodename);
> > +    return phandle;
> > +}
> > diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
> > index de6cc15b6474..7763b81d90dd 100644
> > --- a/hw/intc/xics_spapr.c
> > +++ b/hw/intc/xics_spapr.c
> > @@ -35,6 +35,7 @@
> >  #include "hw/ppc/xics_spapr.h"
> >  #include "hw/ppc/fdt.h"
> >  #include "qapi/visitor.h"
> > +#include "qapi/error.h"
> >  
> >  /*
> >   * Guest interfaces
> > @@ -245,6 +246,8 @@ void xics_spapr_init(sPAPRMachineState *spapr)
> >      spapr_register_hypercall(H_IPOLL, h_ipoll);
> >  }
> >  
> > +#define NODENAME "interrupt-controller"
> > +
> >  void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
> >                     uint32_t phandle)
> >  {
> > @@ -253,7 +256,7 @@ void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
> >      };
> >      int node;
> >  
> > -    _FDT(node = fdt_add_subnode(fdt, 0, "interrupt-controller"));
> > +    _FDT(node = fdt_add_subnode(fdt, 0, NODENAME));
> >  
> >      _FDT(fdt_setprop_string(fdt, node, "device_type",
> >                              "PowerPC-External-Interrupt-Presentation"));
> > @@ -266,3 +269,26 @@ void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
> >      _FDT(fdt_setprop_cell(fdt, node, "linux,phandle", phandle));
> >      _FDT(fdt_setprop_cell(fdt, node, "phandle", phandle));
> >  }
> > +
> > +uint32_t spapr_get_phandle_xics(sPAPRMachineState *spapr, void *fdt,
> > +                                Error **errp)
> > +{  
> 
> This routine is redundant with the spapr_get_phandle_xive() I think. 
> 

Yes both routines do the same, except for the node name being a runtime
thing with XIVE and build time with XICS.

> I would remove the (*get_phandle)() method and move the code under a high 
> level spapr_irq_get_phandle() routine which would call a method of the 
> sPAPR IRQ backend : 
> 
> 	char* (*get_nodename)(sPAPRMachineState *spapr);
> 

Yeah I had this in v1 but I didn't like to do g_strdup() of a fixed
string in the XICS case. Anyway, I could possibly revert to doing that
but I guess the setting of the "phandle" property should be moved to
spapr_irq.c as well.

> The get_nodename_xics and get_nodename_xive methods could be located 
> under the spapr_irq.c file or introduce helpers that could be used
> directly as sPAPR IRQ methods. 
> 
> Thanks,
> 
> C. 
> 
> > +    int phandle = -1, offset;
> > +
> > +    offset = fdt_subnode_offset(fdt, 0, NODENAME);
> > +    if (offset < 0) {
> > +        error_setg(errp, "Can't find node \"%s\": %s", NODENAME,
> > +                   fdt_strerror(offset));
> > +        goto out;
> > +    }
> > +
> > +    phandle = fdt_get_phandle(spapr->fdt_blob, offset);
> > +    if (phandle < 0) {
> > +        error_setg(errp, "Can't get phandle of node \"%s\": %s",
> > +                   NODENAME, fdt_strerror(phandle));
> > +        goto out;
> > +    }
> > +
> > +out:
> > +    return phandle;
> > +}
> > diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
> > index 1da7a32348fc..ba0df9ae2e1b 100644
> > --- a/hw/ppc/spapr_irq.c
> > +++ b/hw/ppc/spapr_irq.c
> > @@ -255,6 +255,7 @@ sPAPRIrq spapr_irq_xics = {
> >      .post_load   = spapr_irq_post_load_xics,
> >      .reset       = spapr_irq_reset_xics,
> >      .set_irq     = spapr_irq_set_irq_xics,
> > +    .get_phandle = spapr_get_phandle_xics,
> >  };
> >  
> >  /*
> > @@ -411,6 +412,7 @@ sPAPRIrq spapr_irq_xive = {
> >      .post_load   = spapr_irq_post_load_xive,
> >      .reset       = spapr_irq_reset_xive,
> >      .set_irq     = spapr_irq_set_irq_xive,
> > +    .get_phandle = spapr_get_phandle_xive,
> >  };
> >  
> >  /*
> > @@ -569,6 +571,13 @@ static void spapr_irq_set_irq_dual(void *opaque, int srcno, int val)
> >      spapr_irq_current(spapr)->set_irq(spapr, srcno, val);
> >  }
> >  
> > +static uint32_t spapr_irq_get_phandle_dual(sPAPRMachineState *spapr, void *fdt,
> > +                                           Error **errp)
> > +{
> > +    return spapr_irq_current(spapr)->get_phandle(spapr, fdt, errp);
> > +}
> > +
> > +
> >  /*
> >   * Define values in sync with the XIVE and XICS backend
> >   */
> > @@ -589,7 +598,8 @@ sPAPRIrq spapr_irq_dual = {
> >      .cpu_intc_create = spapr_irq_cpu_intc_create_dual,
> >      .post_load   = spapr_irq_post_load_dual,
> >      .reset       = spapr_irq_reset_dual,
> > -    .set_irq     = spapr_irq_set_irq_dual
> > +    .set_irq     = spapr_irq_set_irq_dual,
> > +    .get_phandle = spapr_irq_get_phandle_dual,
> >  };
> >  
> >  /*
> > @@ -706,4 +716,5 @@ sPAPRIrq spapr_irq_xics_legacy = {
> >      .cpu_intc_create = spapr_irq_cpu_intc_create_xics,
> >      .post_load   = spapr_irq_post_load_xics,
> >      .set_irq     = spapr_irq_set_irq_xics,
> > +    .get_phandle = spapr_get_phandle_xics,
> >  };
> > diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h
> > index 14b02c3aca33..990743a23582 100644
> > --- a/include/hw/ppc/spapr_irq.h
> > +++ b/include/hw/ppc/spapr_irq.h
> > @@ -47,6 +47,7 @@ typedef struct sPAPRIrq {
> >      int (*post_load)(sPAPRMachineState *spapr, int version_id);
> >      void (*reset)(sPAPRMachineState *spapr, Error **errp);
> >      void (*set_irq)(void *opaque, int srcno, int val);
> > +    uint32_t (*get_phandle)(sPAPRMachineState *spapr, void *fdt, Error **errp);
> >  } sPAPRIrq;
> >  
> >  extern sPAPRIrq spapr_irq_xics;
> > diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h
> > index 7fdc25057420..53a34f14b258 100644
> > --- a/include/hw/ppc/spapr_xive.h
> > +++ b/include/hw/ppc/spapr_xive.h
> > @@ -49,4 +49,6 @@ void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
> >  void spapr_xive_set_tctx_os_cam(XiveTCTX *tctx);
> >  void spapr_xive_mmio_set_enabled(sPAPRXive *xive, bool enable);
> >  
> > +uint32_t spapr_get_phandle_xive(sPAPRMachineState *spapr, void *fdt,
> > +                                Error **errp);
> >  #endif /* PPC_SPAPR_XIVE_H */
> > diff --git a/include/hw/ppc/xics_spapr.h b/include/hw/ppc/xics_spapr.h
> > index b1ab27d022cf..8899c5346375 100644
> > --- a/include/hw/ppc/xics_spapr.h
> > +++ b/include/hw/ppc/xics_spapr.h
> > @@ -31,6 +31,8 @@
> >  
> >  void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
> >                     uint32_t phandle);
> > +uint32_t spapr_get_phandle_xics(sPAPRMachineState *spapr, void *fdt,
> > +                                Error **errp);
> >  int xics_kvm_init(sPAPRMachineState *spapr, Error **errp);
> >  void xics_spapr_init(sPAPRMachineState *spapr);
> >  
> >   
> 

  reply	other threads:[~2019-01-14 10:04 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-11 20:59 [Qemu-devel] [PATCH v2 00/13] spapr: Add support for PHB hotplug Greg Kurz
2019-01-11 21:00 ` [Qemu-devel] [PATCH v2 01/13] ppc: Move spapr-related prototypes from xics.h into a seperate header file Greg Kurz
2019-01-11 21:00 ` [Qemu-devel] [PATCH v2 02/13] spapr: Rename xics to intc in interrupt controller agnostic code Greg Kurz
2019-01-14  7:58   ` Cédric Le Goater
2019-01-14 10:08     ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2019-01-11 21:01 ` [Qemu-devel] [PATCH v2 03/13] spapr_pci: add PHB unrealize Greg Kurz
2019-01-11 21:01 ` [Qemu-devel] [PATCH v2 04/13] spapr: create DR connectors for PHBs Greg Kurz
2019-01-11 21:02 ` [Qemu-devel] [PATCH v2 05/13] spapr: populate PHB DRC entries for root DT node Greg Kurz
2019-01-11 21:02 ` [Qemu-devel] [PATCH v2 06/13] spapr_events: add support for phb hotplug events Greg Kurz
2019-01-11 21:02 ` [Qemu-devel] [PATCH v2 07/13] qdev: pass an Object * to qbus_set_hotplug_handler() Greg Kurz
2019-01-14 12:23   ` Cornelia Huck
2019-01-14 19:36   ` Halil Pasic
2019-01-11 21:03 ` [Qemu-devel] [PATCH v2 08/13] spapr_pci: provide node start offset via spapr_populate_pci_dt() Greg Kurz
2019-01-11 21:03 ` [Qemu-devel] [PATCH v2 09/13] spapr_pci: add ibm, my-drc-index property for PHB hotplug Greg Kurz
2019-01-11 21:04 ` [Qemu-devel] [PATCH v2 10/13] spapr_irq: Expose the phandle of the interrupt controller Greg Kurz
2019-01-14  8:11   ` Cédric Le Goater
2019-01-14 10:03     ` Greg Kurz [this message]
2019-01-14 10:06       ` Cédric Le Goater
2019-01-11 21:04 ` [Qemu-devel] [PATCH v2 11/13] spapr_irq: Allow synchronization of a single irq state to KVM Greg Kurz
2019-01-14  8:19   ` Cédric Le Goater
2019-01-14 15:10     ` Greg Kurz
2019-01-14 16:29       ` Cédric Le Goater
2019-01-14 16:34         ` Greg Kurz
2019-01-11 21:17 ` [Qemu-devel] [PATCH v2 12/13] spapr: add hotplug hooks for PHB hotplug Greg Kurz
2019-01-11 21:17 ` [Qemu-devel] [PATCH v2 13/13] spapr: enable PHB hotplug for default pseries machine type Greg Kurz
2019-01-14 19:06 ` [Qemu-devel] [PATCH v2 00/13] spapr: Add support for PHB hotplug Michael S. Tsirkin
2019-01-15 17:41 ` [Qemu-devel] [Qemu-ppc] " 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=20190114110336.1dce0527@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).