[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-5.0 3/8] xive: Link "xive" property to XiveEndSource::xrtr po
From: |
Greg Kurz |
Subject: |
[PATCH for-5.0 3/8] xive: Link "xive" property to XiveEndSource::xrtr pointer |
Date: |
Fri, 15 Nov 2019 12:53:41 +0100 |
User-agent: |
StGit/unknown-version |
The END source object has both a pointer and a "xive" property pointing to
the router object. Confusing bugs could arise if these ever go out of sync.
Change the property definition so that it explicitely sets the pointer.
The property isn't optional : not being able to set the link is a bug
and QEMU should rather abort than exit in this case.
Signed-off-by: Greg Kurz <address@hidden>
---
hw/intc/pnv_xive.c | 4 ++--
hw/intc/spapr_xive.c | 4 ++--
hw/intc/xive.c | 20 ++++++++++----------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c
index 9e23dc705dc3..6aa7aeed6f83 100644
--- a/hw/intc/pnv_xive.c
+++ b/hw/intc/pnv_xive.c
@@ -1705,8 +1705,8 @@ static void pnv_xive_realize(DeviceState *dev, Error
**errp)
object_property_set_int(OBJECT(end_xsrc), PNV_XIVE_NR_ENDS, "nr-ends",
&error_fatal);
- object_property_add_const_link(OBJECT(end_xsrc), "xive", OBJECT(xive),
- &error_fatal);
+ object_property_set_link(OBJECT(end_xsrc), OBJECT(xive), "xive",
+ &error_abort);
object_property_set_bool(OBJECT(end_xsrc), true, "realized", &local_err);
if (local_err) {
error_propagate(errp, local_err);
diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
index 10890aeeeb5b..729246e906c9 100644
--- a/hw/intc/spapr_xive.c
+++ b/hw/intc/spapr_xive.c
@@ -290,8 +290,8 @@ static void spapr_xive_realize(DeviceState *dev, Error
**errp)
*/
object_property_set_int(OBJECT(end_xsrc), xive->nr_irqs, "nr-ends",
&error_fatal);
- object_property_add_const_link(OBJECT(end_xsrc), "xive", OBJECT(xive),
- &error_fatal);
+ object_property_set_link(OBJECT(end_xsrc), OBJECT(xive), "xive",
+ &error_abort);
object_property_set_bool(OBJECT(end_xsrc), true, "realized", &local_err);
if (local_err) {
error_propagate(errp, local_err);
diff --git a/hw/intc/xive.c b/hw/intc/xive.c
index b69bceb4d255..a32ce0d5bfc6 100644
--- a/hw/intc/xive.c
+++ b/hw/intc/xive.c
@@ -1824,17 +1824,8 @@ static const MemoryRegionOps xive_end_source_ops = {
static void xive_end_source_realize(DeviceState *dev, Error **errp)
{
XiveENDSource *xsrc = XIVE_END_SOURCE(dev);
- Object *obj;
- Error *local_err = NULL;
-
- obj = object_property_get_link(OBJECT(dev), "xive", &local_err);
- if (!obj) {
- error_propagate(errp, local_err);
- error_prepend(errp, "required link 'xive' not found: ");
- return;
- }
- xsrc->xrtr = XIVE_ROUTER(obj);
+ assert(xsrc->xrtr);
if (!xsrc->nr_ends) {
error_setg(errp, "Number of interrupt needs to be greater than 0");
@@ -1863,6 +1854,14 @@ static Property xive_end_source_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
+static void xive_end_source_instance_init(Object *obj)
+{
+ object_property_add_link(obj, "xive", TYPE_XIVE_ROUTER,
+ (Object **) &XIVE_END_SOURCE(obj)->xrtr,
+ qdev_prop_allow_set_link_before_realize,
+ OBJ_PROP_LINK_STRONG, &error_abort);
+}
+
static void xive_end_source_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -1881,6 +1880,7 @@ static const TypeInfo xive_end_source_info = {
.name = TYPE_XIVE_END_SOURCE,
.parent = TYPE_DEVICE,
.instance_size = sizeof(XiveENDSource),
+ .instance_init = xive_end_source_instance_init,
.class_init = xive_end_source_class_init,
};
- [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 <=
- [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, 2019/11/15
- [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