Skip to content

Commit f763c0c

Browse files
committed
hwmon: (k10temp) Define a helper function to read CCD temperature
JIRA: https://issues.redhat.com/browse/RHEL-104300 commit cc66126 Author: Yazen Ghannam <yazen.ghannam@amd.com> Date: Thu Jun 6 11:12:58 2024 -0500 hwmon: (k10temp) Define a helper function to read CCD temperature The CCD temperature register is read in two places. These reads are done using an AMD SMN access, and a number of parameters are needed for the operation. Move the SMN access and parameter gathering into a helper function in order to simplify the code flow. This also has a benefit of centralizing the hardware register access in a single place in case fixes or special decoding is required. Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Acked-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20240606-fix-smn-bad-read-v4-5-ffde21931c3f@amd.com Signed-off-by: David Arcari <darcari@redhat.com>
1 parent 08ecf51 commit f763c0c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/hwmon/k10temp.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ static void read_tempreg_nb_zen(struct pci_dev *pdev, u32 *regval)
163163
*regval = 0;
164164
}
165165

166+
static int read_ccd_temp_reg(struct k10temp_data *data, int ccd, u32 *regval)
167+
{
168+
u16 node_id = amd_pci_dev_to_node_id(data->pdev);
169+
170+
return amd_smn_read(node_id, ZEN_CCD_TEMP(data->ccd_offset, ccd), regval);
171+
}
172+
166173
static long get_raw_temp(struct k10temp_data *data)
167174
{
168175
u32 regval;
@@ -228,9 +235,7 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel,
228235
*val = 0;
229236
break;
230237
case 2 ... 13: /* Tccd{1-12} */
231-
ret = amd_smn_read(amd_pci_dev_to_node_id(data->pdev),
232-
ZEN_CCD_TEMP(data->ccd_offset, channel - 2),
233-
&regval);
238+
ret = read_ccd_temp_reg(data, channel - 2, &regval);
234239

235240
if (ret)
236241
return ret;
@@ -402,8 +407,7 @@ static void k10temp_get_ccd_support(struct pci_dev *pdev,
402407
* the register value. And this will incorrectly pass the TEMP_VALID
403408
* bit check.
404409
*/
405-
if (amd_smn_read(amd_pci_dev_to_node_id(pdev),
406-
ZEN_CCD_TEMP(data->ccd_offset, i), &regval))
410+
if (read_ccd_temp_reg(data, i, &regval))
407411
continue;
408412

409413
if (regval & ZEN_CCD_TEMP_VALID)

0 commit comments

Comments
 (0)