Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v2 0/2] thermal: qcom: tsens: fix temperature handling
@ 2026-05-08 10:06 Priyansh Jain
  2026-05-08 10:06 ` [PATCH v2 1/2] thermal: qcom: tsens: atomic temperature read with hardware-guided retries Priyansh Jain
  2026-05-08 10:07 ` [PATCH v2 2/2] thermal: qcom: tsens: widen temperature limits to match hardware range Priyansh Jain
  0 siblings, 2 replies; 6+ messages in thread
From: Priyansh Jain @ 2026-05-08 10:06 UTC (permalink / raw)
  To: Amit Kucheria, Thara Gopinath, Rafael J . Wysocki, Daniel Lezcano,
	Zhang Rui, Lukasz Luba
  Cc: linux-pm, linux-arm-msm, linux-kernel, manaf.pallikunhi,
	Priyansh Jain

This series fixes multiple issues in the Qualcomm TSENS thermal driver
related to temperature sampling and trip threshold handling.

Patch 1 updates the temperature read path to atomically sample the
temperature value along with its valid bit, in accordance with hardware
programming guidelines. It also implements the recommended retry and
fallback behavior to avoid incorrect readings during transient hardware
update windows.

Patch 2 widens the software trip temperature limits to match the full
hardware-supported range. This prevents repeated threshold
reprogramming and interrupt storms when devices operate beyond the
previously clamped limits on newer chipsets, while preserving behavior
for platforms operating within the original range.


v2:

- Reverted merging of the valid-bit and LAST_TEMP register field logic
  to preserve the regmap differences between TSENS versions
- Defined valid-bit support and last temperature resolution for all
  TSENS v1 and v2 feature structures
- Defined last temperature resolution for Tsens v0 feature structure
- Dropped tsens version checks in favor of valid-bit capability
- Computed masks from resolution to keep a single source of truth
- Minor code cleanups based on review feedback



Priyansh Jain (2):
  thermal: qcom: tsens: atomic temperature read with hardware-guided
    retries
  thermal: qcom: tsens: widen temperature limits to match hardware range

 drivers/thermal/qcom/tsens-v0_1.c |   1 +
 drivers/thermal/qcom/tsens-v1.c   |   4 ++
 drivers/thermal/qcom/tsens-v2.c   |  10 ++-
 drivers/thermal/qcom/tsens.c      | 114 ++++++++++++++++++++----------
 drivers/thermal/qcom/tsens.h      |   7 ++
 5 files changed, 98 insertions(+), 38 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] thermal: qcom: tsens: atomic temperature read with hardware-guided retries
  2026-05-08 10:06 [PATCH v2 0/2] thermal: qcom: tsens: fix temperature handling Priyansh Jain
