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: 10245473 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 E8C6160362 for ; Tue, 27 Feb 2018 14:23:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA1D5288CF for ; Tue, 27 Feb 2018 14:23:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEAA9288D7; Tue, 27 Feb 2018 14:23:22 +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 6B80B288CF for ; Tue, 27 Feb 2018 14:23:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753172AbeB0OXU (ORCPT ); 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 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 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(-) 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);