qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: "Cédric Le Goater" <clg@kaod.org>,
	qemu-ppc@nongnu.org, "Greg Kurz" <groug@kaod.org>,
	qemu-devel@nongnu.org
Subject: [PATCH v3 12/12] pnv/psi: Consolidate some duplicated code in pnv_psi_realize()
Date: Mon,  6 Jan 2020 15:56:45 +0100	[thread overview]
Message-ID: <20200106145645.4539-13-clg@kaod.org> (raw)
In-Reply-To: <20200106145645.4539-1-clg@kaod.org>

From: Greg Kurz <groug@kaod.org>

The proper way to do that would be to use device_class_set_parent_realize(),
but defining a Pnv8PsiClass and a Pnv9PsiClass types with a parent_realize
pointer adds a fair amount of code. Calling pnv_psi_realize() explicitely
is fine for now.

This should probably be achieved with a device realize hook in the
PSI base class and device_class_set_parent_realize() in the children
classes.

Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/ppc/pnv_psi.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c
index cf21e42d93b7..ce7717ccb151 100644
--- a/hw/ppc/pnv_psi.c
+++ b/hw/ppc/pnv_psi.c
@@ -471,6 +471,16 @@ static void pnv_psi_reset_handler(void *dev)
     dc->reset(DEVICE(dev));
 }
 
+static void pnv_psi_realize(DeviceState *dev, Error **errp)
+{
+    PnvPsi *psi = PNV_PSI(dev);
+
+    /* Default BAR for MMIO region */
+    pnv_psi_set_bar(psi, psi->bar | PSIHB_BAR_EN);
+
+    qemu_register_reset(pnv_psi_reset_handler, dev);
+}
+
 static void pnv_psi_power8_instance_init(Object *obj)
 {
     Pnv8Psi *psi8 = PNV8_PSI(obj);
@@ -523,9 +533,6 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp)
     memory_region_init_io(&psi->regs_mr, OBJECT(dev), &psi_mmio_ops, psi,
                           "psihb", PNV_PSIHB_SIZE);
 
-    /* Default BAR for MMIO region */
-    pnv_psi_set_bar(psi, psi->bar | PSIHB_BAR_EN);
-
     /* Default sources in XIVR */
     for (i = 0; i < PSI_NUM_INTERRUPTS; i++) {
         uint8_t xivr = irq_to_xivr[i];
@@ -533,7 +540,7 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp)
             ((uint64_t) i << PSIHB_XIVR_SRC_SH);
     }
 
-    qemu_register_reset(pnv_psi_reset_handler, dev);
+    pnv_psi_realize(dev, errp);
 }
 
 static int pnv_psi_dt_xscom(PnvXScomInterface *dev, void *fdt, int xscom_offset)
@@ -868,9 +875,7 @@ static void pnv_psi_power9_realize(DeviceState *dev, Error **errp)
     memory_region_init_io(&psi->regs_mr, OBJECT(dev), &pnv_psi_p9_mmio_ops, psi,
                           "psihb", PNV9_PSIHB_SIZE);
 
-    pnv_psi_set_bar(psi, psi->bar | PSIHB_BAR_EN);
-
-    qemu_register_reset(pnv_psi_reset_handler, dev);
+    pnv_psi_realize(dev, errp);
 }
 
 static void pnv_psi_power9_class_init(ObjectClass *klass, void *data)
-- 
2.21.1



      parent reply	other threads:[~2020-01-06 15:34 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
2020-01-06 14:56 ` Cédric Le Goater [this message]

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=20200106145645.4539-13-clg@kaod.org \
    --to=clg@kaod.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --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).