From patchwork Tue Feb 27 13:52:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10245289 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 00B5960208 for ; Tue, 27 Feb 2018 13:52:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7B2D28902 for ; Tue, 27 Feb 2018 13:52:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC3B62890B; Tue, 27 Feb 2018 13:52:20 +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 ADC7E28902 for ; Tue, 27 Feb 2018 13:52:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752130AbeB0NwT (ORCPT ); Tue, 27 Feb 2018 08:52:19 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:51197 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752107AbeB0NwS (ORCPT ); Tue, 27 Feb 2018 08:52:18 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180227135215euoutp02ef9259f168ee443c61c2a9f3a09317fa~XMw5R7p4-2567225672euoutp02N; Tue, 27 Feb 2018 13:52:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180227135215euoutp02ef9259f168ee443c61c2a9f3a09317fa~XMw5R7p4-2567225672euoutp02N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519739535; bh=tnaHS6DluBmKTJ+js+pbV+Zv8mr1z7htjximADM1tMM=; h=From:To:Cc:Subject:Date:References:From; b=nI4doalqpVEeAZPGz1wwcNFqkmwiSxYXP9ypUmF9T7i61FyTFQa7b/Zmq4LPlE1N0 nLi5UJKMUh3HJ5Zn0cz9bdH7JuogSoleJYHlJOArus5vuUTs7ZhSSrFuDWprHqDWo4 nryK/KnWTrN1O9PYSbA86kK6iPEufdRaq46YG8T0= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180227135214eucas1p17ca07b83a4b21ee0a71ebe0f6921024b~XMw4POgQY2001020010eucas1p1z; Tue, 27 Feb 2018 13:52:14 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 1A.2C.05700.D82659A5; Tue, 27 Feb 2018 13:52:13 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180227135213eucas1p28aa4784b67e8bb97563f4d3dee953b00~XMw20YlQG1974319743eucas1p2Q; Tue, 27 Feb 2018 13:52:13 +0000 (GMT) X-AuditID: cbfec7f2-5ffe19c000011644-79-5a95628dafb8 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 8C.5A.04183.D82659A5; Tue, 27 Feb 2018 13:52:13 +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 <0P4T00HEXAIUSTB0@eusync1.samsung.com>; Tue, 27 Feb 2018 13:52:13 +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 v2] thermal: exynos: Reading temperature makes sense only when TMU is turned on Date: Tue, 27 Feb 2018 14:52:05 +0100 Message-id: <20180227135205.16000-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.15.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRmVeSWpSXmKPExsWy7djPc7q9SVOjDL59NbfYOGM9q8X8K9dY Lc6f38Bu8bn3CKPFjPP7mCzWHrnLbvHkYR+bA7vHzll32T0W73nJ5LFpVSebR9+WVYwenzfJ BbBGcdmkpOZklqUW6dslcGW8PfieqWChUMXL4+dYGhhn83cxcnJICJhIvP/fyN7FyMUhJLCC UWLPm+NsEM5nRokt938xw1Q1HX3LCpFYxijxZOshdpCEkEADk8SDK0ogNpuAoUTX2y42EFtE wF7i9pNlYDXMAjcZJTat9AOxhQUSJTpvbGICsVkEVCXWbn3EAmLzCthKLD82nw1imbzE4u87 wa6QEHjLKjF3z1dGiISLxKmHvVBFwhKvjm9hh7BlJC5P7maBaOhnlPj3/yUThDODUWL9x1ao KmuJw8cvskKcxCcxadt0oN84gOK8Eh1tQhAlHhIH7r5hhbAdJZ6ff88M8WWsxL8vLcwTGCUX MDKsYhRPLS3OTU8tNsxLLdcrTswtLs1L10vOz93ECIzA0/+Of9rB+PVS0iFGAQ5GJR7eGXJT ooRYE8uKK3MPMUpwMCuJ8K5cPDlKiDclsbIqtSg/vqg0J7X4EKM0B4uSOG+cRl2UkEB6Yklq dmpqQWoRTJaJg1OqgbFy9paQWbUNjgeNTHkOmcSF6Oeu3Lvq98udNt3T3xX6SpwpfLB90bTm fl9ebp5Lhc1/pnO6H98eFWWlv+dSRO3F1FXTvxhEdbYk8FYqOCrfL1l3/6mpz/eQ2KP24uJm 2df8XO1vL1sXaX/e46360fCbyqZ5U4sOOvdbcB9JjV3SdaknQWxhvhJLcUaioRZzUXEiAKf5 NEe8AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAJMWRmVeSWpSXmKPExsVy+t/xy7q9SVOjDBrnc1tsnLGe1WL+lWus FufPb2C3+Nx7hNFixvl9TBZrj9xlt3jysI/Ngd1j56y77B6L97xk8ti0qpPNo2/LKkaPz5vk AlijuGxSUnMyy1KL9O0SuDLeHnzPVLBQqOLl8XMsDYyz+bsYOTkkBEwkmo6+Ze1i5OIQEljC KHGr8Q4jhNPEJLFgyWxWkCo2AUOJrrddbCC2iIC9xO0ny9hBipgFbjNKNK29BFYkLJAo8fvw LBYQm0VAVWLt1kdgNq+ArcTyY/PZINbJSyz+vpNtAiPXAkaGVYwiqaXFuem5xUZ6xYm5xaV5 6XrJ+bmbGIHhsO3Yzy07GLveBR9iFOBgVOLhnSE3JUqINbGsuDL3EKMEB7OSCO/KxZOjhHhT EiurUovy44tKc1KLDzFKc7AoifOeN6iMEhJITyxJzU5NLUgtgskycXBKNTDavRLe5Xdw8n2G T1MOBe7/810j8qNKVuJ+iwrN9YmNeu2XdNViNhg3bf19W8Tj8g3t6x2MZSlGrRbvBa+oz+K+ 0iY15/L0DA39pwvat/3fIOXBttrpRbdBbX7CrUu7/27e7Bf58ltYVZNq46a9D1XWh9svOp/P 2P01mPtkzslSgz26B01u5+5VYinOSDTUYi4qTgQAdIob0gMCAAA= X-CMS-MailID: 20180227135213eucas1p28aa4784b67e8bb97563f4d3dee953b00 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180227135213eucas1p28aa4784b67e8bb97563f4d3dee953b00 X-RootMTR: 20180227135213eucas1p28aa4784b67e8bb97563f4d3dee953b00 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. 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. This patch fixes booting of Exynos4210-based board with TMU enabled (for example Samsung Trats board), which was broken since v4.4 kernel release. --- 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);