aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduardo Valentin <edubezval@gmail.com>2014-12-03 23:11:43 -0500
committerEduardo Valentin <edubezval@gmail.com>2014-12-08 11:08:53 -0500
commit0f1be51c358f740fe5183bd0bcd60076fdfb53d0 (patch)
treefcfa99069607e0d7d2562bb7136804b6f94a16db
parent88910638717dd195cff1dd1ea74772b159632bba (diff)
thermal: cpu_cooling: check for the readiness of cpufreq layer
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>
-rw-r--r--drivers/thermal/cpu_cooling.c5
-rw-r--r--drivers/thermal/db8500_cpufreq_cooling.c5
-rw-r--r--drivers/thermal/imx_thermal.c5
-rw-r--r--drivers/thermal/samsung/exynos_thermal_common.c8
-rw-r--r--drivers/thermal/samsung/exynos_tmu.c5
-rw-r--r--drivers/thermal/ti-soc-thermal/ti-thermal-common.c6
6 files changed, 14 insertions, 20 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index ad09e51ffae4..f98a763af2f5 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -443,6 +443,11 @@ __cpufreq_cooling_register(struct device_node *np,
443 int ret = 0, i; 443 int ret = 0, i;
444 struct cpufreq_policy policy; 444 struct cpufreq_policy policy;
445 445
446 if (!cpufreq_frequency_get_table(cpumask_first(clip_cpus))) {
447 pr_debug("%s: CPUFreq table not found\n", __func__);
448 return ERR_PTR(-EPROBE_DEFER);
449 }
450
446 /* Verify that all the clip cpus have same freq_min, freq_max limit */ 451 /* Verify that all the clip cpus have same freq_min, freq_max limit */
447 for_each_cpu(i, clip_cpus) { 452 for_each_cpu(i, clip_cpus) {
448 /* continue if cpufreq policy not found and not return error */ 453 /* 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 786d19263ab0..1ac7ec651c3f 100644
--- a/drivers/thermal/db8500_cpufreq_cooling.c
+++ b/drivers/thermal/db8500_cpufreq_cooling.c
@@ -18,7 +18,6 @@
18 */ 18 */
19 19
20#include <linux/cpu_cooling.h> 20#include <linux/cpu_cooling.h>
21#include <linux/cpufreq.h>
22#include <linux/err.h> 21#include <linux/err.h>
23#include <linux/module.h> 22#include <linux/module.h>
24#include <linux/of.h> 23#include <linux/of.h>
@@ -30,10 +29,6 @@ static int db8500_cpufreq_cooling_probe(struct platform_device *pdev)
30 struct thermal_cooling_device *cdev; 29 struct thermal_cooling_device *cdev;
31 struct cpumask mask_val; 30 struct cpumask mask_val;
32 31
33 /* make sure cpufreq driver has been initialized */
34 if (!cpufreq_frequency_get_table(0))
35 return -EPROBE_DEFER;
36
37 cpumask_set_cpu(0, &mask_val); 32 cpumask_set_cpu(0, &mask_val);
38 cdev = cpufreq_cooling_register(&mask_val); 33 cdev = cpufreq_cooling_register(&mask_val);
39 34
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 5a1f1070b702..16405b4848f1 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -9,7 +9,6 @@
9 9
10#include <linux/clk.h> 10#include <linux/clk.h>
11#include <linux/cpu_cooling.h> 11#include <linux/cpu_cooling.h>
12#include <linux/cpufreq.h>
13#include <linux/delay.h> 12#include <linux/delay.h>
14#include <linux/device.h> 13#include <linux/device.h>
15#include <linux/init.h> 14#include <linux/init.h>
@@ -459,10 +458,6 @@ static int imx_thermal_probe(struct platform_device *pdev)
459 int measure_freq; 458 int measure_freq;
460 int ret; 459 int ret;
461 460
462 if (!cpufreq_get_current_driver()) {
463 dev_dbg(&pdev->dev, "no cpufreq driver!");
464 return -EPROBE_DEFER;
465 }
466 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 461 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
467 if (!data) 462 if (!data)
468 return -ENOMEM; 463 return -ENOMEM;
diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index b6be572704a4..50a1f17c6221 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)
371 th_zone->cool_dev[th_zone->cool_dev_size] = 371 th_zone->cool_dev[th_zone->cool_dev_size] =
372 cpufreq_cooling_register(&mask_val); 372 cpufreq_cooling_register(&mask_val);
373 if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) { 373 if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
374 dev_err(sensor_conf->dev, 374 ret = PTR_ERR(th_zone->cool_dev[th_zone->cool_dev_size]);
375 "Failed to register cpufreq cooling device\n"); 375 if (ret != -EPROBE_DEFER)
376 ret = -EINVAL; 376 dev_err(sensor_conf->dev,
377 "Failed to register cpufreq cooling device: %d\n",
378 ret);
377 goto err_unregister; 379 goto err_unregister;
378 } 380 }
379 th_zone->cool_dev_size++; 381 th_zone->cool_dev_size++;
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 49c09243fd38..2afca9bf40d5 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)
683 /* Register the sensor with thermal management interface */ 683 /* Register the sensor with thermal management interface */
684 ret = exynos_register_thermal(sensor_conf); 684 ret = exynos_register_thermal(sensor_conf);
685 if (ret) { 685 if (ret) {
686 dev_err(&pdev->dev, "Failed to register thermal interface\n"); 686 if (ret != -EPROBE_DEFER)
687 dev_err(&pdev->dev,
688 "Failed to register thermal interface: %d\n",
689 ret);
687 goto err_clk; 690 goto err_clk;
688 } 691 }
689 data->reg_conf = sensor_conf; 692 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 9eec26dc0448..5f07d7e3a198 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 @@
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/workqueue.h> 29#include <linux/workqueue.h>
30#include <linux/thermal.h> 30#include <linux/thermal.h>
31#include <linux/cpufreq.h>
32#include <linux/cpumask.h> 31#include <linux/cpumask.h>
33#include <linux/cpu_cooling.h> 32#include <linux/cpu_cooling.h>
34#include <linux/of.h> 33#include <linux/of.h>
@@ -403,11 +402,6 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id)
403 if (!data) 402 if (!data)
404 return -EINVAL; 403 return -EINVAL;
405 404
406 if (!cpufreq_get_current_driver()) {
407 dev_dbg(bgp->dev, "no cpufreq driver yet\n");
408 return -EPROBE_DEFER;
409 }
410
411 /* Register cooling device */ 405 /* Register cooling device */
412 data->cool_dev = cpufreq_cooling_register(cpu_present_mask); 406 data->cool_dev = cpufreq_cooling_register(cpu_present_mask);
413 if (IS_ERR(data->cool_dev)) { 407 if (IS_ERR(data->cool_dev)) {