From patchwork Tue Jul 28 11:20:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 51580 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 patches.linaro.org (Postfix) with ESMTPS id 1F3D5214B7 for ; Tue, 28 Jul 2015 11:20:40 +0000 (UTC) Received: by lbcjj5 with SMTP id jj5sf36917660lbc.1 for ; Tue, 28 Jul 2015 04:20:39 -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: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=/ZfyTGZZKt/ITZLMoOepKXQEn8U5d2c08U3FPeVetS0=; b=cecE5ltsAHQNB70itvx2UgmJZ3k+7vF0CtDpk6dXi2rgbI1eAoZmPG8iDNtbu/JixH HNx1rreWbQgj4jC3YtREDaA+vsRtYPJkXEQszBml+iTGL57WgpEHjt7nQ5FAPyqRc71V y3Mr3HbvUnFB5VqZXh15rkCU/lwxBLWf/lGeMiQvqjqQ1binJsKTSiw7tie5yzav7J5x PZao/a7fpIdNe6f7Zq0lBA8B/M1K0/DS1xjN+6a+OgKpNr9kcg7/UzFHxInpw2zaSwC9 Xz2Tn9GjCZ7Kg3RySO7yJ+67eoAyjNW7iub44lmLmiDoiPdQGtQJKzd4sR+DJ1+ovIxE QH4Q== X-Gm-Message-State: ALoCoQl+lq9vOnxJhxgTbf2IaflQCggGrolk3sZ0ssSA31Zu2wdYxAYV0017/Sa6C5h276CLyamG X-Received: by 10.152.120.69 with SMTP id la5mr13836681lab.7.1438082438935; Tue, 28 Jul 2015 04:20:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.70 with SMTP id x6ls776653laa.5.gmail; Tue, 28 Jul 2015 04:20:38 -0700 (PDT) X-Received: by 10.152.245.43 with SMTP id xl11mr29347241lac.26.1438082438750; Tue, 28 Jul 2015 04:20:38 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id ue11si18043297lac.46.2015.07.28.04.20.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jul 2015 04:20:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by lagw2 with SMTP id w2so66432051lag.3 for ; Tue, 28 Jul 2015 04:20:38 -0700 (PDT) X-Received: by 10.112.125.34 with SMTP id mn2mr28947504lbb.76.1438082438316; Tue, 28 Jul 2015 04:20:38 -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 l6csp2075091lba; Tue, 28 Jul 2015 04:20:37 -0700 (PDT) X-Received: by 10.70.131.73 with SMTP id ok9mr79992837pdb.109.1438082436390; Tue, 28 Jul 2015 04:20:36 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3si52271369pdf.232.2015.07.28.04.20.35; Tue, 28 Jul 2015 04:20:36 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932363AbbG1LUc (ORCPT + 28 others); Tue, 28 Jul 2015 07:20:32 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:34470 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755657AbbG1LU1 (ORCPT ); Tue, 28 Jul 2015 07:20:27 -0400 Received: by pacan13 with SMTP id an13so69853586pac.1 for ; Tue, 28 Jul 2015 04:20:27 -0700 (PDT) X-Received: by 10.66.229.65 with SMTP id so1mr79643658pac.92.1438082426936; Tue, 28 Jul 2015 04:20:26 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id c8sm24657747pdj.59.2015.07.28.04.20.24 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 28 Jul 2015 04:20:26 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, b.zolnierkie@samsung.com, nm@ti.com, sboyd@codeaurora.org, Tomasz Figa , Michael Turquette , Javier Martinez Canillas , Thomas Abraham , Viresh Kumar , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Pavel Machek Subject: [PATCH 1/4] opp: add dev_pm_opp_is_turbo() helper Date: Tue, 28 Jul 2015 16:50:00 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: 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: 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.52 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: , From: Bartlomiej Zolnierkiewicz 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 Signed-off-by: Bartlomiej Zolnierkiewicz Signed-off-by: Viresh Kumar --- drivers/base/power/opp.c | 30 ++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 7 +++++++ 2 files changed, 37 insertions(+) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index b38f2600d797..a0c54058c4dd 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -281,6 +281,36 @@ 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 true if opp was trubo OPP + * @opp: opp for which turbo mode is being verified + * + * 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 (unlikely(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;