diff mbox series

[v2,3/3] hwmon: (coretemp) Extend the bitmask to read temperature to 0xff

Message ID 20240425171311.19519-4-ricardo.neri-calderon@linux.intel.com (mailing list archive)
State Accepted
Headers show
Series drivers: thermal/hwmon: intel: Use model-specific bitmasks for temperature registers | expand

Commit Message

Ricardo Neri April 25, 2024, 5:13 p.m. UTC
The Intel Software Development manual defines the temperature digital
readout as the bits [22:16] of the IA32_[PACKAGE]_THERM_STATUS registers.
Bit 23 is specified as reserved.

In recent processors, however, the temperature digital readout uses bits
[23:16]. In those processors, using the bitmask 0x7f would lead to
incorrect readings if the temperature deviates from TjMax by more than
127 degrees Celsius.

Although not guaranteed, bit 23 is likely to be 0 in processors from a few
generations ago. The temperature reading would still be correct in those
processors when using a 0xff bitmask.

Model-specific provisions can be made for older processors in which bit 23
is not 0 should the need arise.

Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Lukasz Luba <lukasz.luba@arm.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: linux-hwmon@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org # v6.7+
---
Changes since v1:
 * Corrected wrong sentence in commit message. (Rui)
 * Removed dependency on INTEL_TCC. (Guenter)
---
 drivers/hwmon/coretemp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Guenter Roeck April 28, 2024, 5:01 p.m. UTC | #1
On Thu, Apr 25, 2024 at 10:13:11AM -0700, Ricardo Neri wrote:
> The Intel Software Development manual defines the temperature digital
> readout as the bits [22:16] of the IA32_[PACKAGE]_THERM_STATUS registers.
> Bit 23 is specified as reserved.
> 
> In recent processors, however, the temperature digital readout uses bits
> [23:16]. In those processors, using the bitmask 0x7f would lead to
> incorrect readings if the temperature deviates from TjMax by more than
> 127 degrees Celsius.
> 
> Although not guaranteed, bit 23 is likely to be 0 in processors from a few
> generations ago. The temperature reading would still be correct in those
> processors when using a 0xff bitmask.
> 
> Model-specific provisions can be made for older processors in which bit 23
> is not 0 should the need arise.
> 
> Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>

Applied.

Thanks,
Guenter
diff mbox series

Patch

diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 616bd1a5b864..1b9203b20d70 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -411,7 +411,7 @@  static ssize_t show_temp(struct device *dev,
 		 * Return it instead of reporting an error which doesn't
 		 * really help at all.
 		 */
-		tdata->temp = tjmax - ((eax >> 16) & 0x7f) * 1000;
+		tdata->temp = tjmax - ((eax >> 16) & 0xff) * 1000;
 		tdata->last_updated = jiffies;
 	}