From nobody Tue Feb 10 16:18:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528388009758620.0563814321844; Thu, 7 Jun 2018 09:13:29 -0700 (PDT) Received: from localhost ([::1]:58925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQxXU-0007Bj-TB for importer@patchew.org; Thu, 07 Jun 2018 12:13:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQxDA-0003AZ-8u for qemu-devel@nongnu.org; Thu, 07 Jun 2018 11:52:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQxD5-0004Q9-Hs for qemu-devel@nongnu.org; Thu, 07 Jun 2018 11:52:28 -0400 Received: from 8.mo1.mail-out.ovh.net ([178.33.110.239]:53848) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQxD5-0004PE-Bq for qemu-devel@nongnu.org; Thu, 07 Jun 2018 11:52:23 -0400 Received: from player169.ha.ovh.net (unknown [10.109.120.103]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id D5F92105B52 for ; Thu, 7 Jun 2018 17:52:21 +0200 (CEST) Received: from zorba.kaod.org.com (deibp9eh1--blueice1n0.emea.ibm.com [195.212.29.162]) (Authenticated sender: clg@kaod.org) by player169.ha.ovh.net (Postfix) with ESMTPSA id 7205E5800B6; Thu, 7 Jun 2018 17:52:16 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org Date: Thu, 7 Jun 2018 17:49:58 +0200 Message-Id: <20180607155003.1580-24-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180607155003.1580-1-clg@kaod.org> References: <20180607155003.1580-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 6103784870269586259 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedthedrjeejgdelgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.110.239 Subject: [Qemu-devel] [PATCH v4 23/28] spapr/xive: add common realize routine for KVM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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=C3=A9dric Le Goater --- 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); =20 /* * 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, } } =20 +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); } =20 -static void spapr_xive_realize(DeviceState *dev, Error **errp) +void spapr_xive_common_realize(sPAPRXive *xive, Error **errp) { - sPAPRXive *xive =3D SPAPR_XIVE(dev); XiveSource *xsrc =3D &xive->source; XiveEQSource *eq_xsrc =3D &xive->eq_source; Error *local_err =3D NULL; @@ -132,6 +131,18 @@ static void spapr_xive_realize(DeviceState *dev, Error= **errp) /* Allocate the routing tables */ xive->ivt =3D g_new0(XiveIVE, xive->nr_irqs); xive->eqdt =3D g_new0(XiveEQ, xive->nr_eqs); +} + +static void spapr_xive_realize(DeviceState *dev, Error **errp) +{ + sPAPRXive *xive =3D SPAPR_XIVE(dev); + Error *local_err =3D NULL; + + spapr_xive_common_realize(xive, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } =20 /* 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) } } =20 -static void xive_source_realize(DeviceState *dev, Error **errp) +void xive_source_common_realize(XiveSource *xsrc, qemu_irq_handler handler, + Error **errp) { - XiveSource *xsrc =3D XIVE_SOURCE(dev); Object *obj; Error *local_err =3D NULL; =20 - obj =3D object_property_get_link(OBJECT(dev), "xive", &local_err); + obj =3D 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, E= rror **errp) return; } =20 - xsrc->qirqs =3D qemu_allocate_irqs(xive_source_set_irq, xsrc, - xsrc->nr_irqs); + xsrc->qirqs =3D qemu_allocate_irqs(handler, xsrc, xsrc->nr_irqs); =20 xsrc->status =3D g_malloc0(xsrc->nr_irqs); =20 xsrc->lsi_map =3D bitmap_new(xsrc->nr_irqs); xsrc->lsi_map_size =3D xsrc->nr_irqs; =20 +} + +static void xive_source_realize(DeviceState *dev, Error **errp) +{ + XiveSource *xsrc =3D XIVE_SOURCE(dev); + Error *local_err =3D 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); --=20 2.13.6