Skip to content

Commit 59edcd9

Browse files
jhovoldDaniel Lezcano
authored andcommitted
thermal/drivers/qcom: Fix lock inversion
The thermal-zone-device lock is held by core when setting trip points and the driver takes its chip lock in the corresponding callback. Fetching the thermal trip points using thermal_zone_get_trip() also involves taking the thermal-zone-device lock, which means that the chip lock can not be held when doing so. Drop the chip lock temporarily during probe to avoid the lock inversion that was detected by lockdep: ====================================================== WARNING: possible circular locking dependency detected 6.1.0-next-20221213 #122 Not tainted ------------------------------------------------------ systemd-udevd/264 is trying to acquire lock: ffff741e444a0920 (&chip->lock){+.+.}-{3:3}, at: qpnp_tm_get_temp+0xb4/0x1b0 [qcom_spmi_temp_alarm] but task is already holding lock: ffff741e44341618 (&tz->lock){+.+.}-{3:3}, at: thermal_zone_device_update+0x2c/0x70 which lock already depends on the new lock. Fixes: 78c3e24 ("thermal/drivers/qcom: Use generic thermal_zone_get_trip() function") Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent b0b5d06 commit 59edcd9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/thermal/qcom/qcom-spmi-temp-alarm.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,12 @@ static int qpnp_tm_init(struct qpnp_tm_chip *chip)
348348
if (stage)
349349
chip->temp = qpnp_tm_decode_temp(chip, stage);
350350

351+
mutex_unlock(&chip->lock);
352+
351353
crit_temp = qpnp_tm_get_critical_trip_temp(chip);
354+
355+
mutex_lock(&chip->lock);
356+
352357
ret = qpnp_tm_update_critical_trip_temp(chip, crit_temp);
353358
if (ret < 0)
354359
goto out;

0 commit comments

Comments
 (0)