@ 2026-05-08 10:06 ` Priyansh Jain
  2026-05-08 12:09   ` Konrad Dybcio
  2026-05-08 10:07 ` [PATCH v2 2/2] thermal: qcom: tsens: widen temperature limits to match hardware range Priyansh Jain
  1 sibling, 1 reply; 6+ messages in thread
From: Priyansh Jain @ 2026-05-08 10:06 UTC (permalink / raw)
  To: Amit Kucheria, Thara Gopinath, Rafael J . Wysocki, Daniel Lezcano,
	Zhang Rui, Lukasz Luba
  Cc: linux-pm, linux-arm-msm, linux-kernel, manaf.pallikunhi,
	Priyansh Jain

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 observe 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.

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>
---
 drivers/thermal/qcom/tsens-v0_1.c |   1 +
 drivers/thermal/qcom/tsens-v1.c   |   4 ++
 drivers/thermal/qcom/tsens-v2.c   |   6 ++
 drivers/thermal/qcom/tsens.c      | 114 ++++++++++++++++++++----------
 drivers/thermal/qcom/tsens.h      |   7 ++
 5 files changed, 96 insertions(+), 36 deletions(-)

diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c
index 32d2d3e33287..9426646d1124 100644
--- a/drivers/thermal/qcom/tsens-v0_1.c
+++ b/drivers/thermal/qcom/tsens-v0_1.c
@@ -287,6 +287,7 @@ static struct tsens_features tsens_v0_1_feat = {
 	.max_sensors	= 11,
 	.trip_min_temp	= -40000,
 	.trip_max_temp	= 120000,
+	.last_temp_resolution = 9,
 };
 
 static const struct reg_field tsens_v0_1_regfields[MAX_REGFIELDS] = {
diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c
index faa5d00788ca..c0263375b771 100644
--- a/drivers/thermal/qcom/tsens-v1.c
+++ b/drivers/thermal/qcom/tsens-v1.c
@@ -77,6 +77,8 @@ static struct tsens_features tsens_v1_feat = {
 	.max_sensors	= 11,
 	.trip_min_temp	= -40000,
 	.trip_max_temp	= 120000,
+	.valid_bit = BIT(14),
+	.last_temp_resolution = 9,
 };
 
 static struct tsens_features tsens_v1_no_rpm_feat = {
@@ -88,6 +90,8 @@ static struct tsens_features tsens_v1_no_rpm_feat = {
 	.max_sensors	= 11,
 	.trip_min_temp	= -40000,
 	.trip_max_temp	= 120000,
+	.valid_bit = BIT(14),
+	.last_temp_resolution = 9,
 };
 
 static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = {
diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c
index 8d9698ea3ec4..d39d3a2923a3 100644
--- a/drivers/thermal/qcom/tsens-v2.c
+++ b/drivers/thermal/qcom/tsens-v2.c
@@ -56,6 +56,8 @@ static struct tsens_features tsens_v2_feat = {
 	.max_sensors	= 16,
 	.trip_min_temp	= -40000,
 	.trip_max_temp	= 120000,
+	.valid_bit = BIT(21),
+	.last_temp_resolution = 11,
 };
 
 static struct tsens_features ipq8074_feat = {
@@ -67,6 +69,8 @@ static struct tsens_features ipq8074_feat = {
 	.max_sensors	= 16,
 	.trip_min_temp	= 0,
 	.trip_max_temp	= 204000,
+	.valid_bit = BIT(21),
+	.last_temp_resolution = 11,
 };
 
 static struct tsens_features ipq5332_feat = {
@@ -78,6 +82,8 @@ static struct tsens_features ipq5332_feat = {
 	.max_sensors	= 16,
 	.trip_min_temp	= 0,
 	.trip_max_temp	= 204000,
+	.valid_bit = BIT(21),
+	.last_temp_resolution = 11,
 };
 
 static const struct reg_field tsens_v2_regfields[MAX_REGFIELDS] = {
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index a2422ebee816..1a7324afe321 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -315,10 +315,64 @@ static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s)
 	return degc;
 }
 
+/**
+ * tsens_read_temp - Retrieve temperature readings from the hardware.
+ * @s:     Pointer to sensor struct
+ * @field: Index into regmap_field array pointing to temperature data
+ * @temp: temperature in deciCelsius to be read from hardware
+ *
+ * This function handles temperature returned in ADC code or deciCelsius
+ * depending on IP version.
+ *
+ * Return: 0 on success, a negative errno will be returned in error cases
+ */
+static int tsens_read_temp(const struct tsens_sensor *s, int field, int *temp)
+{
+	struct tsens_priv *priv = s->priv;
+	int temp_val[MAX_READ_RETRY] = {0};
+	u32 status = 0;
+	int ret;
+
+	for (int i = 0; i < MAX_READ_RETRY; i++) {
+		ret = regmap_read(priv->tm_map, priv->fields[field].reg, &status);
+		if (ret)
+			return ret;
+
+		/* VER_0 doesn't have VALID bit */
+		if (!priv->rf[VALID_0 + s->hw_id]) {
+			*temp = status & priv->feat->last_temp_mask;
+			return 0;
+		}
+
+		temp_val[i] = status & priv->feat->last_temp_mask;
+
+		if (status & priv->feat->valid_bit) {
+			*temp = temp_val[i];
+			return 0;
+		}
+	}
+
+	/* As per the HW guidelines, if none of the attempts observe 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 (temp_val[0] == temp_val[1])
+		*temp = temp_val[1];
+	else if (temp_val[1] == temp_val[2])
+		*temp = temp_val[2];
+	else
+		return -EAGAIN;
+
+	return ret;
+}
+
 /**
  * tsens_hw_to_mC - Return sign-extended temperature in mCelsius.
  * @s:     Pointer to sensor struct
  * @field: Index into regmap_field array pointing to temperature data
+ * @temp: temperature in milliCelsius to be read from hardware
  *
  * This function handles temperature returned in ADC code or deciCelsius
  * depending on IP version.
@@ -326,19 +380,12 @@ static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s)
  * Return: Temperature in milliCelsius on success, a negative errno will
  * be returned in error cases
  */
-static int tsens_hw_to_mC(const struct tsens_sensor *s, int field)
+static int tsens_hw_to_mC(const struct tsens_sensor *s, int temp)
 {
 	struct tsens_priv *priv = s->priv;
 	u32 resolution;
-	u32 temp = 0;
-	int ret;
-
-	resolution = priv->fields[LAST_TEMP_0].msb -
-		priv->fields[LAST_TEMP_0].lsb;
 
-	ret = regmap_field_read(priv->rf[field], &temp);
-	if (ret)
-		return ret;
+	resolution = priv->feat->last_temp_resolution;
 
 	/* Convert temperature from ADC code to milliCelsius */
 	if (priv->feat->adc)
@@ -514,8 +561,12 @@ static int tsens_read_irq_state(struct tsens_priv *priv, u32 hw_id,
 					&d->crit_irq_mask);
 		if (ret)
 			return ret;
-
-		d->crit_thresh = tsens_hw_to_mC(s, CRIT_THRESH_0 + hw_id);
+		ret = regmap_field_read(priv->rf[CRIT_THRESH_0 + hw_id], &d->crit_thresh);
+		if (ret)
+			return ret;
+		d->crit_thresh = tsens_hw_to_mC(s, d->crit_thresh);
+		if (ret)
+			return ret;
 	} else {
 		/* No mask register on older TSENS */
 		d->up_irq_mask = 0;
@@ -524,9 +575,14 @@ static int tsens_read_irq_state(struct tsens_priv *priv, u32 hw_id,
 		d->crit_irq_mask = 0;
 		d->crit_thresh = 0;
 	}
-
-	d->up_thresh  = tsens_hw_to_mC(s, UP_THRESH_0 + hw_id);
-	d->low_thresh = tsens_hw_to_mC(s, LOW_THRESH_0 + hw_id);
+	ret = regmap_field_read(priv->rf[UP_THRESH_0 + hw_id], &d->up_thresh);
+	if (ret)
+		return ret;
+	d->up_thresh = tsens_hw_to_mC(s, d->up_thresh);
+	ret = regmap_field_read(priv->rf[LOW_THRESH_0 + hw_id], &d->low_thresh);
+	if (ret)
+		return ret;
+	d->low_thresh = tsens_hw_to_mC(s, d->low_thresh);
 
 	dev_dbg(priv->dev, "[%u] %s%s: status(%u|%u|%u) | clr(%u|%u|%u) | mask(%u|%u|%u)\n",
 		hw_id, __func__,
@@ -750,33 +806,16 @@ static void tsens_disable_irq(struct tsens_priv *priv)
 
 int get_temp_tsens_valid(const struct tsens_sensor *s, int *temp)
 {
-	struct tsens_priv *priv = s->priv;
+	int ret;
 	int hw_id = s->hw_id;
 	u32 temp_idx = LAST_TEMP_0 + hw_id;
-	u32 valid_idx = VALID_0 + hw_id;
-	u32 valid;
-	int ret;
 
-	/* VER_0 doesn't have VALID bit */
-	if (tsens_version(priv) == VER_0)
-		goto get_temp;
+	ret = tsens_read_temp(s, temp_idx, temp);
 
-	/* Valid bit is 0 for 6 AHB clock cycles.
-	 * At 19.2MHz, 1 AHB clock is ~60ns.
-	 * We should enter this loop very, very rarely.
-	 * Wait 1 us since it's the min of poll_timeout macro.
-	 * Old value was 400 ns.
-	 */
-	ret = regmap_field_read_poll_timeout(priv->rf[valid_idx], valid,
-					     valid, 1, 20 * USEC_PER_MSEC);
-	if (ret)
-		return ret;
-
-get_temp:
-	/* Valid bit is set, OK to read the temperature */
-	*temp = tsens_hw_to_mC(s, temp_idx);
+	if (!ret)
+		*temp = tsens_hw_to_mC(s, *temp);
 
-	return 0;
+		return ret;
 }
 
 int get_temp_common(const struct tsens_sensor *s, int *temp)
@@ -1065,6 +1104,9 @@ int __init init_common(struct tsens_priv *priv)
 		regmap_field_write(priv->rf[CC_MON_MASK], 1);
 	}
 
+	priv->feat->last_temp_mask =
+			GENMASK(priv->feat->last_temp_resolution, 0);
+
 	spin_lock_init(&priv->ul_lock);
 
 	/* VER_0 interrupt doesn't need to be enabled */
diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
index 2a7afa4c899b..e56b6f29621b 100644
--- a/drivers/thermal/qcom/tsens.h
+++ b/drivers/thermal/qcom/tsens.h
@@ -21,6 +21,7 @@
 #define THRESHOLD_MIN_ADC_CODE	0x0
 
 #define MAX_SENSORS 16
+#define MAX_READ_RETRY 3
 
 #include <linux/interrupt.h>
 #include <linux/thermal.h>
@@ -511,6 +512,9 @@ enum regfield_ids {
  * @max_sensors: maximum sensors supported by this version of the IP
  * @trip_min_temp: minimum trip temperature supported by this version of the IP
  * @trip_max_temp: maximum trip temperature supported by this version of the IP
+ * @valid_bit: validate if read temperature is valid or not?
+ * @last_temp_mask: mask register for last temperature
+ * @last_temp_resolution: last temperarure sign bit resolution
  */
 struct tsens_features {
 	unsigned int ver_major;
@@ -522,6 +526,9 @@ struct tsens_features {
 	unsigned int max_sensors;
 	int trip_min_temp;
 	int trip_max_temp;
+	int valid_bit;
+	int last_temp_mask;
+	u32 last_temp_resolution;
 };
 
 /**
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] thermal: qcom: tsens: widen temperature limits to match hardware range
  2026-05-08 10:06 [PATCH v2 0/2] thermal: qcom: tsens: fix temperature handling Priyansh Jain
  2026-05-08 10:06 ` [PATCH v2 1/2] thermal: qcom: tsens: atomic temperature read with hardware-guided retries Priyansh Jain
