From patchwork Tue Feb 27 14:23:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 129795 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1450696lja; Tue, 27 Feb 2018 06:23:22 -0800 (PST) X-Google-Smtp-Source: AH8x227qQMUJLoDCTMgkxeSEuHfKAJW1VwGJlO9OkC8oj4v9FP2AieFGH7byUkGRwITg5iPFpgDA X-Received: by 10.101.97.175 with SMTP id i15mr11223180pgv.55.1519741401924; Tue, 27 Feb 2018 06:23:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519741401; cv=none; d=google.com; s=arc-20160816; b=YO+jD24I5xP/roC7mW+h9hztst/PVv4xzL1nryf6qZDSvOk/e8V4q5eo8+REOve1fH ieRV0mzaWAgayx99e4fU5M5W1jHChQnnDuissl5q7KNBnTY8BwWzfV6N1hqvmOwuMuHO ChQJcm6jabtXn1zXmJA2Tlhln0I0ljJBczOZpSePrrk6Gdg5zKxjXfIvns/j//VUHyQd gytLbs3S7trDMJ9N/IWCyYPWJBJtNyiFMzeL4xxO10qAOWYcxLgmcbLQkh5ncRaE7ljF xt+R0ykhclE8248vlDc5KRQJ/K+oqtwhpTIgWgAQxkt2LsXRRIUyDlCNZAaUWwEKcJN5 Oldg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=alOsL8SetXoSN+e+pTIgOLgMxuOpTXwmqYF4fN9pLr4=; b=Qd7USFq84hATXOFHu5ZFmD2Ppwcjq676eEnRQVuoJ03B0XulDD3ilUz7a0KCCKY+qy plMEX4VdcVU1cinhgNr0l92p/4iyhC3kF/5rVs/Qmmswa/2MqfAU8F9uCdYLdoldC6IO KqLQ+wIO0BrLaS29ZWWmtbsfuoHSErFsatT0LqcPthSnsGOCTkMcCCXCGO7m7zNOl+M0 +zcM90JbPPdv9tzpHjXbXYYkcPTc2Hzj1+OP+GmQo1XZbxHFxMXijs8dj0Vv58AQ0UlJ 4uRJB/FEjSB2FpZI/7NTFCh72cArUF9eeAoBC1/tyONFMBPIuCiV4tgQxAxEQYIPGsh/ lJ5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=vcg722b6; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si7064468pgt.621.2018.02.27.06.23.21; Tue, 27 Feb 2018 06:23:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=vcg722b6; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753172AbeB0OXU (ORCPT + 3 others); Tue, 27 Feb 2018 09:23:20 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:59879 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753133AbeB0OXT (ORCPT ); Tue, 27 Feb 2018 09:23:19 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180227142317euoutp0163871aa28fb438d7f3d6f75de04f4b2a~XNL_rUdWW0537005370euoutp01c; Tue, 27 Feb 2018 14:23:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180227142317euoutp0163871aa28fb438d7f3d6f75de04f4b2a~XNL_rUdWW0537005370euoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519741397; bh=Hg+6AgB4pkUPVYhboVy1opugnSrzCpjYC9QLn2NaVD8=; h=From:To:Cc:Subject:Date:References:From; b=vcg722b6hmctUHuxo7xwgo7LlQ+FlsGFwVo0h1tyeQgz8/w3Ml6cXDEF0M6OCQu/l XCy2Q+mVgkzxKlho6vpS7ZmP6aXK9EPgePgO5mYAJUwE2OaLSR7Ehz2V7Tjfbh2wHU cuIZowDTttfCp6pIUtDlPszdsEZIaC646mj4tKRQ= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180227142316eucas1p1a9f4edb0c5cdaea9762e36334c0e90cc~XNL9t-_S71654216542eucas1p1L; Tue, 27 Feb 2018 14:23:16 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 61.C1.05700.3D9659A5; Tue, 27 Feb 2018 14:23:15 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180227142315eucas1p250e3fc053bd1e8e8085aebea32dc5a07~XNL8_y4GX1962919629eucas1p2L; Tue, 27 Feb 2018 14:23:15 +0000 (GMT) X-AuditID: cbfec7f2-1dbff70000011644-07-5a9569d3ab46 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id AF.BF.04183.3D9659A5; Tue, 27 Feb 2018 14:23:15 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P4T00AGHBYOI880@eusync1.samsung.com>; Tue, 27 Feb 2018 14:23:15 +0000 (GMT) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org Cc: stable@vger.kernel.org, Marek Szyprowski , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Eduardo Valentin , Zhang Rui Subject: [PATCH v3] thermal: exynos: Reading temperature makes sense only when TMU is turned on Date: Tue, 27 Feb 2018 15:23:11 +0100 Message-id: <20180227142311.32538-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.15.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsWy7djPc7qXM6dGGfQv0bPYOGM9q8X8K9dY Lc6f38Bu8bn3CKPFjPP7mCzWHrnLbvHkYR+bxYKNjxgdODx2zrrL7rF4z0smj02rOtk8+ras YvT4vEkugDWKyyYlNSezLLVI3y6BK+PEirmMBY+EKhZffs7cwHidv4uRk0NCwERi6/q3bF2M XBxCAisYJa5fvswI4XxmlOg99JcJpqqtfQ0rRGIZo8TXcw+YIZwGJomzv6+xgVSxCRhKdL3t ArNFBOwlbj9Zxg5SxAwyak/DJHaQhLBAosTx9xvAilgEVCUWHbwGtoJXwFZix+UXUOvkJRZ/ 3wl2lITAV1aJGWv3sUIkXCQOHlzJAmELS7w6voUdwpaRuDy5mwWioZ9R4t//l0wQzgxGifUf W6GqrCUOH78INolZgE9i0rbpQE9wAMV5JTrahCBKPCRuHHjCDGE7SjyaOQ2sXEggVuLQ7/8s ExglFzAyrGIUTy0tzk1PLTbMSy3XK07MLS7NS9dLzs/dxAiMx9P/jn/awfj1UtIhRgEORiUe 3hlyU6KEWBPLiitzDzFKcDArifCuXDw5Sog3JbGyKrUoP76oNCe1+BCjNAeLkjhvnEZdlJBA emJJanZqakFqEUyWiYNTqoExtdFAqvd/yPMvpY8/BB+NvtO8NClx2oU5d82rVupzsPKz/wju YJ+1PE1gy9v6bfMmPa0R2f+2aMq8fap3/JUX5MjEGlWIqZRMn1Gx7OqulBi/T41MsUz7Ni5y 1+ZyLHzg9ezNOblTWw5W3rnKdHGmcVLeT9No0YIg5TdzDDqOsMZ2zfGzWZ2sxFKckWioxVxU nAgAlT6j48MCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKJMWRmVeSWpSXmKPExsVy+t/xy7qXM6dGGXw7yGOxccZ6Vov5V66x Wpw/v4Hd4nPvEUaLGef3MVmsPXKX3eLJwz42iwUbHzE6cHjsnHWX3WPxnpdMHptWdbJ59G1Z xejxeZNcAGsUl01Kak5mWWqRvl0CV8aJFXMZCx4JVSy+/Jy5gfE6fxcjJ4eEgIlEW/sa1i5G Lg4hgSWMEv92rGKCcJqYJCZNO8ACUsUmYCjR9baLDcQWEbCXuP1kGTtIEbPAZ0aJrdvbwIqE BRIl5k1ewQpiswioSiw6eI0JxOYVsJXYcfkFE8Q6eYnF33eyTWDkWsDIsIpRJLW0ODc9t9hI rzgxt7g0L10vOT93EyMwMLYd+7llB2PXu+BDjAIcjEo8vDPkpkQJsSaWFVfmHmKU4GBWEuFd uXhylBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHe8waVUUIC6YklqdmpqQWpRTBZJg5OqQbGndZ2 rx1abl5I7dtdteTfu+C15+3uVCQnp6h8uRGYa73CzMNqpv1kztcLJulHxpveN/QrunMnYc72 KKvLl8U1rl2cfoand0/m991CP5O51+at/Xk6Z8G3uQv3TXhqIqP/7pYan/r6P5+f6moX2DY+ 8Pm+eLpJdNgrS96bDI9aHUrenJ4Ytf+WuxJLcUaioRZzUXEiAJw6SHsIAgAA X-CMS-MailID: 20180227142315eucas1p250e3fc053bd1e8e8085aebea32dc5a07 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180227142315eucas1p250e3fc053bd1e8e8085aebea32dc5a07 X-RootMTR: 20180227142315eucas1p250e3fc053bd1e8e8085aebea32dc5a07 References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org When thermal sensor is not yet enabled, reading temperature might return random value. This might even result in stopping system booting when such temperature is higher than the critical value. Fix this by checking if TMU has been actually enabled before reading the temperature. This change fixes booting of Exynos4210-based board with TMU enabled (for example Samsung Trats board), which was broken since v4.4 kernel release. Signed-off-by: Marek Szyprowski Fixes: 9e4249b40340 ("thermal: exynos: Fix first temperature read after registering sensor") CC: stable@vger.kernel.org # v4.6+ Acked-by: Bartlomiej Zolnierkiewicz --- This issue is there since commit 9e4249b40340 ("thermal: exynos: Fix first temperature read after registering sensor"), but this patch applies cleanly only to v4.6+ kernels. --- drivers/thermal/samsung/exynos_tmu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.15.0 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index ed805c7c5ace..986cbd01aaaa 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -185,6 +185,7 @@ * @regulator: pointer to the TMU regulator structure. * @reg_conf: pointer to structure to register with core thermal. * @ntrip: number of supported trip points. + * @enabled: current status of TMU device * @tmu_initialize: SoC specific TMU initialization method * @tmu_control: SoC specific TMU control method * @tmu_read: SoC specific TMU temperature read method @@ -205,6 +206,7 @@ struct exynos_tmu_data { struct regulator *regulator; struct thermal_zone_device *tzd; unsigned int ntrip; + bool enabled; int (*tmu_initialize)(struct platform_device *pdev); void (*tmu_control)(struct platform_device *pdev, bool on); @@ -398,6 +400,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) mutex_lock(&data->lock); clk_enable(data->clk); data->tmu_control(pdev, on); + data->enabled = on; clk_disable(data->clk); mutex_unlock(&data->lock); } @@ -890,7 +893,7 @@ static int exynos_get_temp(void *p, int *temp) { struct exynos_tmu_data *data = p; - if (!data || !data->tmu_read) + if (!data || !data->tmu_read || !data->enabled) return -EINVAL; mutex_lock(&data->lock);