From patchwork Thu May 4 15:31:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9712161 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 BE65B6020B for ; Thu, 4 May 2017 15:31:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1B1B2869A for ; Thu, 4 May 2017 15:31:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A68EA286BB; Thu, 4 May 2017 15:31:35 +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 382472869A for ; Thu, 4 May 2017 15:31:35 +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 1d6Igu-0004Gm-82; Thu, 04 May 2017 15:29:16 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d6Igt-0004Fm-2q for xen-devel@lists.xenproject.org; Thu, 04 May 2017 15:29:15 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 2D/5E-02192-AC84B095; Thu, 04 May 2017 15:29:14 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTfeEB3e kwbNfhhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8buK+tYCqZKVnQ+3MvewHhYuIuRi0NIYBOj xOzDd9kgnOWMEp/6ZrB2MXJysAnoSuy4+ZoZxBYRCJV4uuA7mM0soCSx/+w1xi5GDg5hgUCJs 29tQMIsAqoSaz++YQSxeQWsJA4dO8oGYksIyEk0nL8P1sopYC2xd+9uMFsIqObDk5NsExi5Fz AyrGJUL04tKkst0jXWSyrKTM8oyU3MzNE1NDDWy00tLk5MT81JTCrWS87P3cQI9C4DEOxgbP7 idIhRkoNJSZRX/RV7pBBfUn5KZUZicUZ8UWlOavEhRhkODiUJXkV37kghwaLU9NSKtMwcYJjB pCU4eJREeDvdgNK8xQWJucWZ6RCpU4y6HH0dH98zCbHk5eelSonzbgApEgApyijNgxsBC/lLj LJSwryMQEcJ8RSkFuVmlqDKv2IU52BUEuYNArmEJzOvBG7TK6AjmICOaJblADmiJBEhJdXAmP MoLPiMfmn6ro3fOaclXpi79lluc/eOle72/N/0VxTrrV7feX/Xtve3CvyZTu7/e24lz8Ifd8T de4MEL986KaKu53ymOmdRUCXDs/cBb2PC5N61JN25Zb759mRdQf5tG9lddoTUb8uSTDqzPTn5 z5U2h5WsR8581Vpc92sbE9dy5o8z1Rl+7lNiKc5INNRiLipOBADxorhqdAIAAA== X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1493911752!87125893!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.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15699 invoked from network); 4 May 2017 15:29:12 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-31.messagelabs.com with SMTP; 4 May 2017 15:29:12 -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 CC06D344; Thu, 4 May 2017 08:29:11 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 16B243F23B; Thu, 4 May 2017 08:29:10 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Thu, 4 May 2017 16:31:14 +0100 Message-Id: <20170504153123.1204-2-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170504153123.1204-1-andre.przywara@arm.com> References: <20170504153123.1204-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [RFC PATCH 01/10] ARM: vGIC: remove rank lock from IRQ routing functions 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 gic_route_irq_to_guest() and gic_remove_irq_from_guest() take the rank lock, however never actually access the rank structure. Avoid taking the lock in those two functions and remove some more unneeded code on the way. Signed-off-by: Andre Przywara --- xen/arch/arm/gic.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index da19130..c734f66 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -136,25 +136,19 @@ void gic_route_irq_to_xen(struct irq_desc *desc, unsigned int priority) int gic_route_irq_to_guest(struct domain *d, unsigned int virq, struct irq_desc *desc, unsigned int priority) { - unsigned long flags; /* Use vcpu0 to retrieve the pending_irq struct. Given that we only * route SPIs to guests, it doesn't make any difference. */ - struct vcpu *v_target = vgic_get_target_vcpu(d->vcpu[0], virq); - struct vgic_irq_rank *rank = vgic_rank_irq(v_target, virq); - struct pending_irq *p = irq_to_pending(v_target, virq); - int res = -EBUSY; + struct pending_irq *p = irq_to_pending(d->vcpu[0], virq); ASSERT(spin_is_locked(&desc->lock)); /* Caller has already checked that the IRQ is an SPI */ ASSERT(virq >= 32); ASSERT(virq < vgic_num_irqs(d)); - vgic_lock_rank(v_target, rank, flags); - if ( p->desc || /* The VIRQ should not be already enabled by the guest */ test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) ) - goto out; + return -EBUSY; desc->handler = gic_hw_ops->gic_guest_irq_type; set_bit(_IRQ_GUEST, &desc->status); @@ -164,29 +158,20 @@ int gic_route_irq_to_guest(struct domain *d, unsigned int virq, gic_set_irq_priority(desc, priority); p->desc = desc; - res = 0; -out: - vgic_unlock_rank(v_target, rank, flags); - - return res; + return 0; } /* This function only works with SPIs for now */ int gic_remove_irq_from_guest(struct domain *d, unsigned int virq, struct irq_desc *desc) { - struct vcpu *v_target = vgic_get_target_vcpu(d->vcpu[0], virq); - struct vgic_irq_rank *rank = vgic_rank_irq(v_target, virq); - struct pending_irq *p = irq_to_pending(v_target, virq); - unsigned long flags; + struct pending_irq *p = irq_to_pending(d->vcpu[0], virq); ASSERT(spin_is_locked(&desc->lock)); ASSERT(test_bit(_IRQ_GUEST, &desc->status)); ASSERT(p->desc == desc); - vgic_lock_rank(v_target, rank, flags); - if ( d->is_dying ) { desc->handler->shutdown(desc); @@ -204,10 +189,7 @@ int gic_remove_irq_from_guest(struct domain *d, unsigned int virq, */ if ( test_bit(_IRQ_INPROGRESS, &desc->status) || !test_bit(_IRQ_DISABLED, &desc->status) ) - { - vgic_unlock_rank(v_target, rank, flags); return -EBUSY; - } } clear_bit(_IRQ_GUEST, &desc->status); @@ -215,8 +197,6 @@ int gic_remove_irq_from_guest(struct domain *d, unsigned int virq, p->desc = NULL; - vgic_unlock_rank(v_target, rank, flags); - return 0; }