All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation
@ 2017-02-27 14:29 Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 01/26] xics: XICS should not be a SysBusDevice Cédric Le Goater
                   ` (26 more replies)
  0 siblings, 27 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater


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.


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 v3:

 - reintroduced 'xics' backlinks to remove useless calls to
   qdev_get_machine()
 - moved InterruptStatsProvider to the sPAPR machine for a better
   output
 - moved move ics-simple post_load under the machine and removed the
   icp_resend() XICSFabric handler
 
Changes since v2:

 - renamed QOM Interface to XICSFabric

Cédric Le Goater (25):
  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: move kernel_xics_fd out of KVMXICSState
  ppc/xics: simplify the cpu_setup() handler
  ppc/xics: move the cpu_setup() handler under the ICPState class
  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: export the XICS init routines
  ppc/xics: remove the XICSState classes
  ppc/xics: move ics-simple post_load under the machine
  ppc/xics: move InterruptStatsProvider to the sPAPR machine
  ppc/xics: rename 'ICPState *' variables to 'icp'

David Gibson (1):
  xics: XICS should not be a SysBusDevice

 hw/intc/xics.c              | 461 +++++++++++++++++---------------------------
 hw/intc/xics_kvm.c          | 184 +++++-------------
 hw/intc/xics_spapr.c        | 128 +++---------
 hw/ppc/spapr.c              | 134 ++++++++++---
 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       |  97 ++++------
 12 files changed, 424 insertions(+), 615 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH v4 01/26] xics: XICS should not be a SysBusDevice
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 02/26] ppc/xics: fix ICP and ICS reset Cédric Le Goater
                   ` (25 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater

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>
Signed-off-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 0b57aade3f83..ceefbb57d0ac 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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 02/26] ppc/xics: fix ICP and ICS reset
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 01/26] xics: XICS should not be a SysBusDevice Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-28  2:00   ` David Gibson
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 03/26] ppc/xics: remove set_nr_irqs() handler from XICSStateClass Cédric Le Goater
                   ` (24 subsequent siblings)
  26 siblings, 1 reply; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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 ceefbb57d0ac..3c79068075e4 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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 03/26] ppc/xics: remove set_nr_irqs() handler from XICSStateClass
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 01/26] xics: XICS should not be a SysBusDevice Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 02/26] ppc/xics: fix ICP and ICS reset Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 04/26] ppc/xics: remove set_nr_servers() " Cédric Le Goater
                   ` (23 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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>
---

 Changes since v3:

 - moved the retrieval link at ICS_BASE level 
 - added a realize() handler to the ICSStateClass and updated the
   descendent classes accordingly

Changes since v1:

 - added a XICS link to the ICS object

 hw/intc/xics.c        | 72 +++++++++++++++++++++++++--------------------------
 hw/intc/xics_kvm.c    | 36 +-------------------------
 hw/intc/xics_spapr.c  | 34 ------------------------
 hw/ppc/spapr.c        | 54 ++++++++++++++++++++++++++------------
 include/hw/ppc/xics.h |  3 +--
 5 files changed, 75 insertions(+), 124 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 372b8311fb8b..f00b77ae15f4 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);
@@ -746,12 +711,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;
+    isc->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;
@@ -769,11 +740,40 @@ static const TypeInfo ics_simple_info = {
     .instance_init = ics_simple_initfn,
 };
 
+static void ics_base_realize(DeviceState *dev, Error **errp)
+{
+    ICSStateClass *icsc = ICS_BASE_GET_CLASS(dev);
+    ICSState *ics = ICS_BASE(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 (icsc->realize) {
+        icsc->realize(dev, errp);
+    }
+}
+
+static void ics_base_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    dc->realize = ics_base_realize;
+}
+
 static const TypeInfo ics_base_info = {
     .name = TYPE_ICS_BASE,
     .parent = TYPE_DEVICE,
     .abstract = true,
     .instance_size = sizeof(ICSState),
+    .class_init = ics_base_class_init,
     .class_size = sizeof(ICSStateClass),
 };
 
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 17694eaa8709..e5ab00b22361 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -308,7 +308,7 @@ static void ics_kvm_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     ICSStateClass *icsc = ICS_BASE_CLASS(klass);
 
-    dc->realize = ics_kvm_realize;
+    icsc->realize = ics_kvm_realize;
     dc->reset = ics_kvm_reset;
     icsc->pre_save = ics_get_kvm_state;
     icsc->post_load = ics_set_kvm_state;
@@ -358,18 +358,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 +377,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 +428,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 +451,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 +458,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 +466,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 3c79068075e4..398ce5a9cc1e 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..a1d12d39c898 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;
 };
@@ -139,6 +137,7 @@ struct ICPState {
 struct ICSStateClass {
     DeviceClass parent_class;
 
+    void (*realize)(DeviceState *dev, Error **errp);
     void (*pre_save)(ICSState *s);
     int (*post_load)(ICSState *s, int version_id);
     void (*reject)(ICSState *s, uint32_t irq);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH v4 04/26] ppc/xics: remove set_nr_servers() handler from XICSStateClass
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (2 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 03/26] ppc/xics: remove set_nr_irqs() handler from XICSStateClass Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 05/26] ppc/xics: store the ICS object under the sPAPR machine Cédric Le Goater
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---

 Changes since v1:

 - added a XICS link to the ICS object
 - removed xics_set_nr_servers() routine
 - removed set_nr_servers() class handler

 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 f00b77ae15f4..d2a417f73fd5 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 e5ab00b22361..2d08c4071d3f 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -358,12 +358,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,
@@ -376,9 +370,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,
@@ -428,16 +420,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;
@@ -458,7 +440,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 398ce5a9cc1e..f1b690e8983e 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 a1d12d39c898..e79a70748e4c 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 {
@@ -190,8 +189,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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 05/26] ppc/xics: store the ICS object under the sPAPR machine
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (3 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 04/26] ppc/xics: remove set_nr_servers() " Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 06/26] ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects Cédric Le Goater
                   ` (21 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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>
---

 Changes since v3:

 - assigned spapr->ics at the end of try_create_xics()

 hw/intc/xics_spapr.c   | 22 +++++++++-------------
 hw/ppc/spapr.c         | 14 +++++++++-----
 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, 29 insertions(+), 28 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 f1b690e8983e..130bfdc0055c 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -95,7 +95,8 @@
 
 #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)
 {
@@ -112,7 +113,7 @@ static XICSState *try_create_xics(const char *type, const char *type_ics,
     }
 
     ics = ICS_SIMPLE(object_new(type_ics));
-    object_property_add_child(OBJECT(xics), "ics", OBJECT(ics), NULL);
+    object_property_add_child(OBJECT(spapr), "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);
@@ -138,6 +139,7 @@ static XICSState *try_create_xics(const char *type, const char *type_ics,
         object_unref(OBJECT(icp));
     }
 
+    spapr->ics = ics;
     return xics;
 
 error:
@@ -158,7 +160,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 +173,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 e79a70748e4c..37d4d9ce3f81 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -181,10 +181,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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 06/26] ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (4 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 05/26] ppc/xics: store the ICS object under the sPAPR machine Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 07/26] ppc/xics: introduce a XICSFabric QOM interface to handle ICSs Cédric Le Goater
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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.

The InterruptStatsProvider will be moved at the machine level after
the XICS cleanups are completed.

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 d2a417f73fd5..c7c9bd600790 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 },
+        { }
+    },
 };
 
 /*
@@ -682,6 +682,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);
 
     isc->realize = ics_simple_realize;
     dc->props = ics_simple_properties;
@@ -691,6 +692,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 = {
@@ -700,6 +702,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 void ics_base_realize(DeviceState *dev, Error **errp)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH v4 07/26] ppc/xics: introduce a XICSFabric QOM interface to handle ICSs
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (5 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 06/26] ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 08/26] ppc/xics: use the QOM interface under the sPAPR machine Cédric Le Goater
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
 Changes since v2:

 - renamed QOM Interface to XICSFabric

 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 c7c9bd600790..433869a696c4 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -745,6 +745,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
  */
