From patchwork Thu Apr 3 20:41:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 27704 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1477820490 for ; Thu, 3 Apr 2014 20:44:08 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id d49sf2565668eek.7 for ; Thu, 03 Apr 2014 13:44: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=c/GnakUFAsOomUhw/Pg1z2sCY1mCW62YD7DISf3McXQ=; b=KLVohc6MXKmsp/Gg6pCRwXv3Imm2hBzJU2ML7rX9/YEu5PlgDwrk1eI/n00qFo8Kug JNf7Kq/ucn63oIpL6XETV/jjB4ZIK5RHG47xN/lvBJZzGjOpDnbx2Yq6lJJAoT9sfXbt Ih33oDyIs4ijRDHK2Wf/c4LYkN5pE9cV1Iz0YMu1L07Tc0yvp7gnUXIoasIvZs77bKv3 4HkcGzKCSsQBVy34MQizW9dbt98VdSRV5YG/JIUt5e1Uu0X8cbnjVXQX4eXKbRnXmNpH rds4GBH9PnElhfaftsJglGAsM9uFpJJdl3Wxkj3u7pak6MyUS9gcVr/DVmBwDfDXnRfm T9qA== X-Gm-Message-State: ALoCoQkmq3wk8En676cuGkMFdDapBUpLNZWRnVBI23AvgUpQ9ZZbLCsvw757DbmK1ZMjlcdG+PKh X-Received: by 10.112.135.8 with SMTP id po8mr2561991lbb.12.1396557847979; Thu, 03 Apr 2014 13:44:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.66 with SMTP id e60ls692236qge.51.gmail; Thu, 03 Apr 2014 13:44:07 -0700 (PDT) X-Received: by 10.52.104.7 with SMTP id ga7mr7886494vdb.29.1396557847859; Thu, 03 Apr 2014 13:44:07 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id i7si398374vei.193.2014.04.03.13.44.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Apr 2014 13:44:07 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.175 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.175; Received: by mail-vc0-f175.google.com with SMTP id lh14so2422020vcb.20 for ; Thu, 03 Apr 2014 13:44:07 -0700 (PDT) X-Received: by 10.58.90.99 with SMTP id bv3mr1380166veb.34.1396557847777; Thu, 03 Apr 2014 13:44:07 -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 v8csp59794vcv; Thu, 3 Apr 2014 13:44:06 -0700 (PDT) X-Received: by 10.140.97.137 with SMTP id m9mr4370313qge.95.1396557840939; Thu, 03 Apr 2014 13:44:00 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id b6si2577978qae.145.2014.04.03.13.44.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 03 Apr 2014 13:44:00 -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 1WVoT2-0008C4-7v; Thu, 03 Apr 2014 20:42:32 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WVoT0-0008BD-9o for xen-devel@lists.xenproject.org; Thu, 03 Apr 2014 20:42:30 +0000 Received: from [85.158.137.68:15508] by server-11.bemta-3.messagelabs.com id A0/F0-19438-5B7CD335; Thu, 03 Apr 2014 20:42:29 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-12.tower-31.messagelabs.com!1396557748!3402537!1 X-Originating-IP: [209.85.212.182] 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 10627 invoked from network); 3 Apr 2014 20:42:28 -0000 Received: from mail-wi0-f182.google.com (HELO mail-wi0-f182.google.com) (209.85.212.182) by server-12.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 3 Apr 2014 20:42:28 -0000 Received: by mail-wi0-f182.google.com with SMTP id d1so93975wiv.15 for ; Thu, 03 Apr 2014 13:42:28 -0700 (PDT) X-Received: by 10.180.102.97 with SMTP id fn1mr14462743wib.15.1396557748116; Thu, 03 Apr 2014 13:42:28 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id t50sm14510572eev.28.2014.04.03.13.42.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Apr 2014 13:42:27 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 3 Apr 2014 21:41:55 +0100 Message-Id: <1396557727-19102-5-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1396557727-19102-1-git-send-email-julien.grall@linaro.org> References: <1396557727-19102-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 v2 04/16] 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.175 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 0095b97..9bf7e1e 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; }