devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Valentin <edubezval@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org, linaro-kernel@lists.linaro.org,
	rui.zhang@intel.com, amit.daniel@samsung.com,
	javi.merino@arm.com, devicetree@vger.kernel.org,
	Grant Likely <grant.likely@linaro.org>,
	Kukjin Kim <kgene.kim@samsung.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	Naveen Krishna Chatradhi <ch.naveen@samsung.com>,
	Rob Herring <robh+dt@kernel.org>
Subject: Re: [PATCH V2 01/26] thermal: cpu_cooling: check for the readiness of cpufreq layer
Date: Thu, 4 Dec 2014 10:08:08 -0400	[thread overview]
Message-ID: <20141204140806.GA6266@developer> (raw)
In-Reply-To: <7b8f5ba72ee0aae221a5c64c1ead2044adbf87d1.1417664938.git.viresh.kumar@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 7158 bytes --]


On Thu, Dec 04, 2014 at 09:41:43AM +0530, Viresh Kumar wrote:
> From: Eduardo Valentin <edubezval@gmail.com>
> 
> In this patch, the cpu_cooling code checks for the usability of cpufreq
> layer before proceeding with the CPU cooling device registration. The
> main reason is: CPU cooling device is not usable if cpufreq cannot
> switch frequencies.
> 
> Similar checks are spread in thermal drivers. Thus, the advantage now
> is to have the check in a single place: cpu cooling device registration.
> For this reason, this patch also updates the existing drivers that
> depend on CPU cooling to simply propagate the error code of the cpu
> cooling registration call. Therefore, in case cpufreq is not ready, the
> thermal drivers will still return -EPROBE_DEFER, in an attempt to try
> again when cpufreq layer gets ready.
> 
> Cc: devicetree@vger.kernel.org
> Cc: Grant Likely <grant.likely@linaro.org>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-samsung-soc@vger.kernel.org
> Cc: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
> ---
>  drivers/thermal/cpu_cooling.c                      | 5 +++++
>  drivers/thermal/db8500_cpufreq_cooling.c           | 5 -----
>  drivers/thermal/imx_thermal.c                      | 5 -----
>  drivers/thermal/samsung/exynos_thermal_common.c    | 8 +++++---
>  drivers/thermal/samsung/exynos_tmu.c               | 5 ++++-
>  drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 6 ------
>  6 files changed, 14 insertions(+), 20 deletions(-)

Hi all,

Here a simple update about the progress in this patch. This is V4 (not V2)
of this patch. Viresh and I agreed to include it in this series because the
patch is related to the fixes and cleanups in cpu cooling. 

This version, on top of V3, has the error codes in the error messages,
as requested by Russel K. Viresh also insisted in having debug messages,
for debug purposes, when EPROBE_DEFER is used, which I did not oppose.

V3 is here:
https://patchwork.kernel.org/patch/5405201/

