From patchwork Tue Jan 12 05:10: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: 59597 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2524936lbb; Mon, 11 Jan 2016 21:11:14 -0800 (PST) X-Received: by 10.66.232.74 with SMTP id tm10mr131667268pac.128.1452575474013; Mon, 11 Jan 2016 21:11:14 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e29si20177562pfj.102.2016.01.11.21.11.13; Mon, 11 Jan 2016 21:11:13 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750727AbcALFLD (ORCPT + 11 others); Tue, 12 Jan 2016 00:11:03 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:33943 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750705AbcALFLC (ORCPT ); Tue, 12 Jan 2016 00:11:02 -0500 Received: by mail-pa0-f47.google.com with SMTP id uo6so316670795pac.1 for ; Mon, 11 Jan 2016 21:11:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=T24Cv636w+XwkUYVe/zqCpKHNdvfNbquvzcH3VHTHiU=; b=Yc+54aWQ2ZzfRxN2rnUAjOSHaXidcTp8aHPXAPM4VAHiRvxgmXQsYN9LV8U6vMMye5 l2+igQ//pbmXg1QRJBh0ezp4ZB06A6CAPWacq+gQyUg0pBWdn/aMlt+FYKyNcHSP+nY2 fgM5PljaWXkP2k9MnXV8JtSS0x09PjONh8VQs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=T24Cv636w+XwkUYVe/zqCpKHNdvfNbquvzcH3VHTHiU=; b=cZ54XdIpYQtudkl013vzl0lrtjDJ80/dgjcHpSpyo+XrJuiWBXoC7fKH/yw8g8LGEu RhtQ2GR+4JrGQ9qcE4CK8qsV0rVEYXvjvt7fJtuGPy1YSs94y9pyKjuskZSafuvSaH5V NviibXsVVreSEhTU9pbQ/EVVagrPgvP7o1ZWU4YrsfVTNagk9WbOHtwMD9adDrCk4neK XGGyZv5g2DplJItzv/rI3Vco+KDu0aPVPG2O0+vqQpPY+WiQaKse6WWtlbvSXowIwS9q G9gWmuidUeO98tmmmwGP80oeAkUBe0KgHYo28DFxdvQIcaEDLaz0Exb7qhv4LOgfemkM o/0w== X-Gm-Message-State: ALoCoQnA25W5sjzfD1ln8HBZ9eoiKAzFq/BkL0H+xzk3g8DUlimirDtXK1pb2VbIR1nzU7yvW8LiWtPr0OS7XmNPg5fQY2G+kA== X-Received: by 10.66.141.165 with SMTP id rp5mr127111023pab.56.1452575461506; Mon, 11 Jan 2016 21:11:01 -0800 (PST) Received: from localhost ([122.172.46.246]) by smtp.gmail.com with ESMTPSA id 7sm26818770pfc.69.2016.01.11.21.11.00 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 11 Jan 2016 21:11:00 -0800 (PST) Date: Tue, 12 Jan 2016 10:40:58 +0530 From: Viresh Kumar To: Stephen Boyd Cc: Rafael Wysocki , linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, nm@ti.com Subject: Re: [PATCH 04/17] PM / OPP: Introduce dev_pm_opp_get_max_volt_latency() Message-ID: <20160112051058.GJ1084@ubuntu> References: <08691b482198b0709fd258d310a5e6ecda2f1a18.1450777582.git.viresh.kumar@linaro.org> <20160112012512.GJ22188@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160112012512.GJ22188@codeaurora.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On 11-01-16, 17:25, Stephen Boyd wrote: > Doesn't rcu_read_lock() disable preemption sometimes? I don't > think we can call regulator ops with preemption disabled because > regulators use mutex locking. It looks like > regulator_list_voltage() may take a mutex anyway. -------------------------8<------------------------- Subject: [PATCH] PM / OPP: Introduce dev_pm_opp_get_max_volt_latency() 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 | 56 ++++++++++++++++++++++++++++++++++++++++++- include/linux/pm_opp.h | 6 +++++ 2 files changed, 61 insertions(+), 1 deletion(-) -- viresh -- 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/core.c b/drivers/base/power/opp/core.c index 052fc6b78dc3..62976d0bd61c 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -231,8 +231,62 @@ 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 regulator *reg; + unsigned long latency_ns = 0; + unsigned long min_uV = ~0, max_uV = 0; + int ret; + + /* + * Hold our list modification lock here as regulator_set_voltage_time() + * can possibly take another mutex, which isn't allowed within rcu + * locks. + */ + mutex_lock(&dev_opp_list_lock); + + dev_opp = _find_device_opp(dev); + if (IS_ERR(dev_opp)) + goto unlock; + + reg = dev_opp->regulator; + /* Regulator may not be available for device */ + if (IS_ERR(reg)) + goto unlock; + + list_for_each_entry_rcu(opp, &dev_opp->opp_list, node) { + if (!opp->available) + continue; + + if (opp->u_volt_min < min_uV) + min_uV = opp->u_volt_min; + if (opp->u_volt_max > max_uV) + max_uV = opp->u_volt_max; + } + + ret = regulator_set_voltage_time(reg, min_uV, max_uV); + if (ret > 0) + latency_ns = ret * 1000; + +unlock: + mutex_unlock(&dev_opp_list_lock); + + 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 + * @dev: device for which we do this operation * * Return: This function returns pointer to the suspend opp if it is * defined and available, otherwise it returns NULL. diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index c70a18ac9c8a..5daa43058ac1 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, @@ -88,6 +89,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;