From: Viresh Kumar <viresh.kumar@linaro.org>
To: Quentin Perret <quentin.perret@arm.com>
Cc: linux-pm@vger.kernel.org, rjw@rjwysocki.net, vireshk@kernel.org,
nm@ti.com, sboyd@codeaurora.org, sudeep.holla@arm.com,
amit.kachhap@gmail.com, javi.merino@kernel.org,
rui.zhang@intel.com, edubezval@gmail.com, matthias.bgg@gmail.com,
dietmar.eggemann@arm.com, morten.rasmussen@arm.com,
patrick.bellasi@arm.com, ionela.voinescu@arm.com
Subject: Re: [PATCH 1/2] PM / OPP: introduce an OPP power estimation helper
Date: Wed, 10 Jan 2018 10:06:25 +0530 [thread overview]
Message-ID: <20180110043625.GD3335@vireshk-i7> (raw)
In-Reply-To: <20180109110252.13557-2-quentin.perret@arm.com>
On 09-01-18, 11:02, Quentin Perret wrote:
> The power dissipated by a CPU at a specific OPP is currently estimated by
> the thermal subsystem as P = C * V^2 * f, with P the power, C the CPU's
> capacitance, V the OPP's voltage and f the OPP's frequency. As this
> feature can be useful for other clients requiring energy models of CPUs,
> this commit introduces an equivalent power estimator directly into the OPP
> library, hence enabling code re-use.
Okay. I am fine with the basic idea of moving this stuff into the OPP
library but will do it a bit differently.
> Signed-off-by: Quentin Perret <quentin.perret@arm.com>
> ---
> drivers/opp/core.c | 40 +++++++++++++++++++++++++++++++++
> drivers/opp/of.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
> drivers/opp/opp.h | 4 ++++
> include/linux/pm_opp.h | 20 +++++++++++++++++
> 4 files changed, 125 insertions(+)
>
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> index 92fa94a6dcc1..b5e1ad2d311d 100644
> --- a/drivers/opp/core.c
> +++ b/drivers/opp/core.c
> @@ -127,6 +127,24 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
> }
> EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq);
>
> +/**
> + * dev_pm_opp_get_power() - Gets the estimated power corresponding to an opp
> + * @opp: opp for which power has to be returned for
> + *
> + * Return: estimated power in mirco-watts corresponding to the opp, else
> + * return 0
> + */
> +unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp)
> +{
> + if (IS_ERR_OR_NULL(opp) || !opp->available) {
Drop the available check here.
> + pr_err("%s: Invalid parameters\n", __func__);
> + return 0;
> + }
> +
> + return opp->power_estimate_uw;
> +}
> +EXPORT_SYMBOL_GPL(dev_pm_opp_get_power);
> +
> /**
> * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not
> * @opp: opp for which turbo mode is being verified
> @@ -148,6 +166,28 @@ bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp)
> }
> EXPORT_SYMBOL_GPL(dev_pm_opp_is_turbo);
>
> +/**
> + * dev_pm_opp_has_power() - Get the status of power values for OPPs
> + * @cpu_dev: CPU device for which we do this operation
> + *
> + * Return: True if the OPPs hold power estimates for the CPU
> + */
> +bool dev_pm_opp_has_power(struct device *cpu_dev)
> +{
> + struct opp_table *opp_table;
> + bool has_power;
> +
> + opp_table = _find_opp_table(cpu_dev);
> + if (IS_ERR(opp_table))
> + return false;
> +
> + has_power = opp_table->has_power;
> +
> + dev_pm_opp_put_opp_table(opp_table);
> +
> + return has_power;
> +}
> +
> /**
> * dev_pm_opp_get_max_clock_latency() - Get max clock latency in nanoseconds
> * @dev: device for which we do this operation
> diff --git a/drivers/opp/of.c b/drivers/opp/of.c
> index cb716aa2f44b..4a376cd00e8d 100644
> --- a/drivers/opp/of.c
> +++ b/drivers/opp/of.c
> @@ -633,3 +633,64 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev,
> return ret;
> }
> EXPORT_SYMBOL_GPL(dev_pm_opp_of_get_sharing_cpus);
> +
> +/**
> + * dev_pm_opp_of_estimate_power() - Estimates the power dissipated by @cpu_dev
> + * at each OPP.
> + * @cpu_dev: CPU device for which we do this estimation
> + *
> + * This estimates the active power consumed by a CPU at each OPP using:
> + * P = C * V^2 * f
> + * with P the power, C the CPU's capacitance, V the OPP's voltage and f the
> + * OPP's frequency. V and f are assumed to be known by the time this function
> + * is called and C is read from DT.
> + *
> + * Returns -EINVAL if the CPU's capacitance cannot be read from DT.
> + */
> +int dev_pm_opp_of_estimate_power(struct device *cpu_dev)
I wouldn't add this special function, but rather fill
power_estimate_uW while creating the OPPs for the first time.
--
viresh
next prev parent reply other threads:[~2018-01-10 4:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-09 11:02 [PATCH 0/2] thermal, OPP: move the CPU power estimation to the OPP library Quentin Perret
2018-01-09 11:02 ` [PATCH 1/2] PM / OPP: introduce an OPP power estimation helper Quentin Perret
2018-01-10 4:36 ` Viresh Kumar [this message]
2018-01-10 10:20 ` Quentin Perret
2018-01-10 10:25 ` Viresh Kumar
2018-01-10 10:36 ` Quentin Perret
2018-01-09 11:02 ` [PATCH 2/2] thermal: cpu_cooling: use power models from the OPP library Quentin Perret
2018-01-10 4:37 ` Viresh Kumar
2018-01-10 19:34 ` [PATCH 0/2] thermal, OPP: move the CPU power estimation to " Eduardo Valentin
2018-01-11 9:42 ` Viresh Kumar
2018-01-11 9:42 ` Quentin Perret
2018-01-12 17:24 ` Eduardo Valentin
2018-01-12 17:44 ` Quentin Perret
2018-01-12 17:47 ` Eduardo Valentin
2018-01-12 17:50 ` Quentin Perret
2018-01-15 4:26 ` Viresh Kumar
2018-01-15 17:46 ` Eduardo Valentin
2018-01-16 9:16 ` Quentin Perret
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=20180110043625.GD3335@vireshk-i7 \
--to=viresh.kumar@linaro.org \
--cc=amit.kachhap@gmail.com \
--cc=dietmar.eggemann@arm.com \
--cc=edubezval@gmail.com \
--cc=ionela.voinescu@arm.com \
--cc=javi.merino@kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=morten.rasmussen@arm.com \
--cc=nm@ti.com \
--cc=patrick.bellasi@arm.com \
--cc=quentin.perret@arm.com \
--cc=rjw@rjwysocki.net \
--cc=rui.zhang@intel.com \
--cc=sboyd@codeaurora.org \
--cc=sudeep.holla@arm.com \
--cc=vireshk@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).