> 
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index ad09e51..f98a763 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -443,6 +443,11 @@ __cpufreq_cooling_register(struct device_node *np,
>  	int ret = 0, i;
>  	struct cpufreq_policy policy;
>  
> +	if (!cpufreq_frequency_get_table(cpumask_first(clip_cpus))) {
> +		pr_debug("%s: CPUFreq table not found\n", __func__);
> +		return ERR_PTR(-EPROBE_DEFER);
> +	}
> +
>  	/* Verify that all the clip cpus have same freq_min, freq_max limit */
>  	for_each_cpu(i, clip_cpus) {
>  		/* continue if cpufreq policy not found and not return error */
> diff --git a/drivers/thermal/db8500_cpufreq_cooling.c b/drivers/thermal/db8500_cpufreq_cooling.c
> index 786d192..1ac7ec6 100644
> --- a/drivers/thermal/db8500_cpufreq_cooling.c
> +++ b/drivers/thermal/db8500_cpufreq_cooling.c
> @@ -18,7 +18,6 @@
>   */
>  
>  #include <linux/cpu_cooling.h>
> -#include <linux/cpufreq.h>
>  #include <linux/err.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> @@ -30,10 +29,6 @@ static int db8500_cpufreq_cooling_probe(struct platform_device *pdev)
>  	struct thermal_cooling_device *cdev;
>  	struct cpumask mask_val;
>  
> -	/* make sure cpufreq driver has been initialized */
> -	if (!cpufreq_frequency_get_table(0))
> -		return -EPROBE_DEFER;
> -
>  	cpumask_set_cpu(0, &mask_val);
>  	cdev = cpufreq_cooling_register(&mask_val);
>  
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index 5a1f107..16405b4 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -9,7 +9,6 @@
>  
>  #include <linux/clk.h>
>  #include <linux/cpu_cooling.h>
> -#include <linux/cpufreq.h>
>  #include <linux/delay.h>
>  #include <linux/device.h>
>  #include <linux/init.h>
> @@ -459,10 +458,6 @@ static int imx_thermal_probe(struct platform_device *pdev)
>  	int measure_freq;
>  	int ret;
>  
> -	if (!cpufreq_get_current_driver()) {
> -		dev_dbg(&pdev->dev, "no cpufreq driver!");
> -		return -EPROBE_DEFER;
> -	}
>  	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
>  	if (!data)
>  		return -ENOMEM;
> diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
> index b6be572..50a1f17 100644
> --- a/drivers/thermal/samsung/exynos_thermal_common.c
> +++ b/drivers/thermal/samsung/exynos_thermal_common.c
> @@ -371,9 +371,11 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
>  		th_zone->cool_dev[th_zone->cool_dev_size] =
>  					cpufreq_cooling_register(&mask_val);
>  		if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
> -			dev_err(sensor_conf->dev,
> -				"Failed to register cpufreq cooling device\n");
> -			ret = -EINVAL;
> +			ret = PTR_ERR(th_zone->cool_dev[th_zone->cool_dev_size]);
> +			if (ret != -EPROBE_DEFER)
> +				dev_err(sensor_conf->dev,
> +					"Failed to register cpufreq cooling device: %d\n",
> +					ret);
>  			goto err_unregister;
>  		}
>  		th_zone->cool_dev_size++;
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index 49c0924..2afca9b 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -683,7 +683,10 @@ static int exynos_tmu_probe(struct platform_device *pdev)
>  	/* Register the sensor with thermal management interface */
>  	ret = exynos_register_thermal(sensor_conf);
>  	if (ret) {
> -		dev_err(&pdev->dev, "Failed to register thermal interface\n");
> +		if (ret != -EPROBE_DEFER)
> +			dev_err(&pdev->dev,
> +				"Failed to register thermal interface: %d\n",
> +				ret);
>  		goto err_clk;
>  	}
>  	data->reg_conf = sensor_conf;
> diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
> index 9eec26d..5f07d7e 100644
> --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
> +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
> @@ -28,7 +28,6 @@
>  #include <linux/kernel.h>
>  #include <linux/workqueue.h>
>  #include <linux/thermal.h>
> -#include <linux/cpufreq.h>
>  #include <linux/cpumask.h>
>  #include <linux/cpu_cooling.h>
>  #include <linux/of.h>
> @@ -403,11 +402,6 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id)
>  	if (!data)
>  		return -EINVAL;
>  
> -	if (!cpufreq_get_current_driver()) {
> -		dev_dbg(bgp->dev, "no cpufreq driver yet\n");
> -		return -EPROBE_DEFER;
> -	}
> -
>  	/* Register cooling device */
>  	data->cool_dev = cpufreq_cooling_register(cpu_present_mask);
>  	if (IS_ERR(data->cool_dev)) {
> -- 
> 2.0.3.693.g996b0fd
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

      reply	other threads:[~2014-12-04 14:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1417664938.git.viresh.kumar@linaro.org>
2014-12-04  4:11 ` [PATCH V2 01/26] thermal: cpu_cooling: check for the readiness of cpufreq layer Viresh Kumar
2014-12-04 14:08   ` Eduardo Valentin [this message]

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=20141204140806.GA6266@developer \
    --to=edubezval@gmail.com \
    --cc=amit.daniel@samsung.com \
    --cc=ch.naveen@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@linaro.org \
    --cc=javi.merino@arm.com \
    --cc=kgene.kim@samsung.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=viresh.kumar@linaro.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).