@ 2026-05-08 10:07 ` Priyansh Jain
  2026-05-08 12:10   ` Konrad Dybcio
  1 sibling, 1 reply; 6+ messages in thread
From: Priyansh Jain @ 2026-05-08 10:07 UTC (permalink / raw)
  To: Amit Kucheria, Thara Gopinath, Rafael J . Wysocki, Daniel Lezcano,
	Zhang Rui, Lukasz Luba
  Cc: linux-pm, linux-arm-msm, linux-kernel, manaf.pallikunhi,
	Priyansh Jain

The TSENS v2 software driver currently clamps trip_min_temp and
trip_max_temp to -40°C and 120°C respectively. However, the
TSENS v2 hardware temperature threshold registers support a wider
programmable range from -204°C to +204°C.

On newer chipsets using TSENS v2, devices may legitimately operate
beyond the existing software limits (for example, up to 130°C). When a
trip temperature is programmed outside the software clamped range, it is
constrained to 120°C on the upper end or -40°C on the lower end.
If the actual temperature continues to exceed this clamped limit, the
threshold is immediately violated again, which can result in a
continuous interrupt storm.

Expand the TSENS v2 software trip temperature limits to match the full
hardware supported range (-204°C to +204°C). This avoids repeated
threshold reprogramming and ensures correct trip handling on TSENS v2
based platforms.

