From patchwork Tue Apr 8 14:43:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 28000 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8A3692066E for ; Tue, 8 Apr 2014 14:46:27 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id w8sf2752805qac.0 for ; Tue, 08 Apr 2014 07:46:27 -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=hkFEfR2bFE3sooUsv6eCyttQUuwHjllY3uKtPAWCXy0=; b=CprXduaBLelES4jbXFVgRVL6/1wcbaM3Q0O3yVpDMbuW+EmIVzUYk9cAsGr6/inwRI +TYe7t1MiHBPfZEqFuq8U9Tjt631elHDz3ttDaqdiIdPNzKhxKW4YSNR41uQqSleO0mg aZVPBN79IxHf9jsH6FvuuYtXjkd62Q4qzjCX7nwy8sT+LWJ/tPEg7SqKll43vCnUVsf4 Y3uthG6a6f/QDOHxbjd/0qj4WcLx3uBPQcXnV48qAuLMuzYnYQjVvnpqVYxlRqYjNGVo 7w6csu3nr4UnSh9PBU9sWTVlDa0lxWJx/lnHxpWIIXO/LIyehpRadQnfWOgvdjUd9SbT wpFQ== X-Gm-Message-State: ALoCoQl/KtiHMXMUFpLzVNRYKGAXOLoTxZiq0LtEvNx2F3iOLRe1+HnYR65s0hCjlSjy7XCVcU7B X-Received: by 10.224.22.71 with SMTP id m7mr1976489qab.8.1396968387340; Tue, 08 Apr 2014 07:46:27 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.104.163 with SMTP id a32ls227670qgf.73.gmail; Tue, 08 Apr 2014 07:46:27 -0700 (PDT) X-Received: by 10.220.103.141 with SMTP id k13mr1371179vco.25.1396968387160; Tue, 08 Apr 2014 07:46:27 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id o2si439395vew.7.2014.04.08.07.46.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Apr 2014 07:46:27 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jw12so839523veb.37 for ; Tue, 08 Apr 2014 07:46:27 -0700 (PDT) X-Received: by 10.221.4.66 with SMTP id ob2mr661121vcb.28.1396968387087; Tue, 08 Apr 2014 07:46:27 -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.220.12.8 with SMTP id v8csp251705vcv; Tue, 8 Apr 2014 07:46:26 -0700 (PDT) X-Received: by 10.58.202.133 with SMTP id ki5mr3440675vec.19.1396968386540; Tue, 08 Apr 2014 07:46:26 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id u5si433124vdo.76.2014.04.08.07.46.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 08 Apr 2014 07:46:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) 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 1WXXGC-0000C6-56; Tue, 08 Apr 2014 14:44:24 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WXXG9-0000AV-M4 for xen-devel@lists.xenproject.org; Tue, 08 Apr 2014 14:44:21 +0000 Received: from [193.109.254.147:60543] by server-13.bemta-14.messagelabs.com id 2F/2B-23211-54B04435; Tue, 08 Apr 2014 14:44:21 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1396968259!7024960!1 X-Originating-IP: [74.125.83.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19264 invoked from network); 8 Apr 2014 14:44:20 -0000 Received: from mail-ee0-f44.google.com (HELO mail-ee0-f44.google.com) (74.125.83.44) by server-9.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 8 Apr 2014 14:44:20 -0000 Received: by mail-ee0-f44.google.com with SMTP id e49so771196eek.17 for ; Tue, 08 Apr 2014 07:44:19 -0700 (PDT) X-Received: by 10.14.215.9 with SMTP id d9mr3429506eep.64.1396968259746; Tue, 08 Apr 2014 07:44:19 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id m42sm5031709eex.21.2014.04.08.07.44.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Apr 2014 07:44:19 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 8 Apr 2014 15:43:56 +0100 Message-Id: <1396968247-8768-8-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1396968247-8768-1-git-send-email-julien.grall@linaro.org> References: <1396968247-8768-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] [PATCH v3 07/18] xen/arm: IRQ: Rework gic_route_irq_to_guest function 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=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: The function gic_route_irq_to_guest contains code which is not related to the GIC. Split the function in 2 parts: - route_dt_irq_to_guest: setup the desc - gic_route_irq_to_guest: setup correctly the GIC and the desc handler Signed-off-by: Julien Grall Acked-by: Ian Campbell --- Changes in v3: - Patch added (split from "Move IRQ management from gic.c to irq.c") --- xen/arch/arm/domain_build.c | 2 +- xen/arch/arm/gic.c | 43 ++++++++++++++++++++++------------ xen/arch/arm/platforms/xgene-storm.c | 2 +- xen/include/asm-arm/gic.h | 3 --- xen/include/asm-arm/irq.h | 3 +++ 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 2035390..e7b1674 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -719,7 +719,7 @@ static int map_device(struct domain *d, const struct dt_device_node *dev) DPRINT("irq %u = %u type = 0x%x\n", i, irq.irq, irq.type); /* Don't check return because the IRQ can be use by multiple device */ - gic_route_irq_to_guest(d, &irq, dt_node_name(dev)); + route_dt_irq_to_guest(d, &irq, dt_node_name(dev)); } /* Map the address ranges */ diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index d5122fc..d30b979 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -286,6 +286,27 @@ static int gic_route_irq(unsigned int irq, bool_t level, return 0; } +/* Program the GIC to route an interrupt to a guest + * - desc.lock must be held + */ +static void gic_route_irq_to_guest(struct domain *d, struct irq_desc *desc, + bool_t level, const cpumask_t *cpu_mask, + unsigned int priority) +{ + struct pending_irq *p; + ASSERT(spin_is_locked(&desc->lock)); + + desc->handler = &gic_guest_irq_type; + desc->status |= IRQ_GUEST; + + gic_set_irq_properties(desc->irq, level, cpumask_of(smp_processor_id()), + GIC_PRI_IRQ); + + /* TODO: do not assume delivery to vcpu0 */ + p = irq_to_pending(d->vcpu[0], desc->irq); + p->desc = desc; +} + /* Program the GIC to route an interrupt with a dt_irq */ void gic_route_dt_irq(const struct dt_irq *irq, const cpumask_t *cpu_mask, unsigned int priority) @@ -874,15 +895,14 @@ void gic_inject(void) GICH[GICH_HCR] &= ~GICH_HCR_UIE; } -int gic_route_irq_to_guest(struct domain *d, const struct dt_irq *irq, - const char * devname) +int route_dt_irq_to_guest(struct domain *d, const struct dt_irq *irq, + const char * devname) { struct irqaction *action; struct irq_desc *desc = irq_to_desc(irq->irq); unsigned long flags; int retval; bool_t level; - struct pending_irq *p; action = xmalloc(struct irqaction); if (!action) @@ -894,23 +914,16 @@ int gic_route_irq_to_guest(struct domain *d, const struct dt_irq *irq, spin_lock_irqsave(&desc->lock, flags); - desc->handler = &gic_guest_irq_type; - desc->status |= IRQ_GUEST; - - level = dt_irq_is_level_triggered(irq); - - gic_set_irq_properties(irq->irq, level, cpumask_of(smp_processor_id()), - GIC_PRI_IRQ); - retval = __setup_irq(desc, action); - if (retval) { + if ( retval ) + { xfree(action); goto out; } - /* TODO: do not assume delivery to vcpu0 */ - p = irq_to_pending(d->vcpu[0], irq->irq); - p->desc = desc; + level = dt_irq_is_level_triggered(irq); + gic_route_irq_to_guest(d, desc, level, cpumask_of(smp_processor_id()), + GIC_PRI_IRQ); out: spin_unlock_irqrestore(&desc->lock, flags); diff --git a/xen/arch/arm/platforms/xgene-storm.c b/xen/arch/arm/platforms/xgene-storm.c index af3b71c..70aab73 100644 --- a/xen/arch/arm/platforms/xgene-storm.c +++ b/xen/arch/arm/platforms/xgene-storm.c @@ -66,7 +66,7 @@ static int map_one_spi(struct domain *d, const char *what, printk("Additional IRQ %u (%s)\n", irq.irq, what); - ret = gic_route_irq_to_guest(d, &irq, what); + ret = route_dt_irq_to_guest(d, &irq, what); if ( ret ) printk("Failed to route %s to dom%d\n", what, d->domain_id); diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 5d8f7f1..1b94fd7 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -184,9 +184,6 @@ extern void __cpuinit init_maintenance_interrupt(void); extern void gic_raise_guest_irq(struct vcpu *v, unsigned int irq, unsigned int priority); extern void gic_remove_from_queues(struct vcpu *v, unsigned int virtual_irq); -extern int gic_route_irq_to_guest(struct domain *d, - const struct dt_irq *irq, - const char * devname); /* Accept an interrupt from the GIC and dispatch its handler */ extern void gic_interrupt(struct cpu_user_regs *regs, int is_fiq); diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h index 9380987..b52c26f 100644 --- a/xen/include/asm-arm/irq.h +++ b/xen/include/asm-arm/irq.h @@ -44,6 +44,9 @@ int request_dt_irq(const struct dt_irq *irq, const char *devname, void *dev_id); int setup_dt_irq(const struct dt_irq *irq, struct irqaction *new); +int route_dt_irq_to_guest(struct domain *d, const struct dt_irq *irq, + const char *devname); + #endif /* _ASM_HW_IRQ_H */ /* * Local variables: