From patchwork Fri Sep 11 12:02:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 53458 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 patches.linaro.org (Postfix) with ESMTPS id 38E0822DD2 for ; Fri, 11 Sep 2015 12:04:02 +0000 (UTC) Received: by wicmn1 with SMTP id mn1sf17717143wic.1 for ; Fri, 11 Sep 2015 05:04:01 -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=f/PFVJ9I0yUGl0/aE/+0f/fwOEsEW+I788uh3kXIAdI=; b=K97fF8m/OSr1Pl626IUdnaVKUgMl/9CtYJR+I394iiGsWL0n7rIE3wqYmB7X5NFgpb 17bmO+HLfL25zoatP/R1gftPohAJhF/CJxUZ9pz95gfJ3+eyj/UrKdsnqNeWK7anjO9T 3Ob9EcM4gU4cWhC2ON5X/B6dTcklRvTXMGLD5jEpFvUFdq0UH2RWNhBmSYkRXBdS6v1b pVs54rOvO+hXqmP6sPMcqYOlG+3kX2O+NOgA3TwoAlbV/nHjetxul8J92j+QrSfHII6F vI7UeBBwDhdx6a1NbNncxGb9AHCf/AB8js7yZSOk+BxQ0wEhSD7zSRR3XusLTbTO/45i BfTg== X-Gm-Message-State: ALoCoQlTqhCLiVEcgtYqXTu7Cw17Aci3U1llXqVMCpqoL46n3e6KkuGnDjcQf5Lx7gx/H3a40MY9 X-Received: by 10.152.120.233 with SMTP id lf9mr5760299lab.2.1441973041273; Fri, 11 Sep 2015 05:04:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.168 with SMTP id o8ls274391lae.47.gmail; Fri, 11 Sep 2015 05:04:01 -0700 (PDT) X-Received: by 10.112.72.37 with SMTP id a5mr26640903lbv.18.1441973041083; Fri, 11 Sep 2015 05:04:01 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id mt3si12668lbb.113.2015.09.11.05.04.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 05:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by lanb10 with SMTP id b10so46176133lan.3 for ; Fri, 11 Sep 2015 05:04:01 -0700 (PDT) X-Received: by 10.152.170.230 with SMTP id ap6mr41515249lac.73.1441973040937; Fri, 11 Sep 2015 05:04:00 -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.59.35 with SMTP id w3csp1545688lbq; Fri, 11 Sep 2015 05:04:00 -0700 (PDT) X-Received: by 10.51.17.37 with SMTP id gb5mr5372807igd.37.1441973039192; Fri, 11 Sep 2015 05:03:59 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3si173583igl.3.2015.09.11.05.03.58; Fri, 11 Sep 2015 05:03:59 -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 S1753219AbbIKMDu (ORCPT + 28 others); Fri, 11 Sep 2015 08:03:50 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:34239 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753130AbbIKMDq (ORCPT ); Fri, 11 Sep 2015 08:03:46 -0400 Received: by padhy16 with SMTP id hy16so73643032pad.1 for ; Fri, 11 Sep 2015 05:03:46 -0700 (PDT) X-Received: by 10.68.108.67 with SMTP id hi3mr38456928pbb.36.1441973026424; Fri, 11 Sep 2015 05:03:46 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id jd12sm52050pbd.44.2015.09.11.05.03.45 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 11 Sep 2015 05:03:45 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , nm@ti.com, sboyd@codeaurora.org Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, rob.herring@linaro.org, lee.jones@linaro.org, Viresh Kumar , Bartlomiej Zolnierkiewicz , Dmitry Torokhov , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Pavel Machek Subject: [PATCH 10/16] PM / OPP: Introduce dev_pm_opp_get_max_volt_latency() Date: Fri, 11 Sep 2015 17:32:06 +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.54 as permitted sender) smtp.mailfrom=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: , In few use cases (like: cpufreq), it is desired to get the maximum voltage latency for changing OPPs. Add support for that. Signed-off-by: Viresh Kumar --- drivers/base/power/opp/core.c | 59 +++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 +++++ 2 files changed, 65 insertions(+) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 04fe181b8132..e272e738a8d0 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -226,6 +226,65 @@ unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev) EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_clock_latency); /** + * dev_pm_opp_get_max_volt_latency() - Get max voltage latency in nanoseconds + * @dev: device for which we do this operation + * + * Return: This function returns the max voltage latency in nanoseconds. + * + * Locking: This function takes rcu_read_lock(). + */ +unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) +{ + struct device_opp *dev_opp; + struct dev_pm_opp *opp; + struct opp_supply *supply; + struct regulator *reg; + unsigned long latency_ns = 0; + unsigned long min_uV, max_uV; + int count, ret; + + rcu_read_lock(); + + dev_opp = _find_device_opp(dev); + if (IS_ERR(dev_opp)) + goto unlock; + + /* Sum max latencies for all supplies */ + for (count = 0; count < dev_opp->supply_count; count++) { + min_uV = ~0; + max_uV = 0; + + reg = dev_opp->regulators[count]; + + /* Regulator may not be available for device */ + if (IS_ERR(reg)) + continue; + + list_for_each_entry_rcu(opp, &dev_opp->opp_list, node) { + if (!opp->available) + continue; + + supply = opp->supplies + count; + + if (supply->u_volt_min < min_uV) + min_uV = supply->u_volt_min; + if (supply->u_volt_max > max_uV) + max_uV = supply->u_volt_max; + } + + ret = regulator_set_voltage_time(reg, min_uV, max_uV); + if (ret > 0) + latency_ns += ret * 1000; + } + +unlock: + rcu_read_unlock(); + + return latency_ns; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_volt_latency); + +/** * dev_pm_opp_get_suspend_opp() - Get suspend opp * @dev: device for which we do this operation * diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 9a2e50337af9..fd58e2074721 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -34,6 +34,7 @@ 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); +unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev); struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev); struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, @@ -81,6 +82,11 @@ static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev) return 0; } +static inline unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) +{ + return 0; +} + static inline struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev) { return NULL;