xics: XICS should not be a SysBusDevice
authorDavid Gibson <david@gibson.dropbear.id.au>
Tue, 14 Feb 2017 01:58:05 +0000 (12:58 +1100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Wed, 1 Mar 2017 00:23:39 +0000 (11:23 +1100)
Currently xics - the component of the IBM POWER interrupt controller
representing the overall interrupt fabric / architecture is
represented as a descendent of SysBusDevice.  However, this is not
really correct - the xics presents nothing in MMIO space so it should
be an "unattached" device in the current QOM model.

Since this device will always be created by the machine type, not created
specifically from the command line, and because it has no migrated state
it should be safe to move it around the device composition tree.

Therefore this patch changes it to a descendent of TYPE_DEVICE, and
makes it an unattached device.  So that its reset handler still gets
called correctly, we add a qdev_set_parent_bus() to attach it to
sysbus.  It's not really clear that's correct (instead of using
register_reset()) but it appears to a common technique.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[clg corrected problems with reset]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[dwg folded together and updated commit message]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/intc/xics.c
hw/ppc/spapr.c
include/hw/ppc/xics.h

index 095c16a3008285c1b4a0be0bc40fa68e2a1e6b53..372b8311fb8b593e0f27af252313d143500c9e6e 100644 (file)
@@ -260,7 +260,7 @@ static void xics_common_class_init(ObjectClass *oc, void *data)
 
 static const TypeInfo xics_common_info = {
     .name          = TYPE_XICS_COMMON,
-    .parent        = TYPE_SYS_BUS_DEVICE,
+    .parent        = TYPE_DEVICE,
     .instance_size = sizeof(XICSState),
     .class_size    = sizeof(XICSStateClass),
     .instance_init = xics_common_initfn,
index e0bb9bcb855bf12c71050f4e1df861a6b1cbaa05..0c475f45ed4a3a282b08776e62bfc7f22126ea22 100644 (file)
@@ -101,9 +101,10 @@ static XICSState *try_create_xics(const char *type, int nr_servers,
     Error *err = NULL;
     DeviceState *dev;
 
-    dev = qdev_create(NULL, type);
+    dev = DEVICE(object_new(type));
     qdev_prop_set_uint32(dev, "nr_servers", nr_servers);
     qdev_prop_set_uint32(dev, "nr_irqs", nr_irqs);
+    qdev_set_parent_bus(dev, sysbus_get_default());
     object_property_set_bool(OBJECT(dev), true, "realized", &err);
     if (err) {
         error_propagate(errp, err);
index 3f0c31610aa46acb724db0456e02f7ef63f42d6c..1aefd3d522578bb1da87cfe7a81ceb30150ce00c 100644 (file)
@@ -80,7 +80,7 @@ struct XICSStateClass {
 
 struct XICSState {
     /*< private >*/
-    SysBusDevice parent_obj;
+    DeviceState parent_obj;
     /*< public >*/
     uint32_t nr_servers;
     uint32_t nr_irqs;