Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] thermal/drivers/airoha: Fix low trip clamp using wrong variable
@ 2026-06-14  0:14 Wayen.Yan
  2026-06-14  7:14 ` Christian Marangi
  0 siblings, 1 reply; 2+ messages in thread
From: Wayen.Yan @ 2026-06-14  0:14 UTC (permalink / raw)
  To: linux-pm
  Cc: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Christian Marangi, Lorenzo Bianconi, linux-kernel, linux-mediatek

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1398 bytes --]

In airoha_thermal_set_trips(), the low trip validation incorrectly
clamps 'high' instead of 'low':

  low = clamp_t(int, high, RAW_TO_TEMP(priv, 0), ...);

This causes TEMPOFFSETL to receive the clamped high-temperature value
instead of the requested low-temperature value, making the low-temperature
alert threshold identical to the high-temperature threshold. As a result,
low-temperature interrupts can never fire independently.

Fix by replacing 'high' with 'low' in the clamp expression, matching
the symmetric pattern used for the high trip on line 264.

Fixes: 42de37f40e1b ("thermal/drivers: Add support for Airoha EN7581 thermal sensor")
Signed-off-by: Wayen <win847@gmail.com>
---
 drivers/thermal/airoha_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/airoha_thermal.c b/drivers/thermal/airoha_thermal.c
index b9fd6bfc88..439aa011b7 100644
--- a/drivers/thermal/airoha_thermal.c
+++ b/drivers/thermal/airoha_thermal.c
@@ -273,7 +273,7 @@ static int airoha_thermal_set_trips(struct thermal_zone_device *tz, int low,
 
 	if (low != -INT_MAX) {
 		/* Validate low and clamp it to a supported value */
-		low = clamp_t(int, high, RAW_TO_TEMP(priv, 0),
+		low = clamp_t(int, low, RAW_TO_TEMP(priv, 0),
 			      RAW_TO_TEMP(priv, FIELD_MAX(EN7581_DOUT_TADC_MASK)));
 
 		/* We offset the low temp of 1°C to trigger correct event */
-- 
2.51.0



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

* Re: [PATCH] thermal/drivers/airoha: Fix low trip clamp using wrong variable
  2026-06-14  0:14 [PATCH] thermal/drivers/airoha: Fix low trip clamp using wrong variable Wayen.Yan
@ 2026-06-14  7:14 ` Christian Marangi
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Marangi @ 2026-06-14  7:14 UTC (permalink / raw)
  To: Wayen.Yan
  Cc: linux-pm, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui,
	Lukasz Luba, Lorenzo Bianconi, linux-kernel, linux-mediatek

On Sun, Jun 14, 2026 at 08:14:11AM +0800, Wayen.Yan wrote:
> In airoha_thermal_set_trips(), the low trip validation incorrectly
> clamps 'high' instead of 'low':
> 
>   low = clamp_t(int, high, RAW_TO_TEMP(priv, 0), ...);
> 
> This causes TEMPOFFSETL to receive the clamped high-temperature value
> instead of the requested low-temperature value, making the low-temperature
> alert threshold identical to the high-temperature threshold. As a result,
> low-temperature interrupts can never fire independently.
> 
> Fix by replacing 'high' with 'low' in the clamp expression, matching
> the symmetric pattern used for the high trip on line 264.
> 
> Fixes: 42de37f40e1b ("thermal/drivers: Add support for Airoha EN7581 thermal sensor")
> Signed-off-by: Wayen <win847@gmail.com>
> ---
>  drivers/thermal/airoha_thermal.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/airoha_thermal.c b/drivers/thermal/airoha_thermal.c
> index b9fd6bfc88..439aa011b7 100644
> --- a/drivers/thermal/airoha_thermal.c
> +++ b/drivers/thermal/airoha_thermal.c
> @@ -273,7 +273,7 @@ static int airoha_thermal_set_trips(struct thermal_zone_device *tz, int low,
>  
>  	if (low != -INT_MAX) {
>  		/* Validate low and clamp it to a supported value */
> -		low = clamp_t(int, high, RAW_TO_TEMP(priv, 0),
> +		low = clamp_t(int, low, RAW_TO_TEMP(priv, 0),
>  			      RAW_TO_TEMP(priv, FIELD_MAX(EN7581_DOUT_TADC_MASK)));
>  
>  		/* We offset the low temp of 1°C to trigger correct event */
> -- 
> 2.51.0
> 
> 

Hi I already submitted the same patch in the AN7583 series. Can you review
that patch so maybe we can try to push fix for this?

-- 
	Ansuel

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

end of thread, other threads:[~2026-06-14  7:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-14  0:14 [PATCH] thermal/drivers/airoha: Fix low trip clamp using wrong variable Wayen.Yan
2026-06-14  7:14 ` Christian Marangi

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