From patchwork Mon Jun 16 16:17:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 31986 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D2A532107C for ; Mon, 16 Jun 2014 16:20:08 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id n16sf33585233oag.10 for ; Mon, 16 Jun 2014 09:20:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=76yHcOuqfbpqQVU1l7Utjz1M9GcKXILXK9QpO8uz7G8=; b=Q9UNMahlusheRNYV2t80zCe9XPOmvjTzwuluXeqw5d6jjFUa6m/4UH37S3LprdjTmz XIDRvhOvtwR62Oeq/8plw9wafyGx//vsrwfM2tin6iWDhNWjTr4FwRRrk2TSof65eMgI z4Qbh3zkKP8KVlqngp2whjV8mOpOYr/pKlG61QInFY8HlBLaH7xPMFhpe47UKPCZNcZb IXAashfN+Y8K2XpNF6KXMoaJ3O6GgwBIsuTlnpycqTCz+MLX5CNlh8iOuP9F8AwHLB6A P+7+jh/vFMc6ef0f6wYPyK8quf4HTXDLp+nFd0GoyDpBYjOVA2JmodlyzZAKD1RSeLM2 WUBQ== X-Gm-Message-State: ALoCoQnVmnZmwLokcttV1JOytpswDEYZoos1LwRCufY6smwjjO4qS+EsMnbvS2HS49uwpSeBfpxu X-Received: by 10.182.34.200 with SMTP id b8mr1031345obj.48.1402935608523; Mon, 16 Jun 2014 09:20:08 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.44.36 with SMTP id f33ls4376093qga.19.gmail; Mon, 16 Jun 2014 09:20:08 -0700 (PDT) X-Received: by 10.52.136.98 with SMTP id pz2mr737513vdb.70.1402935608443; Mon, 16 Jun 2014 09:20:08 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id is9si4277835vdb.47.2014.06.16.09.20.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Jun 2014 09:20:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id lf12so5231675vcb.32 for ; Mon, 16 Jun 2014 09:20:08 -0700 (PDT) X-Received: by 10.58.195.234 with SMTP id ih10mr1672000vec.41.1402935608341; Mon, 16 Jun 2014 09:20:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp146179vcb; Mon, 16 Jun 2014 09:20:07 -0700 (PDT) X-Received: by 10.140.19.21 with SMTP id 21mr26718493qgg.76.1402935606604; Mon, 16 Jun 2014 09:20:06 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id s11si3904481qac.20.2014.06.16.09.20.06 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 16 Jun 2014 09:20:06 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WwZc0-0006ie-63; Mon, 16 Jun 2014 16:18:24 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WwZbz-0006i5-9c for xen-devel@lists.xenproject.org; Mon, 16 Jun 2014 16:18:23 +0000 Received: from [85.158.137.68:34413] by server-14.bemta-3.messagelabs.com id AF/9E-30903-EC81F935; Mon, 16 Jun 2014 16:18:22 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-7.tower-31.messagelabs.com!1402935501!10394483!1 X-Originating-IP: [209.85.212.169] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14391 invoked from network); 16 Jun 2014 16:18:21 -0000 Received: from mail-wi0-f169.google.com (HELO mail-wi0-f169.google.com) (209.85.212.169) by server-7.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 16 Jun 2014 16:18:21 -0000 Received: by mail-wi0-f169.google.com with SMTP id hi2so5544564wib.2 for ; Mon, 16 Jun 2014 09:18:21 -0700 (PDT) X-Received: by 10.180.207.9 with SMTP id ls9mr28743316wic.32.1402935501535; Mon, 16 Jun 2014 09:18:21 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id l45sm34836161eep.25.2014.06.16.09.18.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jun 2014 09:18:20 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 16 Jun 2014 17:17:52 +0100 Message-Id: <1402935486-29136-6-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1402935486-29136-1-git-send-email-julien.grall@linaro.org> References: <1402935486-29136-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [RFC 05/19] xen/arm: Release IRQ routed to a domain when it's destroying X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Xen has to release IRQ routed to a domain in order to reuse later. Currently only SPIs can be routed to the guest so we only need to browse SPIs for a specific domain. Futhermore, a guest can crash and let the IRQ in an incorrect state (i.e has not being EOIed). Add a function to reset a given IRQ to allow Xen route again the IRQ in the future. Also, reset the desc->handler to no_irq_type. This will let you know if we did something wrong with the IRQ management. Signed-off-by: Julien Grall --- xen/arch/arm/gic.c | 12 ++++++++++++ xen/arch/arm/irq.c | 8 ++++++++ xen/arch/arm/vgic.c | 10 ++++++++++ xen/include/asm-arm/gic.h | 3 +++ 4 files changed, 33 insertions(+) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 11e53af..42fc3bc 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -928,6 +928,18 @@ int gicv_setup(struct domain *d) } +/* The guest may not have EOIed the IRQ. + * Be sure to reset correctly the IRQ. + */ +void gic_reset_guest_irq(struct irq_desc *desc) +{ + ASSERT(spin_is_locked(&desc->lock)); + ASSERT(desc->status & IRQ_GUEST); + + if ( desc->status & IRQ_INPROGRESS ) + GICC[GICC_DIR] = desc->irq; +} + static void maintenance_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs) { /* diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 4e51fee..e44a90f 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -274,7 +274,15 @@ void release_irq(unsigned int irq, const void *dev_id) if ( !desc->action ) { desc->handler->shutdown(desc); + + if ( desc->status & IRQ_GUEST ) + { + gic_reset_guest_irq(desc); + desc->status &= ~IRQ_INPROGRESS; + } + desc->status &= ~IRQ_GUEST; + desc->handler = &no_irq_type; } spin_unlock_irqrestore(&desc->lock,flags); diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index cb8df3a..e451324 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -112,6 +112,16 @@ int domain_vgic_init(struct domain *d) void domain_vgic_free(struct domain *d) { + int i; + + for ( i = NR_LOCAL_IRQS; i < d->arch.vgic.nr_lines; i++ ) + { + struct irq_desc *desc = d->arch.vgic.pending_irqs[i].desc; + + if ( desc ) + release_irq(desc->irq, d); + } + xfree(d->arch.vgic.shared_irqs); xfree(d->arch.vgic.pending_irqs); } diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 6e7375c..841d845 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -228,6 +228,9 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize, unsigned int *out_hwirq, unsigned int *out_type); void gic_clear_lrs(struct vcpu *v); +/* Reset an IRQ passthrough to a guest */ +void gic_reset_guest_irq(struct irq_desc *desc); + #endif /* __ASSEMBLY__ */ #endif