From patchwork Tue Apr 8 14:43:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 27986 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A5E2D2066E for ; Tue, 8 Apr 2014 14:45:50 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id md12sf3218545pbc.0 for ; Tue, 08 Apr 2014 07:45:49 -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=Fv74mils30Hmc/0g8oBInMahVswemmmVRbz8tf1uy4Y=; b=M89KD0XVMUyau49IIMWp9h8MLvyx55alj6tV2+mNr1U518WAtSbKEk1KM3rGx3xWzh lax5u75cylDr3Tc5aZiDcM2L+TYiCNs/HdpajSdMWJcdaeZrM4ksnoQgT6sA1WyQzAO/ oprkCsVJEENgU1ap8g+HRRgZelk19jgLfpEIf4iZyL8jHYaiOdbIw8IrF26qkmJBHr1/ PXuCjbvqfVtKjljoTVNbziEB0L/Mx2P0H7DnLvi/VWuw1RnnaO/GYoqTVfURrjK8jmVW dz75WK6h1Ro0lY7T1Ijw2oTjLvOEpU0s0IR2qzB0ac6o14V0byMBlfCOIC4B/diwa033 WrRA== X-Gm-Message-State: ALoCoQn2teOW2J8nqwK/XiOkK6Lshq7fXGYEX0mUs6/W8/gG8IqCQwWBAqd5kIClsdE2ejTj3XTo X-Received: by 10.68.197.73 with SMTP id is9mr2026304pbc.0.1396968349927; Tue, 08 Apr 2014 07:45:49 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.40 with SMTP id 37ls226065qgk.32.gmail; Tue, 08 Apr 2014 07:45:49 -0700 (PDT) X-Received: by 10.52.104.7 with SMTP id ga7mr1618588vdb.29.1396968349699; Tue, 08 Apr 2014 07:45:49 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id j5si426974veb.183.2014.04.08.07.45.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Apr 2014 07:45:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id lg15so837850vcb.2 for ; Tue, 08 Apr 2014 07:45:49 -0700 (PDT) X-Received: by 10.52.6.162 with SMTP id c2mr3011779vda.6.1396968349614; Tue, 08 Apr 2014 07:45:49 -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 v8csp251647vcv; Tue, 8 Apr 2014 07:45:49 -0700 (PDT) X-Received: by 10.221.22.71 with SMTP id qv7mr158049vcb.34.1396968348953; Tue, 08 Apr 2014 07:45:48 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id i3si426117vca.185.2014.04.08.07.45.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 08 Apr 2014 07:45:48 -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 1WXXG8-00009z-Lk; Tue, 08 Apr 2014 14:44:20 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WXXG7-00009L-7d for xen-devel@lists.xenproject.org; Tue, 08 Apr 2014 14:44:19 +0000 Received: from [193.109.254.147:42141] by server-1.bemta-14.messagelabs.com id A3/D1-00839-24B04435; Tue, 08 Apr 2014 14:44:18 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-15.tower-27.messagelabs.com!1396968257!7005246!1 X-Originating-IP: [74.125.83.50] 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 30244 invoked from network); 8 Apr 2014 14:44:17 -0000 Received: from mail-ee0-f50.google.com (HELO mail-ee0-f50.google.com) (74.125.83.50) by server-15.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 8 Apr 2014 14:44:17 -0000 Received: by mail-ee0-f50.google.com with SMTP id c13so767923eek.23 for ; Tue, 08 Apr 2014 07:44:17 -0700 (PDT) X-Received: by 10.14.213.6 with SMTP id z6mr1213610eeo.98.1396968257248; Tue, 08 Apr 2014 07:44:17 -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.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Apr 2014 07:44:16 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 8 Apr 2014 15:43:53 +0100 Message-Id: <1396968247-8768-5-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 04/18] xen/arm: IRQ: move gic {, un}lock in gic_set_irq_properties 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.220.171 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_set_irq_properties is only called in two places: - gic_route_irq: the gic.lock is only taken for the call to the former function. - gic_route_irq_to_guest: the gic.lock is taken for the duration of the function. But the lock is only useful when gic_set_irq_properties. So we can safely move the lock in gic_set_irq_properties and restrict the critical section for the gic.lock in gic_route_irq_to_guest. Signed-off-by: Julien Grall Acked-by: Ian Campbell --- Changes in v2: - Remove useless comment about gic.lock --- xen/arch/arm/gic.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index a0bbde5..bc928ec 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -225,7 +225,6 @@ static hw_irq_controller gic_guest_irq_type = { }; /* - * - needs to be called with gic.lock held * - needs to be called with a valid cpu_mask, ie each cpu in the mask has * already called gic_cpu_init */ @@ -235,7 +234,11 @@ static void gic_set_irq_properties(unsigned int irq, bool_t level, { volatile unsigned char *bytereg; uint32_t cfg, edgebit; - unsigned int mask = gic_cpu_mask(cpu_mask); + unsigned int mask; + + spin_lock(&gic.lock); + + mask = gic_cpu_mask(cpu_mask); /* Set edge / level */ cfg = GICD[GICD_ICFGR + irq / 16]; @@ -254,6 +257,7 @@ static void gic_set_irq_properties(unsigned int irq, bool_t level, bytereg = (unsigned char *) (GICD + GICD_IPRIORITYR); bytereg[irq] = priority; + spin_unlock(&gic.lock); } /* Program the GIC to route an interrupt */ @@ -276,9 +280,7 @@ static int gic_route_irq(unsigned int irq, bool_t level, desc->handler = &gic_host_irq_type; - spin_lock(&gic.lock); gic_set_irq_properties(irq, level, cpu_mask, priority); - spin_unlock(&gic.lock); spin_unlock_irqrestore(&desc->lock, flags); return 0; @@ -892,7 +894,6 @@ int gic_route_irq_to_guest(struct domain *d, const struct dt_irq *irq, action->free_on_release = 1; spin_lock_irqsave(&desc->lock, flags); - spin_lock(&gic.lock); desc->handler = &gic_guest_irq_type; desc->status |= IRQ_GUEST; @@ -913,7 +914,6 @@ int gic_route_irq_to_guest(struct domain *d, const struct dt_irq *irq, p->desc = desc; out: - spin_unlock(&gic.lock); spin_unlock_irqrestore(&desc->lock, flags); return retval; }