From patchwork Mon Sep 28 05:01:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anson Huang X-Patchwork-Id: 11802849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3F6A1746 for ; Mon, 28 Sep 2020 05:06:01 +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 A288322262 for ; Mon, 28 Sep 2020 05:06:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QCuO2gGO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A288322262 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+patchwork-linux-arm=patchwork.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=oS7HuqRaQq2C1dD3Q9EZ2MN6qumMJvpwIfUZ3hKD59g=; b=QCuO2gGOwR2fhrgpiF1T5IcTLa 48xRzI7dQrOjz5vYAeyVgx9FQO7rBkpkOV6axBhQak2i2XNxVCvkT5A4kAxbj3wb/cBFFm13uhlXn g5vTMf5NlX5a93RKExAxv5/ODQSSM0/qIpj7oiJLM68O+xmj7GXgyOr9sm1PIQAhVfk34AORIuOFS 9BaBIN7X5l10WqdszLHEC7DbQN9l9Lzs+4+kxkVuYg2UQRza6sjZNOMpRlCQ37rTIIy6iyiGWj44y fUph42ktXZUNjIJZfiUul1nhv5ZLb/ZZ9TURUn6pnNVEogvbabkAJh/ooijtt/22iX9v3GmI0mcdI FS35jOOg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMlM6-0002dP-0P; Mon, 28 Sep 2020 05:05:42 +0000 Received: from inva020.nxp.com ([92.121.34.13]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMlM3-0002cG-Ee for linux-arm-kernel@lists.infradead.org; Mon, 28 Sep 2020 05:05:40 +0000 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id B20121A0275; Mon, 28 Sep 2020 07:05:37 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 5171B1A01A4; Mon, 28 Sep 2020 07:05:33 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 934B7402B7; Mon, 28 Sep 2020 07:05:27 +0200 (CEST) From: Anson Huang To: rui.zhang@intel.com, daniel.lezcano@linaro.org, amitk@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org, 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: Correct run_measurement check method Date: Mon, 28 Sep 2020 13:01:43 +0800 Message-Id: <1601269303-12167-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-20200928_010539_632605_18C453EE X-CRM114-Status: GOOD ( 12.62 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [92.121.34.13 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org It is incorrect to use irq_enabled flag for run_measurement check, as irq_enabled is NOT always equal to thermal mode, when temperature is higher than passive point, an alarm irq will be pending, and irq_enabled flag will be set to false while thermal mode is still enabled, then the following temperature read will power down thermal sensor, and next time irq_enabled flag will set to true when temperature drop to below than passive point, next temperature read will fail due to thermal sensor is NOT power up at all, the error log is as below: root@imx6qdlsolo:~# cat /sys/class/thermal/thermal_zone0/temp cat: /sys/class/thermal/thermal_zone0/temp: Resource temporarily unavailable So, it should read the thermal sensor's power down bit to decide whether to run measurement. Fixes: d92ed2c9d3ff ("thermal: imx: Use driver's local data to decide whether to run a measurement") Signed-off-by: Anson Huang --- drivers/thermal/imx_thermal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 2c7473d..9f00182 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -255,7 +255,8 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp) bool wait, run_measurement; u32 val; - run_measurement = !data->irq_enabled; + regmap_read(map, soc_data->sensor_ctrl, &val); + run_measurement = val & soc_data->power_down_mask; if (!run_measurement) { /* Check if a measurement is currently in progress */ regmap_read(map, soc_data->temp_data, &val);