From patchwork Tue Feb 27 13:28:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10245205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 196B760211 for ; Tue, 27 Feb 2018 13:28:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CBCA2835B for ; Tue, 27 Feb 2018 13:28:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 016092841C; Tue, 27 Feb 2018 13:28:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ECB92835B for ; Tue, 27 Feb 2018 13:28:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752711AbeB0N2o (ORCPT ); Tue, 27 Feb 2018 08:28:44 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:41240 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752233AbeB0N2n (ORCPT ); Tue, 27 Feb 2018 08:28:43 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180227132840euoutp012a88aea4b167726916bc07b892656cd8~XMcTlhPDB0889208892euoutp01F; Tue, 27 Feb 2018 13:28:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180227132840euoutp012a88aea4b167726916bc07b892656cd8~XMcTlhPDB0889208892euoutp01F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519738121; bh=Nxxdr7bR4uDadlVjjWOYWsg0HKdIJ/hdiUJ2fUJpgeg=; h=From:To:Cc:Subject:Date:References:From; b=BBOPjuPYbgMFJOWwFTrmBore3YKKm+oa1MHu+hMYyr+ZY7fWB0RKaw24czo5EAeJm vSemgfEYLTYlFXezLpJWaKQMKUHVlzJM8EEPswPzEqI22JRRgSneRZiYKS/MUpWU2V cOJnhAC7Z0t7NTllQG1W8TR05k2hgelLLVXptNwE= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180227132839eucas1p2f1e3ecab4cf4489198b59cb340d33db7~XMcSdb5Ca0788107881eucas1p2T; Tue, 27 Feb 2018 13:28:39 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id E2.64.17380.70D559A5; Tue, 27 Feb 2018 13:28:39 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180227132839eucas1p2af68611f1b86f83f32765d53fcebc397~XMcR2AiY10788107881eucas1p2S; Tue, 27 Feb 2018 13:28:39 +0000 (GMT) X-AuditID: cbfec7f4-713ff700000043e4-bb-5a955d074180 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 87.84.04178.70D559A5; Tue, 27 Feb 2018 13:28:39 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P4T00B829FMRK20@eusync3.samsung.com>; Tue, 27 Feb 2018 13:28:39 +0000 (GMT) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org Cc: Marek Szyprowski , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Eduardo Valentin , Zhang Rui Subject: [PATCH] thermal: exynos: Reading temperature makes sense only when TMU is turned on Date: Tue, 27 Feb 2018 14:28:34 +0100 Message-id: <20180227132834.22521-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.15.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRmVeSWpSXmKPExsWy7djP87rssVOjDJa/lrPYOGM9q8X8K9dY Lc6f38Bu8bn3CKPFjPP7mCzWHrnLbvHkYR+bA7vHzll32T0W73nJ5LFpVSebR9+WVYwenzfJ BbBGcdmkpOZklqUW6dslcGU8Pf+XueAzT8Ws3YuYGxifc3UxcnJICJhIdOydwQRiCwmsYJR4 ucS5i5ELyP7MKLHw2TE2mKK7h5sYIRLLGCXm955hhehoYJL4tKwKxGYTMJToetsF1iAiYC9x +8kydhCbWeAmo8SmlX5djBwcwgJxEmvmlIGEWQRUJU58ucMMYvMK2EpsfvCHBWKXvMTi7zvZ QHZJCLxllVh39CkTRMJF4tLqt1AHCUu8Or6FHcKWkejsOMgE0dDPKPHv/0soZwajxPqPrVBV 1hKHj19khbiIT2LStunMIBdJCPBKdLQJQZR4SMyefxGq3FFi5pyNjCAlQgKxEhc2KE9glFzA yLCKUTy1tDg3PbXYKC+1XK84Mbe4NC9dLzk/dxMjMPZO/zv+ZQfjrj9JhxgFOBiVeHgdZKZE CbEmlhVX5h5ilOBgVhLhXbl4cpQQb0piZVVqUX58UWlOavEhRmkOFiVx3jiNuighgfTEktTs 1NSC1CKYLBMHp1QDo+q5ZWdetOgl/q+/oRcsunWp1P/TJxX2n8t5f99B6yqXs01N4S+J0Nes 7pKzbQK1jQwEozaeSCnffOVFA/OztXkHLzi8mNub94OR85K/Of/682UqRx+/UQicsLAuiklf X4c1cmbYhdnh0aUSbveebG0yzmuNuyV5KnOKz8Q3FZfmaC+YxhNhp8RSnJFoqMVcVJwIADNC w3i5AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAJMWRmVeSWpSXmKPExsVy+t/xq7rssVOjDC7PY7LYOGM9q8X8K9dY Lc6f38Bu8bn3CKPFjPP7mCzWHrnLbvHkYR+bA7vHzll32T0W73nJ5LFpVSebR9+WVYwenzfJ BbBGcdmkpOZklqUW6dslcGU8Pf+XueAzT8Ws3YuYGxifc3UxcnJICJhI3D3cxNjFyMUhJLCE UaL99EMop4lJYk7PS2aQKjYBQ4mut11sILaIgL3E7SfL2EGKmAVuM0o0rb3ECpIQFoiTmH/k JlgDi4CqxIkvd8BsXgFbic0P/rBArJOXWPx9J9sERq4FjAyrGEVSS4tz03OLDfWKE3OLS/PS 9ZLzczcxAsNh27Gfm3cwXtoYfIhRgINRiYd3htyUKCHWxLLiytxDjBIczEoivCsXT44S4k1J rKxKLcqPLyrNSS0+xCjNwaIkznveoDJKSCA9sSQ1OzW1ILUIJsvEwSnVwChYnd7Y0KR882ze lJsdu7/vy2jVnz9v1zQl22fzZHctviOS5BC7nJ+Hx7N+/Y+2+nWnvhcGvck5smMJtyVfqdpf gUU63yt9q1jjn8+XSlu0kOvF7RvXN1VqbFq4jlsu++8Fb6vIkqBlcssevXphYV17MYyPzeTO xHS5DN2pia+XMRTF3lNWPKbEUpyRaKjFXFScCAAeGj0fAwIAAA== X-CMS-MailID: 20180227132839eucas1p2af68611f1b86f83f32765d53fcebc397 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180227132839eucas1p2af68611f1b86f83f32765d53fcebc397 X-RootMTR: 20180227132839eucas1p2af68611f1b86f83f32765d53fcebc397 References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 critical value. Fix this by checking if TMU has been actually enabled. Signed-off-by: Marek Szyprowski 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+ kenrels. --- drivers/thermal/samsung/exynos_tmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index ed805c7c5ace..367a9f94ece9 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -205,6 +205,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 +399,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 +892,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);