Re: [PATCH] thermal: exynos: Reading temperature makes sense only when TMU is turned on

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
> CC: stable@xxxxxxxxxxxxxxx # 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@xxxxxxxxxxx>

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SoC Development]     [Linux Rockchip Development]     [Linux USB Development]     [Video for Linux]     [Linux Audio Users]     [Linux SCSI]     [Yosemite News]

  Powered by Linux