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: 129790 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1416189lja; Tue, 27 Feb 2018 05:52:20 -0800 (PST) X-Google-Smtp-Source: AH8x2262bBW8osa+FlOtTl6vzvqevf4NoU+d2ehLcnQI6IksY5YSVU19MHA9t+wV3rDYh2jLCyUK X-Received: by 10.99.106.71 with SMTP id f68mr11421163pgc.262.1519739539906; Tue, 27 Feb 2018 05:52:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519739539; cv=none; d=google.com; s=arc-20160816; b=R+5aAkQti8bC0wEqxGj+23wRa0L77a464y1hmekIH5xGIpTMKMVqLeWKApVykLF20J Gyo0Q624eyBedqYsCtOnfXybJeZLxHIaS8HsiYZMOw9zEXnkZfHs6D/AOjZZ3LW+uBHh KLRsQ1W/T+t9+KV6atJHe0wh1IfF4EhxbFbSSIc+hhf8TGaWIXsDhaOfEyMDaaNs8pKY aQHu9dYIu3vv+/n0s3viniLNpQ/YhihwZrNtWMjiIauf+e5pSq4rvBNOt3UgbmbiSf0G JJqrFTXPdlpYcPUecBb0F68dQuhWJJYVQtphV/yCue14r+ig0d+okEjlbC5Vvqbe56sQ gIMw== 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=VIhsMQkWczsTb3oAmUx0lj7VuK1QCnKH3jTrXhfFJE4=; b=qrtnLppeAlDgcqllTawkKB18ylY0/amTMLlgC+0WjJeFaS3Ikg5ccUUW7nWnIxDJKF xkQWBDYYmHi9OIGWy4mHTvDC8bonaoBMan8scCyI/QSDxtCIrCwcLcn/R/A3sVzjgaGN yEl3kMHcT1Vak3Mk/zRcdYqAoDXm45r9wZQsOUEAzozNGsSEL2jFZ2FpyT8HFrfGQJtQ BPWhLUsgINtWXd5rppXHQ0EhD48WPRnPMUoyYKpJHjPOWpo5i6UXlaKTroYUeTZxgCtU u+VHi0mD1QVcLwHAnRRnsGdqjc2H3xCvuE1gG65AgHZrdZDGQnmI2d5Fb15Ckoch2O/W 7uWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=nI4doalq; 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 k1si7054511pgn.655.2018.02.27.05.52.19; Tue, 27 Feb 2018 05:52:19 -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=nI4doalq; 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 S1752130AbeB0NwT (ORCPT + 3 others); 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 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+ --- 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(-) -- 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 Acked-by: Bartlomiej Zolnierkiewicz 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);