Skip to content

Commit 3b03162

Browse files
committed
hwmon: (k10temp) Use API function to access System Management Network
The SMN (System Management Network) on Family 17h AMD CPUs is also accessed from other drivers, specifically EDAC. Accessing it directly is racy. On top of that, accessing the SMN through root bridge 00:00 is wrong on multi-die CPUs and may result in reading the temperature from the wrong die. Use available API functions to fix the problem. For this to work, add dependency on AMD_NB. Also change the Raven Ridge PCI device ID to point to Data Fabric Function 3, since this ID is used by the API functions to find the CPU node. Cc: [email protected] # v4.16+ Tested-by: Gabriel Craciunescu <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
1 parent f9bc6b2 commit 3b03162

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

drivers/hwmon/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ config SENSORS_K8TEMP
272272

273273
config SENSORS_K10TEMP
274274
tristate "AMD Family 10h+ temperature sensor"
275-
depends on X86 && PCI
275+
depends on X86 && PCI && AMD_NB
276276
help
277277
If you say yes here you get support for the temperature
278278
sensor(s) inside your CPU. Supported are later revisions of

drivers/hwmon/k10temp.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/init.h>
2424
#include <linux/module.h>
2525
#include <linux/pci.h>
26+
#include <asm/amd_nb.h>
2627
#include <asm/processor.h>
2728

2829
MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor");
@@ -40,8 +41,8 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
4041
#define PCI_DEVICE_ID_AMD_17H_DF_F3 0x1463
4142
#endif
4243

43-
#ifndef PCI_DEVICE_ID_AMD_17H_RR_NB
44-
#define PCI_DEVICE_ID_AMD_17H_RR_NB 0x15d0
44+
#ifndef PCI_DEVICE_ID_AMD_17H_M10H_DF_F3
45+
#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F3 0x15eb
4546
#endif
4647

4748
/* CPUID function 0x80000001, ebx */
@@ -136,8 +137,8 @@ static void read_tempreg_nb_f15(struct pci_dev *pdev, u32 *regval)
136137

137138
static void read_tempreg_nb_f17(struct pci_dev *pdev, u32 *regval)
138139
{
139-
amd_nb_index_read(pdev, PCI_DEVFN(0, 0), 0x60,
140-
F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval);
140+
amd_smn_read(amd_pci_dev_to_node_id(pdev),
141+
F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval);
141142
}
142143

143144
static ssize_t temp1_input_show(struct device *dev,
@@ -322,7 +323,7 @@ static const struct pci_device_id k10temp_id_table[] = {
322323
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
323324
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
324325
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
325-
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_RR_NB) },
326+
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F3) },
326327
{}
327328
};
328329
MODULE_DEVICE_TABLE(pci, k10temp_id_table);

0 commit comments

Comments
 (0)