diff mbox series

[2/4] thermal/drivers/exynos: fix set_trip_temp() deadlock

Message ID 20221214131617.2447-3-johan+linaro@kernel.org (mailing list archive)
State Not Applicable
Headers show
Series thermal: fix locking regressions in linux-next | expand

Commit Message

Johan Hovold Dec. 14, 2022, 1:16 p.m. UTC
The set_trip_temp() callback is used when changing the trip temperature
through sysfs. As it is called with the thermal-zone-device lock held
it must not use thermal_zone_get_trip() directly or it will deadlock.

Fixes: 169865e317f2 ("thermal/drivers/exynos: Use generic thermal_zone_get_trip() function")
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Johan Hovold Dec. 14, 2022, 2:45 p.m. UTC | #1
On Wed, Dec 14, 2022 at 02:16:15PM +0100, Johan Hovold wrote:
> The set_trip_temp() callback is used when changing the trip temperature
> through sysfs. As it is called with the thermal-zone-device lock held
> it must not use thermal_zone_get_trip() directly or it will deadlock.
> 
> Fixes: 169865e317f2 ("thermal/drivers/exynos: Use generic thermal_zone_get_trip() function")
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
>  drivers/thermal/samsung/exynos_tmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index 37465af59262..cf9028f80415 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -354,7 +354,7 @@ static void exynos4210_tmu_set_trip_temp(struct exynos_tmu_data *data,
>  	struct thermal_trip trip;
>  	u8 ref, th_code;
>  
> -	if (thermal_zone_get_trip(data->tzd, 0, &trip))
> +	if (__thermal_zone_get_trip(data->tzd, 0, &trip))
>  		return;
>  
>  	ref = trip.temperature / MCELSIUS;

As Daniel noted, this patch is not correct as this function is not
actually a thermal_zone_device_ops::set_trip_temp callback.

Please drop this one.

Johan
diff mbox series

Patch

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 37465af59262..cf9028f80415 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -354,7 +354,7 @@  static void exynos4210_tmu_set_trip_temp(struct exynos_tmu_data *data,
 	struct thermal_trip trip;
 	u8 ref, th_code;
 
-	if (thermal_zone_get_trip(data->tzd, 0, &trip))
+	if (__thermal_zone_get_trip(data->tzd, 0, &trip))
 		return;
 
 	ref = trip.temperature / MCELSIUS;