diff options
| author | Priyansh Jain <priyansh.jain@oss.qualcomm.com> | 2026-05-14 14:36:43 +0300 |
|---|---|---|
| committer | Daniel Lezcano <daniel.lezcano@kernel.org> | 2026-06-03 10:12:24 +0300 |
| commit | e28ef2f3ccea276436bd0f30c93f99e764ba492b (patch) | |
| tree | b8c6380225b25519177f206b2045dea0f9dd3681 /include | |
| parent | dc10bb3cd2e9b44dbb7602e4f5bb96cdd9d62e25 (diff) | |
| download | linux-e28ef2f3ccea276436bd0f30c93f99e764ba492b.tar.xz | |
thermal/drivers/qcom/tsens: Atomic temperature read with hardware-guided retries
The existing TSENS temperature read logic polls the valid bit and then
reads the temperature register. When temperature reads are triggered
at very short intervals, this can race with hardware updates and allow
the temperature field to be read while it is still being updated.
In this case, the valid bit may already be asserted even though the
temperature value is transitioning, resulting in an incorrect reading.
Hardware programming guidelines require the temperature value and the
valid bit to be sampled atomically in the same read transaction. A
reading is considered valid only if the valid bit is observed set in
that same sample.
The guidelines further specify that software should attempt the
temperature read up to three times to account for transient update
windows. If none of the attempts yields a valid sample, a stable fallback
value must be returned: if the first and second samples match, the second
value is returned;otherwise, if the second and third samples match, the
third value is returned;if neither pair matches, -EAGAIN is returned.
Update the TSENS sensor read logic to implement atomic sampling along
with the recommended retry-and-compare fallback behavior. This removes
the race window and ensures deterministic temperature values in
accordance with hardware requirements.
Signed-off-by: Priyansh Jain <priyansh.jain@oss.qualcomm.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://patch.msgid.link/20260514113643.1954111-1-priyansh.jain@oss.qualcomm.com
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions
