From patchwork Thu Mar 21 14:49:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 10863755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E0D76C2 for ; Thu, 21 Mar 2019 15:04:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C692628DED for ; Thu, 21 Mar 2019 15:04:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4D1D28E41; Thu, 21 Mar 2019 15:04:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 637C528F63 for ; Thu, 21 Mar 2019 15:04:23 +0000 (UTC) Received: from localhost ([127.0.0.1]:39103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6zF0-00074S-Oa for patchwork-qemu-devel@patchwork.kernel.org; Thu, 21 Mar 2019 11:04:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6z1w-0004Et-5V for qemu-devel@nongnu.org; Thu, 21 Mar 2019 10:50:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6z1v-0001a9-2A for qemu-devel@nongnu.org; Thu, 21 Mar 2019 10:50:52 -0400 Received: from 7.mo177.mail-out.ovh.net ([46.105.61.149]:59577) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6z1u-0001XS-KC for qemu-devel@nongnu.org; Thu, 21 Mar 2019 10:50:50 -0400 Received: from player788.ha.ovh.net (unknown [10.109.143.109]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id B5E5BEC26C for ; Thu, 21 Mar 2019 15:50:47 +0100 (CET) Received: from kaod.org (deibp9eh1--blueice1n0.emea.ibm.com [195.212.29.162]) (Authenticated sender: clg@kaod.org) by player788.ha.ovh.net (Postfix) with ESMTPSA id 9FBA53E6B80E; Thu, 21 Mar 2019 14:50:41 +0000 (UTC) From: =?utf-8?q?C=C3=A9dric_Le_Goater?= To: David Gibson Date: Thu, 21 Mar 2019 15:49:13 +0100 Message-Id: <20190321144914.19934-15-clg@kaod.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321144914.19934-1-clg@kaod.org> References: <20190321144914.19934-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 11873458945262717926 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedutddrieelgdehhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.105.61.149 Subject: [Qemu-devel] [PATCH v3 14/15] spapr/irq: initialize the IRQ device only once 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: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-ppc@nongnu.org, Greg Kurz , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a check to make sure that the routine initializing the emulated IRQ device is called once. We don't have much to test on the XICS side, so we introduce a 'static bool'. Not very elegant but works well enough. Signed-off-by: Cédric Le Goater --- hw/intc/spapr_xive.c | 9 +++++++++ hw/intc/xics_spapr.c | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index f889c89dc2e9..15d41d9cd36d 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -337,6 +337,15 @@ void spapr_xive_init(SpaprXive *xive, Error **errp) XiveSource *xsrc = &xive->source; XiveENDSource *end_xsrc = &xive->end_source; + /* + * The emulated XIVE device can only be initialized once. If the + * ESB memory region has been already mapped, it means we have been + * through there. + */ + if (memory_region_is_mapped(&xsrc->esb_mmio)) { + return; + } + /* TIMA initialization */ memory_region_init_io(&xive->tm_mmio, OBJECT(xive), &xive_tm_ops, xive, "xive.tima", 4ull << TM_SHIFT); diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index 9d2b8adef7c5..67e82f3720b0 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -239,6 +239,16 @@ static void rtas_int_on(PowerPCCPU *cpu, SpaprMachineState *spapr, void xics_spapr_init(SpaprMachineState *spapr) { + static bool init_done; + + /* + * Emulated mode can only be initialized once. + */ + if (init_done) { + return; + } + init_done = true; + /* 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);