@@ -785,6 +791,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 37d4d9ce3f81..1c43305a0456 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -178,6 +178,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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 08/26] ppc/xics: use the QOM interface under the sPAPR machine
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (6 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 07/26] ppc/xics: introduce a XICSFabric QOM interface to handle ICSs Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 09/26] ppc/xics: use the QOM interface to get irqs Cédric Le Goater
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
 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 433869a696c4..c6bfb610fd32 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 130bfdc0055c..ad41aba44b49 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2913,6 +2913,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);
@@ -2921,6 +2935,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)";
 
@@ -2954,6 +2969,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 = {
@@ -2970,6 +2987,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 1c43305a0456..1161d5487b4f 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -223,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);
 
 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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 09/26] ppc/xics: use the QOM interface to get irqs
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (7 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 08/26] ppc/xics: use the QOM interface under the sPAPR machine Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 10/26] ppc/xics: use the QOM interface to resend irqs Cédric Le Goater
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
 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 c6bfb610fd32..e3dbe63fc021 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -766,9 +766,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 1161d5487b4f..094756dd75a0 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -198,7 +198,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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 10/26] ppc/xics: use the QOM interface to resend irqs
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (8 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 09/26] ppc/xics: use the QOM interface to get irqs Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 11/26] ppc/xics: remove xics_find_source() Cédric Le Goater
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater

Also change the ICPState 'xics' backlink to be a XICSFabric, this
removes the need of using qdev_get_machine() to get the QOM interface
in some of the routines.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---

 Changes since v3:

 - changed ICPState 'xics' backlink to be a XICSFabric.

 hw/intc/xics.c        | 20 +++++++++++---------
 hw/ppc/spapr.c        |  3 ++-
 include/hw/ppc/xics.h |  3 ++-
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index e3dbe63fc021..23e45a87d47a 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -231,14 +231,14 @@ static void icp_check_ipi(ICPState *ss)
 
 static void icp_resend(ICPState *ss)
 {
-    ICSState *ics;
+    XICSFabric *xi = ss->xics;
+    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)
@@ -299,6 +299,8 @@ uint32_t icp_ipoll(ICPState *ss, uint32_t *mfrr)
 
 void icp_eoi(ICPState *ss, uint32_t xirr)
 {
+    XICSFabric *xi = ss->xics;
+    XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
     ICSState *ics;
     uint32_t irq;
 
@@ -306,10 +308,10 @@ 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);
@@ -401,7 +403,7 @@ static void icp_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    icp->xics = XICS_COMMON(obj);
+    icp->xics = XICS_FABRIC(obj);
 }
 
 
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index ad41aba44b49..669a3a621b56 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -100,6 +100,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
                                   const char *type_icp, int nr_servers,
                                   int nr_irqs, Error **errp)
 {
+    XICSFabric *xi = XICS_FABRIC(spapr);
     Error *err = NULL, *local_err = NULL;
     XICSState *xics;
     ICSState *ics = NULL;
@@ -131,7 +132,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
 
         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_add_const_link(OBJECT(icp), "xics", OBJECT(xi), 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 094756dd75a0..b88071529d5b 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -69,6 +69,7 @@ typedef struct ICPState ICPState;
 typedef struct ICSStateClass ICSStateClass;
 typedef struct ICSState ICSState;
 typedef struct ICSIRQState ICSIRQState;
+typedef struct XICSFabric XICSFabric;
 
 struct XICSStateClass {
     DeviceClass parent_class;
@@ -115,7 +116,7 @@ struct ICPState {
     qemu_irq output;
     bool cap_irq_xics_enabled;
 
-    XICSState *xics;
+    XICSFabric *xics;
 };
 
 #define TYPE_ICS_BASE "ics-base"
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH v4 11/26] ppc/xics: remove xics_find_source()
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (9 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 10/26] ppc/xics: use the QOM interface to resend irqs Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 12/26] ppc/xics: register the reset handler of ICS objects Cédric Le Goater
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
 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 23e45a87d47a..a71d3858b13f 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -756,18 +756,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 b88071529d5b..db2bb04de831 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -224,7 +224,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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 12/26] ppc/xics: register the reset handler of ICS objects
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (10 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 11/26] ppc/xics: remove xics_find_source() Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 13/26] ppc/xics: remove the XICS list of ICS Cédric Le Goater
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
 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 a71d3858b13f..97775c2b61e5 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 669a3a621b56..1706d52adec1 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -114,6 +114,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
     }
 
     ics = ICS_SIMPLE(object_new(type_ics));
+    qdev_set_parent_bus(DEVICE(ics), sysbus_get_default());
     object_property_add_child(OBJECT(spapr), "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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH v4 13/26] ppc/xics: remove the XICS list of ICS
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (11 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 12/26] ppc/xics: register the reset handler of ICS objects Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 14/26] ppc/xics: extend the QOM interface to handle ICPs Cédric Le Goater
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
 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 97775c2b61e5..76b50dc7722a 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 1706d52adec1..70b9618309fc 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -123,7 +123,6 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
     if (err) {
         goto error;
     }
-    QLIST_INSERT_HEAD(&xics->ics, 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 db2bb04de831..15c52f9d9eda 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -83,7 +83,6 @@ struct XICSState {
     /*< public >*/
     uint32_t nr_servers;
     ICPState *ss;
-    QLIST_HEAD(, ICSState) ics;
 };
 
 #define TYPE_ICP "icp"
@@ -154,7 +153,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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 14/26] ppc/xics: extend the QOM interface to handle ICPs
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (12 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 13/26] ppc/xics: remove the XICS list of ICS Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 15/26] ppc/xics: move kernel_xics_fd out of KVMXICSState Cédric Le Goater
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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.

