From patchwork Thu Oct 22 04:24:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anson Huang X-Patchwork-Id: 11850203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9481BC388F7 for ; Thu, 22 Oct 2020 04:32:24 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CC962227F for ; Thu, 22 Oct 2020 04:32:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lT5YZL+v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CC962227F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Kjx73lWdFeVIvivNG21WKR0E2S2YRg6LqhnutKow2Is=; b=lT5YZL+vks9Vz4NWYNS+J+d+du 1boed6XRaVYeRE8T0cf1M1YIyoP+vl38c0qQdCzYiqU5KMguqi2v/gTaLY+jBgBfQlGZmgS6g8w2u 3SaRHik2+ZgAtViEgzYZkyRCIwOf2cIaOB7oyK3EyA1UgQyvnsJ/Qp2oDjqlsSaZkwUXe93t3TaBJ PIM/MGShnQ3WUoQtIctVhWxkHWWsR6PRf9ETAeBQ3DrIB0sFMgRAWjUgc+HH1jSoRpk6hDUDFYkTC uVvG4k/CPxEaFz76OYYQe5e2aLwF5tykD1FDvDr5dj0OLVIopyNBhp8BeDgp1Q0xwXMabFVuvEJKG qQFRoxUQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kVSEx-0008Dr-93; Thu, 22 Oct 2020 04:30:15 +0000 Received: from inva021.nxp.com ([92.121.34.21]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kVSEt-0008DB-Un for linux-arm-kernel@lists.infradead.org; Thu, 22 Oct 2020 04:30:13 +0000 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id AE722201849; Thu, 22 Oct 2020 06:30:08 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 4C12F200CA1; Thu, 22 Oct 2020 06:30:04 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 9DFF4402DD; Thu, 22 Oct 2020 06:29:58 +0200 (CEST) From: Anson Huang 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 Subject: [PATCH] thermal: imx: Do NOT return -EPROBE_DEFER when "#cooling-cells" is present Date: Thu, 22 Oct 2020 12:24:54 +0800 Message-Id: <1603340694-29826-1-git-send-email-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201022_003012_106188_18423C1E X-CRM114-Status: GOOD ( 14.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux-imx@nxp.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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;