All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Javi Merino <javi.merino@arm.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	cw00.choi@samsung.com, rufus.hamade@imgtec.com,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>
Subject: Re: [PATCH v4 2/5] PM / OPP: add a function to get the voltage for disabled OPPs
Date: Sat, 15 Aug 2015 11:29:25 +0530	[thread overview]
Message-ID: <20150815055925.GJ1162@linux> (raw)
In-Reply-To: <1439575020-3447-3-git-send-email-javi.merino@arm.com>

On 14-08-15, 18:56, Javi Merino wrote:
> The OPP library is now used for power models to calculate the power
> that a device would consume at a specific OPP.  To do that, we use a
> simple power model which takes frequency and voltage as inputs.  We get
> the voltage and frequency from the OPP library.
> 
> The devfreq cooling device for the thermal framework controls temperature
> by disabling OPPs.  The power model needs to calculate the power that
> would be consumed if we reenabled the OPP.  dev_pm_opp_get_voltage()
> doesn't work for disabled OPPs.
> 
> Add a dev_pm_opp_get_voltage_always() that works both for enabled and
> disabled OPPs to be used by the power model.  The documentation for this
> function clearly states that you should use dev_pm_opp_get_voltage()
> instead unless you know what you're doing.
> 
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Javi Merino <javi.merino@arm.com>
> ---
>  drivers/base/power/opp.c | 37 +++++++++++++++++++++++++++++++++++++
>  include/linux/pm_opp.h   |  7 +++++++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> index 677fb2843553..b1a4216c7ec3 100644
> --- a/drivers/base/power/opp.c
> +++ b/drivers/base/power/opp.c
> @@ -182,6 +182,43 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
>  EXPORT_SYMBOL_GPL(dev_pm_opp_get_voltage);
>  
>  /**
> + * dev_pm_opp_get_voltage_always() - Gets the voltage corresponding to an opp
> + * @opp:	opp for which voltage has to be returned for
> + *
> + * This function is similar to dev_pm_opp_get_voltage() except that it
> + * works for disabled opps as well.  In most cases, you want to
> + * operate only on available opps so you should use
> + * dev_pm_opp_get_voltage() instead.
> + *
> + * Return: voltage in micro volt corresponding to the opp, else
> + * return 0
> + *
> + * 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.
> + */
> +unsigned long dev_pm_opp_get_voltage_always(struct dev_pm_opp *opp)
> +{
> +	struct dev_pm_opp *tmp_opp;
> +	unsigned long v = 0;
> +
> +	opp_rcu_lockdep_assert();
> +
> +	tmp_opp = rcu_dereference(opp);
> +	if (unlikely(IS_ERR_OR_NULL(tmp_opp)))
> +		pr_err("%s: Invalid parameters\n", __func__);
> +	else
> +		v = tmp_opp->u_volt;
> +
> +	return v;
> +}
> +EXPORT_SYMBOL_GPL(dev_pm_opp_get_voltage_always);

I will rather update dev_pm_opp_get_voltage() and remove the
'available' check. There is no need for that.

-- 
viresh

  reply	other threads:[~2015-08-15  5:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-14 17:56 [PATCH v4 0/5] Devfreq cooling device Javi Merino
2015-08-14 17:56 ` [PATCH v4 1/5] PM / devfreq: cache the last call to get_dev_status() Javi Merino
2015-08-14 17:56 ` [PATCH v4 2/5] PM / OPP: add a function to get the voltage for disabled OPPs Javi Merino
2015-08-15  5:59   ` Viresh Kumar [this message]
2015-08-17  9:05     ` Javi Merino
2015-08-14 17:56 ` [PATCH v4 3/5] thermal: Add devfreq cooling Javi Merino
2015-08-17 18:39   ` Javi Merino
2015-08-20 22:32     ` Eduardo Valentin
2015-08-14 17:56 ` [PATCH v4 4/5] devfreq_cooling: add trace information Javi Merino
2015-08-14 17:57 ` [PATCH v4 5/5] PM / devfreq: drop comment about thermal setting max_freq Javi Merino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150815055925.GJ1162@linux \
    --to=viresh.kumar@linaro.org \
    --cc=cw00.choi@samsung.com \
    --cc=javi.merino@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rufus.hamade@imgtec.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.