From: Greg Kurz <groug@kaod.org>
To: "David Gibson" <david@gibson.dropbear.id.au>,
"Cédric Le Goater" <clg@kaod.org>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: [PATCH for-5.0 6/8] ppc/pnv: Link "chip" property to PnvHomer::chip pointer
Date: Fri, 15 Nov 2019 12:53:58 +0100 [thread overview]
Message-ID: <157381883845.136087.16856557105801964895.stgit@bahia.lan> (raw)
In-Reply-To: <157381880498.136087.3775284829737989585.stgit@bahia.lan>
The homer object has both a pointer and a "chip" property pointing to the
chip object. Confusing bugs could arise if these ever go out of sync.
Change the property definition so that it explicitely sets the pointer.
Signed-off-by: Greg Kurz <groug@kaod.org>
---
hw/ppc/pnv.c | 8 ++++----
hw/ppc/pnv_homer.c | 24 +++++++++++++-----------
2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 96c5a23cd1eb..232c817452c0 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -904,8 +904,6 @@ static void pnv_chip_power8_instance_init(Object *obj)
object_initialize_child(obj, "homer", &chip8->homer, sizeof(chip8->homer),
TYPE_PNV8_HOMER, &error_abort, NULL);
- object_property_add_const_link(OBJECT(&chip8->homer), "chip", obj,
- &error_abort);
}
static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error **errp)
@@ -1009,6 +1007,8 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
&chip8->occ.sram_regs);
/* HOMER */
+ object_property_set_link(OBJECT(&chip8->homer), OBJECT(chip), "chip",
+ &error_abort);
object_property_set_bool(OBJECT(&chip8->homer), true, "realized",
&local_err);
if (local_err) {
@@ -1104,8 +1104,6 @@ static void pnv_chip_power9_instance_init(Object *obj)
object_initialize_child(obj, "homer", &chip9->homer, sizeof(chip9->homer),
TYPE_PNV9_HOMER, &error_abort, NULL);
- object_property_add_const_link(OBJECT(&chip9->homer), "chip", obj,
- &error_abort);
}
static void pnv_chip_quad_realize(Pnv9Chip *chip9, Error **errp)
@@ -1222,6 +1220,8 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
&chip9->occ.sram_regs);
/* HOMER */
+ object_property_set_link(OBJECT(&chip9->homer), OBJECT(chip), "chip",
+ &error_abort);
object_property_set_bool(OBJECT(&chip9->homer), true, "realized",
&local_err);
if (local_err) {
diff --git a/hw/ppc/pnv_homer.c b/hw/ppc/pnv_homer.c
index cc881a3b3289..cc08c1e34e2e 100644
--- a/hw/ppc/pnv_homer.c
+++ b/hw/ppc/pnv_homer.c
@@ -22,10 +22,10 @@
#include "exec/memory.h"
#include "sysemu/cpus.h"
#include "hw/qdev-core.h"
+#include "hw/qdev-properties.h"
#include "hw/ppc/pnv.h"
#include "hw/ppc/pnv_homer.h"
-
static bool core_max_array(PnvHomer *homer, hwaddr addr)
{
int i;
@@ -229,22 +229,23 @@ static void pnv_homer_realize(DeviceState *dev, Error **errp)
{
PnvHomer *homer = PNV_HOMER(dev);
PnvHomerClass *hmrc = PNV_HOMER_GET_CLASS(homer);
- Object *obj;
- Error *local_err = NULL;
-
- obj = object_property_get_link(OBJECT(dev), "chip", &local_err);
- if (!obj) {
- error_propagate(errp, local_err);
- error_prepend(errp, "required link 'chip' not found: ");
- return;
- }
- homer->chip = PNV_CHIP(obj);
+
+ assert(homer->chip);
+
/* homer region */
memory_region_init_io(&homer->regs, OBJECT(dev),
hmrc->homer_ops, homer, "homer-main-memory",
hmrc->homer_size);
}
+static void pnv_homer_instance_init(Object *obj)
+{
+ object_property_add_link(obj, "chip", TYPE_PNV_CHIP,
+ (Object **) &PNV_HOMER(obj)->chip,
+ qdev_prop_allow_set_link_before_realize,
+ OBJ_PROP_LINK_STRONG, &error_abort);
+}
+
static void pnv_homer_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -258,6 +259,7 @@ static const TypeInfo pnv_homer_type_info = {
.parent = TYPE_DEVICE,
.instance_size = sizeof(PnvHomer),
.class_init = pnv_homer_class_init,
+ .instance_init = pnv_homer_instance_init,
.class_size = sizeof(PnvHomerClass),
.abstract = true,
};
next prev parent reply other threads:[~2019-11-15 12:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-15 11:53 [PATCH for-5.0 0/8] ppc: Consolidate QOM links and pointers to the same object Greg Kurz
2019-11-15 11:53 ` [PATCH for-5.0 1/8] xive: Link "cpu" property to XiveTCTX::cs pointer Greg Kurz
2019-11-15 11:53 ` [PATCH for-5.0 2/8] xive: Link "xive" property to XiveSource::xive pointer Greg Kurz
2019-11-15 11:53 ` [PATCH for-5.0 3/8] xive: Link "xive" property to XiveEndSource::xrtr pointer Greg Kurz
2019-11-15 11:53 ` [PATCH for-5.0 4/8] ppc/pnv: Link "psi" property to PnvLpc::psi pointer Greg Kurz
2019-11-15 11:53 ` [PATCH for-5.0 5/8] ppc/pnv: Link "psi" property to PnvOCC::psi pointer Greg Kurz
2019-11-15 11:53 ` Greg Kurz [this message]
2019-11-15 11:54 ` [PATCH for-5.0 7/8] ppc/pnv: Link "chip" property to PnvCore::chip pointer Greg Kurz
2019-11-15 12:24 ` Cédric Le Goater
2019-11-15 12:45 ` Greg Kurz
2019-11-15 11:54 ` [PATCH for-5.0 8/8] ppc/pnv: Link "chip" property to PnvXive::chip pointer Greg Kurz
2019-11-15 12:25 ` Cédric Le Goater
2019-11-15 12:46 ` Greg Kurz
2019-11-15 12:16 ` [PATCH for-5.0 0/8] ppc: Consolidate QOM links and pointers to the same object Cédric Le Goater
2019-11-15 13:28 ` 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=157381883845.136087.16856557105801964895.stgit@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).