Message ID | 20180227132834.22521-1-m.szyprowski@samsung.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
On Tuesday, February 27, 2018 02:28:34 PM Marek Szyprowski wrote: > 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. Please also mention the hardware on which the problem happened. > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> > 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. Please add "Fixes:" tag. > --- > 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; Please also update struct exynos_tmu_data documentation. > 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); With 3 above minor nits fixed: Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics
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);
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 <m.szyprowski@samsung.com> 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(-)