[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v3 24/35] spapr/xive: add common realize routine for K
From: |
Cédric Le Goater |
Subject: |
[Qemu-ppc] [PATCH v3 24/35] spapr/xive: add common realize routine for KVM |
Date: |
Thu, 19 Apr 2018 14:43:20 +0200 |
The XiveSource and sPAPRXive device models will be shared between the
emulated 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>
---
hw/intc/spapr_xive.c | 17 +++++++++++++++--
hw/intc/xive.c | 21 ++++++++++++++++-----
include/hw/ppc/spapr_xive.h | 1 +
include/hw/ppc/xive.h | 3 +++
4 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
index f0c2fe52b3c6..bd604089ad49 100644
--- a/hw/intc/spapr_xive.c
+++ b/hw/intc/spapr_xive.c
@@ -84,9 +84,8 @@ static void spapr_xive_init(Object *obj)
object_property_add_child(obj, "source", OBJECT(&xive->source), NULL);
}
-static void spapr_xive_realize(DeviceState *dev, Error **errp)
+void spapr_xive_common_realize(sPAPRXive *xive, int esb_shift, Error **errp)
{
- sPAPRXive *xive = SPAPR_XIVE(dev);
XiveSource *xsrc = &xive->source;
Error *local_err = NULL;
@@ -105,6 +104,8 @@ static void spapr_xive_realize(DeviceState *dev, Error
**errp)
&error_fatal);
object_property_set_int(OBJECT(xsrc), xive->nr_irqs, "nr-irqs",
&error_fatal);
+ object_property_set_int(OBJECT(xsrc), esb_shift, "shift",
+ &error_fatal);
object_property_add_const_link(OBJECT(xsrc), "xive", OBJECT(xive),
&error_fatal);
object_property_set_bool(OBJECT(xsrc), true, "realized", &local_err);
@@ -122,6 +123,18 @@ static void spapr_xive_realize(DeviceState *dev, Error
**errp)
* level views of the TIMA.
*/
xive->tm_base = XIVE_TM_BASE;
+}
+
+static void spapr_xive_realize(DeviceState *dev, Error **errp)
+{
+ sPAPRXive *xive = SPAPR_XIVE(dev);
+ Error *local_err = NULL;
+
+ spapr_xive_common_realize(xive, XIVE_ESB_64K_2PAGE, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
memory_region_init_io(&xive->tm_mmio_user, OBJECT(xive),
&xive_tm_user_ops, xive, "xive.tima.user",
diff --git a/hw/intc/xive.c b/hw/intc/xive.c
index 11af3bf1184a..520b532dbf09 100644
--- a/hw/intc/xive.c
+++ b/hw/intc/xive.c
@@ -903,13 +903,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: ");
@@ -931,13 +931,24 @@ 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);
/* Allocate the SBEs (State Bit Entry). 2 bits, so 4 entries per byte */
xsrc->sbe_size = DIV_ROUND_UP(xsrc->nr_irqs, 4);
xsrc->sbe = g_malloc0(xsrc->sbe_size);
+}
+
+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;
+ }
/* TODO: H_INT_ESB support, which removing the ESB MMIOs */
diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h
index 41e2784403b2..f3ac084a71be 100644
--- a/include/hw/ppc/spapr_xive.h
+++ b/include/hw/ppc/spapr_xive.h
@@ -51,6 +51,7 @@ void spapr_xive_pic_print_info(sPAPRXive *xive, Monitor *mon);
void spapr_xive_mmio_map(sPAPRXive *xive);
void spapr_xive_mmio_unmap(sPAPRXive *xive);
qemu_irq spapr_xive_qirq(sPAPRXive *xive, int lisn);
+void spapr_xive_common_realize(sPAPRXive *xive, int esb_shift, Error **errp);
/*
* sPAPR encoding of EQ indexes
diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h
index 36de10af0109..b040cf580fc9 100644
--- a/include/hw/ppc/xive.h
+++ b/include/hw/ppc/xive.h
@@ -175,6 +175,9 @@ static inline qemu_irq xive_source_qirq(XiveSource *xsrc,
uint32_t srcno)
return xsrc->qirqs[srcno];
}
+void xive_source_common_realize(XiveSource *xsrc, qemu_irq_handler handler,
+ Error **errp);
+
/*
* XIVE Interrupt Presenter
*/
--
2.13.6
- [Qemu-ppc] [PATCH v3 13/35] spapr: add hcalls support for the XIVE exploitation interrupt mode, (continued)
- [Qemu-ppc] [PATCH v3 13/35] spapr: add hcalls support for the XIVE exploitation interrupt mode, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 15/35] sysbus: add a sysbus_mmio_unmap() helper, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 16/35] spapr: introduce a helper to map the XIVE memory regions, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 17/35] spapr: add XIVE support to spapr_qirq(), Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 18/35] spapr: introduce a spapr_icp_create() helper, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 19/35] spapr: toggle the ICP depending on the selected interrupt mode, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 20/35] spapr: add support to dump XIVE information, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 21/35] spapr: advertise XIVE exploitation mode in CAS, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 22/35] spapr: add classes for the XIVE models, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 23/35] target/ppc/kvm: add Linux KVM definitions for XIVE, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 24/35] spapr/xive: add common realize routine for KVM,
Cédric Le Goater <=
- [Qemu-ppc] [PATCH v3 25/35] spapr/xive: add KVM support, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 26/35] spapr/xive: add a XIVE KVM device to the machine, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 27/35] migration: discard non-migratable RAMBlocks, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 28/35] intc: introduce a CPUIntc interface, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 29/35] spapr/xive, xics: use the CPU_INTC handlers to reset KVM, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 30/35] spapr/xive, xics: reset KVM at machine reset, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 31/35] spapr/xive: raise migration priority of the machine, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 32/35] ppc/pnv: introduce a pnv_icp_create() helper, Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 33/35] ppc: externalize ppc_get_vcpu_by_pir(), Cédric Le Goater, 2018/04/19
- [Qemu-ppc] [PATCH v3 34/35] ppc/pnv: add XIVE support, Cédric Le Goater, 2018/04/19