From patchwork Tue Jun 9 16:23:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 49665 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E044421419 for ; Tue, 9 Jun 2015 16:25:10 +0000 (UTC) Received: by wizw5 with SMTP id w5sf5875332wiz.2 for ; Tue, 09 Jun 2015 09:25:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=U3qSNV77G0MobATheP6vyL1iIlKkhP93B7HSS1dFSCI=; b=F9P6gYtVtnXqj6FHb+Y4R1vJKhUIGShqpI0ah2BOi9GEvw/+qH3YDgayzfCjmgLkFb xR8f/HKYfuAKYInTN6Q2uQNA69DTXWgXckYIgpQZERkXbmrcTvQgryauAPZDUK3j+rxm o8XFvzLHuyRvkQjd0dtwr/dYaVA/NhqQ9PZDDDz8XJ4+7KcCo+hAehltNtCstl6zIzUJ m0qS4/be9KOpIO8DeN5zDTGeD/5mOASWqd/fFhgkefDpHVxdWUt1ZgIWQUfVhaGmzrky 10UCRYgMDNHnXZ4+E4lAuKUE5a31foS+2Ufcct7AuOMpJfmhosbP55plvwLUxl/eyjAq TKhg== X-Gm-Message-State: ALoCoQl9d+n4Q2jQlh8BgUPgTdu3RfwQBu4hDVZwICWPRj6O5QrSu9k4RQdAaaNYoURf3uA4EqlT X-Received: by 10.194.179.42 with SMTP id dd10mr22500782wjc.7.1433867110170; Tue, 09 Jun 2015 09:25:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.74 with SMTP id k10ls99660laf.30.gmail; Tue, 09 Jun 2015 09:25:10 -0700 (PDT) X-Received: by 10.112.97.194 with SMTP id ec2mr23346536lbb.88.1433867109995; Tue, 09 Jun 2015 09:25:09 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id dx9si6128891lac.160.2015.06.09.09.25.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jun 2015 09:25:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbcmx3 with SMTP id mx3so14094432lbc.1 for ; Tue, 09 Jun 2015 09:25:09 -0700 (PDT) X-Received: by 10.152.27.1 with SMTP id p1mr22953664lag.112.1433867109848; Tue, 09 Jun 2015 09:25:09 -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.112.108.230 with SMTP id hn6csp2724171lbb; Tue, 9 Jun 2015 09:25:08 -0700 (PDT) X-Received: by 10.70.118.5 with SMTP id ki5mr40757710pdb.6.1433867107879; Tue, 09 Jun 2015 09:25:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix6si9586379pac.46.2015.06.09.09.25.07; Tue, 09 Jun 2015 09:25:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753933AbbFIQZD (ORCPT + 5 others); Tue, 9 Jun 2015 12:25:03 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:36039 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932843AbbFIQYC (ORCPT ); Tue, 9 Jun 2015 12:24:02 -0400 Received: by pdjm12 with SMTP id m12so18440769pdj.3 for ; Tue, 09 Jun 2015 09:24:00 -0700 (PDT) X-Received: by 10.70.42.67 with SMTP id m3mr40258348pdl.88.1433867040233; Tue, 09 Jun 2015 09:24:00 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by mx.google.com with ESMTPSA id fs16sm6095565pdb.12.2015.06.09.09.23.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jun 2015 09:23:59 -0700 (PDT) From: Lina Iyer To: ohad@wizery.com Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Lina Iyer , Jeffrey Hugo , Bjorn Andersson , Andy Gross Subject: [PATCH RFC v2 2/2] hwspinlock: qcom: Lock #7 is special lock, uses dynamic proc_id Date: Tue, 9 Jun 2015 10:23:40 -0600 Message-Id: <1433867020-7746-3-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433867020-7746-1-git-send-email-lina.iyer@linaro.org> References: <1433867020-7746-1-git-send-email-lina.iyer@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lina.iyer@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.217.176 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-Post: , List-Help: , List-Archive: List-Unsubscribe: , Hwspinlocks are widely used between processors in an SoC, and also between elevation levels within in the same processor. QCOM SoC's use hwspinlock to serialize entry into a low power mode when the context switches from Linux to secure monitor. Lock #7 has been assigned for this purpose. In order to differentiate between one cpu core holding a lock while another cpu is contending for the same lock, the proc id written into the lock is (128 + cpu id). This makes it unique value among the cpu cores and therefore when a core locks the hwspinlock, other cores would wait for the lock to be released since they would have a different proc id. This value is specific for the lock #7 only. Declare lock #7 as raw capable, so the hwspinlock framework would not enfore acquiring a s/w spinlock before acquiring the hwspinlock. Cc: Jeffrey Hugo Cc: Bjorn Andersson Cc: Andy Gross Signed-off-by: Lina Iyer --- drivers/hwspinlock/qcom_hwspinlock.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c index 93b62e0..59278b0 100644 --- a/drivers/hwspinlock/qcom_hwspinlock.c +++ b/drivers/hwspinlock/qcom_hwspinlock.c @@ -25,16 +25,26 @@ #include "hwspinlock_internal.h" -#define QCOM_MUTEX_APPS_PROC_ID 1 -#define QCOM_MUTEX_NUM_LOCKS 32 +#define QCOM_MUTEX_APPS_PROC_ID 1 +#define QCOM_MUTEX_CPUIDLE_OFFSET 128 +#define QCOM_CPUIDLE_LOCK 7 +#define QCOM_MUTEX_NUM_LOCKS 32 + +static inline u32 __qcom_get_proc_id(struct hwspinlock *lock) +{ + return hwspin_lock_get_id(lock) == QCOM_CPUIDLE_LOCK ? + (QCOM_MUTEX_CPUIDLE_OFFSET + smp_processor_id()) : + QCOM_MUTEX_APPS_PROC_ID; +} static int qcom_hwspinlock_trylock(struct hwspinlock *lock) { struct regmap_field *field = lock->priv; u32 lock_owner; int ret; + u32 proc_id = __qcom_get_proc_id(lock); - ret = regmap_field_write(field, QCOM_MUTEX_APPS_PROC_ID); + ret = regmap_field_write(field, proc_id); if (ret) return ret; @@ -42,7 +52,7 @@ static int qcom_hwspinlock_trylock(struct hwspinlock *lock) if (ret) return ret; - return lock_owner == QCOM_MUTEX_APPS_PROC_ID; + return lock_owner == proc_id; } static void qcom_hwspinlock_unlock(struct hwspinlock *lock) @@ -57,7 +67,7 @@ static void qcom_hwspinlock_unlock(struct hwspinlock *lock) return; } - if (lock_owner != QCOM_MUTEX_APPS_PROC_ID) { + if (lock_owner != __qcom_get_proc_id(lock)) { pr_err("%s: spinlock not owned by us (actual owner is %d)\n", __func__, lock_owner); } @@ -129,6 +139,8 @@ static int qcom_hwspinlock_probe(struct platform_device *pdev) regmap, field); } + bank->lock[QCOM_CPUIDLE_LOCK].hwcaps = HWL_CAP_ALLOW_RAW; + pm_runtime_enable(&pdev->dev); ret = hwspin_lock_register(bank, &pdev->dev, &qcom_hwspinlock_ops,