[SRU][N][PATCH 3/3] hwmon: (coretemp) Extend the bitmask to read temperature to 0xff

Thibault Ferrante thibault.ferrante at canonical.com
Mon Mar 17 15:52:07 UTC 2025


From: Ricardo Neri <ricardo.neri-calderon at linux.intel.com>

BugLink: https://bugs.launchpad.net/bugs/2103427

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 at linux.intel.com>
Link: https://lore.kernel.org/r/20240425171311.19519-4-ricardo.neri-calderon@linux.intel.com
Signed-off-by: Guenter Roeck <linux at roeck-us.net>
(cherry picked from commit f0c344c000d09e38a0240b4a6ccbcd553b18e762)
Signed-off-by: Thibault Ferrante <thibault.ferrante at canonical.com>
---
 drivers/hwmon/coretemp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 30402de2c889..db2ee5a85f12 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;
 	}
 
-- 
2.45.2




More information about the kernel-team mailing list