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: 129781 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp277610edc; Tue, 27 Feb 2018 05:28:45 -0800 (PST) X-Google-Smtp-Source: AH8x227qwSqg3kb7G24z09jeZlMY/2R6m4zxHLjUrDObfHCYTdGgpxSNUDNBbQyNZvJQlqnghl98 X-Received: by 2002:a17:902:8605:: with SMTP id f5-v6mr14038093plo.120.1519738125768; Tue, 27 Feb 2018 05:28:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519738125; cv=none; d=google.com; s=arc-20160816; b=VpAn3d4aTfQPBrmsqmp1+fqiWrvzA1yk+XCHqpjbNmI8OdFDXtgS8ftEnAoP+O6h1T syn6vHpl5FzOt/7KsolXz1uDklykZnuHbMXlzZhnKtBmkuTSYNCPsNTvXLMXl3U2Ekag ztTyGZ8q3nfiDyivCMKHDHvmeV3kkp0+zpsrKWX2vuMsscO3bFIGgrzK4BQB5MPXljAA koZjsF0P7ja7vB89noCVhB5VNkUE9+YCy6uu0qTcCBZkdT9xzqEYyMDaT/UOu6iX5oye iN2+ot0SVAAhoEhV6Ob/irdLA2XBhY5Ofth8vh2ERNjH4c45OD3gZxvf0ih++UQrAmDG FyZQ== 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=z+lcWQS/cMfvbQbblqDxz2TfH4t+5+DI3frCHEKqFWA=; b=tG2GKEGFsbFQPVfochfG8qfPPm0bgzPLIszIzUwoIygoqMHHvvENYyhHa7emMechZC 7ZgysxYv5Shu+cQu5gFVLJueZJNq7IwasFyJpIH/ogBnybHiAkE8NdIthZeNe6/i0P86 svrMgjXV2rr3aK1I+uF/UIqcq5IgHxBJCYG0yLbi8NNqoKd3Pn8kDDmqiJQNXxwwmY/c E5Iv+U7xaLTwU/XVOxluffM3i9TRB9L9Cuhcn7lST1S8lsHilONcfGcC8j7VLfSs9xjz qTkcLlEFcsph8lvhgp/FSt6S7bCodoIMHu/QygorlFeXmiZl2i9ucBfq7pAcQq2koTe0 ihNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=BBOPjuPY; 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 69-v6si8544227plb.573.2018.02.27.05.28.45; Tue, 27 Feb 2018 05:28:45 -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=BBOPjuPY; 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 S1752711AbeB0N2o (ORCPT + 3 others); 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 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+ --- 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(-) -- 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..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);