[PATCH 08/15] thermal/drivers/samsung: acpm-tmu: Annotate lockless sensor->enabled access

From: Tudor Ambarus

Date: Mon Oct 26 2026 - 12:10:06 EST


acpm_tmu_get_temp() reads sensor->enabled outside sensor->lock as a fast
path before resuming the device via runtime PM, while
acpm_tmu_op_tz_control() updates sensor->enabled under sensor->lock.
Because both accesses are plain C accesses, concurrent execution is a
data race.

Pair READ_ONCE() on the lockless fast-path read with WRITE_ONCE() in
acpm_tmu_op_tz_control() to prevent compiler misoptimizations and KCSAN
data-race warnings.

Fixes: 50a2c5d4062a ("thermal/drivers/samsung: Add Exynos ACPM TMU driver GS101")
Signed-off-by: Tudor Ambarus <tudor.ambarus@xxxxxxxxxx>
---
drivers/thermal/samsung/acpm-tmu.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/samsung/acpm-tmu.c b/drivers/thermal/samsung/acpm-tmu.c
index 1f56c69af76f..65be8884a8c5 100644
--- a/drivers/thermal/samsung/acpm-tmu.c
+++ b/drivers/thermal/samsung/acpm-tmu.c
@@ -7,6 +7,7 @@

#include <linux/cleanup.h>
#include <linux/clk.h>
+#include <linux/compiler.h>
#include <linux/device/devres.h>
#include <linux/err.h>
#include <linux/firmware/samsung/exynos-acpm-protocol.h>
@@ -148,7 +149,7 @@ static int acpm_tmu_op_tz_control(struct acpm_tmu_sensor *sensor, bool on)
if (ret)
return ret;

- sensor->enabled = on;
+ WRITE_ONCE(sensor->enabled, on);

return 0;
}
@@ -199,7 +200,7 @@ static int acpm_tmu_get_temp(struct thermal_zone_device *tz, int *temp)
* concurrent disabling is caught by the second check under the lock
* after PM resume.
*/
- if (!sensor->enabled)
+ if (!READ_ONCE(sensor->enabled))
return -ENODATA;

ret = pm_runtime_resume_and_get(dev);

--
2.56.0.257.gf7497c7d27-goog