From patchwork Fri Jun 9 17:41:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9778985 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 838D960318 for ; Fri, 9 Jun 2017 17:43:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70144286E0 for ; Fri, 9 Jun 2017 17:43:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64B28286E7; Fri, 9 Jun 2017 17:43:56 +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 00EE2286E0 for ; Fri, 9 Jun 2017 17:43:56 +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 1dJNuu-0003Mp-ET; Fri, 09 Jun 2017 17:41:48 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dJNut-0003LM-3E for xen-devel@lists.xenproject.org; Fri, 09 Jun 2017 17:41:47 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id FE/87-03058-ADDDA395; Fri, 09 Jun 2017 17:41:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTffmXat Ig5VTbCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozbTXIF9yQrHk7dyNzAuEG0i5GLQ0hgM6PE gfNv2CGc5YwSB19sZO1i5ORgE9CV2HHzNTOILSIQKvF0wXdmkCJmgeuMEqd3zGfrYuTgEBZwl Xh9MR6khkVAVeL770lsIDavgJXE022vmEBsCQE5iYbz98HmcApYS2zbsxasRgiopuXQZfYJjN wLGBlWMWoUpxaVpRbpGhnpJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIE+pcBCHY wrpkfeIhRkoNJSZR3WoFVpBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3ld3gHKCRanpqRVpmTnA QINJS3DwKInwvjgJlOYtLkjMLc5Mh0idYlSUEufdCNInAJLIKM2Da4MF9yVGWSlhXkagQ4R4C lKLcjNLUOVfMYpzMCoJ8xoCY0WIJzOvBG76K6DFTECLl7yzAFlckoiQkmpgVO9aYOuX7Rnucc o3ePuFJ+sntzdenOX64sKpqyr125/MfrrKt6P038c/iTVxz145SzQnzLb7388t7HFFIZF/wWW V1Tk35nqelkn8IV3EPHES/2EehsQLuRWHmWXc3v02qON8FLIrTTC/79mcVyb/Tqb8VVtYq5X7 h1Fi/dFZP1tr3spvbHxco8RSnJFoqMVcVJwIAOMUXzlpAgAA X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1497030105!97427735!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26615 invoked from network); 9 Jun 2017 17:41:45 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-27.messagelabs.com with SMTP; 9 Jun 2017 17:41:45 -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 4CC3415BF; Fri, 9 Jun 2017 10:41:45 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 045753F578; Fri, 9 Jun 2017 10:41:43 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Fri, 9 Jun 2017 18:41:12 +0100 Message-Id: <20170609174141.5068-6-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170609174141.5068-1-andre.przywara@arm.com> References: <20170609174141.5068-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Vijaya Kumar K , Vijay Kilari , Shanker Donthineni , Manish Jaggi Subject: [Xen-devel] [PATCH v11 05/34] ARM: vGIC: rework gic_remove_from_queues() 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 The function name gic_remove_from_queues() was a bit of a misnomer, since it just removes an IRQ from the pending queue, not both queues. Rename the function to make this more clear, also give it a pointer to a struct pending_irq directly and rely on the VGIC VCPU lock to be already taken, so this can be used in more places. Replace the list removal in gic_clear_pending_irqs() with a call to this function. Signed-off-by: Andre Przywara --- xen/arch/arm/gic.c | 12 ++++-------- xen/arch/arm/vgic.c | 5 ++++- xen/include/asm-arm/gic.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index da19130..6c0c9c3 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -400,15 +400,11 @@ static inline void gic_add_to_lr_pending(struct vcpu *v, struct pending_irq *n) list_add_tail(&n->lr_queue, &v->arch.vgic.lr_pending); } -void gic_remove_from_queues(struct vcpu *v, unsigned int virtual_irq) +void gic_remove_from_lr_pending(struct vcpu *v, struct pending_irq *p) { - struct pending_irq *p = irq_to_pending(v, virtual_irq); - unsigned long flags; + ASSERT(spin_is_locked(&v->arch.vgic.lock)); - spin_lock_irqsave(&v->arch.vgic.lock, flags); - if ( !list_empty(&p->lr_queue) ) - list_del_init(&p->lr_queue); - spin_unlock_irqrestore(&v->arch.vgic.lock, flags); + list_del_init(&p->lr_queue); } void gic_raise_inflight_irq(struct vcpu *v, unsigned int virtual_irq) @@ -609,7 +605,7 @@ void gic_clear_pending_irqs(struct vcpu *v) v->arch.lr_mask = 0; list_for_each_entry_safe ( p, t, &v->arch.vgic.lr_pending, lr_queue ) - list_del_init(&p->lr_queue); + gic_remove_from_lr_pending(v, p); } int gic_events_need_delivery(void) diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 18fe420..45926ab 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -307,9 +307,12 @@ void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n) while ( (i = find_next_bit(&mask, 32, i)) < 32 ) { irq = i + (32 * n); v_target = vgic_get_target_vcpu(v, irq); + spin_lock_irqsave(&v_target->arch.vgic.lock, flags); p = irq_to_pending(v_target, irq); clear_bit(GIC_IRQ_GUEST_ENABLED, &p->status); - gic_remove_from_queues(v_target, irq); + gic_remove_from_lr_pending(v_target, p); + spin_unlock_irqrestore(&v_target->arch.vgic.lock, flags); + if ( p->desc != NULL ) { spin_lock_irqsave(&p->desc->lock, flags); diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 836a103..3130634 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -243,7 +243,7 @@ extern void init_maintenance_interrupt(void); extern void gic_raise_guest_irq(struct vcpu *v, unsigned int irq, unsigned int priority); extern void gic_raise_inflight_irq(struct vcpu *v, unsigned int virtual_irq); -extern void gic_remove_from_queues(struct vcpu *v, unsigned int virtual_irq); +extern void gic_remove_from_lr_pending(struct vcpu *v, struct pending_irq *p); /* Accept an interrupt from the GIC and dispatch its handler */ extern void gic_interrupt(struct cpu_user_regs *regs, int is_fiq);