From patchwork Tue Apr 22 12:58:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 28783 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7E0A1203AC for ; Tue, 22 Apr 2014 13:04:35 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id pa12sf25994109veb.4 for ; Tue, 22 Apr 2014 06:04:35 -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=dbxdXoPk4eIed914dRIsUYRj9hnSWDbNF5LFwsWkTgU=; b=TlSwV5U5IogIwSQ8hzwngPnjRpyQXOSmnwN8U/AJnQ2knEl40++4B7E1wcc6zyUB5z Kwfg2qxIaE7T4Bua4Lg56qyLCmQ3Wn9wV/O9SvYDaX2sqrHf+Ubeh380gAffzV9whrpk LenmmucouvGuh0FHpgfnVOdKvWyzEx2b9Pm43Tdbkb0tnkG38EAFV5mcvl1xRdyrzKN7 xjAAs82NqL5Ih2sQOdvvQU+k+MWWA2cs04n5clC5Lr1P7MGe9RqC7S7HjXk2NoibMo+Y ig/X5mbbS5fiTjzHgTj5j9ETkErPPl86OySY1ZzShaldYDJIGly1v4t5JFpSCj5KV8OR UoQg== X-Gm-Message-State: ALoCoQlsbLL8LySOkKGxCxRrKOkvZ5v2WetlYIjEwggb3OYo51R4bUOxGe38PcJfggfD9FGgBMhr X-Received: by 10.236.137.50 with SMTP id x38mr21640320yhi.9.1398171875085; Tue, 22 Apr 2014 06:04:35 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.40 with SMTP id 37ls97838qgk.32.gmail; Tue, 22 Apr 2014 06:04:35 -0700 (PDT) X-Received: by 10.58.55.170 with SMTP id t10mr1452400vep.29.1398171874959; Tue, 22 Apr 2014 06:04:34 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id b5si6885568vej.29.2014.04.22.06.04.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Apr 2014 06:04:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 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.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so9701478veb.12 for ; Tue, 22 Apr 2014 06:04:34 -0700 (PDT) X-Received: by 10.220.237.146 with SMTP id ko18mr8489vcb.49.1398171874877; Tue, 22 Apr 2014 06:04:34 -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.221.72 with SMTP id ib8csp22884vcb; Tue, 22 Apr 2014 06:04:34 -0700 (PDT) X-Received: by 10.52.123.39 with SMTP id lx7mr30522595vdb.22.1398171874015; Tue, 22 Apr 2014 06:04:34 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id rw5si6881212vcb.145.2014.04.22.06.04.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 22 Apr 2014 06:04:34 -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 1WcaKX-0002Iq-Dy; Tue, 22 Apr 2014 13:01:45 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WcaHu-0001h0-QZ for xen-devel@lists.xenproject.org; Tue, 22 Apr 2014 12:59:44 +0000 Received: from [85.158.143.35:14955] by server-2.bemta-4.messagelabs.com id 3D/FE-06539-69766535; Tue, 22 Apr 2014 12:59:02 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-6.tower-21.messagelabs.com!1398171541!254147!1 X-Originating-IP: [74.125.83.46] 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 14197 invoked from network); 22 Apr 2014 12:59:01 -0000 Received: from mail-ee0-f46.google.com (HELO mail-ee0-f46.google.com) (74.125.83.46) by server-6.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 22 Apr 2014 12:59:01 -0000 Received: by mail-ee0-f46.google.com with SMTP id t10so4621419eei.33 for ; Tue, 22 Apr 2014 05:59:01 -0700 (PDT) X-Received: by 10.15.64.75 with SMTP id n51mr56228836eex.33.1398171541103; Tue, 22 Apr 2014 05:59:01 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id x45sm112862825eef.15.2014.04.22.05.58.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Apr 2014 05:59:00 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 22 Apr 2014 13:58:36 +0100 Message-Id: <1398171530-27391-5-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1398171530-27391-1-git-send-email-julien.grall@linaro.org> References: <1398171530-27391-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 v4 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.128.181 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 8168b7b..842231a 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -221,7 +221,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 */ @@ -231,7 +230,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]; @@ -250,6 +253,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 */ @@ -272,9 +276,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; @@ -779,7 +781,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; @@ -800,7 +801,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; }