public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] hwmon: (peci/cputemp) Fix crit_hyst returning delta instead of absolute temperature
       [not found] <20260323002352.93417-1-sanman.pradhan@hpe.com>
@ 2026-03-23  0:24 ` Pradhan, Sanman
  2026-03-23  1:40   ` Guenter Roeck
  2026-03-23  0:24 ` [PATCH 2/2] hwmon: (peci/cputemp) Fix off-by-one in cputemp_is_visible() Pradhan, Sanman
  1 sibling, 1 reply; 4+ messages in thread
From: Pradhan, Sanman @ 2026-03-23  0:24 UTC (permalink / raw)
  To: linux-hwmon@vger.kernel.org
  Cc: linux@roeck-us.net, iwona.winiarska@intel.com, corbet@lwn.net,
	linux-kernel@vger.kernel.org, Sanman Pradhan,
	stable@vger.kernel.org

From: Sanman Pradhan <psanman@juniper.net>

The hwmon sysfs ABI expects tempN_crit_hyst to report the temperature at
which the critical condition clears, not the hysteresis delta from the
critical limit.

The peci cputemp driver currently returns tjmax - tcontrol for
crit_hyst_type, which is the hysteresis margin rather than the
corresponding absolute temperature.

Return tcontrol directly, and update the documentation accordingly.

Fixes: bf3608f338e9 ("hwmon: peci: Add cputemp driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sanman Pradhan <psanman@juniper.net>
---
 Documentation/hwmon/peci-cputemp.rst | 10 ++++++----
 drivers/hwmon/peci/cputemp.c         |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Documentation/hwmon/peci-cputemp.rst b/Documentation/hwmon/peci-cputemp.rst
index fe0422248dc5e..266b62a46f49c 100644
--- a/Documentation/hwmon/peci-cputemp.rst
+++ b/Documentation/hwmon/peci-cputemp.rst
@@ -51,8 +51,9 @@ temp1_max		Provides thermal control temperature of the CPU package
 temp1_crit		Provides shutdown temperature of the CPU package which
 			is also known as the maximum processor junction
 			temperature, Tjmax or Tprochot.
-temp1_crit_hyst		Provides the hysteresis value from Tcontrol to Tjmax of
-			the CPU package.
+temp1_crit_hyst		Provides the hysteresis temperature of the CPU
+			package. Returns Tcontrol, the temperature at which
+			the critical condition clears.
 
 temp2_label		"DTS"
 temp2_input		Provides current temperature of the CPU package scaled
@@ -62,8 +63,9 @@ temp2_max		Provides thermal control temperature of the CPU package
 temp2_crit		Provides shutdown temperature of the CPU package which
 			is also known as the maximum processor junction
 			temperature, Tjmax or Tprochot.
-temp2_crit_hyst		Provides the hysteresis value from Tcontrol to Tjmax of
-			the CPU package.
+temp2_crit_hyst		Provides the hysteresis temperature of the CPU
+			package. Returns Tcontrol, the temperature at which
+			the critical condition clears.
 
 temp3_label		"Tcontrol"
 temp3_input		Provides current Tcontrol temperature of the CPU
diff --git a/drivers/hwmon/peci/cputemp.c b/drivers/hwmon/peci/cputemp.c
index b2fc936851e14..badec53ff4461 100644
--- a/drivers/hwmon/peci/cputemp.c
+++ b/drivers/hwmon/peci/cputemp.c
@@ -131,7 +131,7 @@ static int get_temp_target(struct peci_cputemp *priv, enum peci_temp_target_type
 		*val = priv->temp.target.tjmax;
 		break;
 	case crit_hyst_type:
-		*val = priv->temp.target.tjmax - priv->temp.target.tcontrol;
+		*val = priv->temp.target.tcontrol;
 		break;
 	default:
 		ret = -EOPNOTSUPP;
-- 
2.34.1


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

* [PATCH 2/2] hwmon: (peci/cputemp) Fix off-by-one in cputemp_is_visible()
       [not found] <20260323002352.93417-1-sanman.pradhan@hpe.com>
  2026-03-23  0:24 ` [PATCH 1/2] hwmon: (peci/cputemp) Fix crit_hyst returning delta instead of absolute temperature Pradhan, Sanman
