From patchwork Fri Jul 31 06:17:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 51738 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id BE26E22A24 for ; Fri, 31 Jul 2015 06:17:20 +0000 (UTC) Received: by labkf3 with SMTP id kf3sf2660740lab.0 for ; Thu, 30 Jul 2015 23:17:19 -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:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=zK1+fnOlC/S/hYe4KFoGhXNuOApsYhCtLqaA3iPvyVY=; b=FjN52s6DrGX2tdokBMjVP33BsgsLK+bh5c0WyUheBPmptdAyPo7QLqpLkCXMArN1K6 7iMZiJJyIh/IseW8yOqEz8NP5der7IwwhpZJUz+18A93NQVo28NQmXKmVx4T4+q++Jl+ OaJjuzOIS01DZ48q1oxJ5WMuFseRqAT3ViE9aR5p+HZM1BoK/lMbJvcWwLzgDKM7SOL1 rI/nDewoCH/cx3fDyDcpeqhwEy4t4SdkTpeq28ik/xllKPuLbBNOGPanWkYuaS5jDI6Z UWWKsWjJdABg3dDmNRCyTRt2TjIsz8+D36K5LvkDtgJN+wsUICsJMiJ305XspV1JdTxv jrhw== X-Gm-Message-State: ALoCoQkNmTUnagdoq3KyljyX5iZ81XB6SDpia8G0WSUif4ERfgqRE3IkwUPF12YbqE7T9IPx7m1C X-Received: by 10.112.122.42 with SMTP id lp10mr396549lbb.5.1438323439694; Thu, 30 Jul 2015 23:17:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.133 with SMTP id y5ls268877laj.19.gmail; Thu, 30 Jul 2015 23:17:19 -0700 (PDT) X-Received: by 10.152.238.2 with SMTP id vg2mr1097694lac.12.1438323439348; Thu, 30 Jul 2015 23:17:19 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id cj9si2684150lad.92.2015.07.30.23.17.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jul 2015 23:17:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by laah7 with SMTP id h7so37782115laa.0 for ; Thu, 30 Jul 2015 23:17:19 -0700 (PDT) X-Received: by 10.112.131.98 with SMTP id ol2mr1095004lbb.56.1438323438836; Thu, 30 Jul 2015 23:17:18 -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.7.198 with SMTP id l6csp165631lba; Thu, 30 Jul 2015 23:17:17 -0700 (PDT) X-Received: by 10.107.5.149 with SMTP id 143mr1934725iof.109.1438323437077; Thu, 30 Jul 2015 23:17:17 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m4si8001385pap.0.2015.07.30.23.17.16; Thu, 30 Jul 2015 23:17:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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 S1751771AbbGaGRP (ORCPT + 12 others); Fri, 31 Jul 2015 02:17:15 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:36181 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751642AbbGaGRO (ORCPT ); Fri, 31 Jul 2015 02:17:14 -0400 Received: by pdjr16 with SMTP id r16so37933107pdj.3 for ; Thu, 30 Jul 2015 23:17:13 -0700 (PDT) X-Received: by 10.70.135.129 with SMTP id ps1mr3223677pdb.110.1438323433492; Thu, 30 Jul 2015 23:17:13 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id wp5sm5447876pab.22.2015.07.30.23.17.11 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 30 Jul 2015 23:17:12 -0700 (PDT) Date: Fri, 31 Jul 2015 11:47:07 +0530 From: Viresh Kumar To: Stephen Boyd Cc: Rafael Wysocki , linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, rob.herring@linaro.org, arnd.bergmann@linaro.org, nm@ti.com, broonie@kernel.org, mturquette@baylibre.com, Sudeep.Holla@arm.com, viswanath.puttagunta@linaro.org, l.stach@pengutronix.de, thomas.petazzoni@free-electrons.com, linux-arm-kernel@lists.infradead.org, ta.omasab@gmail.com, kesavan.abhilash@gmail.com, khilman@linaro.org, santosh.shilimkar@oracle.com, b.zolnierkie@samsung.com, Tomasz Figa , Javier Martinez Canillas , Thomas Abraham , Greg Kroah-Hartman , Len Brown , open list , Pavel Machek Subject: Re: [PATCH V3 12/16] PM / OPP: add dev_pm_opp_is_turbo() helper Message-ID: <20150731061707.GQ17794@linux> References: <1e1445bc7f79eb4adc5bf1a0f5eddf118dc60345.1438166099.git.viresh.kumar@linaro.org> <20150731061023.GL3159@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150731061023.GL3159@codeaurora.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@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.53 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: , On 30-07-15, 23:10, Stephen Boyd wrote: > On 07/29, Viresh Kumar wrote: > > +bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) > > +{ > > + struct dev_pm_opp *tmp_opp; > > + > > + opp_rcu_lockdep_assert(); > > + > > + tmp_opp = rcu_dereference(opp); > > + if (unlikely(IS_ERR_OR_NULL(tmp_opp)) || !tmp_opp->available) { > > IS_ERR_OR_NULL already has unlikely inside it on the error > pointer path so it seems redundant here. > > Otherwise > > Reviewed-by: Stephen Boyd ----------------------8<---------------------- Message-Id: From: Bartlomiej Zolnierkiewicz Date: Thu, 9 Jul 2015 17:43:35 +0200 Subject: [PATCH] PM / OPP: add dev_pm_opp_is_turbo() helper Add dev_pm_opp_is_turbo() helper to verify if an opp is to be used only for turbo mode or not. Cc: Tomasz Figa Cc: Michael Turquette Cc: Javier Martinez Canillas Cc: Thomas Abraham Reviewed-by: Stephen Boyd Signed-off-by: Bartlomiej Zolnierkiewicz Signed-off-by: Viresh Kumar --- drivers/base/power/opp.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 7 +++++++ 2 files changed, 41 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 663aae1c9834..204c6c945168 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -281,6 +281,40 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq); /** + * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not + * @opp: opp for which turbo mode is being verified + * + * Turbo OPPs are not for normal use, and can be enabled (under certain + * conditions) for short duration of times to finish high throughput work + * quickly. Running on them for longer times may overheat the chip. + * + * Return: true if opp is turbo opp, else false. + * + * Locking: This function must be called under rcu_read_lock(). opp is a rcu + * protected pointer. This means that opp which could have been fetched by + * opp_find_freq_{exact,ceil,floor} functions is valid as long as we are + * under RCU lock. The pointer returned by the opp_find_freq family must be + * used in the same section as the usage of this function with the pointer + * prior to unlocking with rcu_read_unlock() to maintain the integrity of the + * pointer. + */ +bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) +{ + struct dev_pm_opp *tmp_opp; + + opp_rcu_lockdep_assert(); + + tmp_opp = rcu_dereference(opp); + if (IS_ERR_OR_NULL(tmp_opp) || !tmp_opp->available) { + pr_err("%s: Invalid parameters\n", __func__); + return false; + } + + return tmp_opp->turbo; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_is_turbo); + +/** * dev_pm_opp_get_max_clock_latency() - Get max clock latency in nanoseconds * @dev: device for which we do this operation * diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index bb52fae5b921..cab7ba55bedb 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -30,6 +30,8 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); +bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp); + int dev_pm_opp_get_opp_count(struct device *dev); unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev); @@ -63,6 +65,11 @@ static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) return 0; } +static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) +{ + return false; +} + static inline int dev_pm_opp_get_opp_count(struct device *dev) { return 0;