The icp_resend() handler is a temporary workaround needed by the
ics-simple post_load() handler. It will be removed when the post_load
portion can be done at the machine level.

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 76b50dc7722a..f828bcb07026 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(ICPState *ss)
+void icp_resend(ICPState *ss)
 {
     XICSFabric *xi = ss->xics;
     XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 70b9618309fc..7273157ad50e 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2928,6 +2928,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(&spapr->xics->ss[i]);
+    }
+}
+
 static void spapr_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -2972,6 +2990,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 15c52f9d9eda..01ca5e2dab50 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -193,6 +193,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
@@ -223,5 +225,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(ICPState *ss);
 
 #endif /* XICS_H */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH v4 15/26] ppc/xics: move kernel_xics_fd out of KVMXICSState
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (13 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 14/26] ppc/xics: extend the QOM interface to handle ICPs Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 16/26] ppc/xics: simplify the cpu_setup() handler Cédric Le Goater
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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 2d08c4071d3f..86ddf470e546 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));
@@ -328,14 +328,13 @@ static void xics_kvm_cpu_setup(XICSState *xics, PowerPCCPU *cpu)
 {
     CPUState *cs;
     ICPState *ss;
-    KVMXICSState *xicskvm = XICS_SPAPR_KVM(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) {
+    if (kernel_xics_fd == -1) {
         abort();
     }
 
@@ -348,7 +347,7 @@ static void xics_kvm_cpu_setup(XICSState *xics, 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",
@@ -369,7 +368,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,
@@ -418,7 +416,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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 16/26] ppc/xics: simplify the cpu_setup() handler
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (14 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 15/26] ppc/xics: move kernel_xics_fd out of KVMXICSState Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 17/26] ppc/xics: move the cpu_setup() handler under the ICPState class Cédric Le Goater
                   ` (10 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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    | 9 ++-------
 include/hw/ppc/xics.h | 2 +-
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index f828bcb07026..a5be0d83cf36 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(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 86ddf470e546..7588280b5d69 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -324,16 +324,11 @@ 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;
+    CPUState *cs = CPU(cpu);
     int ret;
 
-    cs = CPU(cpu);
-    ss = &xics->ss[cs->cpu_index];
-
-    assert(cs->cpu_index < xics->nr_servers);
     if (kernel_xics_fd == -1) {
         abort();
     }
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 01ca5e2dab50..8325dbdaf104 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -74,7 +74,7 @@ typedef struct XICSFabric XICSFabric;
 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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 17/26] ppc/xics: move the cpu_setup() handler under the ICPState class
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (15 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 16/26] ppc/xics: simplify the cpu_setup() handler Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 18/26] ppc/xics: use the QOM interface to grab an ICP Cédric Le Goater
                   ` (9 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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 a5be0d83cf36..674ac4c91b77 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -66,15 +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;
+    ICPStateClass *icpc;
 
     assert(cs->cpu_index < xics->nr_servers);
 
     ss->cs = cs;
 
-    info = XICS_COMMON_GET_CLASS(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 7588280b5d69..07298b09712d 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 = {
@@ -324,33 +353,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,
@@ -429,10 +431,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 8325dbdaf104..d17f62c5cc82 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -73,8 +73,6 @@ typedef struct XICSFabric XICSFabric;
 
 struct XICSStateClass {
     DeviceClass parent_class;
-
-    void (*cpu_setup)(ICPState *icp, PowerPCCPU *cpu);
 };
 
 struct XICSState {
@@ -101,6 +99,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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 18/26] ppc/xics: use the QOM interface to grab an ICP
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (16 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 17/26] ppc/xics: move the cpu_setup() handler under the ICPState class Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 19/26] ppc/xics: simplify spapr_dt_xics() interface Cédric Le Goater
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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>
---

 Changes since v3:

 - changed ICSState 'xics' backlink to be a XICSFabric.

 hw/intc/xics.c          | 32 ++++++++++++++++++--------------
 hw/intc/xics_spapr.c    | 17 +++++++++--------
 hw/ppc/spapr.c          |  2 +-
 hw/ppc/spapr_cpu_core.c |  4 ++--
 include/hw/ppc/xics.h   | 10 +++++-----
 5 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 674ac4c91b77..ddb0a6f48b5c 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);
     ICPStateClass *icpc;
 
-    assert(cs->cpu_index < xics->nr_servers);
+    assert(ss);
 
     ss->cs = cs;
 
@@ -308,8 +308,7 @@ 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;
+    ICPState *ss = xics_icp_get(ics->xics, server);
 
     trace_xics_icp_irq(server, nr, priority);
 
@@ -582,12 +581,10 @@ static void ics_simple_reset(DeviceState *dev)
 
 static int ics_simple_post_load(ICSState *ics, int version_id)
 {
-    int i;
-
-    for (i = 0; i < ics->xics->nr_servers; i++) {
-        icp_resend(&ics->xics->ss[i]);
-    }
+    XICSFabric *xi = ics->xics;
+    XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
 
+    xic->icp_resend(xi);
     return 0;
 }
 
@@ -711,7 +708,7 @@ static void ics_base_realize(DeviceState *dev, Error **errp)
                    __func__, error_get_pretty(err));
         return;
     }