@ 2026-03-23  0:24 ` Pradhan, Sanman
  2026-03-23  1:40   ` Guenter Roeck
  1 sibling, 1 reply; 4+ messages in thread
From: Pradhan, Sanman @ 2026-03-23  0:24 UTC (permalink / raw)
  To: linux-hwmon@vger.kernel.org
  Cc: linux@roeck-us.net, iwona.winiarska@intel.com, corbet@lwn.net,
	linux-kernel@vger.kernel.org, Sanman Pradhan,
	stable@vger.kernel.org

From: Sanman Pradhan <psanman@juniper.net>

cputemp_is_visible() validates the channel index against
CPUTEMP_CHANNEL_NUMS, but currently uses '>' instead of '>='.
As a result, channel == CPUTEMP_CHANNEL_NUMS is not rejected even though
valid indices are 0 .. CPUTEMP_CHANNEL_NUMS - 1.

Fix the bounds check by using '>=' so invalid channel indices are
rejected before indexing the core bitmap.

Fixes: bf3608f338e9 ("hwmon: peci: Add cputemp driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sanman Pradhan <psanman@juniper.net>
---
 drivers/hwmon/peci/cputemp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/peci/cputemp.c b/drivers/hwmon/peci/cputemp.c
index badec53ff4461..457089c561b40 100644
--- a/drivers/hwmon/peci/cputemp.c
+++ b/drivers/hwmon/peci/cputemp.c
@@ -319,7 +319,7 @@ static umode_t cputemp_is_visible(const void *data, enum hwmon_sensor_types type
 {
 	const struct peci_cputemp *priv = data;
 
-	if (channel > CPUTEMP_CHANNEL_NUMS)
+	if (channel >= CPUTEMP_CHANNEL_NUMS)
 		return 0;
 
 	if (channel < channel_core)
-- 
2.34.1


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

* Re: [PATCH 1/2] hwmon: (peci/cputemp) Fix crit_hyst returning delta instead of absolute temperature
  2026-03-23  0:24 ` [PATCH 1/2] hwmon: (peci/cputemp) Fix crit_hyst returning delta instead of absolute temperature Pradhan, Sanman
@ 2026-03-23  1:40   ` Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2026-03-23  1:40 UTC (permalink / raw)
  To: Pradhan, Sanman
  Cc: linux-hwmon@vger.kernel.org, iwona.winiarska@intel.com,
	corbet@lwn.net, linux-kernel@vger.kernel.org, Sanman Pradhan,
	stable@vger.kernel.org

On Mon, Mar 23, 2026 at 12:24:25AM +0000, Pradhan, Sanman wrote:
> From: Sanman Pradhan <psanman@juniper.net>
> 
> The hwmon sysfs ABI expects tempN_crit_hyst to report the temperature at
> which the critical condition clears, not the hysteresis delta from the
> critical limit.
> 
> The peci cputemp driver currently returns tjmax - tcontrol for
> crit_hyst_type, which is the hysteresis margin rather than the
> corresponding absolute temperature.
> 
> Return tcontrol directly, and update the documentation accordingly.
> 
> Fixes: bf3608f338e9 ("hwmon: peci: Add cputemp driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Sanman Pradhan <psanman@juniper.net>

Applied.

Thanks,
Guenter

> ---
>  Documentation/hwmon/peci-cputemp.rst | 10 ++++++----
>  drivers/hwmon/peci/cputemp.c         |  2 +-
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/hwmon/peci-cputemp.rst b/Documentation/hwmon/peci-cputemp.rst
> index fe0422248dc5e..266b62a46f49c 100644
> --- a/Documentation/hwmon/peci-cputemp.rst
> +++ b/Documentation/hwmon/peci-cputemp.rst
> @@ -51,8 +51,9 @@ temp1_max		Provides thermal control temperature of the CPU package
>  temp1_crit		Provides shutdown temperature of the CPU package which
>  			is also known as the maximum processor junction
>  			temperature, Tjmax or Tprochot.
> -temp1_crit_hyst		Provides the hysteresis value from Tcontrol to Tjmax of
> -			the CPU package.
> +temp1_crit_hyst		Provides the hysteresis temperature of the CPU
> +			package. Returns Tcontrol, the temperature at which
> +			the critical condition clears.
>  
>  temp2_label		"DTS"
>  temp2_input		Provides current temperature of the CPU package scaled
> @@ -62,8 +63,9 @@ temp2_max		Provides thermal control temperature of the CPU package
>  temp2_crit		Provides shutdown temperature of the CPU package which
>  			is also known as the maximum processor junction
>  			temperature, Tjmax or Tprochot.
> -temp2_crit_hyst		Provides the hysteresis value from Tcontrol to Tjmax of
> -			the CPU package.
> +temp2_crit_hyst		Provides the hysteresis temperature of the CPU
> +			package. Returns Tcontrol, the temperature at which
> +			the critical condition clears.
>  
>  temp3_label		"Tcontrol"
>  temp3_input		Provides current Tcontrol temperature of the CPU
> diff --git a/drivers/hwmon/peci/cputemp.c b/drivers/hwmon/peci/cputemp.c
> index b2fc936851e14..badec53ff4461 100644
> --- a/drivers/hwmon/peci/cputemp.c
> +++ b/drivers/hwmon/peci/cputemp.c
> @@ -131,7 +131,7 @@ static int get_temp_target(struct peci_cputemp *priv, enum peci_temp_target_type
>  		*val = priv->temp.target.tjmax;
>  		break;
>  	case crit_hyst_type:
> -		*val = priv->temp.target.tjmax - priv->temp.target.tcontrol;
> +		*val = priv->temp.target.tcontrol;
>  		break;
>  	default:
>  		ret = -EOPNOTSUPP;

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

* Re: [PATCH 2/2] hwmon: (peci/cputemp) Fix off-by-one in cputemp_is_visible()
  2026-03-23  0:24 ` [PATCH 2/2] hwmon: (peci/cputemp) Fix off-by-one in cputemp_is_visible() Pradhan, Sanman
@ 2026-03-23  1:40   ` Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2026-03-23  1:40 UTC (permalink / raw)
  To: Pradhan, Sanman
  Cc: linux-hwmon@vger.kernel.org, iwona.winiarska@intel.com,
	corbet@lwn.net, linux-kernel@vger.kernel.org, Sanman Pradhan,
	stable@vger.kernel.org

On Mon, Mar 23, 2026 at 12:24:37AM +0000, Pradhan, Sanman wrote:
> From: Sanman Pradhan <psanman@juniper.net>
> 
> cputemp_is_visible() validates the channel index against
> CPUTEMP_CHANNEL_NUMS, but currently uses '>' instead of '>='.
> As a result, channel == CPUTEMP_CHANNEL_NUMS is not rejected even though
> valid indices are 0 .. CPUTEMP_CHANNEL_NUMS - 1.
> 
> Fix the bounds check by using '>=' so invalid channel indices are
> rejected before indexing the core bitmap.
> 
> Fixes: bf3608f338e9 ("hwmon: peci: Add cputemp driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Sanman Pradhan <psanman@juniper.net>

Applied.

Thanks,
Guenter

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

end of thread, other threads:[~2026-03-23  1:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260323002352.93417-1-sanman.pradhan@hpe.com>
2026-03-23  0:24 ` [PATCH 1/2] hwmon: (peci/cputemp) Fix crit_hyst returning delta instead of absolute temperature Pradhan, Sanman
2026-03-23  1:40   ` Guenter Roeck
2026-03-23  0:24 ` [PATCH 2/2] hwmon: (peci/cputemp) Fix off-by-one in cputemp_is_visible() Pradhan, Sanman
2026-03-23  1:40   ` Guenter Roeck

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