All of lore.kernel.org
 help / color / mirror / Atom feed
From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
To: Thorsten Blum <blum@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	 Daniel Lezcano <daniel.lezcano@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Lukasz Luba <lukasz.luba@arm.com>,
	 Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	 linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] thermal: intel: int340x: Fix temperature selection around 0 C
Date: Fri, 28 Aug 2026 13:20:50 -0700	[thread overview]
Message-ID: <fb91525abdaa6b6955d9af96f3b16f0dbbae8e85.camel@linux.intel.com> (raw)
In-Reply-To: <20260826153144.299746-3-blum@kernel.org>

On Wed, 2026-08-26 at 17:31 +0200, Thorsten Blum wrote:
> Since commit 7251b9e8a007 ("thermal/intel: Fix intel_tcc_get_temp()
> to
> support negative CPU temperature"), intel_tcc_get_temp() can report
> negative temperatures.
> 
> proc_thermal_get_zone_temp() still uses *temp as the current maximum
> and
> as an implicit "no reading yet" marker. However, this breaks when a
> CPU
> reports 0 C, because a subsequent negative reading can overwrite it.
> 
> Use bool temp_valid to track whether a valid temperature has been
> read.
> Initialize *temp with the first valid reading and only update it with
> warmer readings.
> 
> Fixes: 7251b9e8a007 ("thermal/intel: Fix intel_tcc_get_temp() to
> support negative CPU temperature")
> Cc: stable@vger.kernel.org # 6.3+
> Signed-off-by: Thorsten Blum <blum@kernel.org>

    Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> ---
>  .../intel/int340x_thermal/processor_thermal_device.c   | 10 +++++++-
> --
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git
> a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> index f80dbe2ca7e4..b0284c2e2e74 100644
> ---
> a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> +++
> b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> @@ -179,17 +179,21 @@ static int proc_thermal_get_zone_temp(struct
> thermal_zone_device *zone,
>  {
>  	int cpu;
>  	int curr_temp, ret;
> -
> -	*temp = 0;
> +	bool temp_valid = false;
>  
>  	for_each_online_cpu(cpu) {
>  		ret = intel_tcc_get_temp(cpu, &curr_temp, false);
>  		if (ret < 0)
>  			return ret;
> -		if (!*temp || curr_temp > *temp)
> +		if (!temp_valid || curr_temp > *temp) {
>  			*temp = curr_temp;
> +			temp_valid = true;
> +		}
>  	}
>  
> +	if (!temp_valid)
> +		return -ENODATA;
> +
>  	*temp *= 1000;
>  
>  	return 0;

  reply	other threads:[~2026-08-28 20:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 15:31 [PATCH] thermal: intel: int340x: Fix temperature selection around 0 C Thorsten Blum
2026-08-28 20:20 ` srinivas pandruvada [this message]
2026-09-04 14:44   ` Rafael J. Wysocki (Intel)

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=fb91525abdaa6b6955d9af96f3b16f0dbbae8e85.camel@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=blum@kernel.org \
    --cc=daniel.lezcano@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=stanislaw.gruszka@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.