From patchwork Thu Apr 21 08:58:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 66349 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp17019qge; Thu, 21 Apr 2016 01:59:53 -0700 (PDT) X-Received: by 10.66.145.35 with SMTP id sr3mr18702539pab.82.1461229191000; Thu, 21 Apr 2016 01:59:51 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f22si2477904pfj.46.2016.04.21.01.59.50; Thu, 21 Apr 2016 01:59:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752318AbcDUI7m (ORCPT + 29 others); Thu, 21 Apr 2016 04:59:42 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:33381 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752265AbcDUI7i (ORCPT ); Thu, 21 Apr 2016 04:59:38 -0400 Received: by mail-pf0-f175.google.com with SMTP id 184so28327223pff.0 for ; Thu, 21 Apr 2016 01:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Y/hvd6x+Eho1DVTVtCSU8BaItKmIPzhcjrku7zB5ClM=; b=JPOothhJfxHmflx57BMQhZ3q/Tsq5/IblMt4ufeGbcJZYJduueIcGTNwVV52m7CMQD pGmTvVilTCSh2S1Ee1GJOKpig+jeDKfQ1+BHDppboKfWyUdhKWkF+avg/zQqBxj57ku0 TLFTQaJnVaDqe2xraIxQXsFewuVcGgdXlhcuo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=Y/hvd6x+Eho1DVTVtCSU8BaItKmIPzhcjrku7zB5ClM=; b=GvaN+UJRcxN92eMihQGO6u9W7BwiYnaLnHb83Dh2mByen0gEtc9gA6+PEF3qRCnO0q NBmjV3VKTTGqKaefDZyV4Djz8xfSIin8mWc6Db9UYBsPi3p4CGeevHlEmc+3qQpoevg7 8vQK9ZVTw7p4czm1uEEGyJCQ6U+Frzs7QlD2DyrtjexeebPqUJXdc0A9SY2FBBDgyuQe 3BC2huUmwZe+R2Bg90bJLrIGV8MbvHBNrFNY/oD4bR9E2eBAI3LIbL3p/jhvdPBKAtEg wKXPFNnAct42LvV2NGlkqE0aabj5VQ+/st+ie1sIwAXdJxELNsXQo2InsRwtS6AW0sxO d5IA== X-Gm-Message-State: AOPr4FVnkDcSbK0lnKpua52a3hCWts2BqOWAWJ/dnBMBzscxnRMbaxTSlhiS1MV0/yQ6rHpr X-Received: by 10.98.69.213 with SMTP id n82mr2047601pfi.48.1461229177782; Thu, 21 Apr 2016 01:59:37 -0700 (PDT) Received: from localhost ([122.167.26.250]) by smtp.gmail.com with ESMTPSA id 27sm3080659pfo.58.2016.04.21.01.59.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Apr 2016 01:59:37 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, arnd.bergmann@linaro.org, andrew@lunn.ch, gregory.clement@free-electrons.com, jason@lakedaemon.net, sebastian.hesselbarth@gmail.com, thomas.petazzoni@free-electrons.com, Viresh Kumar , linux-kernel@vger.kernel.org Subject: [PATCH 06/10] PM / OPP: Add dev_pm_opp_get_sharing_cpus() Date: Thu, 21 Apr 2016 14:28:58 +0530 Message-Id: <63f1a01a5a5a93a316ce95953efdd320a20a9cc6.1461228504.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org OPP core allows a platform to mark OPP table as shared, when the platform isn't using operating-points-v2 bindings. And, so there should be a non DT way of finding out if the OPP table is shared or not. This patch adds dev_pm_opp_get_sharing_cpus(), which first tries to get OPP sharing information from the opp-table (in case it is already marked as shared), otherwise it uses the existing DT way of finding sharing information. Signed-off-by: Viresh Kumar --- drivers/base/power/opp/cpu.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 51 insertions(+) -- 2.7.1.410.g6faf27b diff --git a/drivers/base/power/opp/cpu.c b/drivers/base/power/opp/cpu.c index 55cbf9bd8707..9c4eb90759fb 100644 --- a/drivers/base/power/opp/cpu.c +++ b/drivers/base/power/opp/cpu.c @@ -329,3 +329,48 @@ int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask) return ret; } EXPORT_SYMBOL_GPL(dev_pm_opp_set_sharing_cpus); + +/** + * dev_pm_opp_get_sharing_cpus() - Get cpumask of CPUs sharing OPPs with @cpu_dev + * @cpu_dev: CPU device for which we do this operation + * @cpumask: cpumask to update with information of sharing CPUs + * + * This updates the @cpumask with CPUs that are sharing OPPs with @cpu_dev. + * + * Returns -ENODEV if OPP table isn't already present. + * + * Locking: The internal opp_table and opp structures are RCU protected. + * Hence this function internally uses RCU updater strategy with mutex locks + * to keep the integrity of the internal data structures. Callers should ensure + * that this function is *NOT* called under RCU protection or in contexts where + * mutex cannot be locked. + */ +int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask) +{ + struct opp_device *opp_dev; + struct opp_table *opp_table; + int ret = 0; + + mutex_lock(&opp_table_lock); + + opp_table = _find_opp_table(cpu_dev); + if (IS_ERR(opp_table)) { + ret = PTR_ERR(opp_table); + goto unlock; + } + + cpumask_clear(cpumask); + + if (opp_table->shared_opp) { + list_for_each_entry(opp_dev, &opp_table->dev_list, node) + cpumask_set_cpu(opp_dev->dev->id, cpumask); + } else { + cpumask_set_cpu(cpu_dev->id, cpumask); + } + +unlock: + mutex_unlock(&opp_table_lock); + + return ret; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_sharing_cpus); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 5b6ad31403a5..d6effc931013 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -66,6 +66,7 @@ int dev_pm_opp_set_regulator(struct device *dev, const char *name); void dev_pm_opp_put_regulator(struct device *dev); int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask); +int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask); #else static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) { @@ -184,6 +185,11 @@ static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_va return -ENOSYS; } +static inline int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask) +{ + return -ENOSYS; +} + #endif /* CONFIG_PM_OPP */ #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)