From patchwork Thu Oct 19 12:48:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 10016639 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 9D86A60224 for ; Thu, 19 Oct 2017 12:51:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EC2428D42 for ; Thu, 19 Oct 2017 12:51:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73A2528D45; Thu, 19 Oct 2017 12:51:24 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 25F5028D42 for ; Thu, 19 Oct 2017 12:51:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5AGE-0004YR-1D; Thu, 19 Oct 2017 12:49:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5AGD-0004X0-FS for xen-devel@lists.xenproject.org; Thu, 19 Oct 2017 12:49:17 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id EB/31-30115-C4F98E95; Thu, 19 Oct 2017 12:49:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTddn/ot Ig52fhSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozmxwsYC24KV3xadZmpgXE+fxcjF4eQwAZG iWsXZrB2MXICOcsZJb7PVwOx2QR0JXbcfM0MYosIREicfnyJCcRmFlCS2H/2GiOILSzgLHFt+ zQWEJtFQFViy4MJYHFeAWuJdXuegNVLCMhLnHtwG2wOJ1D89t4bjBC7rCS2PXzHOIGRewEjwy pGjeLUorLUIl1DI72kosz0jJLcxMwcXUMDM73c1OLixPTUnMSkYr3k/NxNjED/MgDBDsbLGwM OMUpyMCmJ8n6sehEpxJeUn1KZkVicEV9UmpNafIhRhoNDSYKXeR5QTrAoNT21Ii0zBxhoMGkJ Dh4lEV5vkDRvcUFibnFmOkTqFKMuR8fNu3+YhFjy8vNSpcR5Y0CKBECKMkrz4EbAgv4So6yUM C8j0FFCPAWpRbmZJajyrxjFORiVhHk1QKbwZOaVwG16BXQEE9AR7PZgR5QkIqSkGhh1Jh9X4J O72aXyfeFun/5uyfW1P5/5LGMKmOx0Jlzg/JvkyNOvapZX82iZ6ly89np5xc/0DR/qpG5/79n 9WapuC89GVptm30Al6coS3c0rn7Dp9y43PvV4vaHZ2dl7YpYUy17sn6j963Jj+qEJl5ie7VVi Y85RKDGJz0gX7fwwRbDa8orN31QlluKMREMt5qLiRACyI/8adQIAAA== X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1508417355!77996773!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62956 invoked from network); 19 Oct 2017 12:49:16 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-21.messagelabs.com with SMTP; 19 Oct 2017 12:49:16 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 984F5F; Thu, 19 Oct 2017 05:49:15 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AC7FC3F3E1; Thu, 19 Oct 2017 05:49:14 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Thu, 19 Oct 2017 13:48:46 +0100 Message-Id: <20171019124847.5978-12-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171019124847.5978-1-andre.przywara@arm.com> References: <20171019124847.5978-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH 11/12] ARM: VGIC: factor out vgic_get_hw_irq_desc() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP At the moment we happily access the VGIC internal struct pending_irq (which describes a virtual IRQ) in irq.c. Factor out the actually needed functionality to learn the associated hardware IRQ and move that into gic-vgic.c to improve abstraction. Signed-off-by: Andre Przywara Acked-by: Stefano Stabellini --- xen/arch/arm/gic-vgic.c | 15 +++++++++++++++ xen/arch/arm/irq.c | 7 ++----- xen/include/asm-arm/vgic.h | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/gic-vgic.c b/xen/arch/arm/gic-vgic.c index bf9455a34e..7765d83432 100644 --- a/xen/arch/arm/gic-vgic.c +++ b/xen/arch/arm/gic-vgic.c @@ -385,6 +385,21 @@ void gic_inject(struct vcpu *v) gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 1); } +struct irq_desc *vgic_get_hw_irq_desc(struct domain *d, struct vcpu *v, + unsigned int virq) +{ + struct pending_irq *p; + + if ( !v ) + v = d->vcpu[0]; + + p = irq_to_pending(v, virq); + if ( !p ) + return NULL; + + return p->desc; +} + int vgic_connect_hw_irq(struct domain *d, struct vcpu *v, unsigned int virq, struct irq_desc *desc) { diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 7f133de549..62103a20e3 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -534,19 +534,16 @@ int release_guest_irq(struct domain *d, unsigned int virq) struct irq_desc *desc; struct irq_guest *info; unsigned long flags; - struct pending_irq *p; int ret; /* Only SPIs are supported */ if ( virq < NR_LOCAL_IRQS || virq >= vgic_num_irqs(d) ) return -EINVAL; - p = spi_to_pending(d, virq); - if ( !p->desc ) + desc = vgic_get_hw_irq_desc(d, NULL, virq); + if ( !desc ) return -EINVAL; - desc = p->desc; - spin_lock_irqsave(&desc->lock, flags); ret = -EINVAL; diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index cf02dc6394..947950875b 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -220,6 +220,8 @@ int vgic_v2_init(struct domain *d, int *mmio_count); int vgic_v3_init(struct domain *d, int *mmio_count); bool vgic_evtchn_irq_pending(struct vcpu *v); +struct irq_desc *vgic_get_hw_irq_desc(struct domain *d, struct vcpu *v, + unsigned int virq); int vgic_connect_hw_irq(struct domain *d, struct vcpu *v, unsigned int virq, struct irq_desc *desc);