Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (k10temp) Rework the temperature offset calculation

Some of the existing assumptions made do not scale properly
to new silicon in upcoming changes. This commit should cause
no functional changes to existing silicon.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20210827201527.24454-2-mario.limonciello@amd.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Mario Limonciello and committed by
Guenter Roeck
0e3f52bb 02a2484c

+12 -6
+12 -6
drivers/hwmon/k10temp.c
··· 65 65 #define F15H_M60H_HARDWARE_TEMP_CTRL_OFFSET 0xd8200c64 66 66 #define F15H_M60H_REPORTED_TEMP_CTRL_OFFSET 0xd8200ca4 67 67 68 - /* Common for Zen CPU families (Family 17h and 18h) */ 69 - #define ZEN_REPORTED_TEMP_CTRL_OFFSET 0x00059800 68 + /* Common for Zen CPU families (Family 17h and 18h and 19h) */ 69 + #define ZEN_REPORTED_TEMP_CTRL_BASE 0x00059800 70 70 71 - #define ZEN_CCD_TEMP(x) (0x00059954 + ((x) * 4)) 71 + #define ZEN_CCD_TEMP(offset, x) (ZEN_REPORTED_TEMP_CTRL_BASE + \ 72 + (offset) + ((x) * 4)) 72 73 #define ZEN_CCD_TEMP_VALID BIT(11) 73 74 #define ZEN_CCD_TEMP_MASK GENMASK(10, 0) 74 75 ··· 104 103 u32 temp_adjust_mask; 105 104 u32 show_temp; 106 105 bool is_zen; 106 + u32 ccd_offset; 107 107 }; 108 108 109 109 #define TCTL_BIT 0 ··· 165 163 static void read_tempreg_nb_zen(struct pci_dev *pdev, u32 *regval) 166 164 { 167 165 amd_smn_read(amd_pci_dev_to_node_id(pdev), 168 - ZEN_REPORTED_TEMP_CTRL_OFFSET, regval); 166 + ZEN_REPORTED_TEMP_CTRL_BASE, regval); 169 167 } 170 168 171 169 static long get_raw_temp(struct k10temp_data *data) ··· 228 226 break; 229 227 case 2 ... 9: /* Tccd{1-8} */ 230 228 amd_smn_read(amd_pci_dev_to_node_id(data->pdev), 231 - ZEN_CCD_TEMP(channel - 2), &regval); 229 + ZEN_CCD_TEMP(data->ccd_offset, channel - 2), 230 + &regval); 232 231 *val = (regval & ZEN_CCD_TEMP_MASK) * 125 - 49000; 233 232 break; 234 233 default: ··· 390 387 391 388 for (i = 0; i < limit; i++) { 392 389 amd_smn_read(amd_pci_dev_to_node_id(pdev), 393 - ZEN_CCD_TEMP(i), &regval); 390 + ZEN_CCD_TEMP(data->ccd_offset, i), &regval); 394 391 if (regval & ZEN_CCD_TEMP_VALID) 395 392 data->show_temp |= BIT(TCCD_BIT(i)); 396 393 } ··· 436 433 case 0x8: /* Zen+ */ 437 434 case 0x11: /* Zen APU */ 438 435 case 0x18: /* Zen+ APU */ 436 + data->ccd_offset = 0x154; 439 437 k10temp_get_ccd_support(pdev, data, 4); 440 438 break; 441 439 case 0x31: /* Zen2 Threadripper */ 442 440 case 0x60: /* Renoir */ 443 441 case 0x68: /* Lucienne */ 444 442 case 0x71: /* Zen2 */ 443 + data->ccd_offset = 0x154; 445 444 k10temp_get_ccd_support(pdev, data, 8); 446 445 break; 447 446 } ··· 456 451 case 0x0 ... 0x1: /* Zen3 SP3/TR */ 457 452 case 0x21: /* Zen3 Ryzen Desktop */ 458 453 case 0x50 ... 0x5f: /* Green Sardine */ 454 + data->ccd_offset = 0x154; 459 455 k10temp_get_ccd_support(pdev, data, 8); 460 456 break; 461 457 }