From patchwork Fri May 1 17:06:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 47894 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0946F20553 for ; Fri, 1 May 2015 17:07:13 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf27648402lbc.1 for ; Fri, 01 May 2015 10:07:11 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=tfV/CDdODfCvTQoDMcfu12NAUmNMQ3cAq18czePYSq8=; b=RSTA/oSe/CkQ/b7Tz/u4cZCp/p3CCxYZes7inW7bkGnhrVKOI89CLihj06TtzOEpwG fZS9vQvclFQzuD1yv47ncXIPjzBBgIL4/xIOgb/h5ttlD7WzFk9hY454eaE3UbpM8wzM jwgP9lEA4cPRlZ0ZtJv4d5RxP+2D6/VZLrQWpYYLrhbh/OGiu5ItzBQg+dZ+V9v/B7NJ aAeorUWIVPbOvRoj/FNHJ/93P1eGS5gScb7A+aj1kMJZhu/4qURRHf8bLDLOIobXs1q8 dJWNDVNsjWY0pXrN7Rjd+a/1kVj2da/WflDMYAEZQddv6uPi9qC96mhisgV/mTOlkuoW ErPA== X-Gm-Message-State: ALoCoQnUA3tSwV3AFzMtwXuiFO0rCDy21FN4cpbtBEeNK1ZG4t/1tn2pkSEWqz7xMekHwmCdNS5V X-Received: by 10.152.203.233 with SMTP id kt9mr8959486lac.7.1430500031861; Fri, 01 May 2015 10:07:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.116.38 with SMTP id jt6ls587978lab.101.gmail; Fri, 01 May 2015 10:07:11 -0700 (PDT) X-Received: by 10.152.243.9 with SMTP id wu9mr8789924lac.63.1430500031681; Fri, 01 May 2015 10:07:11 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id pk3si4334831lbb.75.2015.05.01.10.07.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 May 2015 10:07:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by labbd9 with SMTP id bd9so67844459lab.2 for ; Fri, 01 May 2015 10:07:11 -0700 (PDT) X-Received: by 10.152.87.204 with SMTP id ba12mr9121708lab.35.1430500031542; Fri, 01 May 2015 10:07:11 -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.67.65 with SMTP id l1csp395182lbt; Fri, 1 May 2015 10:07:10 -0700 (PDT) X-Received: by 10.68.115.42 with SMTP id jl10mr19683905pbb.39.1430500029547; Fri, 01 May 2015 10:07:09 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j2si8713713pdn.104.2015.05.01.10.07.08; Fri, 01 May 2015 10:07:09 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752117AbbEARHE (ORCPT + 28 others); Fri, 1 May 2015 13:07:04 -0400 Received: from mail-ig0-f182.google.com ([209.85.213.182]:33644 "EHLO mail-ig0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751933AbbEARG7 (ORCPT ); Fri, 1 May 2015 13:06:59 -0400 Received: by igbpi8 with SMTP id pi8so31171535igb.0 for ; Fri, 01 May 2015 10:06:59 -0700 (PDT) X-Received: by 10.50.66.230 with SMTP id i6mr11740244igt.22.1430500019295; Fri, 01 May 2015 10:06:59 -0700 (PDT) Received: from localhost.localdomain (c-24-8-37-141.hsd1.co.comcast.net. [24.8.37.141]) by mx.google.com with ESMTPSA id t41sm3869172ioe.5.2015.05.01.10.06.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 May 2015 10:06:58 -0700 (PDT) From: Lina Iyer To: ohad@wizery.com, s-anna@ti.com, Bjorn.Andersson@sonymobile.com, agross@codeaurora.org Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, galak@codeaurora.org, jhugo@codeaurora.org, Lina Iyer , Bjorn Andersson Subject: [PATCH] hwspinlock: qcom: Lock #7 is special lock, uses dynamic proc_id Date: Fri, 1 May 2015 11:06:32 -0600 Message-Id: <1430499992-47944-1-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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.215.43 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. Cc: Jeffrey Hugo Cc: Bjorn Andersson Cc: Andy Gross Signed-off-by: Lina Iyer --- drivers/hwspinlock/qcom_hwspinlock.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c index 93b62e0..043c62c 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); }