All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Dawei Chien <dawei.chien@mediatek.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Daniel Kurtz <djkurtz@chromium.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com,
	Sascha Hauer <kernel@pengutronix.de>,
	Punit Agrawal <punit.agrawal@arm.com>
Subject: Re: [PATCH v4 3/3] thermal: mediatek: Add cpu dynamic power cooling model.
Date: Mon, 30 Nov 2015 11:08:45 +0530	[thread overview]
Message-ID: <20151130053845.GM3373@ubuntu> (raw)
In-Reply-To: <1448616727-29367-4-git-send-email-dawei.chien@mediatek.com>

On 27-11-15, 17:32, Dawei Chien wrote:
> MT8173 cpufreq driver use of_cpufreq_power_cooling_register registering
> cooling devices with dynamic power coefficient.
> 
> Signed-off-by: Dawei Chien <dawei.chien@mediatek.com>
> ---
> This patch is base on patchset:
> https://lkml.org/lkml/2015/11/17/251
> ---
>  drivers/cpufreq/mt8173-cpufreq.c |   28 ++++++++++++++++++++--------
>  1 file changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c
> index 83001dc..4d39468 100644
> --- a/drivers/cpufreq/mt8173-cpufreq.c
> +++ b/drivers/cpufreq/mt8173-cpufreq.c
> @@ -263,24 +263,34 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
>  	return 0;
>  }
>  
> +#define DYNAMIC_POWER "dynamic-power-coefficient"
> +
>  static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
>  {
>  	struct mtk_cpu_dvfs_info *info = policy->driver_data;
>  	struct device_node *np = of_node_get(info->cpu_dev->of_node);
> +	u32 capacitance;
>  
>  	if (WARN_ON(!np))
>  		return;
>  
>  	if (of_find_property(np, "#cooling-cells", NULL)) {
> -		info->cdev = of_cpufreq_cooling_register(np,
> -							 policy->related_cpus);
> +		if (!info->cdev) {

Why will info->cdev be non-NULL here ?

> +			of_property_read_u32(np, DYNAMIC_POWER, &capacitance);

This can fail, in which case capacitance will be used uninitialized.
Fix that by initializing it with 0 at the beginning of this routine.

> +			info->cdev = of_cpufreq_power_cooling_register(np,
> +							policy->related_cpus,
> +							capacitance,
> +							NULL);
>  
> -		if (IS_ERR(info->cdev)) {
> -			dev_err(info->cpu_dev,
> -				"running cpufreq without cooling device: %ld\n",
> -				PTR_ERR(info->cdev));
> +			if (IS_ERR(info->cdev)) {
> +				dev_err(info->cpu_dev,
> +					"running cpufreq without cooling device: %ld\n",
> +					PTR_ERR(info->cdev));
>  
> -			info->cdev = NULL;
> +				info->cdev = NULL;
> +			}
>  		}
>  	}
>  
> @@ -460,7 +470,9 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
>  {
>  	struct mtk_cpu_dvfs_info *info = policy->driver_data;
>  
> -	cpufreq_cooling_unregister(info->cdev);
> +	if (info->cdev)
> +		cpufreq_cooling_unregister(info->cdev);
> +

Why do you need to update this?

>  	dev_pm_opp_free_cpufreq_table(info->cpu_dev, &policy->freq_table);
>  	mtk_cpu_dvfs_info_release(info);
>  	kfree(info);
> -- 
> 1.7.9.5

-- 
viresh

WARNING: multiple messages have this Message-ID (diff)
From: viresh.kumar@linaro.org (Viresh Kumar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 3/3] thermal: mediatek: Add cpu dynamic power cooling model.
Date: Mon, 30 Nov 2015 11:08:45 +0530	[thread overview]
Message-ID: <20151130053845.GM3373@ubuntu> (raw)
In-Reply-To: <1448616727-29367-4-git-send-email-dawei.chien@mediatek.com>

On 27-11-15, 17:32, Dawei Chien wrote:
> MT8173 cpufreq driver use of_cpufreq_power_cooling_register registering
> cooling devices with dynamic power coefficient.
> 
> Signed-off-by: Dawei Chien <dawei.chien@mediatek.com>
> ---
> This patch is base on patchset:
> https://lkml.org/lkml/2015/11/17/251
> ---
>  drivers/cpufreq/mt8173-cpufreq.c |   28 ++++++++++++++++++++--------
>  1 file changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c
> index 83001dc..4d39468 100644
> --- a/drivers/cpufreq/mt8173-cpufreq.c
> +++ b/drivers/cpufreq/mt8173-cpufreq.c
> @@ -263,24 +263,34 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
>  	return 0;
>  }
>  
> +#define DYNAMIC_POWER "dynamic-power-coefficient"
> +
>  static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
>  {
>  	struct mtk_cpu_dvfs_info *info = policy->driver_data;
>  	struct device_node *np = of_node_get(info->cpu_dev->of_node);
> +	u32 capacitance;
>  
>  	if (WARN_ON(!np))
>  		return;
>  
>  	if (of_find_property(np, "#cooling-cells", NULL)) {
> -		info->cdev = of_cpufreq_cooling_register(np,
> -							 policy->related_cpus);
> +		if (!info->cdev) {

Why will info->cdev be non-NULL here ?

> +			of_property_read_u32(np, DYNAMIC_POWER, &capacitance);

This can fail, in which case capacitance will be used uninitialized.
Fix that by initializing it with 0 at the beginning of this routine.

> +			info->cdev = of_cpufreq_power_cooling_register(np,
> +							policy->related_cpus,
> +							capacitance,
> +							NULL);
>  
> -		if (IS_ERR(info->cdev)) {
> -			dev_err(info->cpu_dev,
> -				"running cpufreq without cooling device: %ld\n",
> -				PTR_ERR(info->cdev));
> +			if (IS_ERR(info->cdev)) {
> +				dev_err(info->cpu_dev,
> +					"running cpufreq without cooling device: %ld\n",
> +					PTR_ERR(info->cdev));
>  
> -			info->cdev = NULL;
> +				info->cdev = NULL;
> +			}
>  		}
>  	}
>  
> @@ -460,7 +470,9 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
>  {
>  	struct mtk_cpu_dvfs_info *info = policy->driver_data;
>  
> -	cpufreq_cooling_unregister(info->cdev);
> +	if (info->cdev)
> +		cpufreq_cooling_unregister(info->cdev);
> +

Why do you need to update this?

>  	dev_pm_opp_free_cpufreq_table(info->cpu_dev, &policy->freq_table);
>  	mtk_cpu_dvfs_info_release(info);
>  	kfree(info);
> -- 
> 1.7.9.5

-- 
viresh

  reply	other threads:[~2015-11-30  5:38 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-27  9:32 [PATCH v4 0/3] thermal: mediatek: Add cpu power cooling model Dawei Chien
2015-11-27  9:32 ` Dawei Chien
2015-11-27  9:32 ` Dawei Chien
2015-11-27  9:32 ` [PATCH v4 2/3] arm64: dts: mt8173: Add dynamic power node Dawei Chien
2015-11-27  9:32   ` Dawei Chien
2015-11-27  9:32   ` Dawei Chien
     [not found] ` <1448616727-29367-1-git-send-email-dawei.chien-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2015-11-27  9:32   ` [PATCH v4 1/3] arm64: dts: mt8173: Add thermal zone node Dawei Chien
2015-11-27  9:32     ` Dawei Chien
2015-11-27  9:32     ` Dawei Chien
2015-11-27  9:32   ` [PATCH v4 3/3] thermal: mediatek: Add cpu dynamic power cooling model Dawei Chien
2015-11-27  9:32     ` Dawei Chien
2015-11-27  9:32     ` Dawei Chien
2015-11-30  5:38     ` Viresh Kumar [this message]
2015-11-30  5:38       ` Viresh Kumar
2015-11-30  9:26       ` dawei chien
2015-11-30  9:26         ` dawei chien
2015-11-30  9:26         ` dawei chien
2015-11-30  9:30         ` Viresh Kumar
2015-11-30  9:30           ` Viresh Kumar
2015-11-30 10:21           ` dawei chien
2015-11-30 10:21             ` dawei chien
2015-11-30 10:21             ` dawei chien
2015-11-30 10:34             ` Viresh Kumar
2015-11-30 10:34               ` Viresh Kumar
2015-11-30 10:34               ` Viresh Kumar
2015-11-30 12:16               ` dawei chien
2015-11-30 12:16                 ` dawei chien
2015-11-30 12:16                 ` dawei chien

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=20151130053845.GM3373@ubuntu \
    --to=viresh.kumar@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=dawei.chien@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=djkurtz@chromium.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=pawel.moll@arm.com \
    --cc=punit.agrawal@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=srv_heupstream@mediatek.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.