-    ics->xics = XICS_COMMON(obj);
+    ics->xics = XICS_FABRIC(obj);
 
 
     if (icsc->realize) {
@@ -756,6 +753,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.c b/hw/ppc/spapr.c
index 7273157ad50e..309b9ff91563 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -117,7 +117,7 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
     qdev_set_parent_bus(DEVICE(ics), sysbus_get_default());
     object_property_add_child(OBJECT(spapr), "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_add_const_link(OBJECT(ics), "xics", OBJECT(xi), NULL);
     object_property_set_bool(OBJECT(ics), true, "realized", &local_err);
     error_propagate(&err, local_err);
     if (err) {
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 d17f62c5cc82..c57e80e4187b 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -151,7 +151,7 @@ struct ICSState {
     uint32_t offset;
     qemu_irq *qirqs;
     ICSIRQState *irqs;
-    XICSState *xics;
+    XICSFabric *xics;
 };
 
 static inline bool ics_valid_irq(ICSState *ics, uint32_t nr)
@@ -198,16 +198,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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 19/26] ppc/xics: simplify spapr_dt_xics() interface
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (17 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 18/26] ppc/xics: use the QOM interface to grab an ICP Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 20/26] ppc/xics: register the reset handler of ICP objects Cédric Le Goater
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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 309b9ff91563..aa62292c8c90 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -966,7 +966,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 c57e80e4187b..f618848009cf 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -202,7 +202,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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 20/26] ppc/xics: register the reset handler of ICP objects
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (18 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 19/26] ppc/xics: simplify spapr_dt_xics() interface Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 21/26] ppc/xics: move the ICP array under the sPAPR machine Cédric Le Goater
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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 ddb0a6f48b5c..51e6c0c85fca 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 aa62292c8c90..88539557abd3 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -131,6 +131,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(xi), NULL);
         object_property_set_bool(OBJECT(icp), true, "realized", &err);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH v4 21/26] ppc/xics: move the ICP array under the sPAPR machine
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (19 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 20/26] ppc/xics: register the reset handler of ICP objects Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 22/26] ppc/xics: export the XICS init routines Cédric Le Goater
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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 88539557abd3..358bdec7d2ad 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -124,15 +124,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(xi), NULL);
         object_property_set_bool(OBJECT(icp), true, "realized", &err);
         if (err) {
@@ -967,7 +967,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) {
@@ -2933,8 +2933,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)
@@ -2942,8 +2941,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(&spapr->xics->ss[i]);
+    for (i = 0; i < spapr->nr_servers; i++) {
+        icp_resend(&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 f618848009cf..50a5933df535 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -79,8 +79,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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 22/26] ppc/xics: export the XICS init routines
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (20 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 21/26] ppc/xics: move the ICP array under the sPAPR machine Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 23/26] ppc/xics: remove the XICSState classes Cédric Le Goater
                   ` (4 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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 07298b09712d..99836112cd12 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 358bdec7d2ad..3caef0c7e683 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -161,7 +161,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);
@@ -175,6 +176,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 50a5933df535..b0b01e2975df 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -224,4 +224,9 @@ void ics_set_irq_type(ICSState *ics, int srcno, bool lsi);
 void ics_resend(ICSState *ics);
 void icp_resend(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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 23/26] ppc/xics: remove the XICSState classes
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (21 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 22/26] ppc/xics: export the XICS init routines Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 24/26] ppc/xics: move ics-simple post_load under the machine Cédric Le Goater
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 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         | 45 ++++++++++++++++-----------------------------
 include/hw/ppc/spapr.h |  1 -
 include/hw/ppc/xics.h  | 35 -----------------------------------
 6 files changed, 16 insertions(+), 103 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 51e6c0c85fca..159cd131420a 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
  */
 
@@ -752,7 +742,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 99836112cd12..14de5d4bb8cc 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 3caef0c7e683..1d0daef5ad3e 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -95,24 +95,15 @@
 
 #define HTAB_SIZE(spapr)        (1ULL << ((spapr)->htab_shift))
 
-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)
+static int try_create_xics(sPAPRMachineState *spapr, const char *type_ics,
+                           const char *type_icp, int nr_servers,
+                           int nr_irqs, Error **errp)
 {
     XICSFabric *xi = XICS_FABRIC(spapr);
     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_bool(OBJECT(xics), true, "realized", &err);
-    if (err) {
-        goto error;
-    }
-
     ics = ICS_SIMPLE(object_new(type_ics));
     qdev_set_parent_bus(DEVICE(ics), sysbus_get_default());
     object_property_add_child(OBJECT(spapr), "ics", OBJECT(ics), NULL);
@@ -142,32 +133,30 @@ static XICSState *try_create_xics(sPAPRMachineState *spapr,
     }
 
     spapr->ics = ics;
-    return xics;
+    return 0;
 
 error:
     error_propagate(errp, err);
     if (ics) {
         object_unparent(OBJECT(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,
-                                   TYPE_KVM_ICP, nr_servers, nr_irqs, &err);
+            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 {
@@ -175,14 +164,13 @@ 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,
@@ -1947,9 +1935,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 b0b01e2975df..2514cfd86ea9 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,8 +39,6 @@
  * (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;
@@ -71,16 +46,6 @@ typedef struct ICSState ICSState;
 typedef struct ICSIRQState ICSIRQState;
 typedef struct XICSFabric XICSFabric;
 
-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] 30+ messages in thread

* [Qemu-devel] [PATCH v4 24/26] ppc/xics: move ics-simple post_load under the machine
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (22 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 23/26] ppc/xics: remove the XICSState classes Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 25/26] ppc/xics: move InterruptStatsProvider to the sPAPR machine Cédric Le Goater
                   ` (2 subsequent siblings)
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater

The ICS object uses a post_load() handler which is implicitly relying
on the fact that the internal state of the ICS and ICP objects has
been restored but this is not guaranteed. So, let's move the code
under the post_load() handler of the machine where we know the objects
have been fully restored.

The icp_resend() handler of the XICSFabric QOM interface is also
removed as it is now obsolete.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/intc/xics.c        | 10 ----------
 hw/ppc/spapr.c        | 18 +++++++-----------
 include/hw/ppc/xics.h |  1 -
 3 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 159cd131420a..ce6e8d75b891 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -551,15 +551,6 @@ static void ics_simple_reset(DeviceState *dev)
     }
 }
 
-static int ics_simple_post_load(ICSState *ics, int version_id)
-{
-    XICSFabric *xi = ics->xics;
-    XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
-
-    xic->icp_resend(xi);
-    return 0;
-}
-
 static void ics_simple_dispatch_pre_save(void *opaque)
 {
     ICSState *ics = opaque;
@@ -647,7 +638,6 @@ static void ics_simple_class_init(ObjectClass *klass, void *data)
     dc->props = ics_simple_properties;
     dc->vmsd = &vmstate_ics_simple;
     dc->reset = ics_simple_reset;
-    isc->post_load = ics_simple_post_load;
     isc->reject = ics_simple_reject;
     isc->resend = ics_simple_resend;
     isc->eoi = ics_simple_eoi;
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 1d0daef5ad3e..e097ff8de1a4 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1285,6 +1285,13 @@ static int spapr_post_load(void *opaque, int version_id)
     sPAPRMachineState *spapr = (sPAPRMachineState *)opaque;
     int err = 0;
 
+    if (!object_dynamic_cast(OBJECT(spapr->ics), TYPE_ICS_KVM)) {
+        int i;
+        for (i = 0; i < spapr->nr_servers; i++) {
+            icp_resend(&spapr->icps[i]);
+        }
+    }
+
     /* In earlier versions, there was no separate qdev for the PAPR
      * RTC, so the RTC offset was stored directly in sPAPREnvironment.
      * So when migrating from those versions, poke the incoming offset
@@ -2925,16 +2932,6 @@ static ICPState *spapr_icp_get(XICSFabric *xi, int server)
     return (server < spapr->nr_servers) ? &spapr->icps[server] : NULL;
 }
 
-static void spapr_icp_resend(XICSFabric *xi)
-{
-    sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
-    int i;
-
-    for (i = 0; i < spapr->nr_servers; i++) {
-        icp_resend(&spapr->icps[i]);
-    }
-}
-
 static void spapr_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -2980,7 +2977,6 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
     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 2514cfd86ea9..007ee2f16d16 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -156,7 +156,6 @@ typedef struct XICSFabricClass {
     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
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH v4 25/26] ppc/xics: move InterruptStatsProvider to the sPAPR machine
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (23 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 24/26] ppc/xics: move ics-simple post_load under the machine Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 26/26] ppc/xics: rename 'ICPState *' variables to 'icp' Cédric Le Goater
  2017-02-28  3:54 ` [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation David Gibson
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater

It provides a better monitor output of the ICP and ICS objects, else
the objects are printed out of order.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/intc/xics.c        | 20 ++------------------
 hw/ppc/spapr.c        | 17 +++++++++++++++++
 include/hw/ppc/xics.h |  2 ++
 3 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index ce6e8d75b891..5bcb9550abb5 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -93,10 +93,8 @@ void xics_cpu_setup(XICSFabric *xi, PowerPCCPU *cpu)
     }
 }
 
-static void icp_pic_print_info(InterruptStatsProvider *obj,
-                           Monitor *mon)
+void icp_pic_print_info(ICPState *icp, Monitor *mon)
 {
-    ICPState *icp = ICP(obj);
     int cpu_index = icp->cs ? icp->cs->cpu_index : -1;
 
     if (!icp->output) {
@@ -107,10 +105,8 @@ static void icp_pic_print_info(InterruptStatsProvider *obj,
                    icp->pending_priority, icp->mfrr);
 }
 
-static void ics_simple_pic_print_info(InterruptStatsProvider *obj,
-                                      Monitor *mon)
+void ics_pic_print_info(ICSState *ics, Monitor *mon)
 {
-    ICSState *ics = ICS_SIMPLE(obj);
     uint32_t i;
 
     monitor_printf(mon, "ICS %4x..%4x %p\n",
@@ -369,12 +365,10 @@ 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 = {
@@ -383,10 +377,6 @@ static const TypeInfo icp_info = {
     .instance_size = sizeof(ICPState),
     .class_init = icp_class_init,
     .class_size = sizeof(ICPStateClass),
-    .interfaces = (InterfaceInfo[]) {
-        { TYPE_INTERRUPT_STATS_PROVIDER },
-        { }
-    },
 };
 
 /*
@@ -632,7 +622,6 @@ 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);
 
     isc->realize = ics_simple_realize;
     dc->props = ics_simple_properties;
@@ -641,7 +630,6 @@ 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 = {
@@ -651,10 +639,6 @@ 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 void ics_base_realize(DeviceState *dev, Error **errp)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index e097ff8de1a4..69a6bed09fef 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -63,6 +63,7 @@
 #include "qemu/error-report.h"
 #include "trace.h"
 #include "hw/nmi.h"
+#include "hw/intc/intc.h"
 
 #include "hw/compat.h"
 #include "qemu/cutils.h"
@@ -2932,6 +2933,19 @@ static ICPState *spapr_icp_get(XICSFabric *xi, int server)
     return (server < spapr->nr_servers) ? &spapr->icps[server] : NULL;
 }
 
+static void spapr_pic_print_info(InterruptStatsProvider *obj,
+                                 Monitor *mon)
+{
+    sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
+    int i;
+
+    for (i = 0; i < spapr->nr_servers; i++) {
+        icp_pic_print_info(&spapr->icps[i], mon);
+    }
+
+    ics_pic_print_info(spapr->ics, mon);
+}
+
 static void spapr_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -2941,6 +2955,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
     PPCVirtualHypervisorClass *vhc = PPC_VIRTUAL_HYPERVISOR_CLASS(oc);
     XICSFabricClass *xic = XICS_FABRIC_CLASS(oc);
+    InterruptStatsProviderClass *ispc = INTERRUPT_STATS_PROVIDER_CLASS(oc);
 
     mc->desc = "pSeries Logical Partition (PAPR compliant)";
 
@@ -2977,6 +2992,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
     xic->ics_get = spapr_ics_get;
     xic->ics_resend = spapr_ics_resend;
     xic->icp_get = spapr_icp_get;
+    ispc->print_info = spapr_pic_print_info;
 }
 
 static const TypeInfo spapr_machine_info = {
@@ -2994,6 +3010,7 @@ static const TypeInfo spapr_machine_info = {
         { TYPE_HOTPLUG_HANDLER },
         { TYPE_PPC_VIRTUAL_HYPERVISOR },
         { TYPE_XICS_FABRIC },
+        { TYPE_INTERRUPT_STATS_PROVIDER },
         { }
     },
 };
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 007ee2f16d16..1945913bf1c9 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -184,6 +184,8 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,
                            uint8_t priority, uint8_t saved_priority);
 
 void ics_set_irq_type(ICSState *ics, int srcno, bool lsi);
+void icp_pic_print_info(ICPState *icp, Monitor *mon);
+void ics_pic_print_info(ICSState *ics, Monitor *mon);
 
 void ics_resend(ICSState *ics);
 void icp_resend(ICPState *ss);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [Qemu-devel] [PATCH v4 26/26] ppc/xics: rename 'ICPState *' variables to 'icp'
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (24 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 25/26] ppc/xics: move InterruptStatsProvider to the sPAPR machine Cédric Le Goater
@ 2017-02-27 14:29 ` Cédric Le Goater
  2017-02-28  3:54 ` [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation David Gibson
  26 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-27 14:29 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater

'ICPState *' variables are currently named 'ss'. This is confusing, so
let's give them an appropriate name: 'icp'.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/intc/xics.c     | 154 ++++++++++++++++++++++++++---------------------------
 hw/intc/xics_kvm.c |  34 ++++++------
 2 files changed, 94 insertions(+), 94 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 5bcb9550abb5..ffc0747c7fa2 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -52,38 +52,38 @@ int xics_get_cpu_index_by_dt_id(int cpu_dt_id)
 void xics_cpu_destroy(XICSFabric *xi, PowerPCCPU *cpu)
 {
     CPUState *cs = CPU(cpu);
-    ICPState *ss = xics_icp_get(xi, cs->cpu_index);
+    ICPState *icp = xics_icp_get(xi, cs->cpu_index);
 
-    assert(ss);
-    assert(cs == ss->cs);
+    assert(icp);
+    assert(cs == icp->cs);
 
-    ss->output = NULL;
-    ss->cs = NULL;
+    icp->output = NULL;
+    icp->cs = NULL;
 }
 
 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);
+    ICPState *icp = xics_icp_get(xi, cs->cpu_index);
     ICPStateClass *icpc;
 
-    assert(ss);
+    assert(icp);
 
-    ss->cs = cs;
+    icp->cs = cs;
 
-    icpc = ICP_GET_CLASS(ss);
+    icpc = ICP_GET_CLASS(icp);
     if (icpc->cpu_setup) {
-        icpc->cpu_setup(ss, cpu);
+        icpc->cpu_setup(icp, cpu);
     }
 
     switch (PPC_INPUT(env)) {
     case PPC_FLAGS_INPUT_POWER7:
-        ss->output = env->irq_inputs[POWER7_INPUT_INT];
+        icp->output = env->irq_inputs[POWER7_INPUT_INT];
         break;
 
     case PPC_FLAGS_INPUT_970:
-        ss->output = env->irq_inputs[PPC970_INPUT_INT];
+        icp->output = env->irq_inputs[PPC970_INPUT_INT];
         break;
 
     default:
@@ -137,8 +137,8 @@ void ics_pic_print_info(ICSState *ics, Monitor *mon)
 #define XISR_MASK  0x00ffffff
 #define CPPR_MASK  0xff000000
 
-#define XISR(ss)   (((ss)->xirr) & XISR_MASK)
-#define CPPR(ss)   (((ss)->xirr) >> 24)
+#define XISR(icp)   (((icp)->xirr) & XISR_MASK)
+#define CPPR(icp)   (((icp)->xirr) >> 24)
 
 static void ics_reject(ICSState *ics, uint32_t nr)
 {
@@ -167,152 +167,152 @@ static void ics_eoi(ICSState *ics, int nr)
     }
 }
 
-static void icp_check_ipi(ICPState *ss)
+static void icp_check_ipi(ICPState *icp)
 {
-    if (XISR(ss) && (ss->pending_priority <= ss->mfrr)) {
+    if (XISR(icp) && (icp->pending_priority <= icp->mfrr)) {
         return;
     }
 
-    trace_xics_icp_check_ipi(ss->cs->cpu_index, ss->mfrr);
+    trace_xics_icp_check_ipi(icp->cs->cpu_index, icp->mfrr);
 
-    if (XISR(ss) && ss->xirr_owner) {
-        ics_reject(ss->xirr_owner, XISR(ss));
+    if (XISR(icp) && icp->xirr_owner) {
+        ics_reject(icp->xirr_owner, XISR(icp));
     }
 
-    ss->xirr = (ss->xirr & ~XISR_MASK) | XICS_IPI;
-    ss->pending_priority = ss->mfrr;
-    ss->xirr_owner = NULL;
-    qemu_irq_raise(ss->output);
+    icp->xirr = (icp->xirr & ~XISR_MASK) | XICS_IPI;
+    icp->pending_priority = icp->mfrr;
+    icp->xirr_owner = NULL;
+    qemu_irq_raise(icp->output);
 }
 
-void icp_resend(ICPState *ss)
+void icp_resend(ICPState *icp)
 {
-    XICSFabric *xi = ss->xics;
+    XICSFabric *xi = icp->xics;
     XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
 
-    if (ss->mfrr < CPPR(ss)) {
-        icp_check_ipi(ss);
+    if (icp->mfrr < CPPR(icp)) {
+        icp_check_ipi(icp);
     }
 
     xic->ics_resend(xi);
 }
 
-void icp_set_cppr(ICPState *ss, uint8_t cppr)
+void icp_set_cppr(ICPState *icp, uint8_t cppr)
 {
     uint8_t old_cppr;
     uint32_t old_xisr;
 
-    old_cppr = CPPR(ss);
-    ss->xirr = (ss->xirr & ~CPPR_MASK) | (cppr << 24);
+    old_cppr = CPPR(icp);
+    icp->xirr = (icp->xirr & ~CPPR_MASK) | (cppr << 24);
 
     if (cppr < old_cppr) {
-        if (XISR(ss) && (cppr <= ss->pending_priority)) {
-            old_xisr = XISR(ss);
-            ss->xirr &= ~XISR_MASK; /* Clear XISR */
-            ss->pending_priority = 0xff;
-            qemu_irq_lower(ss->output);
-            if (ss->xirr_owner) {
-                ics_reject(ss->xirr_owner, old_xisr);
-                ss->xirr_owner = NULL;
+        if (XISR(icp) && (cppr <= icp->pending_priority)) {
+            old_xisr = XISR(icp);
+            icp->xirr &= ~XISR_MASK; /* Clear XISR */
+            icp->pending_priority = 0xff;
+            qemu_irq_lower(icp->output);
+            if (icp->xirr_owner) {
+                ics_reject(icp->xirr_owner, old_xisr);
+                icp->xirr_owner = NULL;
             }
         }
     } else {
-        if (!XISR(ss)) {
-            icp_resend(ss);
+        if (!XISR(icp)) {
+            icp_resend(icp);
         }
     }
 }
 
-void icp_set_mfrr(ICPState *ss, uint8_t mfrr)
+void icp_set_mfrr(ICPState *icp, uint8_t mfrr)
 {
-    ss->mfrr = mfrr;
-    if (mfrr < CPPR(ss)) {
-        icp_check_ipi(ss);
+    icp->mfrr = mfrr;
+    if (mfrr < CPPR(icp)) {
+        icp_check_ipi(icp);
     }
 }
 
-uint32_t icp_accept(ICPState *ss)
+uint32_t icp_accept(ICPState *icp)
 {
-    uint32_t xirr = ss->xirr;
+    uint32_t xirr = icp->xirr;
 
-    qemu_irq_lower(ss->output);
-    ss->xirr = ss->pending_priority << 24;
-    ss->pending_priority = 0xff;
-    ss->xirr_owner = NULL;
+    qemu_irq_lower(icp->output);
+    icp->xirr = icp->pending_priority << 24;
+    icp->pending_priority = 0xff;
+    icp->xirr_owner = NULL;
 
-    trace_xics_icp_accept(xirr, ss->xirr);
+    trace_xics_icp_accept(xirr, icp->xirr);
 
     return xirr;
 }
 
-uint32_t icp_ipoll(ICPState *ss, uint32_t *mfrr)
+uint32_t icp_ipoll(ICPState *icp, uint32_t *mfrr)
 {
     if (mfrr) {
-        *mfrr = ss->mfrr;
+        *mfrr = icp->mfrr;
     }
-    return ss->xirr;
+    return icp->xirr;
 }
 
-void icp_eoi(ICPState *ss, uint32_t xirr)
+void icp_eoi(ICPState *icp, uint32_t xirr)
 {
-    XICSFabric *xi = ss->xics;
+    XICSFabric *xi = icp->xics;
     XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
     ICSState *ics;
     uint32_t irq;
 
     /* Send EOI -> ICS */
-    ss->xirr = (ss->xirr & ~CPPR_MASK) | (xirr & CPPR_MASK);
-    trace_xics_icp_eoi(ss->cs->cpu_index, xirr, ss->xirr);
+    icp->xirr = (icp->xirr & ~CPPR_MASK) | (xirr & CPPR_MASK);
+    trace_xics_icp_eoi(icp->cs->cpu_index, xirr, icp->xirr);
     irq = xirr & XISR_MASK;
 
     ics = xic->ics_get(xi, irq);
     if (ics) {
         ics_eoi(ics, irq);
     }
-    if (!XISR(ss)) {
-        icp_resend(ss);
+    if (!XISR(icp)) {
+        icp_resend(icp);
     }
 }
 
 static void icp_irq(ICSState *ics, int server, int nr, uint8_t priority)
 {
-    ICPState *ss = xics_icp_get(ics->xics, server);
+    ICPState *icp = xics_icp_get(ics->xics, server);
 
     trace_xics_icp_irq(server, nr, priority);
 
-    if ((priority >= CPPR(ss))
-        || (XISR(ss) && (ss->pending_priority <= priority))) {
+    if ((priority >= CPPR(icp))
+        || (XISR(icp) && (icp->pending_priority <= priority))) {
         ics_reject(ics, nr);
     } else {
-        if (XISR(ss) && ss->xirr_owner) {
-            ics_reject(ss->xirr_owner, XISR(ss));
-            ss->xirr_owner = NULL;
+        if (XISR(icp) && icp->xirr_owner) {
+            ics_reject(icp->xirr_owner, XISR(icp));
+            icp->xirr_owner = NULL;
         }
-        ss->xirr = (ss->xirr & ~XISR_MASK) | (nr & XISR_MASK);
-        ss->xirr_owner = ics;
-        ss->pending_priority = priority;
-        trace_xics_icp_raise(ss->xirr, ss->pending_priority);
-        qemu_irq_raise(ss->output);
+        icp->xirr = (icp->xirr & ~XISR_MASK) | (nr & XISR_MASK);
+        icp->xirr_owner = ics;
+        icp->pending_priority = priority;
+        trace_xics_icp_raise(icp->xirr, icp->pending_priority);
+        qemu_irq_raise(icp->output);
     }
 }
 
 static void icp_dispatch_pre_save(void *opaque)
 {
-    ICPState *ss = opaque;
-    ICPStateClass *info = ICP_GET_CLASS(ss);
+    ICPState *icp = opaque;
+    ICPStateClass *info = ICP_GET_CLASS(icp);
 
     if (info->pre_save) {
-        info->pre_save(ss);
+        info->pre_save(icp);
     }
 }
 
 static int icp_dispatch_post_load(void *opaque, int version_id)
 {
-    ICPState *ss = opaque;
-    ICPStateClass *info = ICP_GET_CLASS(ss);
+    ICPState *icp = opaque;
+    ICPStateClass *info = ICP_GET_CLASS(icp);
 
     if (info->post_load) {
-        return info->post_load(ss, version_id);
+        return info->post_load(icp, version_id);
     }
 
     return 0;
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 14de5d4bb8cc..0a3daca3bb5a 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -45,7 +45,7 @@ static int kernel_xics_fd = -1;
 /*
  * ICP-KVM
  */
-static void icp_get_kvm_state(ICPState *ss)
+static void icp_get_kvm_state(ICPState *icp)
 {
     uint64_t state;
     struct kvm_one_reg reg = {
@@ -55,25 +55,25 @@ static void icp_get_kvm_state(ICPState *ss)
     int ret;
 
     /* ICP for this CPU thread is not in use, exiting */
-    if (!ss->cs) {
+    if (!icp->cs) {
         return;
     }
 
-    ret = kvm_vcpu_ioctl(ss->cs, KVM_GET_ONE_REG, &reg);
+    ret = kvm_vcpu_ioctl(icp->cs, KVM_GET_ONE_REG, &reg);
     if (ret != 0) {
         error_report("Unable to retrieve KVM interrupt controller state"
-                " for CPU %ld: %s", kvm_arch_vcpu_id(ss->cs), strerror(errno));
+                " for CPU %ld: %s", kvm_arch_vcpu_id(icp->cs), strerror(errno));
         exit(1);
     }
 
-    ss->xirr = state >> KVM_REG_PPC_ICP_XISR_SHIFT;
-    ss->mfrr = (state >> KVM_REG_PPC_ICP_MFRR_SHIFT)
+    icp->xirr = state >> KVM_REG_PPC_ICP_XISR_SHIFT;
+    icp->mfrr = (state >> KVM_REG_PPC_ICP_MFRR_SHIFT)
         & KVM_REG_PPC_ICP_MFRR_MASK;
-    ss->pending_priority = (state >> KVM_REG_PPC_ICP_PPRI_SHIFT)
+    icp->pending_priority = (state >> KVM_REG_PPC_ICP_PPRI_SHIFT)
         & KVM_REG_PPC_ICP_PPRI_MASK;
 }
 
-static int icp_set_kvm_state(ICPState *ss, int version_id)
+static int icp_set_kvm_state(ICPState *icp, int version_id)
 {
     uint64_t state;
     struct kvm_one_reg reg = {
@@ -83,18 +83,18 @@ static int icp_set_kvm_state(ICPState *ss, int version_id)
     int ret;
 
     /* ICP for this CPU thread is not in use, exiting */
-    if (!ss->cs) {
+    if (!icp->cs) {
         return 0;
     }
 
-    state = ((uint64_t)ss->xirr << KVM_REG_PPC_ICP_XISR_SHIFT)
-        | ((uint64_t)ss->mfrr << KVM_REG_PPC_ICP_MFRR_SHIFT)
-        | ((uint64_t)ss->pending_priority << KVM_REG_PPC_ICP_PPRI_SHIFT);
+    state = ((uint64_t)icp->xirr << KVM_REG_PPC_ICP_XISR_SHIFT)
+        | ((uint64_t)icp->mfrr << KVM_REG_PPC_ICP_MFRR_SHIFT)
+        | ((uint64_t)icp->pending_priority << KVM_REG_PPC_ICP_PPRI_SHIFT);
 
-    ret = kvm_vcpu_ioctl(ss->cs, KVM_SET_ONE_REG, &reg);
+    ret = kvm_vcpu_ioctl(icp->cs, KVM_SET_ONE_REG, &reg);
     if (ret != 0) {
         error_report("Unable to restore KVM interrupt controller state (0x%"
-                PRIx64 ") for CPU %ld: %s", state, kvm_arch_vcpu_id(ss->cs),
+                PRIx64 ") for CPU %ld: %s", state, kvm_arch_vcpu_id(icp->cs),
                 strerror(errno));
         return ret;
     }
@@ -118,7 +118,7 @@ static void icp_kvm_reset(DeviceState *dev)
     icp_set_kvm_state(icp, 1);
 }
 
-static void icp_kvm_cpu_setup(ICPState *ss, PowerPCCPU *cpu)
+static void icp_kvm_cpu_setup(ICPState *icp, PowerPCCPU *cpu)
 {
     CPUState *cs = CPU(cpu);
     int ret;
@@ -132,7 +132,7 @@ static void icp_kvm_cpu_setup(ICPState *ss, PowerPCCPU *cpu)
      * which was hot-removed earlier we don't have to renable
      * KVM_CAP_IRQ_XICS capability again.
      */
-    if (ss->cap_irq_xics_enabled) {
+    if (icp->cap_irq_xics_enabled) {
         return;
     }
 
@@ -143,7 +143,7 @@ static void icp_kvm_cpu_setup(ICPState *ss, PowerPCCPU *cpu)
                      kvm_arch_vcpu_id(cs), strerror(errno));
         exit(1);
     }
-    ss->cap_irq_xics_enabled = true;
+    icp->cap_irq_xics_enabled = true;
 }
 
 static void icp_kvm_class_init(ObjectClass *klass, void *data)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH v4 02/26] ppc/xics: fix ICP and ICS reset
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 02/26] ppc/xics: fix ICP and ICS reset Cédric Le Goater
@ 2017-02-28  2:00   ` David Gibson
  2017-02-28  6:54     ` Cédric Le Goater
  0 siblings, 1 reply; 30+ messages in thread
From: David Gibson @ 2017-02-28  2:00 UTC (permalink / raw)
  To: Cédric Le Goater; +Cc: qemu-ppc, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2010 bytes --]

On Mon, Feb 27, 2017 at 03:29:09PM +0100, Cédric Le Goater wrote:
> 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>

I've merged 1&2 into my tree, but folded together.  First, I don't
want to break bisects, second you reference an explicit commit above,
which would have been made incorrect by rebases of the first patch.

> ---
>  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 ceefbb57d0ac..3c79068075e4 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;

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation
  2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
                   ` (25 preceding siblings ...)
  2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 26/26] ppc/xics: rename 'ICPState *' variables to 'icp' Cédric Le Goater
@ 2017-02-28  3:54 ` David Gibson
  26 siblings, 0 replies; 30+ messages in thread
From: David Gibson @ 2017-02-28  3:54 UTC (permalink / raw)
  To: Cédric Le Goater; +Cc: qemu-ppc, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 4887 bytes --]


On Mon, Feb 27, 2017 at 03:29:07PM +0100, 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.
> 
> 
> 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

There are some things I'd do differently, and I think there's room for
some future improvements, but this is certainly much better than where
we started.  So I've merged this into ppc-for-2.9.  Assuming my usual
tests pass, I hope to send a pull request shortly, to squeeze in just
in time for the soft freeze.

> 
> 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 v3:
> 
>  - reintroduced 'xics' backlinks to remove useless calls to
>    qdev_get_machine()
>  - moved InterruptStatsProvider to the sPAPR machine for a better
>    output
>  - moved move ics-simple post_load under the machine and removed the
>    icp_resend() XICSFabric handler
>  
> Changes since v2:
> 
>  - renamed QOM Interface to XICSFabric
> 
> Cédric Le Goater (25):
>   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: move kernel_xics_fd out of KVMXICSState
>   ppc/xics: simplify the cpu_setup() handler
>   ppc/xics: move the cpu_setup() handler under the ICPState class
>   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: export the XICS init routines
>   ppc/xics: remove the XICSState classes
>   ppc/xics: move ics-simple post_load under the machine
>   ppc/xics: move InterruptStatsProvider to the sPAPR machine
>   ppc/xics: rename 'ICPState *' variables to 'icp'
> 
> David Gibson (1):
>   xics: XICS should not be a SysBusDevice
> 
>  hw/intc/xics.c              | 461 +++++++++++++++++---------------------------
>  hw/intc/xics_kvm.c          | 184 +++++-------------
>  hw/intc/xics_spapr.c        | 128 +++---------
>  hw/ppc/spapr.c              | 134 ++++++++++---
>  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       |  97 ++++------
>  12 files changed, 424 insertions(+), 615 deletions(-)
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [Qemu-devel] [PATCH v4 02/26] ppc/xics: fix ICP and ICS reset
  2017-02-28  2:00   ` David Gibson
@ 2017-02-28  6:54     ` Cédric Le Goater
  0 siblings, 0 replies; 30+ messages in thread
From: Cédric Le Goater @ 2017-02-28  6:54 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-ppc, qemu-devel

On 02/28/2017 03:00 AM, David Gibson wrote:
> On Mon, Feb 27, 2017 at 03:29:09PM +0100, Cédric Le Goater wrote:
>> 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>
> 
> I've merged 1&2 into my tree, but folded together.  First, I don't
> want to break bisects, second you reference an explicit commit above,
> which would have been made incorrect by rebases of the first patch.

Perfect. That was the thing to do. 

Thanks,

C.

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2017-02-28  6:55 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-27 14:29 [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 01/26] xics: XICS should not be a SysBusDevice Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 02/26] ppc/xics: fix ICP and ICS reset Cédric Le Goater
2017-02-28  2:00   ` David Gibson
2017-02-28  6:54     ` Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 03/26] ppc/xics: remove set_nr_irqs() handler from XICSStateClass Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 04/26] ppc/xics: remove set_nr_servers() " Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 05/26] ppc/xics: store the ICS object under the sPAPR machine Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 06/26] ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 07/26] ppc/xics: introduce a XICSFabric QOM interface to handle ICSs Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 08/26] ppc/xics: use the QOM interface under the sPAPR machine Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 09/26] ppc/xics: use the QOM interface to get irqs Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 10/26] ppc/xics: use the QOM interface to resend irqs Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 11/26] ppc/xics: remove xics_find_source() Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 12/26] ppc/xics: register the reset handler of ICS objects Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 13/26] ppc/xics: remove the XICS list of ICS Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 14/26] ppc/xics: extend the QOM interface to handle ICPs Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 15/26] ppc/xics: move kernel_xics_fd out of KVMXICSState Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 16/26] ppc/xics: simplify the cpu_setup() handler Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 17/26] ppc/xics: move the cpu_setup() handler under the ICPState class Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 18/26] ppc/xics: use the QOM interface to grab an ICP Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 19/26] ppc/xics: simplify spapr_dt_xics() interface Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 20/26] ppc/xics: register the reset handler of ICP objects Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 21/26] ppc/xics: move the ICP array under the sPAPR machine Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 22/26] ppc/xics: export the XICS init routines Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 23/26] ppc/xics: remove the XICSState classes Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 24/26] ppc/xics: move ics-simple post_load under the machine Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 25/26] ppc/xics: move InterruptStatsProvider to the sPAPR machine Cédric Le Goater
2017-02-27 14:29 ` [Qemu-devel] [PATCH v4 26/26] ppc/xics: rename 'ICPState *' variables to 'icp' Cédric Le Goater
2017-02-28  3:54 ` [Qemu-devel] [PATCH v4 00/26] ppc/xics: simplify ICS and ICP creation David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.