From: Greg Kurz <groug@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: qemu-ppc@nongnu.org, "Cédric Le Goater" <clg@kaod.org>,
qemu-devel@nongnu.org
Subject: Re: [PATCH v3 11/12] pnv/psi: Add device reset hook
Date: Tue, 7 Jan 2020 09:00:42 +0100 [thread overview]
Message-ID: <20200107090042.225b45d7@bahia.lan> (raw)
In-Reply-To: <20200107002344.GG2098@umbus>
[-- Attachment #1: Type: text/plain, Size: 3664 bytes --]
On Tue, 7 Jan 2020 11:23:44 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:
> On Mon, Jan 06, 2020 at 03:56:44PM +0100, Cédric Le Goater wrote:
> > From: Greg Kurz <groug@kaod.org>
> >
> > And call it from a QEMU reset handler. This allows each PNV child class to
> > override the reset hook if needed, eg. POWER8 doesn't but POWER9 does.
> > The proper way to do that would be to use device_class_set_parent_reset(),
> > but defining a Pnv8PsiClass and a Pnv9PsiClass types with a parent_reset
> > pointer adds a fair amount of code. Calling pnv_psi_reset() explicitely is
> > fine for now.
> >
> > A subsequent patch will consolidate the call to qemu_register_reset() in
> > a single place.
> >
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > Signed-off-by: Cédric Le Goater <clg@kaod.org>
> > ---
> > hw/ppc/pnv_psi.c | 17 +++++++++++++----
> > 1 file changed, 13 insertions(+), 4 deletions(-)
> >
> > diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c
> > index 4da3d2568624..cf21e42d93b7 100644
> > --- a/hw/ppc/pnv_psi.c
> > +++ b/hw/ppc/pnv_psi.c
> > @@ -455,7 +455,7 @@ static const MemoryRegionOps pnv_psi_xscom_ops = {
> > }
> > };
> >
> > -static void pnv_psi_reset(void *dev)
> > +static void pnv_psi_reset(DeviceState *dev)
> > {
> > PnvPsi *psi = PNV_PSI(dev);
> >
> > @@ -464,6 +464,13 @@ static void pnv_psi_reset(void *dev)
> > psi->regs[PSIHB_XSCOM_BAR] = psi->bar | PSIHB_BAR_EN;
> > }
> >
> > +static void pnv_psi_reset_handler(void *dev)
> > +{
> > + DeviceClass *dc = DEVICE_GET_CLASS(dev);
> > +
> > + dc->reset(DEVICE(dev));
>
> I think it would be better to use device_reset() here rather than
> explicitly accessing the dc->reset pointer yourself.
>
Of course ! Not sure why I didn't do that...
> > +}
> > +
> > static void pnv_psi_power8_instance_init(Object *obj)
> > {
> > Pnv8Psi *psi8 = PNV8_PSI(obj);
> > @@ -526,7 +533,7 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp)
> > ((uint64_t) i << PSIHB_XIVR_SRC_SH);
> > }
> >
> > - qemu_register_reset(pnv_psi_reset, dev);
> > + qemu_register_reset(pnv_psi_reset_handler, dev);
> > }
> >
> > static int pnv_psi_dt_xscom(PnvXScomInterface *dev, void *fdt, int xscom_offset)
> > @@ -809,7 +816,7 @@ static void pnv_psi_power9_irq_set(PnvPsi *psi, int irq, bool state)
> > qemu_set_irq(psi->qirqs[irq], state);
> > }
> >
> > -static void pnv_psi_power9_reset(void *dev)
> > +static void pnv_psi_power9_reset(DeviceState *dev)
> > {
> > Pnv9Psi *psi = PNV9_PSI(dev);
> >
> > @@ -863,7 +870,7 @@ static void pnv_psi_power9_realize(DeviceState *dev, Error **errp)
> >
> > pnv_psi_set_bar(psi, psi->bar | PSIHB_BAR_EN);
> >
> > - qemu_register_reset(pnv_psi_power9_reset, dev);
> > + qemu_register_reset(pnv_psi_reset_handler, dev);
> > }
> >
> > static void pnv_psi_power9_class_init(ObjectClass *klass, void *data)
> > @@ -875,6 +882,7 @@ static void pnv_psi_power9_class_init(ObjectClass *klass, void *data)
> >
> > dc->desc = "PowerNV PSI Controller POWER9";
> > dc->realize = pnv_psi_power9_realize;
> > + dc->reset = pnv_psi_power9_reset;
> >
> > ppc->xscom_pcba = PNV9_XSCOM_PSIHB_BASE;
> > ppc->xscom_size = PNV9_XSCOM_PSIHB_SIZE;
> > @@ -927,6 +935,7 @@ static void pnv_psi_class_init(ObjectClass *klass, void *data)
> >
> > dc->desc = "PowerNV PSI Controller";
> > dc->props = pnv_psi_properties;
> > + dc->reset = pnv_psi_reset;
> > }
> >
> > static const TypeInfo pnv_psi_info = {
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-01-07 9:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-06 14:56 [PATCH v3 00/12] ppc/pnv: remove the use of qdev_get_machine() Cédric Le Goater
2020-01-06 14:56 ` [PATCH v3 01/12] ppc/pnv: Introduce a "xics" property alias under the PSI model Cédric Le Goater
2020-01-06 14:56 ` [PATCH v3 02/12] ppc/pnv: Introduce a "xics" property under the POWER8 chip Cédric Le Goater
2020-01-06 14:56 ` [PATCH v3 03/12] pnv/xive: Use device_class_set_parent_realize() Cédric Le Goater
2020-01-06 14:56 ` [PATCH v3 04/12] spapr, pnv, xive: Add a "xive-fabric" link to the XIVE router Cédric Le Goater
2020-01-06 14:56 ` [PATCH v3 05/12] xive: Use the XIVE fabric link under " Cédric Le Goater
2020-01-07 0:11 ` David Gibson
2020-01-06 14:56 ` [PATCH v3 06/12] ppc/pnv: Add an "nr-threads" property to the base chip class Cédric Le Goater
2020-01-06 14:56 ` [PATCH v3 07/12] ppc/pnv: Add a "pnor" const link property to the BMC internal simulator Cédric Le Goater
2020-01-06 14:56 ` [PATCH v3 08/12] xive: Add a "presenter" link property to the TCTX object Cédric Le Goater
2020-01-06 14:56 ` [PATCH v3 09/12] spapr/xive: Deduce the SpaprXive pointer from XiveTCTX::xptr Cédric Le Goater
2020-01-06 14:56 ` [PATCH v3 10/12] pnv/xive: Deduce the PnvXive " Cédric Le Goater
2020-01-07 0:16 ` David Gibson
2020-01-06 14:56 ` [PATCH v3 11/12] pnv/psi: Add device reset hook Cédric Le Goater
2020-01-07 0:23 ` David Gibson
2020-01-07 8:00 ` Greg Kurz [this message]
2020-01-06 14:56 ` [PATCH v3 12/12] pnv/psi: Consolidate some duplicated code in pnv_psi_realize() Cédric Le Goater
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=20200107090042.225b45d7@bahia.lan \
--to=groug@kaod.org \
--cc=clg@kaod.org \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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 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).