From patchwork Wed Nov 26 17:50:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 5387181 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9DECF9F319 for ; Wed, 26 Nov 2014 17:52:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 96C1C2017D for ; Wed, 26 Nov 2014 17:52:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 87D152010E for ; Wed, 26 Nov 2014 17:52:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xtgjq-0000YE-N9; Wed, 26 Nov 2014 17:50:50 +0000 Received: from mail-qa0-x229.google.com ([2607:f8b0:400d:c00::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xtgjl-0000G0-Er for linux-arm-kernel@lists.infradead.org; Wed, 26 Nov 2014 17:50:46 +0000 Received: by mail-qa0-f41.google.com with SMTP id f12so2285260qad.14 for ; Wed, 26 Nov 2014 09:50:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=cRw5DuVnyAuNCq7etID1lYKhlLsEfZiQoQYMXbOpHfU=; b=i1GtZ9OrDdpcOlJpC1sILSpN4KaJ0tBmxV4/+gAnS8baoNwIc/eCRZBZe2t+6PgYvt vRbHrqZnYTUb4cJ08TP2O0wxSfSaxBKgoOKUH88/OJqn4WOIeeFq4LiCKB9pLtluZu/1 bPwTNzPvVCA1ul1WHWhiVwRkz9joxOmWDc5YVvuc5Kp/kmGQIa3tWkpBZOhbvpbCTghL 3sZCStoqL773xG9MkZgJh/28mXiKi8H1MZNWJreomZTPCoXJYXJPnXVh0/rFSrfT2Ywa h409nQ/YMY1wQq/EUMrC7jDzpMcRAbZWG3GUd8Y6P43X+7I97E7Ee94bDGu8qUpwsy7+ jQ/w== X-Received: by 10.229.111.201 with SMTP id t9mr47045197qcp.9.1417024222657; Wed, 26 Nov 2014 09:50:22 -0800 (PST) Received: from localhost ([201.75.27.229]) by mx.google.com with ESMTPSA id j5sm4442715qaz.36.2014.11.26.09.50.18 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Wed, 26 Nov 2014 09:50:21 -0800 (PST) From: Eduardo Valentin To: Linux PM , Viresh Kumar , Lukasz Majewski Subject: [PATCH 1/1] thermal: cpu_cooling: check for the readiness of cpufreq layer Date: Wed, 26 Nov 2014 13:50:12 -0400 Message-Id: <1417024212-1775-1-git-send-email-edubezval@gmail.com> X-Mailer: git-send-email 2.1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141126_095045_592194_7F6106DE X-CRM114-Status: GOOD ( 19.22 ) X-Spam-Score: -0.8 (/) Cc: devicetree@vger.kernel.org, Kukjin Kim , LKML , Rob Herring , Eduardo Valentin , linux-samsung-soc@vger.kernel.org, Grant Likely , Zhang Rui , Naveen Krishna Chatradhi , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Kukjin Kim 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 Cc: Rob Herring Cc: Zhang Rui Signed-off-by: Eduardo Valentin Acked-by: Viresh Kumar Acked-by: does not necessarily indicate acknowledgement of the entire patch. --- 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 | 2 +- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 6 ------ 5 files changed, 6 insertions(+), 17 deletions(-) --- This is attempt to organize the cpu cooling vs. cpufreq boot sequencing. The main change in this patch, as in the commit log, is to have the check for the cpufreq layer in the cpu cooling device registration, instead of in thermal drivers. This way, drivers don't need to bother about it, they just need to propagate the error value. This change was tested on top of: (0) - Viresh's change in cpufreq layer and cpufreq-dt (up to patch 4): https://patchwork.kernel.org/patch/5384141/ https://patchwork.kernel.org/patch/5384151/ https://patchwork.kernel.org/patch/5384161/ https://patchwork.kernel.org/patch/5384171/ (1) - fix of thermal core: https://patchwork.kernel.org/patch/5326991/ After Viresh's changes, cpufreq-dt is properly sequenced with cpu cooling registration. Non-of based drivers also should take advantage if these changes, as now they do not need to check for cpufreq layer. The check is where it belongs, in cpu cooling device registration. BR, Eduardo Valentin diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 1ab0018..9e6945b 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -440,6 +440,11 @@ __cpufreq_cooling_register(struct device_node *np, int ret = 0, i; struct cpufreq_policy policy; + if (!cpufreq_get_current_driver() || !cpufreq_frequency_get_table(0)) { + pr_err("cpu_cooling: cpufreq layer not ready! Deferring.\n"); + 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 -#include #include #include #include @@ -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 #include -#include #include #include #include @@ -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 3f5ad25..f84975e 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.c +++ b/drivers/thermal/samsung/exynos_thermal_common.c @@ -373,7 +373,7 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) 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]); goto err_unregister; } th_zone->cool_dev_size++; diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c index 5fd0386..cf88585 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 #include #include -#include #include #include #include @@ -407,11 +406,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)) {