Signed-off-by: Priyansh Jain <priyansh.jain@oss.qualcomm.com>
---
 drivers/thermal/qcom/tsens-v2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c
index d39d3a2923a3..7e967d47aafe 100644
--- a/drivers/thermal/qcom/tsens-v2.c
+++ b/drivers/thermal/qcom/tsens-v2.c
@@ -54,8 +54,8 @@ static struct tsens_features tsens_v2_feat = {
 	.adc		= 0,
 	.srot_split	= 1,
 	.max_sensors	= 16,
-	.trip_min_temp	= -40000,
-	.trip_max_temp	= 120000,
+	.trip_min_temp	= -204000,
+	.trip_max_temp	= 204000,
 	.valid_bit = BIT(21),
 	.last_temp_resolution = 11,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] thermal: qcom: tsens: atomic temperature read with hardware-guided retries
  2026-05-08 10:06 ` [PATCH v2 1/2] thermal: qcom: tsens: atomic temperature read with hardware-guided retries Priyansh Jain
@ 2026-05-08 12:09   ` Konrad Dybcio
  2026-05-11  6:15     ` Priyansh Jain
  0 siblings, 1 reply; 6+ messages in thread
From: Konrad Dybcio @ 2026-05-08 12:09 UTC (permalink / raw)
  To: Priyansh Jain, Amit Kucheria, Thara Gopinath, Rafael J . Wysocki,
	Daniel Lezcano, Zhang Rui, Lukasz Luba
  Cc: linux-pm, linux-arm-msm, linux-kernel, manaf.pallikunhi

On 5/8/26 12:06 PM, Priyansh Jain wrote:
> 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 observe 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.
> 
> 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>
> ---

[...]

>  struct tsens_features {
>  	unsigned int ver_major;
> @@ -522,6 +526,9 @@ struct tsens_features {
>  	unsigned int max_sensors;
>  	int trip_min_temp;
>  	int trip_max_temp;
> +	int valid_bit;
> +	int last_temp_mask;
> +	u32 last_temp_resolution;

You don't need this now that you aren't altering the regfield
definitions

Konrad

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] thermal: qcom: tsens: widen temperature limits to match hardware range
  2026-05-08 10:07 ` [PATCH v2 2/2] thermal: qcom: tsens: widen temperature limits to match hardware range Priyansh Jain
