Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal/drivers/tegra-bpmp: Handle offline zones

Thermal zones located in power domains may not be accessible when
the domain is powergated. In this situation, reading the temperature
will return -BPMP_EFAULT. When evaluating trips, BPMP will internally
use -256C as the temperature for offline zones.

For smooth operation, for offline zones, return -EAGAIN when reading
the temperature and allow registration of zones even if they are
offline during probe.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230330094904.2589428-1-cyndis@kapsi.fi

authored by

Mikko Perttunen and committed by
Daniel Lezcano
cdd6076b fee5caec

+8 -1
+8 -1
drivers/thermal/tegra/tegra-bpmp-thermal.c
··· 52 52 err = tegra_bpmp_transfer(zone->tegra->bpmp, &msg); 53 53 if (err) 54 54 return err; 55 + if (msg.rx.ret == -BPMP_EFAULT) 56 + return -EAGAIN; 55 57 if (msg.rx.ret) 56 58 return -EINVAL; 57 59 ··· 211 209 zone->tegra = tegra; 212 210 213 211 err = __tegra_bpmp_thermal_get_temp(zone, &temp); 214 - if (err < 0) { 212 + 213 + /* 214 + * Sensors in powergated domains may temporarily fail to be read 215 + * (-EAGAIN), but will become accessible when the domain is powered on. 216 + */ 217 + if (err < 0 && err != -EAGAIN) { 215 218 devm_kfree(&pdev->dev, zone); 216 219 continue; 217 220 }