diff options
author | Cédric Le Goater <clg@kaod.org> | 2017-02-27 15:29:10 +0100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2017-03-01 11:23:39 +1100 |
commit | 4e4169f7a22a47f1b03457390e105abcf8ebfcc2 (patch) | |
tree | ab5ee3a5e2d766afc5911fac05e73b3938cc2c8e /hw/ppc/spapr.c | |
parent | 738d5db8240a226ed370b84bf5f5775437bf1158 (diff) | |
download | qemu-4e4169f7a22a47f1b03457390e105abcf8ebfcc2.zip qemu-4e4169f7a22a47f1b03457390e105abcf8ebfcc2.tar.gz qemu-4e4169f7a22a47f1b03457390e105abcf8ebfcc2.tar.bz2 |
ppc/xics: remove set_nr_irqs() handler from XICSStateClass
Today, the ICS (Interrupt Controller Source) object is created and
realized by the init and realize routines of the XICS object, but some
of the parameters are only known at the machine level.
These parameters are passed from the sPAPR machine to the ICS object
in a rather convoluted way using property handlers and a class handler
of the XICS object. The number of irqs required to allocate the IRQ
state objects in the ICS realize routine is one of them.
Let's simplify the process by creating the ICS object along with the
XICS object at the machine level and link the ICS into the XICS list
of ICSs at this level also. In the sPAPR machine, there is only a
single ICS but that will change with the PowerNV machine.
Also, QOMify the creation of the objects and get rid of the
superfluous code.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'hw/ppc/spapr.c')
-rw-r--r-- | hw/ppc/spapr.c | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0c475f4..6729b4d 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -95,23 +95,42 @@ #define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift)) -static XICSState *try_create_xics(const char *type, int nr_servers, - int nr_irqs, Error **errp) -{ - Error *err = NULL; - DeviceState *dev; +static XICSState *try_create_xics(const char *type, const char *type_ics, + int nr_servers, int nr_irqs, Error **errp) +{ + Error *err = NULL, *local_err = NULL; + XICSState *xics; + ICSState *ics = NULL; + + xics = XICS_COMMON(object_new(type)); + qdev_set_parent_bus(DEVICE(xics), sysbus_get_default()); + object_property_set_int(OBJECT(xics), nr_servers, "nr_servers", &err); + object_property_set_bool(OBJECT(xics), true, "realized", &local_err); + error_propagate(&err, local_err); + if (err) { + goto error; + } - 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); + ics = ICS_SIMPLE(object_new(type_ics)); + object_property_add_child(OBJECT(xics), "ics", OBJECT(ics), NULL); + object_property_set_int(OBJECT(ics), nr_irqs, "nr-irqs", &err); + object_property_add_const_link(OBJECT(ics), "xics", OBJECT(xics), NULL); + object_property_set_bool(OBJECT(ics), true, "realized", &local_err); + error_propagate(&err, local_err); if (err) { - error_propagate(errp, err); - object_unparent(OBJECT(dev)); - return NULL; + goto error; } - return XICS_COMMON(dev); + QLIST_INSERT_HEAD(&xics->ics, ics, list); + + return xics; + +error: + error_propagate(errp, err); + if (ics) { + object_unparent(OBJECT(ics)); + } + object_unparent(OBJECT(xics)); + return NULL; } static XICSState *xics_system_init(MachineState *machine, @@ -123,8 +142,8 @@ static XICSState *xics_system_init(MachineState *machine, Error *err = NULL; if (machine_kernel_irqchip_allowed(machine)) { - xics = try_create_xics(TYPE_XICS_SPAPR_KVM, nr_servers, nr_irqs, - &err); + xics = try_create_xics(TYPE_XICS_SPAPR_KVM, TYPE_ICS_KVM, + nr_servers, nr_irqs, &err); } if (machine_kernel_irqchip_required(machine) && !xics) { error_reportf_err(err, @@ -135,7 +154,8 @@ static XICSState *xics_system_init(MachineState *machine, } if (!xics) { - xics = try_create_xics(TYPE_XICS_SPAPR, nr_servers, nr_irqs, errp); + xics = try_create_xics(TYPE_XICS_SPAPR, TYPE_ICS_SIMPLE, nr_servers, + nr_irqs, errp); } return xics; |