From patchwork Sun Oct 29 18:12:15 2017 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: 10031585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0F7BD602D6 for ; Sun, 29 Oct 2017 18:17:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0709E285E2 for ; Sun, 29 Oct 2017 18:17:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0295286F9; Sun, 29 Oct 2017 18:17:53 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 66998285E2 for ; Sun, 29 Oct 2017 18:17:53 +0000 (UTC) Received: from localhost ([::1]:37308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s9g-0007Xf-Ju for patchwork-qemu-devel@patchwork.kernel.org; Sun, 29 Oct 2017 14:17:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s5G-00052R-75 for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8s5D-0005ye-1j for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:18 -0400 Received: from 1.mo178.mail-out.ovh.net ([178.33.251.53]:41791) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e8s5C-0005yQ-Rm for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:14 -0400 Received: from player793.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id 89A0E637BF for ; Sun, 29 Oct 2017 19:13:13 +0100 (CET) Received: from zorba.kaod.org (ken64-2-78-199-76-109.fbx.proxad.net [78.199.76.109]) (Authenticated sender: clg@kaod.org) by player793.ha.ovh.net (Postfix) with ESMTPSA id 0EE514007C; Sun, 29 Oct 2017 19:13:06 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Sun, 29 Oct 2017 19:12:15 +0100 Message-Id: <20171029181217.9927-7-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171029181217.9927-1-clg@kaod.org> References: <20171029181217.9927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1889541518792297299 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrfeekgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.251.53 Subject: [Qemu-devel] [PATCH 6/8] sparp: merge ics_set_irq_type() in irq_alloc_block() operation 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=20Le=20Goater?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Setting the XICS_FLAGS_IRQ_LSI (or XICS_FLAGS_IRQ_MSI) for pre-2.11 pseries machines can now be done directly under the irq_alloc_block() operation. let's remove ics_set_irq_type() which becomes useless. The PowerNV machine is a bit special because it does not manage its own IRQ number allocator yet. But, as it only handles the PSI interrupts which are LSIs, this is not a problem. For compatibility with older machines, we use the machine class flag 'pre_2_11_has_no_bitmap'. Signed-off-by: Cédric Le Goater --- hw/intc/xics.c | 8 -------- hw/intc/xics_spapr.c | 9 +-------- hw/ppc/pnv_psi.c | 4 ---- hw/ppc/spapr.c | 9 ++++++++- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 42880e736697..237eed3c11f8 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -710,14 +710,6 @@ ICPState *xics_icp_get(XICSFabric *xi, int server) 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)); - - ics->irqs[srcno].flags |= - lsi ? XICS_FLAGS_IRQ_LSI : XICS_FLAGS_IRQ_MSI; -} - static void xics_register_types(void) { type_register_static(&ics_simple_info); diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index e1f158302a6a..23d81ff83182 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -264,7 +264,6 @@ int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp) } } - ics_set_irq_type(ics, irq - ics->offset, lsi); trace_xics_alloc(irq); return irq; @@ -277,7 +276,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) { - int i, first = -1; + int first = -1; XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(ics->xics); @@ -300,12 +299,6 @@ int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, return -1; } - if (first >= 0) { - for (i = first; i < first + num; ++i) { - ics_set_irq_type(ics, i - ics->offset, lsi); - } - } - trace_xics_alloc_block(first, num, lsi, align); return first; diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c index 9876c266223d..ee7fca311cbf 100644 --- a/hw/ppc/pnv_psi.c +++ b/hw/ppc/pnv_psi.c @@ -487,10 +487,6 @@ static void pnv_psi_realize(DeviceState *dev, Error **errp) return; } - for (i = 0; i < ics->nr_irqs; i++) { - ics_set_irq_type(ics, i, true); - } - /* XSCOM region for PSI registers */ pnv_xscom_region_init(&psi->xscom_regs, OBJECT(dev), &pnv_psi_xscom_ops, psi, "xscom-psi", PNV_XSCOM_PSIHB_SIZE); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d97f287118f0..557d89d9ecb5 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3598,7 +3598,7 @@ static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align, bool lsi) sPAPRMachineState *spapr = SPAPR_MACHINE(xi); sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr); int start = 0; - int srcno; + int srcno, i; if (!lsi && !smc->pre_2_11_has_no_bitmap) { start = SPAPR_MAX_LSI; @@ -3614,6 +3614,13 @@ static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align, bool lsi) return -1; } + if (lsi && smc->pre_2_11_has_no_bitmap) { + for (i = srcno; i < srcno + count; ++i) { + assert(!(spapr->ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MASK)); + spapr->ics->irqs[srcno].flags = XICS_FLAGS_IRQ_LSI; + } + } + bitmap_set(spapr->irq_map, srcno, count); return srcno + spapr->irq_base; }