linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anson Huang <Anson.Huang@nxp.com>
To: rui.zhang@intel.com, daniel.lezcano@linaro.org, amitk@kernel.org,
	shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, festevam@gmail.com,
	linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Cc: Linux-imx@nxp.com
Subject: [PATCH] thermal: imx: Do NOT return -EPROBE_DEFER when "#cooling-cells" is present
Date: Thu, 22 Oct 2020 12:24:54 +0800	[thread overview]
Message-ID: <1603340694-29826-1-git-send-email-Anson.Huang@nxp.com> (raw)

The legacy CPU cooling should ONLY be used when "#cooling-cells" is NOT
present in cpu node, current implementation for registering legacy cooling
always return -EPROBE_DEFER when cpufreq is NOT ready, that will cause
thermal driver probe failed when cpufreq failed to probe with a non
-EPROBE_DEFER reason. In such case, thermal driver should continue probe
and provide temperature monitor and other cooling methods.

So, for the case of "#cooling-cells" present in cpu node, no need to
return -EPROBE_DEFER even cpufreq is NOT ready, this is to make sure
thermal driver can continue probe.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
 drivers/thermal/imx_thermal.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 9f00182..df60dcb 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -630,17 +630,29 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
 static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
 {
 	struct device_node *np;
+	struct device *cpu_dev;
 	int ret = 0;
 
-	data->policy = cpufreq_cpu_get(0);
-	if (!data->policy) {
-		pr_debug("%s: CPUFreq policy not found\n", __func__);
-		return -EPROBE_DEFER;
+	cpu_dev = get_cpu_device(0);
+	if (!cpu_dev) {
+		pr_err("imx thermal: failed to get cpu0 device\n");
+		return -ENODEV;
+	}
+
+	np = of_node_get(cpu_dev->of_node);
+	if (!np) {
+		pr_err("imx thermal: failed to find cpu0 node\n");
+		return -ENOENT;
 	}
 
-	np = of_get_cpu_node(data->policy->cpu, NULL);
+	if (!of_find_property(np, "#cooling-cells", NULL)) {
+		data->policy = cpufreq_cpu_get(0);
+		if (!data->policy) {
+			pr_debug("%s: CPUFreq policy not found\n", __func__);
+			ret = -EPROBE_DEFER;
+			goto put_node;
+		}
 
-	if (!np || !of_find_property(np, "#cooling-cells", NULL)) {
 		data->cdev = cpufreq_cooling_register(data->policy);
 		if (IS_ERR(data->cdev)) {
 			ret = PTR_ERR(data->cdev);
@@ -648,6 +660,7 @@ static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
 		}
 	}
 
+put_node:
 	of_node_put(np);
 
 	return ret;
-- 
2.7.4


                 reply	other threads:[~2020-10-22  4:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1603340694-29826-1-git-send-email-Anson.Huang@nxp.com \
    --to=anson.huang@nxp.com \
    --cc=Linux-imx@nxp.com \
    --cc=amitk@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.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).