* [Qemu-devel] [PATCH v3 01/24] xics: XICS should not be a SysBusDevice
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 02/24] ppc/xics: fix ICP and ICS reset Cédric Le Goater
` (23 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel
From: David Gibson <david@gibson.dropbear.id.au>
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.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 2 +-
hw/ppc/spapr.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 095c16a30082..372b8311fb8b 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -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,
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 5904e6498f49..8af54494f166 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -101,7 +101,7 @@ 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);
object_property_set_bool(OBJECT(dev), true, "realized", &err);
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 02/24] ppc/xics: fix ICP and ICS reset
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 01/24] xics: XICS should not be a SysBusDevice Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 03/24] ppc/xics: remove set_nr_irqs() handler from XICSStateClass Cédric Le Goater
` (22 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
commit 5b17c7207938 ("xics: XICS should not be a SysBusDevice")
changed the nature of the XICS object to be a descendent of
TYPE_DEVICE. By doing so, the object is not on a bus and its reset
handler is not called anymore. The direct consequence is that the ICP
and ICS objects are not correctly initialized and so the IRQ subsystem
is broken in the guest.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/ppc/spapr.c | 1 +
include/hw/ppc/xics.h | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 8af54494f166..fa6a2947c791 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -104,6 +104,7 @@ static XICSState *try_create_xics(const char *type, int nr_servers,
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);
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 3f0c31610aa4..1aefd3d52257 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -80,7 +80,7 @@ struct XICSStateClass {
struct XICSState {
/*< private >*/
- SysBusDevice parent_obj;
+ DeviceState parent_obj;
/*< public >*/
uint32_t nr_servers;
uint32_t nr_irqs;
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 03/24] ppc/xics: remove set_nr_irqs() handler from XICSStateClass
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 01/24] xics: XICS should not be a SysBusDevice Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 02/24] ppc/xics: fix ICP and ICS reset Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 04/24] ppc/xics: remove set_nr_servers() " Cédric Le Goater
` (21 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
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>
---
hw/intc/xics.c | 51 +++++++++++++++---------------------------------
hw/intc/xics_kvm.c | 44 ++++++++++-------------------------------
hw/intc/xics_spapr.c | 34 --------------------------------
hw/ppc/spapr.c | 54 +++++++++++++++++++++++++++++++++++----------------
include/hw/ppc/xics.h | 2 --
5 files changed, 63 insertions(+), 122 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 372b8311fb8b..e70d3b8b1095 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -151,38 +151,6 @@ static void xics_common_reset(DeviceState *d)
}
}
-static void xics_prop_get_nr_irqs(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp)
-{
- XICSState *xics = XICS_COMMON(obj);
- int64_t value = xics->nr_irqs;
-
- visit_type_int(v, name, &value, errp);
-}
-
-static void xics_prop_set_nr_irqs(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp)
-{
- XICSState *xics = XICS_COMMON(obj);
- XICSStateClass *info = XICS_COMMON_GET_CLASS(xics);
- Error *error = NULL;
- int64_t value;
-
- visit_type_int(v, name, &value, &error);
- if (error) {
- error_propagate(errp, error);
- return;
- }
- if (xics->nr_irqs) {
- error_setg(errp, "Number of interrupts is already set to %u",
- xics->nr_irqs);
- return;
- }
-
- assert(info->set_nr_irqs);
- info->set_nr_irqs(xics, value, errp);
-}
-
void xics_set_nr_servers(XICSState *xics, uint32_t nr_servers,
const char *typename, Error **errp)
{
@@ -241,9 +209,6 @@ static void xics_common_initfn(Object *obj)
XICSState *xics = XICS_COMMON(obj);
QLIST_INIT(&xics->ics);
- object_property_add(obj, "nr_irqs", "int",
- xics_prop_get_nr_irqs, xics_prop_set_nr_irqs,
- NULL, NULL, NULL);
object_property_add(obj, "nr_servers", "int",
xics_prop_get_nr_servers, xics_prop_set_nr_servers,
NULL, NULL, NULL);
@@ -737,6 +702,16 @@ static void ics_simple_initfn(Object *obj)
static void ics_simple_realize(DeviceState *dev, Error **errp)
{
ICSState *ics = ICS_SIMPLE(dev);
+ Object *obj;
+ Error *err = NULL;
+
+ obj = object_property_get_link(OBJECT(dev), "xics", &err);
+ if (!obj) {
+ error_setg(errp, "%s: required link 'xics' not found: %s",
+ __func__, error_get_pretty(err));
+ return;
+ }
+ ics->xics = XICS_COMMON(obj);
if (!ics->nr_irqs) {
error_setg(errp, "Number of interrupts needs to be greater 0");
@@ -746,12 +721,18 @@ static void ics_simple_realize(DeviceState *dev, Error **errp)
ics->qirqs = qemu_allocate_irqs(ics_simple_set_irq, ics, ics->nr_irqs);
}
+static Property ics_simple_properties[] = {
+ DEFINE_PROP_UINT32("nr-irqs", ICSState, nr_irqs, 0),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static void ics_simple_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
ICSStateClass *isc = ICS_BASE_CLASS(klass);
dc->realize = ics_simple_realize;
+ dc->props = ics_simple_properties;
dc->vmsd = &vmstate_ics_simple;
dc->reset = ics_simple_reset;
isc->post_load = ics_simple_post_load;
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 17694eaa8709..4a6c0522feb6 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -294,6 +294,16 @@ static void ics_kvm_reset(DeviceState *dev)
static void ics_kvm_realize(DeviceState *dev, Error **errp)
{
ICSState *ics = ICS_SIMPLE(dev);
+ Object *obj;
+ Error *err = NULL;
+
+ obj = object_property_get_link(OBJECT(dev), "xics", &err);
+ if (!obj) {
+ error_setg(errp, "%s: required link 'xics' not found: %s",
+ __func__, error_get_pretty(err));
+ return;
+ }
+ ics->xics = XICS_COMMON(obj);
if (!ics->nr_irqs) {
error_setg(errp, "Number of interrupts needs to be greater 0");
@@ -358,18 +368,6 @@ static void xics_kvm_cpu_setup(XICSState *xics, PowerPCCPU *cpu)
ss->cap_irq_xics_enabled = true;
}
-static void xics_kvm_set_nr_irqs(XICSState *xics, uint32_t nr_irqs,
- Error **errp)
-{
- ICSState *ics = QLIST_FIRST(&xics->ics);
-
- /* This needs to be deprecated ... */
- xics->nr_irqs = nr_irqs;
- if (ics) {
- ics->nr_irqs = nr_irqs;
- }
-}
-
static void xics_kvm_set_nr_servers(XICSState *xics, uint32_t nr_servers,
Error **errp)
{
@@ -389,7 +387,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp)
{
KVMXICSState *xicskvm = XICS_SPAPR_KVM(dev);
XICSState *xics = XICS_COMMON(dev);
- ICSState *ics;
int i, rc;
Error *error = NULL;
struct kvm_create_device xics_create_device = {
@@ -441,14 +438,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp)
xicskvm->kernel_xics_fd = xics_create_device.fd;
- QLIST_FOREACH(ics, &xics->ics, list) {
- object_property_set_bool(OBJECT(ics), true, "realized", &error);
- if (error) {
- error_propagate(errp, error);
- goto fail;
- }
- }
-
assert(xics->nr_servers);
for (i = 0; i < xics->nr_servers; i++) {
object_property_set_bool(OBJECT(&xics->ss[i]), true, "realized",
@@ -472,17 +461,6 @@ fail:
kvmppc_define_rtas_kernel_token(0, "ibm,int-off");
}
-static void xics_kvm_initfn(Object *obj)
-{
- XICSState *xics = XICS_COMMON(obj);
- ICSState *ics;
-
- ics = ICS_SIMPLE(object_new(TYPE_ICS_KVM));
- object_property_add_child(obj, "ics", OBJECT(ics), NULL);
- ics->xics = xics;
- QLIST_INSERT_HEAD(&xics->ics, ics, list);
-}
-
static void xics_kvm_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
@@ -490,7 +468,6 @@ static void xics_kvm_class_init(ObjectClass *oc, void *data)
dc->realize = xics_kvm_realize;
xsc->cpu_setup = xics_kvm_cpu_setup;
- xsc->set_nr_irqs = xics_kvm_set_nr_irqs;
xsc->set_nr_servers = xics_kvm_set_nr_servers;
}
@@ -499,7 +476,6 @@ static const TypeInfo xics_spapr_kvm_info = {
.parent = TYPE_XICS_COMMON,
.instance_size = sizeof(KVMXICSState),
.class_init = xics_kvm_class_init,
- .instance_init = xics_kvm_initfn,
};
static void xics_kvm_register_types(void)
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index 2e3f1c5e95b2..03e42a866603 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -239,18 +239,6 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr,
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
}
-static void xics_spapr_set_nr_irqs(XICSState *xics, uint32_t nr_irqs,
- Error **errp)
-{
- ICSState *ics = QLIST_FIRST(&xics->ics);
-
- /* This needs to be deprecated ... */
- xics->nr_irqs = nr_irqs;
- if (ics) {
- ics->nr_irqs = nr_irqs;
- }
-}
-
static void xics_spapr_set_nr_servers(XICSState *xics, uint32_t nr_servers,
Error **errp)
{
@@ -260,7 +248,6 @@ static void xics_spapr_set_nr_servers(XICSState *xics, uint32_t nr_servers,
static void xics_spapr_realize(DeviceState *dev, Error **errp)
{
XICSState *xics = XICS_SPAPR(dev);
- ICSState *ics;
Error *error = NULL;
int i;
@@ -282,14 +269,6 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp)
spapr_register_hypercall(H_EOI, h_eoi);
spapr_register_hypercall(H_IPOLL, h_ipoll);
- QLIST_FOREACH(ics, &xics->ics, list) {
- object_property_set_bool(OBJECT(ics), true, "realized", &error);
- if (error) {
- error_propagate(errp, error);
- return;
- }
- }
-
for (i = 0; i < xics->nr_servers; i++) {
object_property_set_bool(OBJECT(&xics->ss[i]), true, "realized",
&error);
@@ -300,24 +279,12 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp)
}
}
-static void xics_spapr_initfn(Object *obj)
-{
- XICSState *xics = XICS_SPAPR(obj);
- ICSState *ics;
-
- ics = ICS_SIMPLE(object_new(TYPE_ICS_SIMPLE));
- object_property_add_child(obj, "ics", OBJECT(ics), NULL);
- ics->xics = xics;
- QLIST_INSERT_HEAD(&xics->ics, ics, list);
-}
-
static void xics_spapr_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
XICSStateClass *xsc = XICS_SPAPR_CLASS(oc);
dc->realize = xics_spapr_realize;
- xsc->set_nr_irqs = xics_spapr_set_nr_irqs;
xsc->set_nr_servers = xics_spapr_set_nr_servers;
}
@@ -327,7 +294,6 @@ static const TypeInfo xics_spapr_info = {
.instance_size = sizeof(XICSState),
.class_size = sizeof(XICSStateClass),
.class_init = xics_spapr_class_init,
- .instance_init = xics_spapr_initfn,
};
#define ICS_IRQ_FREE(ics, srcno) \
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index fa6a2947c791..93a57258efc6 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;
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 1aefd3d52257..88621591d7d0 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -74,7 +74,6 @@ struct XICSStateClass {
DeviceClass parent_class;
void (*cpu_setup)(XICSState *icp, PowerPCCPU *cpu);
- void (*set_nr_irqs)(XICSState *icp, uint32_t nr_irqs, Error **errp);
void (*set_nr_servers)(XICSState *icp, uint32_t nr_servers, Error **errp);
};
@@ -83,7 +82,6 @@ struct XICSState {
DeviceState parent_obj;
/*< public >*/
uint32_t nr_servers;
- uint32_t nr_irqs;
ICPState *ss;
QLIST_HEAD(, ICSState) ics;
};
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 04/24] ppc/xics: remove set_nr_servers() handler from XICSStateClass
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (2 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 03/24] ppc/xics: remove set_nr_irqs() handler from XICSStateClass Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 05/24] ppc/xics: store the ICS object under the sPAPR machine Cédric Le Goater
` (20 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
Today, the ICP (Interrupt Controller Presenter) objects are created by
the 'nr_servers' property handler of the XICS object and a class
handler. They are realized in the XICS object realize routine.
Let's simplify the process by creating the ICP objects along with the
XICS object at the machine level.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 74 +++++++++++++--------------------------------------
hw/intc/xics_kvm.c | 21 +--------------
hw/intc/xics_spapr.c | 26 ------------------
hw/ppc/spapr.c | 30 ++++++++++++++++-----
include/hw/ppc/xics.h | 3 ---
5 files changed, 42 insertions(+), 112 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index e70d3b8b1095..9f22814815c9 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -151,67 +151,11 @@ static void xics_common_reset(DeviceState *d)
}
}
-void xics_set_nr_servers(XICSState *xics, uint32_t nr_servers,
- const char *typename, Error **errp)
-{
- int i;
-
- xics->nr_servers = nr_servers;
-
- xics->ss = g_malloc0(xics->nr_servers * sizeof(ICPState));
- for (i = 0; i < xics->nr_servers; i++) {
- char name[32];
- ICPState *icp = &xics->ss[i];
-
- object_initialize(icp, sizeof(*icp), typename);
- snprintf(name, sizeof(name), "icp[%d]", i);
- object_property_add_child(OBJECT(xics), name, OBJECT(icp), errp);
- icp->xics = xics;
- }
-}
-
-static void xics_prop_get_nr_servers(Object *obj, Visitor *v,
- const char *name, void *opaque,
- Error **errp)
-{
- XICSState *xics = XICS_COMMON(obj);
- int64_t value = xics->nr_servers;
-
- visit_type_int(v, name, &value, errp);
-}
-
-static void xics_prop_set_nr_servers(Object *obj, Visitor *v,
- const char *name, void *opaque,
- Error **errp)
-{
- XICSState *xics = XICS_COMMON(obj);
- XICSStateClass *xsc = XICS_COMMON_GET_CLASS(xics);
- Error *error = NULL;
- int64_t value;
-
- visit_type_int(v, name, &value, &error);
- if (error) {
- error_propagate(errp, error);
- return;
- }
- if (xics->nr_servers) {
- error_setg(errp, "Number of servers is already set to %u",
- xics->nr_servers);
- return;
- }
-
- assert(xsc->set_nr_servers);
- xsc->set_nr_servers(xics, value, errp);
-}
-
static void xics_common_initfn(Object *obj)
{
XICSState *xics = XICS_COMMON(obj);
QLIST_INIT(&xics->ics);
- object_property_add(obj, "nr_servers", "int",
- xics_prop_get_nr_servers, xics_prop_set_nr_servers,
- NULL, NULL, NULL);
}
static void xics_common_class_init(ObjectClass *oc, void *data)
@@ -450,12 +394,30 @@ static void icp_reset(DeviceState *dev)
qemu_set_irq(icp->output, 0);
}
+static void icp_realize(DeviceState *dev, Error **errp)
+{
+ ICPState *icp = ICP(dev);
+ Object *obj;
+ Error *err = NULL;
+
+ obj = object_property_get_link(OBJECT(dev), "xics", &err);
+ if (!obj) {
+ error_setg(errp, "%s: required link 'xics' not found: %s",
+ __func__, error_get_pretty(err));
+ return;
+ }
+
+ icp->xics = XICS_COMMON(obj);
+}
+
+
static void icp_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->reset = icp_reset;
dc->vmsd = &vmstate_icp_server;
+ dc->realize = icp_realize;
}
static const TypeInfo icp_info = {
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 4a6c0522feb6..6cabc11f6be1 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -368,12 +368,6 @@ static void xics_kvm_cpu_setup(XICSState *xics, PowerPCCPU *cpu)
ss->cap_irq_xics_enabled = true;
}
-static void xics_kvm_set_nr_servers(XICSState *xics, uint32_t nr_servers,
- Error **errp)
-{
- xics_set_nr_servers(xics, nr_servers, TYPE_KVM_ICP, errp);
-}
-
static void rtas_dummy(PowerPCCPU *cpu, sPAPRMachineState *spapr,
uint32_t token,
uint32_t nargs, target_ulong args,
@@ -386,9 +380,7 @@ static void rtas_dummy(PowerPCCPU *cpu, sPAPRMachineState *spapr,
static void xics_kvm_realize(DeviceState *dev, Error **errp)
{
KVMXICSState *xicskvm = XICS_SPAPR_KVM(dev);
- XICSState *xics = XICS_COMMON(dev);
- int i, rc;
- Error *error = NULL;
+ int rc;
struct kvm_create_device xics_create_device = {
.type = KVM_DEV_TYPE_XICS,
.flags = 0,
@@ -438,16 +430,6 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp)
xicskvm->kernel_xics_fd = xics_create_device.fd;
- assert(xics->nr_servers);
- for (i = 0; i < xics->nr_servers; i++) {
- object_property_set_bool(OBJECT(&xics->ss[i]), true, "realized",
- &error);
- if (error) {
- error_propagate(errp, error);
- goto fail;
- }
- }
-
kvm_kernel_irqchip = true;
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_direct_mapping = true;
@@ -468,7 +450,6 @@ static void xics_kvm_class_init(ObjectClass *oc, void *data)
dc->realize = xics_kvm_realize;
xsc->cpu_setup = xics_kvm_cpu_setup;
- xsc->set_nr_servers = xics_kvm_set_nr_servers;
}
static const TypeInfo xics_spapr_kvm_info = {
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index 03e42a866603..859b5675e175 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -239,23 +239,8 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr,
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
}
-static void xics_spapr_set_nr_servers(XICSState *xics, uint32_t nr_servers,
- Error **errp)
-{
- xics_set_nr_servers(xics, nr_servers, TYPE_ICP, errp);
-}
-
static void xics_spapr_realize(DeviceState *dev, Error **errp)
{
- XICSState *xics = XICS_SPAPR(dev);
- Error *error = NULL;
- int i;
-
- if (!xics->nr_servers) {
- error_setg(errp, "Number of servers needs to be greater 0");
- return;
- }
-
/* Registration of global state belongs into realize */
spapr_rtas_register(RTAS_IBM_SET_XIVE, "ibm,set-xive", rtas_set_xive);
spapr_rtas_register(RTAS_IBM_GET_XIVE, "ibm,get-xive", rtas_get_xive);
@@ -268,24 +253,13 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp)
spapr_register_hypercall(H_XIRR_X, h_xirr_x);
spapr_register_hypercall(H_EOI, h_eoi);
spapr_register_hypercall(H_IPOLL, h_ipoll);
-
- for (i = 0; i < xics->nr_servers; i++) {
- object_property_set_bool(OBJECT(&xics->ss[i]), true, "realized",
- &error);
- if (error) {
- error_propagate(errp, error);
- return;
- }
- }
}
static void xics_spapr_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
- XICSStateClass *xsc = XICS_SPAPR_CLASS(oc);
dc->realize = xics_spapr_realize;
- xsc->set_nr_servers = xics_spapr_set_nr_servers;
}
static const TypeInfo xics_spapr_info = {
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 93a57258efc6..1c6ab756a46e 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -96,17 +96,17 @@
#define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift))
static XICSState *try_create_xics(const char *type, const char *type_ics,
- int nr_servers, int nr_irqs, Error **errp)
+ const char *type_icp, int nr_servers,
+ int nr_irqs, Error **errp)
{
Error *err = NULL, *local_err = NULL;
XICSState *xics;
ICSState *ics = NULL;
+ int i;
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);
+ object_property_set_bool(OBJECT(xics), true, "realized", &err);
if (err) {
goto error;
}
@@ -122,6 +122,22 @@ static XICSState *try_create_xics(const char *type, const char *type_ics,
}
QLIST_INSERT_HEAD(&xics->ics, ics, list);
+ xics->ss = g_malloc0(nr_servers * sizeof(ICPState));
+ xics->nr_servers = nr_servers;
+
+ for (i = 0; i < nr_servers; i++) {
+ ICPState *icp = &xics->ss[i];
+
+ object_initialize(icp, sizeof(*icp), type_icp);
+ object_property_add_child(OBJECT(xics), "icp[*]", OBJECT(icp), NULL);
+ object_property_add_const_link(OBJECT(icp), "xics", OBJECT(xics), NULL);
+ object_property_set_bool(OBJECT(icp), true, "realized", &err);
+ if (err) {
+ goto error;
+ }
+ object_unref(OBJECT(icp));
+ }
+
return xics;
error:
@@ -143,7 +159,7 @@ static XICSState *xics_system_init(MachineState *machine,
if (machine_kernel_irqchip_allowed(machine)) {
xics = try_create_xics(TYPE_XICS_SPAPR_KVM, TYPE_ICS_KVM,
- nr_servers, nr_irqs, &err);
+ TYPE_KVM_ICP, nr_servers, nr_irqs, &err);
}
if (machine_kernel_irqchip_required(machine) && !xics) {
error_reportf_err(err,
@@ -154,8 +170,8 @@ static XICSState *xics_system_init(MachineState *machine,
}
if (!xics) {
- xics = try_create_xics(TYPE_XICS_SPAPR, TYPE_ICS_SIMPLE, nr_servers,
- nr_irqs, errp);
+ xics = try_create_xics(TYPE_XICS_SPAPR, TYPE_ICS_SIMPLE, TYPE_ICP,
+ nr_servers, nr_irqs, errp);
}
return xics;
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 88621591d7d0..0ec585cc93ca 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -74,7 +74,6 @@ struct XICSStateClass {
DeviceClass parent_class;
void (*cpu_setup)(XICSState *icp, PowerPCCPU *cpu);
- void (*set_nr_servers)(XICSState *icp, uint32_t nr_servers, Error **errp);
};
struct XICSState {
@@ -189,8 +188,6 @@ void spapr_dt_xics(XICSState *xics, void *fdt, uint32_t phandle);
void xics_cpu_setup(XICSState *icp, PowerPCCPU *cpu);
void xics_cpu_destroy(XICSState *icp, PowerPCCPU *cpu);
-void xics_set_nr_servers(XICSState *xics, uint32_t nr_servers,
- const char *typename, Error **errp);
/* Internal XICS interfaces */
int xics_get_cpu_index_by_dt_id(int cpu_dt_id);
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 05/24] ppc/xics: store the ICS object under the sPAPR machine
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (3 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 04/24] ppc/xics: remove set_nr_servers() " Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 06/24] ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects Cédric Le Goater
` (19 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
A list of ICS objects was introduced under the XICS object for the
PowerNV machine but, for the sPAPR machine, it brings extra complexity
as there is only a single ICS. To simplify the code, let's add the ICS
pointer under the sPAPR machine and try to reduce the use of this list
where possible.
Also, change the xics_spapr_*() routines to use an ICS object instead
of an XICSState and change their name to reflect that these are
specific to the sPAPR ICS object.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics_spapr.c | 22 +++++++++-------------
hw/ppc/spapr.c | 29 ++++++++++++++++-------------
hw/ppc/spapr_events.c | 4 ++--
hw/ppc/spapr_pci.c | 8 ++++----
hw/ppc/spapr_vio.c | 2 +-
include/hw/ppc/spapr.h | 1 +
include/hw/ppc/xics.h | 6 +++---
7 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index 859b5675e175..1501e796e5e0 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -118,7 +118,7 @@ static void rtas_set_xive(PowerPCCPU *cpu, sPAPRMachineState *spapr,
uint32_t nargs, target_ulong args,
uint32_t nret, target_ulong rets)
{
- ICSState *ics = QLIST_FIRST(&spapr->xics->ics);
+ ICSState *ics = spapr->ics;
uint32_t nr, srcno, server, priority;
if ((nargs != 3) || (nret != 1)) {
@@ -151,7 +151,7 @@ static void rtas_get_xive(PowerPCCPU *cpu, sPAPRMachineState *spapr,
uint32_t nargs, target_ulong args,
uint32_t nret, target_ulong rets)
{
- ICSState *ics = QLIST_FIRST(&spapr->xics->ics);
+ ICSState *ics = spapr->ics;
uint32_t nr, srcno;
if ((nargs != 1) || (nret != 3)) {
@@ -181,7 +181,7 @@ static void rtas_int_off(PowerPCCPU *cpu, sPAPRMachineState *spapr,
uint32_t nargs, target_ulong args,
uint32_t nret, target_ulong rets)
{
- ICSState *ics = QLIST_FIRST(&spapr->xics->ics);
+ ICSState *ics = spapr->ics;
uint32_t nr, srcno;
if ((nargs != 1) || (nret != 1)) {
@@ -212,7 +212,7 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr,
uint32_t nargs, target_ulong args,
uint32_t nret, target_ulong rets)
{
- ICSState *ics = QLIST_FIRST(&spapr->xics->ics);
+ ICSState *ics = spapr->ics;
uint32_t nr, srcno;
if ((nargs != 1) || (nret != 1)) {
@@ -294,9 +294,8 @@ static int ics_find_free_block(ICSState *ics, int num, int alignnum)
return -1;
}
-int xics_spapr_alloc(XICSState *xics, int irq_hint, bool lsi, Error **errp)
+int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp)
{
- ICSState *ics = QLIST_FIRST(&xics->ics);
int irq;
if (!ics) {
@@ -327,10 +326,9 @@ int xics_spapr_alloc(XICSState *xics, int irq_hint, bool lsi, Error **errp)
* Allocate block of consecutive IRQs, and return the number of the first IRQ in
* the block. If align==true, aligns the first IRQ number to num.
*/
-int xics_spapr_alloc_block(XICSState *xics, int num, bool lsi, bool align,
- Error **errp)
+int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi,
+ bool align, Error **errp)
{
- ICSState *ics = QLIST_FIRST(&xics->ics);
int i, first = -1;
if (!ics) {
@@ -380,11 +378,9 @@ static void ics_free(ICSState *ics, int srcno, int num)
}
}
-void xics_spapr_free(XICSState *xics, int irq, int num)
+void spapr_ics_free(ICSState *ics, int irq, int num)
{
- ICSState *ics = xics_find_source(xics, irq);
-
- if (ics) {
+ if (ics_valid_irq(ics, irq)) {
trace_xics_ics_free(0, irq, num);
ics_free(ics, irq - ics->offset, num);
}
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 1c6ab756a46e..5d2527a0e160 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -95,13 +95,13 @@
#define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift))
-static XICSState *try_create_xics(const char *type, const char *type_ics,
+static XICSState *try_create_xics(sPAPRMachineState *spapr,
+ const char *type, const char *type_ics,
const char *type_icp, int nr_servers,
int nr_irqs, Error **errp)
{
Error *err = NULL, *local_err = NULL;
XICSState *xics;
- ICSState *ics = NULL;
int i;
xics = XICS_COMMON(object_new(type));
@@ -111,16 +111,17 @@ static XICSState *try_create_xics(const char *type, const char *type_ics,
goto error;
}
- 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);
+ spapr->ics = ICS_SIMPLE(object_new(type_ics));
+ object_property_add_child(OBJECT(spapr), "ics", OBJECT(spapr->ics), NULL);
+ object_property_set_int(OBJECT(spapr->ics), nr_irqs, "nr-irqs", &err);
+ object_property_add_const_link(OBJECT(spapr->ics), "xics", OBJECT(xics),
+ NULL);
+ object_property_set_bool(OBJECT(spapr->ics), true, "realized", &local_err);
error_propagate(&err, local_err);
if (err) {
goto error;
}
- QLIST_INSERT_HEAD(&xics->ics, ics, list);
+ QLIST_INSERT_HEAD(&xics->ics, spapr->ics, list);
xics->ss = g_malloc0(nr_servers * sizeof(ICPState));
xics->nr_servers = nr_servers;
@@ -142,8 +143,8 @@ static XICSState *try_create_xics(const char *type, const char *type_ics,
error:
error_propagate(errp, err);
- if (ics) {
- object_unparent(OBJECT(ics));
+ if (spapr->ics) {
+ object_unparent(OBJECT(spapr->ics));
}
object_unparent(OBJECT(xics));
return NULL;
@@ -158,7 +159,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, TYPE_ICS_KVM,
+ xics = try_create_xics(SPAPR_MACHINE(machine),
+ TYPE_XICS_SPAPR_KVM, TYPE_ICS_KVM,
TYPE_KVM_ICP, nr_servers, nr_irqs, &err);
}
if (machine_kernel_irqchip_required(machine) && !xics) {
@@ -170,8 +172,9 @@ static XICSState *xics_system_init(MachineState *machine,
}
if (!xics) {
- xics = try_create_xics(TYPE_XICS_SPAPR, TYPE_ICS_SIMPLE, TYPE_ICP,
- nr_servers, nr_irqs, errp);
+ xics = try_create_xics(SPAPR_MACHINE(machine),
+ TYPE_XICS_SPAPR, TYPE_ICS_SIMPLE,
+ TYPE_ICP, nr_servers, nr_irqs, errp);
}
return xics;
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index f85a9c32a7fc..38b4258a9be7 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -752,7 +752,7 @@ void spapr_events_init(sPAPRMachineState *spapr)
spapr->event_sources = spapr_event_sources_new();
spapr_event_sources_register(spapr->event_sources, EVENT_CLASS_EPOW,
- xics_spapr_alloc(spapr->xics, 0, false,
+ spapr_ics_alloc(spapr->ics, 0, false,
&error_fatal));
/* NOTE: if machine supports modern/dedicated hotplug event source,
@@ -765,7 +765,7 @@ void spapr_events_init(sPAPRMachineState *spapr)
*/
if (spapr->use_hotplug_event_source) {
spapr_event_sources_register(spapr->event_sources, EVENT_CLASS_HOT_PLUG,
- xics_spapr_alloc(spapr->xics, 0, false,
+ spapr_ics_alloc(spapr->ics, 0, false,
&error_fatal));
}
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 1c4fa8b0f606..3f580a68be8e 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -326,7 +326,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr,
return;
}
- xics_spapr_free(spapr->xics, msi->first_irq, msi->num);
+ spapr_ics_free(spapr->ics, msi->first_irq, msi->num);
if (msi_present(pdev)) {
spapr_msi_setmsg(pdev, 0, false, 0, 0);
}
@@ -364,7 +364,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr,
}
/* Allocate MSIs */
- irq = xics_spapr_alloc_block(spapr->xics, req_num, false,
+ irq = spapr_ics_alloc_block(spapr->ics, req_num, false,
ret_intr_type == RTAS_TYPE_MSI, &err);
if (err) {
error_reportf_err(err, "Can't allocate MSIs for device %x: ",
@@ -375,7 +375,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr,
/* Release previous MSIs */
if (msi) {
- xics_spapr_free(spapr->xics, msi->first_irq, msi->num);
+ spapr_ics_free(spapr->ics, msi->first_irq, msi->num);
g_hash_table_remove(phb->msi, &config_addr);
}
@@ -1747,7 +1747,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
uint32_t irq;
Error *local_err = NULL;
- irq = xics_spapr_alloc_block(spapr->xics, 1, true, false, &local_err);
+ irq = spapr_ics_alloc_block(spapr->ics, 1, true, false, &local_err);
if (local_err) {
error_propagate(errp, local_err);
error_prepend(errp, "can't allocate LSIs: ");
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
index 8bfc5f971f8e..a0ee4fd26586 100644
--- a/hw/ppc/spapr_vio.c
+++ b/hw/ppc/spapr_vio.c
@@ -454,7 +454,7 @@ static void spapr_vio_busdev_realize(DeviceState *qdev, Error **errp)
dev->qdev.id = id;
}
- dev->irq = xics_spapr_alloc(spapr->xics, dev->irq, false, &local_err);
+ dev->irq = spapr_ics_alloc(spapr->ics, dev->irq, false, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index f9b17d860a75..21e506b13cfa 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -59,6 +59,7 @@ struct sPAPRMachineState {
QLIST_HEAD(, sPAPRPHBState) phbs;
struct sPAPRNVRAM *nvram;
XICSState *xics;
+ ICSState *ics;
DeviceState *rtc;
void *htab;
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 0ec585cc93ca..a36dae79cab5 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -180,10 +180,10 @@ struct ICSIRQState {
#define XICS_IRQS_SPAPR 1024
qemu_irq xics_get_qirq(XICSState *icp, int irq);
-int xics_spapr_alloc(XICSState *icp, int irq_hint, bool lsi, Error **errp);
-int xics_spapr_alloc_block(XICSState *icp, int num, bool lsi, bool align,
+int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp);
+int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, bool align,
Error **errp);
-void xics_spapr_free(XICSState *icp, int irq, int num);
+void spapr_ics_free(ICSState *ics, int irq, int num);
void spapr_dt_xics(XICSState *xics, void *fdt, uint32_t phandle);
void xics_cpu_setup(XICSState *icp, PowerPCCPU *cpu);
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 06/24] ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (4 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 05/24] ppc/xics: store the ICS object under the sPAPR machine Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 07/24] ppc/xics: introduce a XICSFabric QOM interface to handle ICSs Cédric Le Goater
` (18 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
This is, again, to reduce the use of the list of ICS objects. Let's
make each individual ICS and ICP object an InterruptStatsProvider and
remove this same interface from XICSState.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 76 +++++++++++++++++++++++++++++++---------------------------
1 file changed, 41 insertions(+), 35 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 9f22814815c9..b1294417a0ae 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -92,44 +92,44 @@ void xics_cpu_setup(XICSState *xics, PowerPCCPU *cpu)
}
}
-static void xics_common_pic_print_info(InterruptStatsProvider *obj,
- Monitor *mon)
+static void icp_pic_print_info(InterruptStatsProvider *obj,
+ Monitor *mon)
{
- XICSState *xics = XICS_COMMON(obj);
- ICSState *ics;
+ ICPState *icp = ICP(obj);
+ int cpu_index = icp->cs ? icp->cs->cpu_index : -1;
+
+ if (!icp->output) {
+ return;
+ }
+ monitor_printf(mon, "CPU %d XIRR=%08x (%p) PP=%02x MFRR=%02x\n",
+ cpu_index, icp->xirr, icp->xirr_owner,
+ icp->pending_priority, icp->mfrr);
+}
+
+static void ics_simple_pic_print_info(InterruptStatsProvider *obj,
+ Monitor *mon)
+{
+ ICSState *ics = ICS_SIMPLE(obj);
uint32_t i;
- for (i = 0; i < xics->nr_servers; i++) {
- ICPState *icp = &xics->ss[i];
+ monitor_printf(mon, "ICS %4x..%4x %p\n",
+ ics->offset, ics->offset + ics->nr_irqs - 1, ics);
- if (!icp->output) {
- continue;
- }
- monitor_printf(mon, "CPU %d XIRR=%08x (%p) PP=%02x MFRR=%02x\n",
- i, icp->xirr, icp->xirr_owner,
- icp->pending_priority, icp->mfrr);
+ if (!ics->irqs) {
+ return;
}
- QLIST_FOREACH(ics, &xics->ics, list) {
- monitor_printf(mon, "ICS %4x..%4x %p\n",
- ics->offset, ics->offset + ics->nr_irqs - 1, ics);
+ for (i = 0; i < ics->nr_irqs; i++) {
+ ICSIRQState *irq = ics->irqs + i;
- if (!ics->irqs) {
+ if (!(irq->flags & XICS_FLAGS_IRQ_MASK)) {
continue;
}
-
- for (i = 0; i < ics->nr_irqs; i++) {
- ICSIRQState *irq = ics->irqs + i;
-
- if (!(irq->flags & XICS_FLAGS_IRQ_MASK)) {
- continue;
- }
- monitor_printf(mon, " %4x %s %02x %02x\n",
- ics->offset + i,
- (irq->flags & XICS_FLAGS_IRQ_LSI) ?
- "LSI" : "MSI",
- irq->priority, irq->status);
- }
+ monitor_printf(mon, " %4x %s %02x %02x\n",
+ ics->offset + i,
+ (irq->flags & XICS_FLAGS_IRQ_LSI) ?
+ "LSI" : "MSI",
+ irq->priority, irq->status);
}
}
@@ -161,10 +161,8 @@ static void xics_common_initfn(Object *obj)
static void xics_common_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
- InterruptStatsProviderClass *ic = INTERRUPT_STATS_PROVIDER_CLASS(oc);
dc->reset = xics_common_reset;
- ic->print_info = xics_common_pic_print_info;
}
static const TypeInfo xics_common_info = {
@@ -174,10 +172,6 @@ static const TypeInfo xics_common_info = {
.class_size = sizeof(XICSStateClass),
.instance_init = xics_common_initfn,
.class_init = xics_common_class_init,
- .interfaces = (InterfaceInfo[]) {
- { TYPE_INTERRUPT_STATS_PROVIDER },
- { }
- },
};
/*
@@ -414,10 +408,12 @@ static void icp_realize(DeviceState *dev, Error **errp)
static void icp_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
+ InterruptStatsProviderClass *ic = INTERRUPT_STATS_PROVIDER_CLASS(klass);
dc->reset = icp_reset;
dc->vmsd = &vmstate_icp_server;
dc->realize = icp_realize;
+ ic->print_info = icp_pic_print_info;
}
static const TypeInfo icp_info = {
@@ -426,6 +422,10 @@ static const TypeInfo icp_info = {
.instance_size = sizeof(ICPState),
.class_init = icp_class_init,
.class_size = sizeof(ICPStateClass),
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_INTERRUPT_STATS_PROVIDER },
+ { }
+ },
};
/*
@@ -692,6 +692,7 @@ static void ics_simple_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
ICSStateClass *isc = ICS_BASE_CLASS(klass);
+ InterruptStatsProviderClass *ic = INTERRUPT_STATS_PROVIDER_CLASS(klass);
dc->realize = ics_simple_realize;
dc->props = ics_simple_properties;
@@ -701,6 +702,7 @@ static void ics_simple_class_init(ObjectClass *klass, void *data)
isc->reject = ics_simple_reject;
isc->resend = ics_simple_resend;
isc->eoi = ics_simple_eoi;
+ ic->print_info = ics_simple_pic_print_info;
}
static const TypeInfo ics_simple_info = {
@@ -710,6 +712,10 @@ static const TypeInfo ics_simple_info = {
.class_init = ics_simple_class_init,
.class_size = sizeof(ICSStateClass),
.instance_init = ics_simple_initfn,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_INTERRUPT_STATS_PROVIDER },
+ { }
+ },
};
static const TypeInfo ics_base_info = {
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 07/24] ppc/xics: introduce a XICSFabric QOM interface to handle ICSs
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (5 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 06/24] ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 08/24] ppc/xics: use the QOM interface under the sPAPR machine Cédric Le Goater
` (17 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
This interface provides two simple handlers. One is to get an ICS
(Interrupt Source Controller) object from an irq number and a second
to resend the irqs when needed.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 7 +++++++
include/hw/ppc/xics.h | 18 ++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index b1294417a0ae..ba800bacc9ac 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -726,6 +726,12 @@ static const TypeInfo ics_base_info = {
.class_size = sizeof(ICSStateClass),
};
+static const TypeInfo xics_fabric_info = {
+ .name = TYPE_XICS_FABRIC,
+ .parent = TYPE_INTERFACE,
+ .class_size = sizeof(XICSFabricClass),
+};
+
/*
* Exported functions
*/
@@ -766,6 +772,7 @@ static void xics_register_types(void)
type_register_static(&ics_simple_info);
type_register_static(&ics_base_info);
type_register_static(&icp_info);
+ type_register_static(&xics_fabric_info);
}
type_init(xics_register_types)
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index a36dae79cab5..58d1caa42ad3 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -177,6 +177,24 @@ struct ICSIRQState {
uint8_t flags;
};
+typedef struct XICSFabric {
+ Object parent;
+} XICSFabric;
+
+#define TYPE_XICS_FABRIC "xics-fabric"
+#define XICS_FABRIC(obj) \
+ OBJECT_CHECK(XICSFabric, (obj), TYPE_XICS_FABRIC)
+#define XICS_FABRIC_CLASS(klass) \
+ OBJECT_CLASS_CHECK(XICSFabricClass, (klass), TYPE_XICS_FABRIC)
+#define XICS_FABRIC_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(XICSFabricClass, (obj), TYPE_XICS_FABRIC)
+
+typedef struct XICSFabricClass {
+ InterfaceClass parent;
+ ICSState *(*ics_get)(XICSFabric *xi, int irq);
+ void (*ics_resend)(XICSFabric *xi);
+} XICSFabricClass;
+
#define XICS_IRQS_SPAPR 1024
qemu_irq xics_get_qirq(XICSState *icp, int irq);
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 08/24] ppc/xics: use the QOM interface under the sPAPR machine
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (6 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 07/24] ppc/xics: introduce a XICSFabric QOM interface to handle ICSs Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 09/24] ppc/xics: use the QOM interface to get irqs Cédric Le Goater
` (16 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
Add 'ics_get' and 'ics_resend' handlers to the sPAPR machine. These
are relatively simple for a single ICS.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 2 +-
hw/ppc/spapr.c | 18 ++++++++++++++++++
include/hw/ppc/xics.h | 1 +
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index ba800bacc9ac..d654f2103cce 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -193,7 +193,7 @@ static void ics_reject(ICSState *ics, uint32_t nr)
}
}
-static void ics_resend(ICSState *ics)
+void ics_resend(ICSState *ics)
{
ICSStateClass *k = ICS_BASE_GET_CLASS(ics);
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 5d2527a0e160..d4b97c81fa47 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2909,6 +2909,20 @@ static void spapr_phb_placement(sPAPRMachineState *spapr, uint32_t index,
*mmio64 = SPAPR_PCI_BASE + (index + 1) * SPAPR_PCI_MEM64_WIN_SIZE;
}
+static ICSState *spapr_ics_get(XICSFabric *dev, int irq)
+{
+ sPAPRMachineState *spapr = SPAPR_MACHINE(dev);
+
+ return ics_valid_irq(spapr->ics, irq) ? spapr->ics : NULL;
+}
+
+static void spapr_ics_resend(XICSFabric *dev)
+{
+ sPAPRMachineState *spapr = SPAPR_MACHINE(dev);
+
+ ics_resend(spapr->ics);
+}
+
static void spapr_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -2917,6 +2931,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
NMIClass *nc = NMI_CLASS(oc);
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
PPCVirtualHypervisorClass *vhc = PPC_VIRTUAL_HYPERVISOR_CLASS(oc);
+ XICSFabricClass *xic = XICS_FABRIC_CLASS(oc);
mc->desc = "pSeries Logical Partition (PAPR compliant)";
@@ -2950,6 +2965,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
nc->nmi_monitor_handler = spapr_nmi;
smc->phb_placement = spapr_phb_placement;
vhc->hypercall = emulate_spapr_hypercall;
+ xic->ics_get = spapr_ics_get;
+ xic->ics_resend = spapr_ics_resend;
}
static const TypeInfo spapr_machine_info = {
@@ -2966,6 +2983,7 @@ static const TypeInfo spapr_machine_info = {
{ TYPE_NMI },
{ TYPE_HOTPLUG_HANDLER },
{ TYPE_PPC_VIRTUAL_HYPERVISOR },
+ { TYPE_XICS_FABRIC },
{ }
},
};
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 58d1caa42ad3..446c10917291 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -222,5 +222,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,
void ics_set_irq_type(ICSState *ics, int srcno, bool lsi);
ICSState *xics_find_source(XICSState *icp, int irq);
+void ics_resend(ICSState *ics);
#endif /* XICS_H */
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 09/24] ppc/xics: use the QOM interface to get irqs
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (7 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 08/24] ppc/xics: use the QOM interface under the sPAPR machine Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 10/24] ppc/xics: use the QOM interface to resend irqs Cédric Le Goater
` (15 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 5 +++--
hw/ppc/spapr_events.c | 6 +++---
hw/ppc/spapr_pci.c | 2 +-
include/hw/pci-host/spapr.h | 2 +-
include/hw/ppc/spapr_vio.h | 2 +-
include/hw/ppc/xics.h | 3 ++-
6 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index d654f2103cce..fbd76b24f51c 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -747,9 +747,10 @@ ICSState *xics_find_source(XICSState *xics, int irq)
return NULL;
}
-qemu_irq xics_get_qirq(XICSState *xics, int irq)
+qemu_irq xics_get_qirq(XICSFabric *xi, int irq)
{
- ICSState *ics = xics_find_source(xics, irq);
+ XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
+ ICSState *ics = xic->ics_get(xi, irq);
if (ics) {
return ics->qirqs[irq - ics->offset];
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index 38b4258a9be7..24a5758e6243 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -481,7 +481,7 @@ static void spapr_powerdown_req(Notifier *n, void *opaque)
rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, new_epow, true);
- qemu_irq_pulse(xics_get_qirq(spapr->xics,
+ qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
rtas_event_log_to_irq(spapr,
RTAS_LOG_TYPE_EPOW)));
}
@@ -574,7 +574,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,
rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp, true);
- qemu_irq_pulse(xics_get_qirq(spapr->xics,
+ qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr),
rtas_event_log_to_irq(spapr,
RTAS_LOG_TYPE_HOTPLUG)));
}
@@ -695,7 +695,7 @@ static void check_exception(PowerPCCPU *cpu, sPAPRMachineState *spapr,
spapr_event_sources_get_source(spapr->event_sources, i);
g_assert(source->enabled);
- qemu_irq_pulse(xics_get_qirq(spapr->xics, source->irq));
+ qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr), source->irq));
}
}
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 3f580a68be8e..701eb3fec94e 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -737,7 +737,7 @@ static void spapr_msi_write(void *opaque, hwaddr addr,
trace_spapr_pci_msi_write(addr, data, irq);
- qemu_irq_pulse(xics_get_qirq(spapr->xics, irq));
+ qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr), irq));
}
static const MemoryRegionOps spapr_msi_ops = {
diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h
index 092294ed5a65..dfa76143f305 100644
--- a/include/hw/pci-host/spapr.h
+++ b/include/hw/pci-host/spapr.h
@@ -106,7 +106,7 @@ static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRPHBState *phb, int pin)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
- return xics_get_qirq(spapr->xics, phb->lsi_table[pin].irq);
+ return xics_get_qirq(XICS_FABRIC(spapr), phb->lsi_table[pin].irq);
}
PCIHostState *spapr_create_phb(sPAPRMachineState *spapr, int index);
diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h
index fc6f673ea086..2e9685a5d900 100644
--- a/include/hw/ppc/spapr_vio.h
+++ b/include/hw/ppc/spapr_vio.h
@@ -87,7 +87,7 @@ static inline qemu_irq spapr_vio_qirq(VIOsPAPRDevice *dev)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
- return xics_get_qirq(spapr->xics, dev->irq);
+ return xics_get_qirq(XICS_FABRIC(spapr), dev->irq);
}
static inline bool spapr_vio_dma_valid(VIOsPAPRDevice *dev, uint64_t taddr,
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 446c10917291..8a367a27e04d 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -197,7 +197,8 @@ typedef struct XICSFabricClass {
#define XICS_IRQS_SPAPR 1024
-qemu_irq xics_get_qirq(XICSState *icp, int irq);
+qemu_irq xics_get_qirq(XICSFabric *xi, int irq);
+
int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp);
int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, bool align,
Error **errp);
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 10/24] ppc/xics: use the QOM interface to resend irqs
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (8 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 09/24] ppc/xics: use the QOM interface to get irqs Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 11/24] ppc/xics: remove xics_find_source() Cédric Le Goater
` (14 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index fbd76b24f51c..92bf44a1a82b 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -229,16 +229,15 @@ static void icp_check_ipi(ICPState *ss)
qemu_irq_raise(ss->output);
}
-static void icp_resend(ICPState *ss)
+static void icp_resend(XICSFabric *xi, ICPState *ss)
{
- ICSState *ics;
+ XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
if (ss->mfrr < CPPR(ss)) {
icp_check_ipi(ss);
}
- QLIST_FOREACH(ics, &ss->xics->ics, list) {
- ics_resend(ics);
- }
+
+ xic->ics_resend(xi);
}
void icp_set_cppr(ICPState *ss, uint8_t cppr)
@@ -262,7 +261,7 @@ void icp_set_cppr(ICPState *ss, uint8_t cppr)
}
} else {
if (!XISR(ss)) {
- icp_resend(ss);
+ icp_resend(XICS_FABRIC(qdev_get_machine()), ss);
}
}
}
@@ -299,6 +298,8 @@ uint32_t icp_ipoll(ICPState *ss, uint32_t *mfrr)
void icp_eoi(ICPState *ss, uint32_t xirr)
{
+ XICSFabric *xi = XICS_FABRIC(qdev_get_machine());
+ XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
ICSState *ics;
uint32_t irq;
@@ -306,13 +307,13 @@ void icp_eoi(ICPState *ss, uint32_t xirr)
ss->xirr = (ss->xirr & ~CPPR_MASK) | (xirr & CPPR_MASK);
trace_xics_icp_eoi(ss->cs->cpu_index, xirr, ss->xirr);
irq = xirr & XISR_MASK;
- QLIST_FOREACH(ics, &ss->xics->ics, list) {
- if (ics_valid_irq(ics, irq)) {
- ics_eoi(ics, irq);
- }
+
+ ics = xic->ics_get(xi, irq);
+ if (ics) {
+ ics_eoi(ics, irq);
}
if (!XISR(ss)) {
- icp_resend(ss);
+ icp_resend(xi, ss);
}
}
@@ -592,10 +593,11 @@ static void ics_simple_reset(DeviceState *dev)
static int ics_simple_post_load(ICSState *ics, int version_id)
{
+ XICSFabric *xi = XICS_FABRIC(qdev_get_machine());
int i;
for (i = 0; i < ics->xics->nr_servers; i++) {
- icp_resend(&ics->xics->ss[i]);
+ icp_resend(xi, &ics->xics->ss[i]);
}
return 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 11/24] ppc/xics: remove xics_find_source()
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (9 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 10/24] ppc/xics: use the QOM interface to resend irqs Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 12/24] ppc/xics: register the reset handler of ICS objects Cédric Le Goater
` (13 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
It is not used anymore now that we have the QOM interface for XICS.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 12 ------------
include/hw/ppc/xics.h | 1 -
2 files changed, 13 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 92bf44a1a82b..04138bea0abe 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -737,18 +737,6 @@ static const TypeInfo xics_fabric_info = {
/*
* Exported functions
*/
-ICSState *xics_find_source(XICSState *xics, int irq)
-{
- ICSState *ics;
-
- QLIST_FOREACH(ics, &xics->ics, list) {
- if (ics_valid_irq(ics, irq)) {
- return ics;
- }
- }
- return NULL;
-}
-
qemu_irq xics_get_qirq(XICSFabric *xi, int irq)
{
XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 8a367a27e04d..aaf84b451d3f 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -222,7 +222,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,
void ics_set_irq_type(ICSState *ics, int srcno, bool lsi);
-ICSState *xics_find_source(XICSState *icp, int irq);
void ics_resend(ICSState *ics);
#endif /* XICS_H */
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 12/24] ppc/xics: register the reset handler of ICS objects
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (10 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 11/24] ppc/xics: remove xics_find_source() Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 13/24] ppc/xics: remove the XICS list of ICS Cédric Le Goater
` (12 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
The reset of the ICS objects is currently handled by XICS but this can
be done for each individual ICS. This also reduces the use of the XICS
list of ICS.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 5 -----
hw/ppc/spapr.c | 1 +
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 04138bea0abe..0673253330d4 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -139,16 +139,11 @@ static void ics_simple_pic_print_info(InterruptStatsProvider *obj,
static void xics_common_reset(DeviceState *d)
{
XICSState *xics = XICS_COMMON(d);
- ICSState *ics;
int i;
for (i = 0; i < xics->nr_servers; i++) {
device_reset(DEVICE(&xics->ss[i]));
}
-
- QLIST_FOREACH(ics, &xics->ics, list) {
- device_reset(DEVICE(ics));
- }
}
static void xics_common_initfn(Object *obj)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index d4b97c81fa47..ed109bfb11fa 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -112,6 +112,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
}
spapr->ics = ICS_SIMPLE(object_new(type_ics));
+ qdev_set_parent_bus(DEVICE(spapr->ics), sysbus_get_default());
object_property_add_child(OBJECT(spapr), "ics", OBJECT(spapr->ics), NULL);
object_property_set_int(OBJECT(spapr->ics), nr_irqs, "nr-irqs", &err);
object_property_add_const_link(OBJECT(spapr->ics), "xics", OBJECT(xics),
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 13/24] ppc/xics: remove the XICS list of ICS
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (11 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 12/24] ppc/xics: register the reset handler of ICS objects Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 14/24] ppc/xics: extend the QOM interface to handle ICPs Cédric Le Goater
` (11 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
This is not used anymore.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 8 --------
hw/ppc/spapr.c | 1 -
include/hw/ppc/xics.h | 2 --
3 files changed, 11 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 0673253330d4..2dd0c3165609 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -146,13 +146,6 @@ static void xics_common_reset(DeviceState *d)
}
}
-static void xics_common_initfn(Object *obj)
-{
- XICSState *xics = XICS_COMMON(obj);
-
- QLIST_INIT(&xics->ics);
-}
-
static void xics_common_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
@@ -165,7 +158,6 @@ static const TypeInfo xics_common_info = {
.parent = TYPE_DEVICE,
.instance_size = sizeof(XICSState),
.class_size = sizeof(XICSStateClass),
- .instance_init = xics_common_initfn,
.class_init = xics_common_class_init,
};
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index ed109bfb11fa..f2528255c9e9 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -122,7 +122,6 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
if (err) {
goto error;
}
- QLIST_INSERT_HEAD(&xics->ics, spapr->ics, list);
xics->ss = g_malloc0(nr_servers * sizeof(ICPState));
xics->nr_servers = nr_servers;
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index aaf84b451d3f..f333500b473d 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -82,7 +82,6 @@ struct XICSState {
/*< public >*/
uint32_t nr_servers;
ICPState *ss;
- QLIST_HEAD(, ICSState) ics;
};
#define TYPE_ICP "icp"
@@ -152,7 +151,6 @@ struct ICSState {
qemu_irq *qirqs;
ICSIRQState *irqs;
XICSState *xics;
- QLIST_ENTRY(ICSState) list;
};
static inline bool ics_valid_irq(ICSState *ics, uint32_t nr)
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 14/24] ppc/xics: extend the QOM interface to handle ICPs
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (12 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 13/24] ppc/xics: remove the XICS list of ICS Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 15/24] ppc/xics: simplify the cpu_setup() handler Cédric Le Goater
` (10 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
Let's add two new handlers for ICPs. One is to get an ICP object from
a server number and a second is to resend the irqs when needed.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 2 +-
hw/ppc/spapr.c | 20 ++++++++++++++++++++
include/hw/ppc/xics.h | 3 +++
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 2dd0c3165609..05922a040fb5 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -216,7 +216,7 @@ static void icp_check_ipi(ICPState *ss)
qemu_irq_raise(ss->output);
}
-static void icp_resend(XICSFabric *xi, ICPState *ss)
+void icp_resend(XICSFabric *xi, ICPState *ss)
{
XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index f2528255c9e9..fa589d5d260c 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2923,6 +2923,24 @@ static void spapr_ics_resend(XICSFabric *dev)
ics_resend(spapr->ics);
}
+static ICPState *spapr_icp_get(XICSFabric *xi, int server)
+{
+ sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
+
+ return (server < spapr->xics->nr_servers) ? &spapr->xics->ss[server] :
+ NULL;
+}
+
+static void spapr_icp_resend(XICSFabric *xi)
+{
+ sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
+ int i;
+
+ for (i = 0; i < spapr->xics->nr_servers; i++) {
+ icp_resend(xi, &spapr->xics->ss[i]);
+ }
+}
+
static void spapr_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -2967,6 +2985,8 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
vhc->hypercall = emulate_spapr_hypercall;
xic->ics_get = spapr_ics_get;
xic->ics_resend = spapr_ics_resend;
+ xic->icp_get = spapr_icp_get;
+ xic->icp_resend = spapr_icp_resend;
}
static const TypeInfo spapr_machine_info = {
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index f333500b473d..814f7ebe2246 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -191,6 +191,8 @@ typedef struct XICSFabricClass {
InterfaceClass parent;
ICSState *(*ics_get)(XICSFabric *xi, int irq);
void (*ics_resend)(XICSFabric *xi);
+ ICPState *(*icp_get)(XICSFabric *xi, int server);
+ void (*icp_resend)(XICSFabric *xi);
} XICSFabricClass;
#define XICS_IRQS_SPAPR 1024
@@ -221,5 +223,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,
void ics_set_irq_type(ICSState *ics, int srcno, bool lsi);
void ics_resend(ICSState *ics);
+void icp_resend(XICSFabric *xi, ICPState *ss);
#endif /* XICS_H */
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 15/24] ppc/xics: simplify the cpu_setup() handler
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (13 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 14/24] ppc/xics: extend the QOM interface to handle ICPs Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 16/24] ppc/xics: use the QOM interface to grab an ICP Cédric Le Goater
` (9 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
The cpu_setup() handler currently takes a 'XICSState *' argument to
grab the kernel ICP file descriptor. This interface can be simplified
by using the 'xics' backlink of the ICP object.
This change is also required by subsequent patches which makes use of
the QOM interface for XICS.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 5 +++--
hw/intc/xics_kvm.c | 11 +++--------
include/hw/ppc/xics.h | 2 +-
3 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 05922a040fb5..5e98d53ecc94 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -66,14 +66,15 @@ void xics_cpu_setup(XICSState *xics, PowerPCCPU *cpu)
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
ICPState *ss = &xics->ss[cs->cpu_index];
- XICSStateClass *info = XICS_COMMON_GET_CLASS(xics);
+ XICSStateClass *info;
assert(cs->cpu_index < xics->nr_servers);
ss->cs = cs;
+ info = XICS_COMMON_GET_CLASS(ss->xics);
if (info->cpu_setup) {
- info->cpu_setup(xics, cpu);
+ info->cpu_setup(ss, cpu);
}
switch (PPC_INPUT(env)) {
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 6cabc11f6be1..3941f31c5b3f 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -334,17 +334,12 @@ static const TypeInfo ics_kvm_info = {
/*
* XICS-KVM
*/
-static void xics_kvm_cpu_setup(XICSState *xics, PowerPCCPU *cpu)
+static void xics_kvm_cpu_setup(ICPState *ss, PowerPCCPU *cpu)
{
- CPUState *cs;
- ICPState *ss;
- KVMXICSState *xicskvm = XICS_SPAPR_KVM(xics);
+ CPUState *cs = CPU(cpu);
+ KVMXICSState *xicskvm = XICS_SPAPR_KVM(ss->xics);
int ret;
- cs = CPU(cpu);
- ss = &xics->ss[cs->cpu_index];
-
- assert(cs->cpu_index < xics->nr_servers);
if (xicskvm->kernel_xics_fd == -1) {
abort();
}
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 814f7ebe2246..3e7bee107da5 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -73,7 +73,7 @@ typedef struct ICSIRQState ICSIRQState;
struct XICSStateClass {
DeviceClass parent_class;
- void (*cpu_setup)(XICSState *icp, PowerPCCPU *cpu);
+ void (*cpu_setup)(ICPState *icp, PowerPCCPU *cpu);
};
struct XICSState {
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 16/24] ppc/xics: use the QOM interface to grab an ICP
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (14 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 15/24] ppc/xics: simplify the cpu_setup() handler Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 17/24] ppc/xics: simplify spapr_dt_xics() interface Cédric Le Goater
` (8 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
Also introduce a xics_icp_get() helper to simplify the changes.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 31 ++++++++++++++++++-------------
hw/intc/xics_spapr.c | 17 +++++++++--------
hw/ppc/spapr_cpu_core.c | 4 ++--
include/hw/ppc/xics.h | 8 ++++----
4 files changed, 33 insertions(+), 27 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 5e98d53ecc94..688802abd80e 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -49,26 +49,26 @@ int xics_get_cpu_index_by_dt_id(int cpu_dt_id)
return -1;
}
-void xics_cpu_destroy(XICSState *xics, PowerPCCPU *cpu)
+void xics_cpu_destroy(XICSFabric *xi, PowerPCCPU *cpu)
{
CPUState *cs = CPU(cpu);
- ICPState *ss = &xics->ss[cs->cpu_index];
+ ICPState *ss = xics_icp_get(xi, cs->cpu_index);
- assert(cs->cpu_index < xics->nr_servers);
+ assert(ss);
assert(cs == ss->cs);
ss->output = NULL;
ss->cs = NULL;
}
-void xics_cpu_setup(XICSState *xics, PowerPCCPU *cpu)
+void xics_cpu_setup(XICSFabric *xi, PowerPCCPU *cpu)
{
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
- ICPState *ss = &xics->ss[cs->cpu_index];
+ ICPState *ss = xics_icp_get(xi, cs->cpu_index);
XICSStateClass *info;
- assert(cs->cpu_index < xics->nr_servers);
+ assert(ss);
ss->cs = cs;
@@ -307,8 +307,9 @@ void icp_eoi(ICPState *ss, uint32_t xirr)
static void icp_irq(ICSState *ics, int server, int nr, uint8_t priority)
{
- XICSState *xics = ics->xics;
- ICPState *ss = xics->ss + server;
+ XICSFabric *xi = XICS_FABRIC(qdev_get_machine());
+ XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
+ ICPState *ss = xic->icp_get(xi, server);
trace_xics_icp_irq(server, nr, priority);
@@ -582,12 +583,9 @@ static void ics_simple_reset(DeviceState *dev)
static int ics_simple_post_load(ICSState *ics, int version_id)
{
XICSFabric *xi = XICS_FABRIC(qdev_get_machine());
- int i;
-
- for (i = 0; i < ics->xics->nr_servers; i++) {
- icp_resend(xi, &ics->xics->ss[i]);
- }
+ XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
+ xic->icp_resend(xi);
return 0;
}
@@ -737,6 +735,13 @@ qemu_irq xics_get_qirq(XICSFabric *xi, int irq)
return NULL;
}
+ICPState *xics_icp_get(XICSFabric *xi, int server)
+{
+ XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
+
+ return xic->icp_get(xi, server);
+}
+
void ics_set_irq_type(ICSState *ics, int srcno, bool lsi)
{
assert(!(ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MASK));
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index 1501e796e5e0..bc62b0ccc254 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -44,7 +44,7 @@ static target_ulong h_cppr(PowerPCCPU *cpu, sPAPRMachineState *spapr,
target_ulong opcode, target_ulong *args)
{
CPUState *cs = CPU(cpu);
- ICPState *icp = &spapr->xics->ss[cs->cpu_index];
+ ICPState *icp = xics_icp_get(XICS_FABRIC(spapr), cs->cpu_index);
target_ulong cppr = args[0];
icp_set_cppr(icp, cppr);
@@ -56,12 +56,13 @@ static target_ulong h_ipi(PowerPCCPU *cpu, sPAPRMachineState *spapr,
{
target_ulong server = xics_get_cpu_index_by_dt_id(args[0]);
target_ulong mfrr = args[1];
+ ICPState *icp = xics_icp_get(XICS_FABRIC(spapr), server);
- if (server >= spapr->xics->nr_servers) {
+ if (!icp) {
return H_PARAMETER;
}
- icp_set_mfrr(spapr->xics->ss + server, mfrr);
+ icp_set_mfrr(icp, mfrr);
return H_SUCCESS;
}
@@ -69,7 +70,7 @@ static target_ulong h_xirr(PowerPCCPU *cpu, sPAPRMachineState *spapr,
target_ulong opcode, target_ulong *args)
{
CPUState *cs = CPU(cpu);
- ICPState *icp = &spapr->xics->ss[cs->cpu_index];
+ ICPState *icp = xics_icp_get(XICS_FABRIC(spapr), cs->cpu_index);
uint32_t xirr = icp_accept(icp);
args[0] = xirr;
@@ -80,7 +81,7 @@ static target_ulong h_xirr_x(PowerPCCPU *cpu, sPAPRMachineState *spapr,
target_ulong opcode, target_ulong *args)
{
CPUState *cs = CPU(cpu);
- ICPState *icp = &spapr->xics->ss[cs->cpu_index];
+ ICPState *icp = xics_icp_get(XICS_FABRIC(spapr), cs->cpu_index);
uint32_t xirr = icp_accept(icp);
args[0] = xirr;
@@ -92,7 +93,7 @@ static target_ulong h_eoi(PowerPCCPU *cpu, sPAPRMachineState *spapr,
target_ulong opcode, target_ulong *args)
{
CPUState *cs = CPU(cpu);
- ICPState *icp = &spapr->xics->ss[cs->cpu_index];
+ ICPState *icp = xics_icp_get(XICS_FABRIC(spapr), cs->cpu_index);
target_ulong xirr = args[0];
icp_eoi(icp, xirr);
@@ -103,7 +104,7 @@ static target_ulong h_ipoll(PowerPCCPU *cpu, sPAPRMachineState *spapr,
target_ulong opcode, target_ulong *args)
{
CPUState *cs = CPU(cpu);
- ICPState *icp = &spapr->xics->ss[cs->cpu_index];
+ ICPState *icp = xics_icp_get(XICS_FABRIC(spapr), cs->cpu_index);
uint32_t mfrr;
uint32_t xirr = icp_ipoll(icp, &mfrr);
@@ -134,7 +135,7 @@ static void rtas_set_xive(PowerPCCPU *cpu, sPAPRMachineState *spapr,
server = xics_get_cpu_index_by_dt_id(rtas_ld(args, 1));
priority = rtas_ld(args, 2);
- if (!ics_valid_irq(ics, nr) || (server >= ics->xics->nr_servers)
+ if (!ics_valid_irq(ics, nr) || !xics_icp_get(XICS_FABRIC(spapr), server)
|| (priority > 0xff)) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 55cd0456ebe8..befe53a65863 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -42,7 +42,7 @@ static void spapr_cpu_destroy(PowerPCCPU *cpu)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
- xics_cpu_destroy(spapr->xics, cpu);
+ xics_cpu_destroy(XICS_FABRIC(spapr), cpu);
qemu_unregister_reset(spapr_cpu_reset, cpu);
}
@@ -76,7 +76,7 @@ static void spapr_cpu_init(sPAPRMachineState *spapr, PowerPCCPU *cpu,
cs->numa_node = i;
}
- xics_cpu_setup(spapr->xics, cpu);
+ xics_cpu_setup(XICS_FABRIC(spapr), cpu);
qemu_register_reset(spapr_cpu_reset, cpu);
spapr_cpu_reset(cpu);
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 3e7bee107da5..1961ee2a690f 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -197,16 +197,16 @@ typedef struct XICSFabricClass {
#define XICS_IRQS_SPAPR 1024
-qemu_irq xics_get_qirq(XICSFabric *xi, int irq);
-
int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp);
int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, bool align,
Error **errp);
void spapr_ics_free(ICSState *ics, int irq, int num);
void spapr_dt_xics(XICSState *xics, void *fdt, uint32_t phandle);
-void xics_cpu_setup(XICSState *icp, PowerPCCPU *cpu);
-void xics_cpu_destroy(XICSState *icp, PowerPCCPU *cpu);
+qemu_irq xics_get_qirq(XICSFabric *xi, int irq);
+ICPState *xics_icp_get(XICSFabric *xi, int server);
+void xics_cpu_setup(XICSFabric *xi, PowerPCCPU *cpu);
+void xics_cpu_destroy(XICSFabric *xi, PowerPCCPU *cpu);
/* Internal XICS interfaces */
int xics_get_cpu_index_by_dt_id(int cpu_dt_id);
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 17/24] ppc/xics: simplify spapr_dt_xics() interface
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (15 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 16/24] ppc/xics: use the QOM interface to grab an ICP Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 18/24] ppc/xics: register the reset handler of ICP objects Cédric Le Goater
` (7 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
spapr_dt_xics() only needs the number of servers to build the device
tree nodes. Let's change the routine interface to reflect that.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics_spapr.c | 4 ++--
hw/ppc/spapr.c | 2 +-
include/hw/ppc/xics.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index bc62b0ccc254..35045a20b860 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -387,10 +387,10 @@ void spapr_ics_free(ICSState *ics, int irq, int num)
}
}
-void spapr_dt_xics(XICSState *xics, void *fdt, uint32_t phandle)
+void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle)
{
uint32_t interrupt_server_ranges_prop[] = {
- 0, cpu_to_be32(xics->nr_servers),
+ 0, cpu_to_be32(nr_servers),
};
int node;
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index fa589d5d260c..82f6cfb21ece 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -964,7 +964,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,
_FDT(fdt_setprop_cell(fdt, 0, "#size-cells", 2));
/* /interrupt controller */
- spapr_dt_xics(spapr->xics, fdt, PHANDLE_XICP);
+ spapr_dt_xics(spapr->xics->nr_servers, fdt, PHANDLE_XICP);
ret = spapr_populate_memory(spapr, fdt);
if (ret < 0) {
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 1961ee2a690f..879853cc69c2 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -201,7 +201,7 @@ int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp);
int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, bool align,
Error **errp);
void spapr_ics_free(ICSState *ics, int irq, int num);
-void spapr_dt_xics(XICSState *xics, void *fdt, uint32_t phandle);
+void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle);
qemu_irq xics_get_qirq(XICSFabric *xi, int irq);
ICPState *xics_icp_get(XICSFabric *xi, int server);
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 18/24] ppc/xics: register the reset handler of ICP objects
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (16 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 17/24] ppc/xics: simplify spapr_dt_xics() interface Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 19/24] ppc/xics: move the ICP array under the sPAPR machine Cédric Le Goater
` (6 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
The reset of the ICP objects is currently handled by XICS but this can
be done for each individual ICP.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 18 ------------------
hw/ppc/spapr.c | 1 +
2 files changed, 1 insertion(+), 18 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 688802abd80e..30ddc54ce8e3 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -137,29 +137,11 @@ static void ics_simple_pic_print_info(InterruptStatsProvider *obj,
/*
* XICS Common class - parent for emulated XICS and KVM-XICS
*/
-static void xics_common_reset(DeviceState *d)
-{
- XICSState *xics = XICS_COMMON(d);
- int i;
-
- for (i = 0; i < xics->nr_servers; i++) {
- device_reset(DEVICE(&xics->ss[i]));
- }
-}
-
-static void xics_common_class_init(ObjectClass *oc, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(oc);
-
- dc->reset = xics_common_reset;
-}
-
static const TypeInfo xics_common_info = {
.name = TYPE_XICS_COMMON,
.parent = TYPE_DEVICE,
.instance_size = sizeof(XICSState),
.class_size = sizeof(XICSStateClass),
- .class_init = xics_common_class_init,
};
/*
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 82f6cfb21ece..ae9a59b226c7 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -130,6 +130,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
ICPState *icp = &xics->ss[i];
object_initialize(icp, sizeof(*icp), type_icp);
+ qdev_set_parent_bus(DEVICE(icp), sysbus_get_default());
object_property_add_child(OBJECT(xics), "icp[*]", OBJECT(icp), NULL);
object_property_add_const_link(OBJECT(icp), "xics", OBJECT(xics), NULL);
object_property_set_bool(OBJECT(icp), true, "realized", &err);
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 19/24] ppc/xics: move the ICP array under the sPAPR machine
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (17 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 18/24] ppc/xics: register the reset handler of ICP objects Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 20/24] ppc/xics: move kernel_xics_fd out of KVMXICSState Cédric Le Goater
` (5 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
This is the last step to remove the XICSState abstraction and have the
machine hold all the objects related to interrupts : ICSs and ICPs.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/ppc/spapr.c | 17 ++++++++---------
include/hw/ppc/spapr.h | 3 +++
include/hw/ppc/xics.h | 2 --
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index ae9a59b226c7..032c8ab008d8 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -123,15 +123,15 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
goto error;
}
- xics->ss = g_malloc0(nr_servers * sizeof(ICPState));
- xics->nr_servers = nr_servers;
+ spapr->icps = g_malloc0(nr_servers * sizeof(ICPState));
+ spapr->nr_servers = nr_servers;
for (i = 0; i < nr_servers; i++) {
- ICPState *icp = &xics->ss[i];
+ ICPState *icp = &spapr->icps[i];
object_initialize(icp, sizeof(*icp), type_icp);
qdev_set_parent_bus(DEVICE(icp), sysbus_get_default());
- object_property_add_child(OBJECT(xics), "icp[*]", OBJECT(icp), NULL);
+ object_property_add_child(OBJECT(spapr), "icp[*]", OBJECT(icp), NULL);
object_property_add_const_link(OBJECT(icp), "xics", OBJECT(xics), NULL);
object_property_set_bool(OBJECT(icp), true, "realized", &err);
if (err) {
@@ -965,7 +965,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,
_FDT(fdt_setprop_cell(fdt, 0, "#size-cells", 2));
/* /interrupt controller */
- spapr_dt_xics(spapr->xics->nr_servers, fdt, PHANDLE_XICP);
+ spapr_dt_xics(spapr->nr_servers, fdt, PHANDLE_XICP);
ret = spapr_populate_memory(spapr, fdt);
if (ret < 0) {
@@ -2928,8 +2928,7 @@ static ICPState *spapr_icp_get(XICSFabric *xi, int server)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
- return (server < spapr->xics->nr_servers) ? &spapr->xics->ss[server] :
- NULL;
+ return (server < spapr->nr_servers) ? &spapr->icps[server] : NULL;
}
static void spapr_icp_resend(XICSFabric *xi)
@@ -2937,8 +2936,8 @@ static void spapr_icp_resend(XICSFabric *xi)
sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
int i;
- for (i = 0; i < spapr->xics->nr_servers; i++) {
- icp_resend(xi, &spapr->xics->ss[i]);
+ for (i = 0; i < spapr->nr_servers; i++) {
+ icp_resend(xi, &spapr->icps[i]);
}
}
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 21e506b13cfa..f5bbb040f941 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -95,6 +95,9 @@ struct sPAPRMachineState {
/*< public >*/
char *kvm_type;
MemoryHotplugState hotplug_memory;
+
+ uint32_t nr_servers;
+ ICPState *icps;
};
#define H_SUCCESS 0
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 879853cc69c2..332a96b51d1c 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -80,8 +80,6 @@ struct XICSState {
/*< private >*/
DeviceState parent_obj;
/*< public >*/
- uint32_t nr_servers;
- ICPState *ss;
};
#define TYPE_ICP "icp"
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 20/24] ppc/xics: move kernel_xics_fd out of KVMXICSState
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (18 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 19/24] ppc/xics: move the ICP array under the sPAPR machine Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 21/24] ppc/xics: move the cpu_setup() handler under the ICPState class Cédric Le Goater
` (4 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
The kernel ICP file descriptor is the only reason behind the
KVMXICSState class and it's in the way of more cleanups. Let's make it
a static for the moment and move forward.
If this is problem, we could use an attribute under the sPAPR machine
later on.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics_kvm.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 3941f31c5b3f..19c55fa74412 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -40,6 +40,8 @@
#include <sys/ioctl.h>
+static int kernel_xics_fd = -1;
+
typedef struct KVMXICSState {
XICSState parent_obj;
@@ -145,7 +147,6 @@ static const TypeInfo icp_kvm_info = {
*/
static void ics_get_kvm_state(ICSState *ics)
{
- KVMXICSState *xicskvm = XICS_SPAPR_KVM(ics->xics);
uint64_t state;
struct kvm_device_attr attr = {
.flags = 0,
@@ -160,7 +161,7 @@ static void ics_get_kvm_state(ICSState *ics)
attr.attr = i + ics->offset;
- ret = ioctl(xicskvm->kernel_xics_fd, KVM_GET_DEVICE_ATTR, &attr);
+ ret = ioctl(kernel_xics_fd, KVM_GET_DEVICE_ATTR, &attr);
if (ret != 0) {
error_report("Unable to retrieve KVM interrupt controller state"
" for IRQ %d: %s", i + ics->offset, strerror(errno));
@@ -204,7 +205,6 @@ static void ics_get_kvm_state(ICSState *ics)
static int ics_set_kvm_state(ICSState *ics, int version_id)
{
- KVMXICSState *xicskvm = XICS_SPAPR_KVM(ics->xics);
uint64_t state;
struct kvm_device_attr attr = {
.flags = 0,
@@ -238,7 +238,7 @@ static int ics_set_kvm_state(ICSState *ics, int version_id)
}
}
- ret = ioctl(xicskvm->kernel_xics_fd, KVM_SET_DEVICE_ATTR, &attr);
+ ret = ioctl(kernel_xics_fd, KVM_SET_DEVICE_ATTR, &attr);
if (ret != 0) {
error_report("Unable to restore KVM interrupt controller state"
" for IRQs %d: %s", i + ics->offset, strerror(errno));
@@ -337,10 +337,9 @@ static const TypeInfo ics_kvm_info = {
static void xics_kvm_cpu_setup(ICPState *ss, PowerPCCPU *cpu)
{
CPUState *cs = CPU(cpu);
- KVMXICSState *xicskvm = XICS_SPAPR_KVM(ss->xics);
int ret;
- if (xicskvm->kernel_xics_fd == -1) {
+ if (kernel_xics_fd == -1) {
abort();
}
@@ -353,7 +352,7 @@ static void xics_kvm_cpu_setup(ICPState *ss, PowerPCCPU *cpu)
return;
}
- ret = kvm_vcpu_enable_cap(cs, KVM_CAP_IRQ_XICS, 0, xicskvm->kernel_xics_fd,
+ ret = kvm_vcpu_enable_cap(cs, KVM_CAP_IRQ_XICS, 0, kernel_xics_fd,
kvm_arch_vcpu_id(cs));
if (ret < 0) {
error_report("Unable to connect CPU%ld to kernel XICS: %s",
@@ -374,7 +373,6 @@ static void rtas_dummy(PowerPCCPU *cpu, sPAPRMachineState *spapr,
static void xics_kvm_realize(DeviceState *dev, Error **errp)
{
- KVMXICSState *xicskvm = XICS_SPAPR_KVM(dev);
int rc;
struct kvm_create_device xics_create_device = {
.type = KVM_DEV_TYPE_XICS,
@@ -423,7 +421,7 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp)
goto fail;
}
- xicskvm->kernel_xics_fd = xics_create_device.fd;
+ kernel_xics_fd = xics_create_device.fd;
kvm_kernel_irqchip = true;
kvm_msi_via_irqfd_allowed = true;
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 21/24] ppc/xics: move the cpu_setup() handler under the ICPState class
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (19 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 20/24] ppc/xics: move kernel_xics_fd out of KVMXICSState Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 22/24] ppc/xics: remove the 'xics' backlinks Cédric Le Goater
` (3 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
The cpu_setup() handler is currently under the XICSState class but it
really belongs under ICPState as it is setting up an individual vCPU.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 8 +++----
hw/intc/xics_kvm.c | 58 +++++++++++++++++++++++++--------------------------
include/hw/ppc/xics.h | 3 +--
3 files changed, 34 insertions(+), 35 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 30ddc54ce8e3..571063a67125 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -66,15 +66,15 @@ void xics_cpu_setup(XICSFabric *xi, PowerPCCPU *cpu)
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
ICPState *ss = xics_icp_get(xi, cs->cpu_index);
- XICSStateClass *info;
+ ICPStateClass *icpc;
assert(ss);
ss->cs = cs;
- info = XICS_COMMON_GET_CLASS(ss->xics);
- if (info->cpu_setup) {
- info->cpu_setup(ss, cpu);
+ icpc = ICP_GET_CLASS(ss);
+ if (icpc->cpu_setup) {
+ icpc->cpu_setup(ss, cpu);
}
switch (PPC_INPUT(env)) {
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 19c55fa74412..850777eab913 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -124,6 +124,34 @@ static void icp_kvm_reset(DeviceState *dev)
icp_set_kvm_state(icp, 1);
}
+static void icp_kvm_cpu_setup(ICPState *ss, PowerPCCPU *cpu)
+{
+ CPUState *cs = CPU(cpu);
+ int ret;
+
+ if (kernel_xics_fd == -1) {
+ abort();
+ }
+
+ /*
+ * If we are reusing a parked vCPU fd corresponding to the CPU
+ * which was hot-removed earlier we don't have to renable
+ * KVM_CAP_IRQ_XICS capability again.
+ */
+ if (ss->cap_irq_xics_enabled) {
+ return;
+ }
+
+ ret = kvm_vcpu_enable_cap(cs, KVM_CAP_IRQ_XICS, 0, kernel_xics_fd,
+ kvm_arch_vcpu_id(cs));
+ if (ret < 0) {
+ error_report("Unable to connect CPU%ld to kernel XICS: %s",
+ kvm_arch_vcpu_id(cs), strerror(errno));
+ exit(1);
+ }
+ ss->cap_irq_xics_enabled = true;
+}
+
static void icp_kvm_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -132,6 +160,7 @@ static void icp_kvm_class_init(ObjectClass *klass, void *data)
dc->reset = icp_kvm_reset;
icpc->pre_save = icp_get_kvm_state;
icpc->post_load = icp_set_kvm_state;
+ icpc->cpu_setup = icp_kvm_cpu_setup;
}
static const TypeInfo icp_kvm_info = {
@@ -334,33 +363,6 @@ static const TypeInfo ics_kvm_info = {
/*
* XICS-KVM
*/
-static void xics_kvm_cpu_setup(ICPState *ss, PowerPCCPU *cpu)
-{
- CPUState *cs = CPU(cpu);
- int ret;
-
- if (kernel_xics_fd == -1) {
- abort();
- }
-
- /*
- * If we are reusing a parked vCPU fd corresponding to the CPU
- * which was hot-removed earlier we don't have to renable
- * KVM_CAP_IRQ_XICS capability again.
- */
- if (ss->cap_irq_xics_enabled) {
- return;
- }
-
- ret = kvm_vcpu_enable_cap(cs, KVM_CAP_IRQ_XICS, 0, kernel_xics_fd,
- kvm_arch_vcpu_id(cs));
- if (ret < 0) {
- error_report("Unable to connect CPU%ld to kernel XICS: %s",
- kvm_arch_vcpu_id(cs), strerror(errno));
- exit(1);
- }
- ss->cap_irq_xics_enabled = true;
-}
static void rtas_dummy(PowerPCCPU *cpu, sPAPRMachineState *spapr,
uint32_t token,
@@ -439,10 +441,8 @@ fail:
static void xics_kvm_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
- XICSStateClass *xsc = XICS_COMMON_CLASS(oc);
dc->realize = xics_kvm_realize;
- xsc->cpu_setup = xics_kvm_cpu_setup;
}
static const TypeInfo xics_spapr_kvm_info = {
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 332a96b51d1c..1ea8d8139678 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -72,8 +72,6 @@ typedef struct ICSIRQState ICSIRQState;
struct XICSStateClass {
DeviceClass parent_class;
-
- void (*cpu_setup)(ICPState *icp, PowerPCCPU *cpu);
};
struct XICSState {
@@ -98,6 +96,7 @@ struct ICPStateClass {
void (*pre_save)(ICPState *s);
int (*post_load)(ICPState *s, int version_id);
+ void (*cpu_setup)(ICPState *icp, PowerPCCPU *cpu);
};
struct ICPState {
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 22/24] ppc/xics: remove the 'xics' backlinks
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (20 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 21/24] ppc/xics: move the cpu_setup() handler under the ICPState class Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 23/24] ppc/xics: export the XICS init routines Cédric Le Goater
` (2 subsequent siblings)
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
These are not used anymore. Do the cleanups
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 28 ----------------------------
hw/intc/xics_kvm.c | 10 ----------
hw/ppc/spapr.c | 3 ---
include/hw/ppc/xics.h | 3 ---
4 files changed, 44 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 571063a67125..565b5ec0686a 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -360,23 +360,6 @@ static void icp_reset(DeviceState *dev)
qemu_set_irq(icp->output, 0);
}
-static void icp_realize(DeviceState *dev, Error **errp)
-{
- ICPState *icp = ICP(dev);
- Object *obj;
- Error *err = NULL;
-
- obj = object_property_get_link(OBJECT(dev), "xics", &err);
- if (!obj) {
- error_setg(errp, "%s: required link 'xics' not found: %s",
- __func__, error_get_pretty(err));
- return;
- }
-
- icp->xics = XICS_COMMON(obj);
-}
-
-
static void icp_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -384,7 +367,6 @@ static void icp_class_init(ObjectClass *klass, void *data)
dc->reset = icp_reset;
dc->vmsd = &vmstate_icp_server;
- dc->realize = icp_realize;
ic->print_info = icp_pic_print_info;
}
@@ -634,16 +616,6 @@ static void ics_simple_initfn(Object *obj)
static void ics_simple_realize(DeviceState *dev, Error **errp)
{
ICSState *ics = ICS_SIMPLE(dev);
- Object *obj;
- Error *err = NULL;
-
- obj = object_property_get_link(OBJECT(dev), "xics", &err);
- if (!obj) {
- error_setg(errp, "%s: required link 'xics' not found: %s",
- __func__, error_get_pretty(err));
- return;
- }
- ics->xics = XICS_COMMON(obj);
if (!ics->nr_irqs) {
error_setg(errp, "Number of interrupts needs to be greater 0");
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 850777eab913..7c1809873c29 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -323,16 +323,6 @@ static void ics_kvm_reset(DeviceState *dev)
static void ics_kvm_realize(DeviceState *dev, Error **errp)
{
ICSState *ics = ICS_SIMPLE(dev);
- Object *obj;
- Error *err = NULL;
-
- obj = object_property_get_link(OBJECT(dev), "xics", &err);
- if (!obj) {
- error_setg(errp, "%s: required link 'xics' not found: %s",
- __func__, error_get_pretty(err));
- return;
- }
- ics->xics = XICS_COMMON(obj);
if (!ics->nr_irqs) {
error_setg(errp, "Number of interrupts needs to be greater 0");
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 032c8ab008d8..cfd0139dd418 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -115,8 +115,6 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
qdev_set_parent_bus(DEVICE(spapr->ics), sysbus_get_default());
object_property_add_child(OBJECT(spapr), "ics", OBJECT(spapr->ics), NULL);
object_property_set_int(OBJECT(spapr->ics), nr_irqs, "nr-irqs", &err);
- object_property_add_const_link(OBJECT(spapr->ics), "xics", OBJECT(xics),
- NULL);
object_property_set_bool(OBJECT(spapr->ics), true, "realized", &local_err);
error_propagate(&err, local_err);
if (err) {
@@ -132,7 +130,6 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
object_initialize(icp, sizeof(*icp), type_icp);
qdev_set_parent_bus(DEVICE(icp), sysbus_get_default());
object_property_add_child(OBJECT(spapr), "icp[*]", OBJECT(icp), NULL);
- object_property_add_const_link(OBJECT(icp), "xics", OBJECT(xics), NULL);
object_property_set_bool(OBJECT(icp), true, "realized", &err);
if (err) {
goto error;
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 1ea8d8139678..d1d110051c72 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -110,8 +110,6 @@ struct ICPState {
uint8_t mfrr;
qemu_irq output;
bool cap_irq_xics_enabled;
-
- XICSState *xics;
};
#define TYPE_ICS_BASE "ics-base"
@@ -147,7 +145,6 @@ struct ICSState {
uint32_t offset;
qemu_irq *qirqs;
ICSIRQState *irqs;
- XICSState *xics;
};
static inline bool ics_valid_irq(ICSState *ics, uint32_t nr)
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 23/24] ppc/xics: export the XICS init routines
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (21 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 22/24] ppc/xics: remove the 'xics' backlinks Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 24/24] ppc/xics: remove the XICSState classes Cédric Le Goater
2017-02-24 10:41 ` [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
There is nothing left related to the XICS object in the realize
functions of the KVMXICSState and XICSState class. So adapt the
interfaces to call these routines directly from the sPAPR machine init
sequence.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics_kvm.c | 13 +++----------
hw/intc/xics_spapr.c | 11 ++---------
hw/ppc/spapr.c | 4 +++-
include/hw/ppc/xics.h | 5 +++++
4 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 7c1809873c29..4ea34ea6dac5 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -363,7 +363,7 @@ static void rtas_dummy(PowerPCCPU *cpu, sPAPRMachineState *spapr,
__func__);
}
-static void xics_kvm_realize(DeviceState *dev, Error **errp)
+int xics_kvm_init(sPAPRMachineState *spapr, Error **errp)
{
int rc;
struct kvm_create_device xics_create_device = {
@@ -419,27 +419,20 @@ static void xics_kvm_realize(DeviceState *dev, Error **errp)
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_direct_mapping = true;
- return;
+ return rc;
fail:
kvmppc_define_rtas_kernel_token(0, "ibm,set-xive");
kvmppc_define_rtas_kernel_token(0, "ibm,get-xive");
kvmppc_define_rtas_kernel_token(0, "ibm,int-on");
kvmppc_define_rtas_kernel_token(0, "ibm,int-off");
-}
-
-static void xics_kvm_class_init(ObjectClass *oc, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(oc);
-
- dc->realize = xics_kvm_realize;
+ return -1;
}
static const TypeInfo xics_spapr_kvm_info = {
.name = TYPE_XICS_SPAPR_KVM,
.parent = TYPE_XICS_COMMON,
.instance_size = sizeof(KVMXICSState),
- .class_init = xics_kvm_class_init,
};
static void xics_kvm_register_types(void)
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index 35045a20b860..aaf6808cd220 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -240,7 +240,7 @@ static void rtas_int_on(PowerPCCPU *cpu, sPAPRMachineState *spapr,
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
}
-static void xics_spapr_realize(DeviceState *dev, Error **errp)
+int xics_spapr_init(sPAPRMachineState *spapr, Error **errp)
{
/* Registration of global state belongs into realize */
spapr_rtas_register(RTAS_IBM_SET_XIVE, "ibm,set-xive", rtas_set_xive);
@@ -254,13 +254,7 @@ static void xics_spapr_realize(DeviceState *dev, Error **errp)
spapr_register_hypercall(H_XIRR_X, h_xirr_x);
spapr_register_hypercall(H_EOI, h_eoi);
spapr_register_hypercall(H_IPOLL, h_ipoll);
-}
-
-static void xics_spapr_class_init(ObjectClass *oc, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(oc);
-
- dc->realize = xics_spapr_realize;
+ return 0;
}
static const TypeInfo xics_spapr_info = {
@@ -268,7 +262,6 @@ static const TypeInfo xics_spapr_info = {
.parent = TYPE_XICS_COMMON,
.instance_size = sizeof(XICSState),
.class_size = sizeof(XICSStateClass),
- .class_init = xics_spapr_class_init,
};
#define ICS_IRQ_FREE(ics, srcno) \
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index cfd0139dd418..0a730bd69862 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -156,7 +156,8 @@ static XICSState *xics_system_init(MachineState *machine,
if (kvm_enabled()) {
Error *err = NULL;
- if (machine_kernel_irqchip_allowed(machine)) {
+ if (machine_kernel_irqchip_allowed(machine) &&
+ !xics_kvm_init(SPAPR_MACHINE(machine), errp)) {
xics = try_create_xics(SPAPR_MACHINE(machine),
TYPE_XICS_SPAPR_KVM, TYPE_ICS_KVM,
TYPE_KVM_ICP, nr_servers, nr_irqs, &err);
@@ -170,6 +171,7 @@ static XICSState *xics_system_init(MachineState *machine,
}
if (!xics) {
+ xics_spapr_init(SPAPR_MACHINE(machine), errp);
xics = try_create_xics(SPAPR_MACHINE(machine),
TYPE_XICS_SPAPR, TYPE_ICS_SIMPLE,
TYPE_ICP, nr_servers, nr_irqs, errp);
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index d1d110051c72..ac98d5448d19 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -219,4 +219,9 @@ void ics_set_irq_type(ICSState *ics, int srcno, bool lsi);
void ics_resend(ICSState *ics);
void icp_resend(XICSFabric *xi, ICPState *ss);
+typedef struct sPAPRMachineState sPAPRMachineState;
+
+int xics_kvm_init(sPAPRMachineState *spapr, Error **errp);
+int xics_spapr_init(sPAPRMachineState *spapr, Error **errp);
+
#endif /* XICS_H */
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v3 24/24] ppc/xics: remove the XICSState classes
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (22 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 23/24] ppc/xics: export the XICS init routines Cédric Le Goater
@ 2017-02-24 10:18 ` Cédric Le Goater
2017-02-24 10:41 ` [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:18 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater
The XICSState classes are not used anymore. They have now been fully
deprecated by the XICSFabric QOM interface. Do the cleanups.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/intc/xics.c | 11 -----------
hw/intc/xics_kvm.c | 13 -------------
hw/intc/xics_spapr.c | 14 --------------
hw/ppc/spapr.c | 41 +++++++++++++++--------------------------
include/hw/ppc/spapr.h | 1 -
include/hw/ppc/xics.h | 35 -----------------------------------
6 files changed, 15 insertions(+), 100 deletions(-)
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 565b5ec0686a..5c078ce6950e 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -135,16 +135,6 @@ static void ics_simple_pic_print_info(InterruptStatsProvider *obj,
}
/*
- * XICS Common class - parent for emulated XICS and KVM-XICS
- */
-static const TypeInfo xics_common_info = {
- .name = TYPE_XICS_COMMON,
- .parent = TYPE_DEVICE,
- .instance_size = sizeof(XICSState),
- .class_size = sizeof(XICSStateClass),
-};
-
-/*
* ICP: Presentation layer
*/
@@ -706,7 +696,6 @@ void ics_set_irq_type(ICSState *ics, int srcno, bool lsi)
static void xics_register_types(void)
{
- type_register_static(&xics_common_info);
type_register_static(&ics_simple_info);
type_register_static(&ics_base_info);
type_register_static(&icp_info);
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 4ea34ea6dac5..15e3e338f39c 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -42,12 +42,6 @@
static int kernel_xics_fd = -1;
-typedef struct KVMXICSState {
- XICSState parent_obj;
-
- int kernel_xics_fd;
-} KVMXICSState;
-
/*
* ICP-KVM
*/
@@ -429,15 +423,8 @@ fail:
return -1;
}
-static const TypeInfo xics_spapr_kvm_info = {
- .name = TYPE_XICS_SPAPR_KVM,
- .parent = TYPE_XICS_COMMON,
- .instance_size = sizeof(KVMXICSState),
-};
-
static void xics_kvm_register_types(void)
{
- type_register_static(&xics_spapr_kvm_info);
type_register_static(&ics_kvm_info);
type_register_static(&icp_kvm_info);
}
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index aaf6808cd220..84d24b2837a7 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -257,13 +257,6 @@ int xics_spapr_init(sPAPRMachineState *spapr, Error **errp)
return 0;
}
-static const TypeInfo xics_spapr_info = {
- .name = TYPE_XICS_SPAPR,
- .parent = TYPE_XICS_COMMON,
- .instance_size = sizeof(XICSState),
- .class_size = sizeof(XICSStateClass),
-};
-
#define ICS_IRQ_FREE(ics, srcno) \
(!((ics)->irqs[(srcno)].flags & (XICS_FLAGS_IRQ_MASK)))
@@ -400,10 +393,3 @@ void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle)
_FDT(fdt_setprop_cell(fdt, node, "linux,phandle", phandle));
_FDT(fdt_setprop_cell(fdt, node, "phandle", phandle));
}
-
-static void xics_spapr_register_types(void)
-{
- type_register_static(&xics_spapr_info);
-}
-
-type_init(xics_spapr_register_types)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0a730bd69862..1e8e152c6f49 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -95,22 +95,13 @@
#define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift))
-static XICSState *try_create_xics(sPAPRMachineState *spapr,
- const char *type, const char *type_ics,
+static int try_create_xics(sPAPRMachineState *spapr, const char *type_ics,
const char *type_icp, int nr_servers,
int nr_irqs, Error **errp)
{
Error *err = NULL, *local_err = NULL;
- XICSState *xics;
int i;
- xics = XICS_COMMON(object_new(type));
- qdev_set_parent_bus(DEVICE(xics), sysbus_get_default());
- object_property_set_bool(OBJECT(xics), true, "realized", &err);
- if (err) {
- goto error;
- }
-
spapr->ics = ICS_SIMPLE(object_new(type_ics));
qdev_set_parent_bus(DEVICE(spapr->ics), sysbus_get_default());
object_property_add_child(OBJECT(spapr), "ics", OBJECT(spapr->ics), NULL);
@@ -137,32 +128,31 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
object_unref(OBJECT(icp));
}
- return xics;
+ return 0;
error:
error_propagate(errp, err);
if (spapr->ics) {
object_unparent(OBJECT(spapr->ics));
}
- object_unparent(OBJECT(xics));
- return NULL;
+ return -1;
}
-static XICSState *xics_system_init(MachineState *machine,
- int nr_servers, int nr_irqs, Error **errp)
+static int xics_system_init(MachineState *machine,
+ int nr_servers, int nr_irqs, Error **errp)
{
- XICSState *xics = NULL;
+ int rc = -1;
if (kvm_enabled()) {
Error *err = NULL;
if (machine_kernel_irqchip_allowed(machine) &&
!xics_kvm_init(SPAPR_MACHINE(machine), errp)) {
- xics = try_create_xics(SPAPR_MACHINE(machine),
- TYPE_XICS_SPAPR_KVM, TYPE_ICS_KVM,
+ rc = try_create_xics(SPAPR_MACHINE(machine),
+ TYPE_ICS_KVM,
TYPE_KVM_ICP, nr_servers, nr_irqs, &err);
}
- if (machine_kernel_irqchip_required(machine) && !xics) {
+ if (machine_kernel_irqchip_required(machine) && rc < 0) {
error_reportf_err(err,
"kernel_irqchip requested but unavailable: ");
} else {
@@ -170,14 +160,14 @@ static XICSState *xics_system_init(MachineState *machine,
}
}
- if (!xics) {
+ if (rc < 0) {
xics_spapr_init(SPAPR_MACHINE(machine), errp);
- xics = try_create_xics(SPAPR_MACHINE(machine),
- TYPE_XICS_SPAPR, TYPE_ICS_SIMPLE,
+ rc = try_create_xics(SPAPR_MACHINE(machine),
+ TYPE_ICS_SIMPLE,
TYPE_ICP, nr_servers, nr_irqs, errp);
}
- return xics;
+ return rc;
}
static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
@@ -1939,9 +1929,8 @@ static void ppc_spapr_init(MachineState *machine)
load_limit = MIN(spapr->rma_size, RTAS_MAX_ADDR) - FW_OVERHEAD;
/* Set up Interrupt Controller before we create the VCPUs */
- spapr->xics = xics_system_init(machine,
- DIV_ROUND_UP(max_cpus * smt, smp_threads),
- XICS_IRQS_SPAPR, &error_fatal);
+ xics_system_init(machine, DIV_ROUND_UP(max_cpus * smt, smp_threads),
+ XICS_IRQS_SPAPR, &error_fatal);
/* Set up containers for ibm,client-set-architecture negotiated options */
spapr->ov5 = spapr_ovec_new();
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index f5bbb040f941..cfd271129dd0 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -58,7 +58,6 @@ struct sPAPRMachineState {
struct VIOsPAPRBus *vio_bus;
QLIST_HEAD(, sPAPRPHBState) phbs;
struct sPAPRNVRAM *nvram;
- XICSState *xics;
ICSState *ics;
DeviceState *rtc;
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index ac98d5448d19..d7f2ef143436 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -30,29 +30,6 @@
#include "hw/sysbus.h"
-#define TYPE_XICS_COMMON "xics-common"
-#define XICS_COMMON(obj) OBJECT_CHECK(XICSState, (obj), TYPE_XICS_COMMON)
-
-/*
- * Retain xics as the type name to be compatible for migration. Rest all the
- * functions, class and variables are renamed as xics_spapr.
- */
-#define TYPE_XICS_SPAPR "xics"
-#define XICS_SPAPR(obj) OBJECT_CHECK(XICSState, (obj), TYPE_XICS_SPAPR)
-
-#define TYPE_XICS_SPAPR_KVM "xics-spapr-kvm"
-#define XICS_SPAPR_KVM(obj) \
- OBJECT_CHECK(KVMXICSState, (obj), TYPE_XICS_SPAPR_KVM)
-
-#define XICS_COMMON_CLASS(klass) \
- OBJECT_CLASS_CHECK(XICSStateClass, (klass), TYPE_XICS_COMMON)
-#define XICS_SPAPR_CLASS(klass) \
- OBJECT_CLASS_CHECK(XICSStateClass, (klass), TYPE_XICS_SPAPR)
-#define XICS_COMMON_GET_CLASS(obj) \
- OBJECT_GET_CLASS(XICSStateClass, (obj), TYPE_XICS_COMMON)
-#define XICS_SPAPR_GET_CLASS(obj) \
- OBJECT_GET_CLASS(XICSStateClass, (obj), TYPE_XICS_SPAPR)
-
#define XICS_IPI 0x2
#define XICS_BUID 0x1
#define XICS_IRQ_BASE (XICS_BUID << 12)
@@ -62,24 +39,12 @@
* (the kernel implementation supports more but we don't exploit
* that yet)
*/
-typedef struct XICSStateClass XICSStateClass;
-typedef struct XICSState XICSState;
typedef struct ICPStateClass ICPStateClass;
typedef struct ICPState ICPState;
typedef struct ICSStateClass ICSStateClass;
typedef struct ICSState ICSState;
typedef struct ICSIRQState ICSIRQState;
-struct XICSStateClass {
- DeviceClass parent_class;
-};
-
-struct XICSState {
- /*< private >*/
- DeviceState parent_obj;
- /*< public >*/
-};
-
#define TYPE_ICP "icp"
#define ICP(obj) OBJECT_CHECK(ICPState, (obj), TYPE_ICP)
--
2.7.4
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation
2017-02-24 10:17 [Qemu-devel] [PATCH v3 00/24] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
` (23 preceding siblings ...)
2017-02-24 10:18 ` [Qemu-devel] [PATCH v3 24/24] ppc/xics: remove the XICSState classes Cédric Le Goater
@ 2017-02-24 10:41 ` Cédric Le Goater
24 siblings, 0 replies; 26+ messages in thread
From: Cédric Le Goater @ 2017-02-24 10:41 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, qemu-devel
On 02/24/2017 11:17 AM, Cédric Le Goater wrote:
> Hello,
>
> The goal behind this series is to simplify the XICS interface by
> moving back in the machine the way the ICS and ICP objects interact
> together. It's up to the machine to implement this "fabric" logic by
> providing a set of handlers of a QOM interface. These handlers are
> used to grab an ICS or an ICP object and also do irq resends. The idea
> was suggested by David Gibson.
David,
For some reason, my email filters went wild and I missed all your
comments a part from the one on XICSFabric ... So please ignore v3.
I will go through your emails now that I see them ...
Sorry for the noise,
C.
> The patchset is organised as follow. It starts with a preliminary
> cleanup to get rid of the set_nr_irqs() and set_nr_servers()
> handlers. It also moves the creation of the ICS and ICP objects from
> the XICS object to the sPAPR machine. This simplifies the code
> significantly and prepares ground for future changes.
>
> As the sPAPR machine only makes use of a single ICS, we can store it
> at the machine level. This lets us remove dependencies on the list of
> ICS of the XICS object and simplify even more the code for the
> following changes.
>
> The QOM interface to interact with the ICS and ICP objects is then
> introduced. These are moved under the machine and cleanups are done
> accordingly.
>
> Finally, the XICSState classes are removed as they have been
> deprecated by the QOM interface.
>
>
> After the initial cleanups, which are rather big, each patch are small
> and simple. The make target 'check-qtest-ppc64' runs succesfully for
> each of them and so does migration of HV and TCG guests.
>
> The tree is available here :
>
> https://github.com/legoater/qemu/tree/ppc-2.9
>
> Thanks,
>
> C.
>
>
>
> Caveats:
>
> - The kernel ICP file descriptor 'kernel_xics_fd' was made static to
> ease changes but that could be an issue. We could move it under the
> sPAPR machine if needed.
>
> Changes since v2:
>
> - renamed QOM Interface to XICSFabric
>
> Cédric Le Goater (23):
> ppc/xics: fix ICP and ICS reset
> ppc/xics: remove set_nr_irqs() handler from XICSStateClass
> ppc/xics: remove set_nr_servers() handler from XICSStateClass
> ppc/xics: store the ICS object under the sPAPR machine
> ppc/xics: add an InterruptStatsProvider interface to ICS and ICP
> objects
> ppc/xics: introduce a XICSFabric QOM interface to handle ICSs
> ppc/xics: use the QOM interface under the sPAPR machine
> ppc/xics: use the QOM interface to get irqs
> ppc/xics: use the QOM interface to resend irqs
> ppc/xics: remove xics_find_source()
> ppc/xics: register the reset handler of ICS objects
> ppc/xics: remove the XICS list of ICS
> ppc/xics: extend the QOM interface to handle ICPs
> ppc/xics: simplify the cpu_setup() handler
> ppc/xics: use the QOM interface to grab an ICP
> ppc/xics: simplify spapr_dt_xics() interface
> ppc/xics: register the reset handler of ICP objects
> ppc/xics: move the ICP array under the sPAPR machine
> ppc/xics: move kernel_xics_fd out of KVMXICSState
> ppc/xics: move the cpu_setup() handler under the ICPState class
> ppc/xics: remove the 'xics' backlinks
> ppc/xics: export the XICS init routines
> ppc/xics: remove the XICSState classes
>
> David Gibson (1):
> xics: XICS should not be a SysBusDevice
>
> hw/intc/xics.c | 295 +++++++++++++-------------------------------
> hw/intc/xics_kvm.c | 154 ++++++-----------------
> hw/intc/xics_spapr.c | 128 ++++---------------
> hw/ppc/spapr.c | 116 +++++++++++++----
> hw/ppc/spapr_cpu_core.c | 4 +-
> hw/ppc/spapr_events.c | 10 +-
> hw/ppc/spapr_pci.c | 10 +-
> hw/ppc/spapr_vio.c | 2 +-
> include/hw/pci-host/spapr.h | 2 +-
> include/hw/ppc/spapr.h | 5 +-
> include/hw/ppc/spapr_vio.h | 2 +-
> include/hw/ppc/xics.h | 93 ++++++--------
> 12 files changed, 294 insertions(+), 527 deletions(-)
>
^ permalink raw reply [flat|nested] 26+ messages in thread