@ 2026-05-08 12:10   ` Konrad Dybcio
  0 siblings, 0 replies; 6+ messages in thread
From: Konrad Dybcio @ 2026-05-08 12:10 UTC (permalink / raw)
  To: Priyansh Jain, Amit Kucheria, Thara Gopinath, Rafael J . Wysocki,
	Daniel Lezcano, Zhang Rui, Lukasz Luba
  Cc: linux-pm, linux-arm-msm, linux-kernel, manaf.pallikunhi

On 5/8/26 12:07 PM, Priyansh Jain wrote:
> The TSENS v2 software driver currently clamps trip_min_temp and
> trip_max_temp to -40°C and 120°C respectively. However, the
> TSENS v2 hardware temperature threshold registers support a wider
> programmable range from -204°C to +204°C.
> 
> On newer chipsets using TSENS v2, devices may legitimately operate
> beyond the existing software limits (for example, up to 130°C). When a
> trip temperature is programmed outside the software clamped range, it is
> constrained to 120°C on the upper end or -40°C on the lower end.
> If the actual temperature continues to exceed this clamped limit, the
> threshold is immediately violated again, which can result in a
> continuous interrupt storm.
> 
> Expand the TSENS v2 software trip temperature limits to match the full
> hardware supported range (-204°C to +204°C). This avoids repeated
> threshold reprogramming and ensures correct trip handling on TSENS v2
> based platforms.
> 
> Signed-off-by: Priyansh Jain <priyansh.jain@oss.qualcomm.com>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] thermal: qcom: tsens: atomic temperature read with hardware-guided retries
  2026-05-08 12:09   ` Konrad Dybcio
@ 2026-05-11  6:15     ` Priyansh Jain
  0 siblings, 0 replies; 6+ messages in thread
From: Priyansh Jain @ 2026-05-11  6:15 UTC (permalink / raw)
  To: Konrad Dybcio, Amit Kucheria, Thara Gopinath, Rafael J . Wysocki,
	Daniel Lezcano, Zhang Rui, Lukasz Luba
  Cc: linux-pm, linux-arm-msm, linux-kernel, manaf.pallikunhi



On 08-05-2026 05:39 pm, Konrad Dybcio wrote:
> On 5/8/26 12:06 PM, Priyansh Jain wrote:
>> 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 observe 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.
>>
>> 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>
>> ---
> 
> [...]
> 
>>   struct tsens_features {
>>   	unsigned int ver_major;
>> @@ -522,6 +526,9 @@ struct tsens_features {
>>   	unsigned int max_sensors;
>>   	int trip_min_temp;
>>   	int trip_max_temp;
>> +	int valid_bit;
>> +	int last_temp_mask;
>> +	u32 last_temp_resolution;
> 
> You don't need this now that you aren't altering the regfield
> definitions
> 
Yes, that's correct. Thanks for pointing this out — I will update the 
code accordingly in the next patch version.

Thanks,
Priyansh

> Konrad


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-05-11  6:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08 10:06 [PATCH v2 0/2] thermal: qcom: tsens: fix temperature handling Priyansh Jain
2026-05-08 10:06 ` [PATCH v2 1/2] thermal: qcom: tsens: atomic temperature read with hardware-guided retries Priyansh Jain
2026-05-08 12:09   ` Konrad Dybcio
2026-05-11  6:15     ` Priyansh Jain
2026-05-08 10:07 ` [PATCH v2 2/2] thermal: qcom: tsens: widen temperature limits to match hardware range Priyansh Jain
2026-05-08 12:10   ` Konrad Dybcio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox