Linux Power Management development
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: Priyansh Jain <priyansh.jain@oss.qualcomm.com>,
	Amit Kucheria <amitk@kernel.org>,
	Thara Gopinath <thara.gopinath@gmail.com>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	Daniel Lezcano <daniel.lezcano@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Lukasz Luba <lukasz.luba@arm.com>
Cc: linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, manaf.pallikunhi@oss.qualcomm.com
Subject: Re: [PATCH v3] thermal: qcom: tsens: atomic temperature read with hardware-guided retries
Date: Tue, 12 May 2026 11:19:50 +0200	[thread overview]
Message-ID: <06073a6c-1f75-4dad-9309-9bc47a2b4708@oss.qualcomm.com> (raw)
In-Reply-To: <20260511071024.3130247-1-priyansh.jain@oss.qualcomm.com>


Hi Priyansh,

On 5/11/26 09:10, 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.

In future, please add the '---' annotation in order to have the 
changelog below not included when git-apply'ing the patch

> Changes in 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
> 
> Changes in v3:
> - Remove valid_bit, last_temp_mask, and last_temp_resolution fields from
>    struct tsens_features in tsens.h
> - Compute last_temp_mask, resolution, and valid_bit on-the-fly using
>    regmap field definitions
> - Remove field initializations from all platform data files
>    (tsens-v0_1.c, tsens-v1.c, tsens-v2.c)
> - Remove the initialization line in init_common() that was computing
>    last_temp_mask
> 
> Signed-off-by: Priyansh Jain <priyansh.jain@oss.qualcomm.com>
> ---

Applied, thanks


  reply	other threads:[~2026-05-12  9:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11  7:10 [PATCH v3] thermal: qcom: tsens: atomic temperature read with hardware-guided retries Priyansh Jain
2026-05-12  9:19 ` Daniel Lezcano [this message]
2026-05-12  9:29   ` Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=06073a6c-1f75-4dad-9309-9bc47a2b4708@oss.qualcomm.com \
    --to=daniel.lezcano@oss.qualcomm.com \
    --cc=amitk@kernel.org \
    --cc=daniel.lezcano@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=manaf.pallikunhi@oss.qualcomm.com \
    --cc=priyansh.jain@oss.qualcomm.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=thara.gopinath@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox