[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-5.0 7/8] ppc/pnv: Link "chip" property to PnvCore::chip point
From: |
Greg Kurz |
Subject: |
[PATCH for-5.0 7/8] ppc/pnv: Link "chip" property to PnvCore::chip pointer |
Date: |
Fri, 15 Nov 2019 12:54:04 +0100 |
User-agent: |
StGit/unknown-version |
The core 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 <address@hidden>
---
hw/ppc/pnv.c | 4 ++--
hw/ppc/pnv_core.c | 18 ++++++++++--------
include/hw/ppc/pnv_core.h | 2 +-
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 232c817452c0..8851875bcfd7 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -1326,8 +1326,8 @@ static void pnv_chip_core_realize(PnvChip *chip, Error
**errp)
object_property_set_int(OBJECT(pnv_core),
pcc->core_pir(chip, core_hwid),
"pir", &error_fatal);
- object_property_add_const_link(OBJECT(pnv_core), "chip",
- OBJECT(chip), &error_fatal);
+ object_property_set_link(OBJECT(pnv_core), OBJECT(chip), "chip",
+ &error_abort);
object_property_set_bool(OBJECT(pnv_core), true, "realized",
&error_fatal);
diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
index 61b3d3ce2250..56d185f6290d 100644
--- a/hw/ppc/pnv_core.c
+++ b/hw/ppc/pnv_core.c
@@ -217,15 +217,8 @@ static void pnv_core_realize(DeviceState *dev, Error
**errp)
void *obj;
int i, j;
char name[32];
- Object *chip;
- chip = object_property_get_link(OBJECT(dev), "chip", &local_err);
- if (!chip) {
- error_propagate_prepend(errp, local_err,
- "required link 'chip' not found: ");
- return;
- }
- pc->chip = PNV_CHIP(chip);
+ assert(pc->chip);
pc->threads = g_new(PowerPCCPU *, cc->nr_threads);
for (i = 0; i < cc->nr_threads; i++) {
@@ -323,6 +316,14 @@ static void pnv_core_class_init(ObjectClass *oc, void
*data)
dc->props = pnv_core_properties;
}
+static void pnv_core_instance_init(Object *obj)
+{
+ object_property_add_link(obj, "chip", TYPE_PNV_CHIP,
+ (Object **) &PNV_CORE(obj)->chip,
+ qdev_prop_allow_set_link_before_realize,
+ OBJ_PROP_LINK_STRONG, &error_abort);
+}
+
#define DEFINE_PNV_CORE_TYPE(family, cpu_model) \
{ \
.parent = TYPE_PNV_CORE, \
@@ -335,6 +336,7 @@ static const TypeInfo pnv_core_infos[] = {
.name = TYPE_PNV_CORE,
.parent = TYPE_CPU_CORE,
.instance_size = sizeof(PnvCore),
+ .instance_init = pnv_core_instance_init,
.class_size = sizeof(PnvCoreClass),
.class_init = pnv_core_class_init,
.abstract = true,
diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h
index 55eee95104da..fce6d8d9b31b 100644
--- a/include/hw/ppc/pnv_core.h
+++ b/include/hw/ppc/pnv_core.h
@@ -36,11 +36,11 @@ typedef struct PnvChip PnvChip;
typedef struct PnvCore {
/*< private >*/
CPUCore parent_obj;
+ PnvChip *chip;
/*< public >*/
PowerPCCPU **threads;
uint32_t pir;
- PnvChip *chip;
MemoryRegion xscom_regs;
} PnvCore;
- [PATCH for-5.0 0/8] ppc: Consolidate QOM links and pointers to the same object, Greg Kurz, 2019/11/15
- [PATCH for-5.0 2/8] xive: Link "xive" property to XiveSource::xive pointer, Greg Kurz, 2019/11/15
- [PATCH for-5.0 1/8] xive: Link "cpu" property to XiveTCTX::cs pointer, Greg Kurz, 2019/11/15
- [PATCH for-5.0 3/8] xive: Link "xive" property to XiveEndSource::xrtr pointer, Greg Kurz, 2019/11/15
- [PATCH for-5.0 4/8] ppc/pnv: Link "psi" property to PnvLpc::psi pointer, Greg Kurz, 2019/11/15
- [PATCH for-5.0 5/8] ppc/pnv: Link "psi" property to PnvOCC::psi pointer, Greg Kurz, 2019/11/15
- [PATCH for-5.0 6/8] ppc/pnv: Link "chip" property to PnvHomer::chip pointer, Greg Kurz, 2019/11/15
- [PATCH for-5.0 7/8] ppc/pnv: Link "chip" property to PnvCore::chip pointer,
Greg Kurz <=
- [PATCH for-5.0 8/8] ppc/pnv: Link "chip" property to PnvXive::chip pointer, Greg Kurz, 2019/11/15
- Re: [PATCH for-5.0 0/8] ppc: Consolidate QOM links and pointers to the same object, Cédric Le Goater, 2019/11/15