From patchwork Fri Jul 21 19:59:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9857603 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 B977E60393 for ; Fri, 21 Jul 2017 20:02:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB7A92863B for ; Fri, 21 Jul 2017 20:02:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A09922864F; Fri, 21 Jul 2017 20:02: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 3AC2A2863B for ; Fri, 21 Jul 2017 20:02: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 1dYe5l-00051o-Ed; Fri, 21 Jul 2017 20:00:05 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dYe5k-0004rH-Lr for xen-devel@lists.xenproject.org; Fri, 21 Jul 2017 20:00:04 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id C5/3F-03368-44D52795; Fri, 21 Jul 2017 20:00:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOLMWRWlGSWpSXmKPExsVysyfVTdc5tij S4OIWGYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPV3rfsBe8UKt5928HYwHheqouRk0NIYBOj xJHv7BD2ckaJ5T1lIDabgK7EjpuvmUFsEYFQiacLvoPZzAJKEvvPXmMEsYUFkiROLekEi7MIq Eq0nHsFZvMKWEu0X9rHBGJLCMhJNJy/DxbnFLCRWHH5CRvELmuJ5sVTWSYwci9gZFjFqFGcWl SWWqRrZKaXVJSZnlGSm5iZo2toYKaXm1pcnJiempOYVKyXnJ+7iRHoXQYg2MF4ZkHgIUZJDiY lUV5Nq6JIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8S6KBcoJFqempFWmZOcAwg0lLcPAoifCK xACleYsLEnOLM9MhUqcYjTk6Zvz8xsTxasL/b0xCLHn5ealS4rxNIJMEQEozSvPgBsHC/xKjr JQwLyPQaUI8BalFuZklqPKvGMU5GJWEefeATOHJzCuB2/cK6BQmoFMeuRWAnFKSiJCSamBc+S rwygkDPWXHSwVTBHnl/z1P/PrcwGzXkYCm3sYTUQ8i1OVeRPzO/2Fjob35uecx/58eXq3pFqW K4k+aeDoX2c9tjFFxja2Z7f/v4P8q3XkW+TpBz8493/AkWzlMqb/GeqX49hiLX/FpCXfDlh/e 8o2/6GvgBsPNFp+vPn7l8GGGqHDJXA4lluKMREMt5qLiRADjzFv2egIAAA== X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1500667202!51350354!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10369 invoked from network); 21 Jul 2017 20:00:03 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-21.messagelabs.com with SMTP; 21 Jul 2017 20:00:03 -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 994DE80D; Fri, 21 Jul 2017 13:00:02 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CE7D13F3E1; Fri, 21 Jul 2017 13:00:01 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Fri, 21 Jul 2017 20:59:51 +0100 Message-Id: <20170721200010.29010-4-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170721200010.29010-1-andre.przywara@arm.com> References: <20170721200010.29010-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [RFC PATCH v2 03/22] ARM: vGIC: move gic_raise_inflight_irq() into vgic_vcpu_inject_irq() 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 Currently there is a gic_raise_inflight_irq(), which serves the very special purpose of handling a newly injected interrupt while an older one is still handled. This has only one user, in vgic_vcpu_inject_irq(). Now with the introduction of the pending_irq lock this will later on result in a nasty deadlock, which can only be solved properly by actually embedding the function into the caller (and dropping the lock later in-between). This has the admittedly hideous consequence of needing to export gic_update_one_lr(), but this will go away in a later stage of a rework. In this respect this patch is more a temporary kludge. Signed-off-by: Andre Przywara --- xen/arch/arm/gic.c | 30 +----------------------------- xen/arch/arm/vgic.c | 11 ++++++++++- xen/include/asm-arm/gic.h | 2 +- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 2c99d71..5bd66a2 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -44,8 +44,6 @@ static DEFINE_PER_CPU(uint64_t, lr_mask); #undef GIC_DEBUG -static void gic_update_one_lr(struct vcpu *v, int i); - static const struct gic_hw_operations *gic_hw_ops; void register_gic_ops(const struct gic_hw_operations *ops) @@ -416,32 +414,6 @@ void gic_remove_irq_from_queues(struct vcpu *v, struct pending_irq *p) gic_remove_from_lr_pending(v, p); } -void gic_raise_inflight_irq(struct vcpu *v, unsigned int virtual_irq) -{ - struct pending_irq *n = irq_to_pending(v, virtual_irq); - - /* If an LPI has been removed meanwhile, there is nothing left to raise. */ - if ( unlikely(!n) ) - return; - - ASSERT(spin_is_locked(&v->arch.vgic.lock)); - - /* Don't try to update the LR if the interrupt is disabled */ - if ( !test_bit(GIC_IRQ_GUEST_ENABLED, &n->status) ) - return; - - if ( list_empty(&n->lr_queue) ) - { - if ( v == current ) - gic_update_one_lr(v, n->lr); - } -#ifdef GIC_DEBUG - else - gdprintk(XENLOG_DEBUG, "trying to inject irq=%u into d%dv%d, when it is still lr_pending\n", - virtual_irq, v->domain->domain_id, v->vcpu_id); -#endif -} - /* * Find an unused LR to insert an IRQ into, starting with the LR given * by @lr. If this new interrupt is a PRISTINE LPI, scan the other LRs to @@ -503,7 +475,7 @@ void gic_raise_guest_irq(struct vcpu *v, unsigned int virtual_irq, gic_add_to_lr_pending(v, p); } -static void gic_update_one_lr(struct vcpu *v, int i) +void gic_update_one_lr(struct vcpu *v, int i) { struct pending_irq *p; int irq; diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 38dacd3..7b122cd 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -536,7 +536,16 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int virq) if ( !list_empty(&n->inflight) ) { - gic_raise_inflight_irq(v, virq); + bool update = test_bit(GIC_IRQ_GUEST_ENABLED, &n->status) && + list_empty(&n->lr_queue) && (v == current); + + if ( update ) + gic_update_one_lr(v, n->lr); +#ifdef GIC_DEBUG + else + gdprintk(XENLOG_DEBUG, "trying to inject irq=%u into d%dv%d, when it is still lr_pending\n", + n->irq, v->domain->domain_id, v->vcpu_id); +#endif goto out; } diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 6203dc5..cf8b8fb 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -237,12 +237,12 @@ int gic_remove_irq_from_guest(struct domain *d, unsigned int virq, extern void gic_inject(void); extern void gic_clear_pending_irqs(struct vcpu *v); +extern void gic_update_one_lr(struct vcpu *v, int lr); extern int gic_events_need_delivery(void); 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_lr_pending(struct vcpu *v, struct pending_irq *p); extern void gic_remove_irq_from_queues(struct vcpu *v, struct pending_irq *p);