qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-ppc] [PATCH v4 23/28] spapr/xive: add common realize routine for K


From: Cédric Le Goater
Subject: [Qemu-ppc] [PATCH v4 23/28] spapr/xive: add common realize routine for KVM
Date: Thu, 7 Jun 2018 17:49:58 +0200

The XiveSource and sPAPRXive device models will be shared between the
TCG and the KVM mode. The difference will reside in the way the memory
regions are initialized and in the qemu_irq handler.

Introduce common realize routines to share some code.

Signed-off-by: Cédric Le Goater <address@hidden>
---
 include/hw/ppc/spapr_xive.h |  1 +
 include/hw/ppc/xive.h       |  3 +++
 hw/intc/spapr_xive.c        | 15 +++++++++++++--
 hw/intc/xive.c              | 22 +++++++++++++++++-----
 4 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h
index 1284784f1152..4aa04bc48ccb 100644
--- a/include/hw/ppc/spapr_xive.h
+++ b/include/hw/ppc/spapr_xive.h
@@ -55,6 +55,7 @@ bool spapr_xive_irq_enable(sPAPRXive *xive, uint32_t lisn, 
bool lsi);
 bool spapr_xive_irq_disable(sPAPRXive *xive, uint32_t lisn);
 void spapr_xive_pic_print_info(sPAPRXive *xive, Monitor *mon);
 qemu_irq spapr_xive_qirq(sPAPRXive *xive, uint32_t lisn);
+void spapr_xive_common_realize(sPAPRXive *xive, Error **errp);
 
 /*
  * sPAPR VP and EQ indexing helpers
diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h
index d943770efd9d..7a54b3ce594f 100644
--- a/include/hw/ppc/xive.h
+++ b/include/hw/ppc/xive.h
@@ -183,6 +183,9 @@ static inline void xive_source_irq_set(XiveSource *xsrc, 
uint32_t srcno,
     }
 }
 
+void xive_source_common_realize(XiveSource *xsrc, qemu_irq_handler handler,
+                                Error **errp);
+
 /*
  * XIVE Router
  */
diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
index 91f9b28ebcc4..2812b1a1a030 100644
--- a/hw/intc/spapr_xive.c
+++ b/hw/intc/spapr_xive.c
@@ -84,9 +84,8 @@ static void spapr_xive_instance_init(Object *obj)
     object_property_add_child(obj, "eq_source", OBJECT(&xive->eq_source), 
NULL);
 }
 
-static void spapr_xive_realize(DeviceState *dev, Error **errp)
+void spapr_xive_common_realize(sPAPRXive *xive, Error **errp)
 {
-    sPAPRXive *xive = SPAPR_XIVE(dev);
     XiveSource *xsrc = &xive->source;
     XiveEQSource *eq_xsrc = &xive->eq_source;
     Error *local_err = NULL;
@@ -132,6 +131,18 @@ static void spapr_xive_realize(DeviceState *dev, Error 
**errp)
     /* Allocate the routing tables */
     xive->ivt = g_new0(XiveIVE, xive->nr_irqs);
     xive->eqdt = g_new0(XiveEQ, xive->nr_eqs);
+}
+
+static void spapr_xive_realize(DeviceState *dev, Error **errp)
+{
+    sPAPRXive *xive = SPAPR_XIVE(dev);
+    Error *local_err = NULL;
+
+    spapr_xive_common_realize(xive, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
 
     /* TIMA */
     memory_region_init_io(&xive->tm_mmio, OBJECT(xive), &xive_tm_ops, xive,
diff --git a/hw/intc/xive.c b/hw/intc/xive.c
index 5cf9fc4e1cb3..4d073c37bbda 100644
--- a/hw/intc/xive.c
+++ b/hw/intc/xive.c
@@ -1003,13 +1003,13 @@ static void xive_source_reset(DeviceState *dev)
     }
 }
 
-static void xive_source_realize(DeviceState *dev, Error **errp)
+void xive_source_common_realize(XiveSource *xsrc, qemu_irq_handler handler,
+                                Error **errp)
 {
-    XiveSource *xsrc = XIVE_SOURCE(dev);
     Object *obj;
     Error *local_err = NULL;
 
-    obj = object_property_get_link(OBJECT(dev), "xive", &local_err);
+    obj = object_property_get_link(OBJECT(xsrc), "xive", &local_err);
     if (!obj) {
         error_propagate(errp, local_err);
         error_prepend(errp, "required link 'xive' not found: ");
@@ -1031,14 +1031,26 @@ static void xive_source_realize(DeviceState *dev, Error 
**errp)
         return;
     }
 
-    xsrc->qirqs = qemu_allocate_irqs(xive_source_set_irq, xsrc,
-                                     xsrc->nr_irqs);
+    xsrc->qirqs = qemu_allocate_irqs(handler, xsrc, xsrc->nr_irqs);
 
     xsrc->status = g_malloc0(xsrc->nr_irqs);
 
     xsrc->lsi_map = bitmap_new(xsrc->nr_irqs);
     xsrc->lsi_map_size = xsrc->nr_irqs;
 
+}
+
+static void xive_source_realize(DeviceState *dev, Error **errp)
+{
+    XiveSource *xsrc = XIVE_SOURCE(dev);
+    Error *local_err = NULL;
+
+    xive_source_common_realize(xsrc, xive_source_set_irq, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
     memory_region_init_io(&xsrc->esb_mmio, OBJECT(xsrc),
                           &xive_source_esb_ops, xsrc, "xive.esb",
                           (1ull << xsrc->esb_shift) * xsrc->nr_irqs);
-- 
2.13.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]