linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Valentin <edubezval@gmail.com>
To: Leo Yan <leo.yan@linaro.org>
Cc: Zhang Rui <rui.zhang@intel.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	javi.merino@arm.com
Subject: Re: [PATCH v2] thermal: re-calculate k_po/k_pu when update sustainable power
Date: Thu, 31 Dec 2015 09:21:26 -0800	[thread overview]
Message-ID: <20151231172125.GA11863@localhost.localdomain> (raw)
In-Reply-To: <1451471920-2148-1-git-send-email-leo.yan@linaro.org>

On Wed, Dec 30, 2015 at 06:38:40PM +0800, Leo Yan wrote:
> k_po/k_pu are in essence ratio values compared with sustainable power.
> So when update sustainable power, we can recalculate k_po/k_pu simply
> with below formula:
> 
>                sustainable_power(new)
>     k_p(new) = ---------------------- * k_p(old)
>                sustainable_power(old)
> 
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>  drivers/thermal/thermal_core.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index d9e525c..223f8df 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -908,7 +908,7 @@ sustainable_power_store(struct device *dev, struct device_attribute *devattr,
>  			const char *buf, size_t count)
>  {
>  	struct thermal_zone_device *tz = to_thermal_zone(dev);
> -	u32 sustainable_power;
> +	u32 sustainable_power, old_val;
>  
>  	if (!tz->tzp)
>  		return -EIO;
> @@ -916,8 +916,12 @@ sustainable_power_store(struct device *dev, struct device_attribute *devattr,
>  	if (kstrtou32(buf, 10, &sustainable_power))
>  		return -EINVAL;
>  
> +	old_val = tz->tzp->sustainable_power;
> +
>  	tz->tzp->sustainable_power = sustainable_power;
>  
> +	tz->tzp->k_po = (tz->tzp->k_po * sustainable_power) / old_val;
> +	tz->tzp->k_pu = (tz->tzp->k_pu * sustainable_power) / old_val;

I believe this has to be done by the governor. These properties are
power_allocator specific. thermal_core should not really care about
them.

>  	return count;
>  }
>  static DEVICE_ATTR(sustainable_power, S_IWUSR | S_IRUGO, sustainable_power_show,
> -- 
> 1.9.1
> 

  reply	other threads:[~2015-12-31 17:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-30 10:38 [PATCH v2] thermal: re-calculate k_po/k_pu when update sustainable power Leo Yan
2015-12-31 17:21 ` Eduardo Valentin [this message]
2016-01-01  0:03   ` Leo Yan
2016-01-04 11:22     ` Daniel Thompson
2016-01-04 14:31       ` Leo Yan
2016-01-05 16:33       ` Javi Merino
2016-01-05 16:50         ` Daniel Thompson
2016-01-05 17:40           ` Punit Agrawal
2016-01-05 18:02             ` Daniel Thompson
2016-01-05 16:31     ` 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=20151231172125.GA11863@localhost.localdomain \
    --to=edubezval@gmail.com \
    --cc=javi.merino@arm.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.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 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).