Skip to contentSkip to conversation

hwmon: (k10temp): Check range scale when CUR_TEMP register is read-write

PATCH Applied Babu Moger 2 participants 3 messages Apr 13, 2023 – Apr 17, 2023

Subsystems (2)
lore
Share & tools
lore

Babu Moger

author
#0 lore raw

PATCH 1/1 hwmon: (k10temp): Check range scale when CUR_TEMP register is read-write

From: Babu Moger <[email protected]>

Spec says, when CUR_TEMP_TJ_SEL == 3 and CUR_TEMP_RANGE_SEL == 0, it should use RangeUnadjusted is 0, which is (CurTmp*0.125 -49) C. The CUR_TEMP register is read-write when CUR_TEMP_TJ_SEL == 3 (bit 17-16).

Add the check to detect it.

Sensors command's output before the patch.
$sensors
k10temp-pci-00c3
Adapter: PCI adapter

 Tctl:         +76.6°C <- Wrong value
 Tccd1:        +26.5°C
 Tccd2:        +27.5°C
 Tccd3:        +27.2°C
 Tccd4:        +27.5°C
 Tccd5:        +26.0°C
 Tccd6:        +26.2°C
 Tccd7:        +25.0°C
 Tccd8:        +26.5°C

Sensors command's output after the patch.
$sensors
k10temp-pci-00c3
Adapter: PCI adapter

 Tctl:         +28.8°C <- corrected value
 Tccd1:        +27.5°C
 Tccd2:        +28.5°C
 Tccd3:        +28.5°C
 Tccd4:        +28.5°C
 Tccd5:        +27.0°C
 Tccd6:        +27.5°C
 Tccd7:        +27.0°C
 Tccd8:        +27.5°C
---
 drivers/hwmon/k10temp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/k10temp.c +3 -1
index 5a9d47a229e4..be8bbb1c3a02 100644
@@ -75,6 +75,7 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
 
 #define ZEN_CUR_TEMP_SHIFT			21
 #define ZEN_CUR_TEMP_RANGE_SEL_MASK		BIT(19)
+#define ZEN_CUR_TEMP_TJ_SEL_MASK		GENMASK(17, 16)
 
 struct k10temp_data {
 	struct pci_dev *pdev;
@@ -155,7 +156,8 @@ static long get_raw_temp(struct k10temp_data *data)
 
 	data->read_tempreg(data->pdev, &regval);
 	temp = (regval >> ZEN_CUR_TEMP_SHIFT) * 125;
-	if (regval & data->temp_adjust_mask)
+	if ((regval & data->temp_adjust_mask) ||
+	    (regval & ZEN_CUR_TEMP_TJ_SEL_MASK) == ZEN_CUR_TEMP_TJ_SEL_MASK)
 		temp -= 49000;
 	return temp;
 }
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 36 lines · Babu Moger

From: Babu Moger <[email protected]>

Spec says, when CUR_TEMP_TJ_SEL == 3 and CUR_TEMP_RANGE_SEL == 0, it should use RangeUnadjusted is 0, which is (CurTmp*0.125 -49) C. The CUR_TEMP register is read-write when CUR_TEMP_TJ_SEL == 3 (bit 17-16).

Add the check to detect it.

Sensors command's output before the patch.
$sensors
k10temp-pci-00c3
Adapter: PCI adapter

 Tctl:         +76.6°C <- Wrong value
 Tccd1:        +26.5°C
 Tccd2:        +27.5°C
 Tccd3:        +27.2°C
 Tccd4:        +27.5°C
 Tccd5:        +26.0°C
 Tccd6:        +26.2°C
 Tccd7:        +25.0°C
 Tccd8:        +26.5°C

Sensors command's output after the patch.
$sensors
k10temp-pci-00c3
Adapter: PCI adapter

 Tctl:         +28.8°C <- corrected value
 Tccd1:        +27.5°C
 Tccd2:        +28.5°C
 Tccd3:        +28.5°C
 Tccd4:        +28.5°C
 Tccd5:        +27.0°C
 Tccd6:        +27.5°C
 Tccd7:        +27.0°C
 Tccd8:        +27.5°C
Quoted 1 line

Applied. Please update your e-mail address configuration to avoid the following checkpatch message.

CHECK: From:/Signed-off-by: email comments mismatch: 'From: Babu Moger <[email protected]>' != 'Signed-off-by: Babu Moger <[email protected]>'

Thanks,
Guenter

#2 lore raw
Quoted 37 lines · Guenter Roeck
Quoted 36 lines · Babu Moger

From: Babu Moger <[email protected]>

Spec says, when CUR_TEMP_TJ_SEL == 3 and CUR_TEMP_RANGE_SEL == 0, it should use RangeUnadjusted is 0, which is (CurTmp*0.125 -49) C. The CUR_TEMP register is read-write when CUR_TEMP_TJ_SEL == 3 (bit 17-16).

Add the check to detect it.

Sensors command's output before the patch.
$sensors
k10temp-pci-00c3
Adapter: PCI adapter

 Tctl:         +76.6°C <- Wrong value
 Tccd1:        +26.5°C
 Tccd2:        +27.5°C
 Tccd3:        +27.2°C
 Tccd4:        +27.5°C
 Tccd5:        +26.0°C
 Tccd6:        +26.2°C
 Tccd7:        +25.0°C
 Tccd8:        +26.5°C

Sensors command's output after the patch.
$sensors
k10temp-pci-00c3
Adapter: PCI adapter

 Tctl:         +28.8°C <- corrected value
 Tccd1:        +27.5°C
 Tccd2:        +28.5°C
 Tccd3:        +28.5°C
 Tccd4:        +28.5°C
 Tccd5:        +27.0°C
 Tccd6:        +27.5°C
 Tccd7:        +27.0°C
 Tccd8:        +27.5°C
Quoted 4 lines
Quoted 1 line

Applied. Please update your e-mail address configuration to avoid the following checkpatch message.

Thank you.

Quoted 2 lines

CHECK: From:/Signed-off-by: email comments mismatch: 'From: Babu Moger <[email protected]>' != 'Signed-off-by: Babu Moger <[email protected]>'

Sure. Will update.

Quoted 3 lines

Thanks,
Guenter

Signature · 2 lines
Thanks
Babu Moger