thermal/drivers/qcom: Fix set_trip_temp() deadlock
authorJohan Hovold <johan+linaro@kernel.org>
Wed, 14 Dec 2022 13:16:14 +0000 (14:16 +0100)
committerDaniel Lezcano <daniel.lezcano@kernel.org>
Fri, 6 Jan 2023 13:14:48 +0000 (14:14 +0100)
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: 78c3e2429be8 ("thermal/drivers/qcom: Use generic thermal_zone_get_trip() function")
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20221214131617.2447-2-johan+linaro@kernel.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
drivers/thermal/qcom/qcom-spmi-temp-alarm.c
drivers/thermal/thermal_core.c
include/linux/thermal.h

index 58055a7..bfaec74 100644 (file)
@@ -270,7 +270,7 @@ static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip_id, in
        struct thermal_trip trip;
        int ret;
 
-       ret = thermal_zone_get_trip(chip->tz_dev, trip_id, &trip);
+       ret = __thermal_zone_get_trip(chip->tz_dev, trip_id, &trip);
        if (ret)
                return ret;
 
index c24c9ef..d9a3d95 100644 (file)
@@ -1214,6 +1214,7 @@ int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
 
        return tz->ops->get_trip_type(tz, trip_id, &trip->type);
 }
+EXPORT_SYMBOL_GPL(__thermal_zone_get_trip);
 
 int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
                          struct thermal_trip *trip)
index e2797f3..30353e4 100644 (file)
@@ -334,6 +334,8 @@ static inline void devm_thermal_of_zone_unregister(struct device *dev,
 }
 #endif
 
+int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
+                           struct thermal_trip *trip);
 int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
                          struct thermal_trip *trip);