Skip to contentSkip to conversation

x86/amd_nb: Add support for Raven Ridge CPUs

PATCH Superseded Guenter Roeck 4 participants 12 messages Apr 29, 2018 – Apr 30, 2018

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/2 x86/amd_nb: Add support for Raven Ridge CPUs

Add Raven Ridge root bridge and data fabric PCI IDs. This is required for amd_pci_dev_to_node_id() and amd_smn_read().

---
This patch is a prerequisite for the second patch in the series. I'll be happy to apply both patches through hwmon if that is acceptable (and Cc: stable for 4.16+). If not, I'll be happy to wait for this patch to be available upstream.

Since that there is no public documentation available for Raven Ridge, PCI IDs are derived from output of lspci.

 arch/x86/kernel/amd_nb.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/kernel/amd_nb.c +6 -0
index c88e0b127810..bd33613ecb7c 100644
@@ -14,8 +14,11 @@
 #include <asm/amd_nb.h>
 
 #define PCI_DEVICE_ID_AMD_17H_ROOT	0x1450
+#define PCI_DEVICE_ID_AMD_17H_RR_ROOT	0x15d0
 #define PCI_DEVICE_ID_AMD_17H_DF_F3	0x1463
 #define PCI_DEVICE_ID_AMD_17H_DF_F4	0x1464
+#define PCI_DEVICE_ID_AMD_17H_RR_DF_F3	0x15eb
+#define PCI_DEVICE_ID_AMD_17H_RR_DF_F4	0x15ec
 
 /* Protect the PCI config register pairs used for SMN and DF indirect access. */
 static DEFINE_MUTEX(smn_mutex);
@@ -24,6 +27,7 @@ static u32 *flush_words;
 
 static const struct pci_device_id amd_root_ids[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_ROOT) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_RR_ROOT) },
 	{}
 };
 
@@ -39,6 +43,7 @@ const struct pci_device_id amd_nb_misc_ids[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_RR_DF_F3) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) },
 	{}
 };
@@ -51,6 +56,7 @@ static const struct pci_device_id amd_nb_link_ids[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F4) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_RR_DF_F4) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F4) },
 	{}
 };
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH 2/2 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, 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.

---
 drivers/hwmon/k10temp.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/hwmon/k10temp.c +6 -5
index b06bb1f90853..00e785afae0d 100644
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <asm/amd_nb.h>
 #include <asm/processor.h>
 
 MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor");
@@ -40,8 +41,8 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
 #define PCI_DEVICE_ID_AMD_17H_DF_F3	0x1463
 #endif
 
-#ifndef PCI_DEVICE_ID_AMD_17H_RR_NB
-#define PCI_DEVICE_ID_AMD_17H_RR_NB	0x15d0
+#ifndef PCI_DEVICE_ID_AMD_17H_RR_DF_F3
+#define PCI_DEVICE_ID_AMD_17H_RR_DF_F3	0x14eb
 #endif
 
 /* CPUID function 0x80000001, ebx */
@@ -136,8 +137,8 @@ static void read_tempreg_nb_f15(struct pci_dev *pdev, u32 *regval)
 
 static void read_tempreg_nb_f17(struct pci_dev *pdev, u32 *regval)
 {
-	amd_nb_index_read(pdev, PCI_DEVFN(0, 0), 0x60,
-			  F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval);
+	amd_smn_read(amd_pci_dev_to_node_id(pdev),
+		     F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval);
 }
 
 static ssize_t temp1_input_show(struct device *dev,
@@ -323,7 +324,7 @@ static const struct pci_device_id k10temp_id_table[] = {
 	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
 	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
 	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
-	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_RR_NB) },
+	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_RR_DF_F3) },
 	{}
 };
 MODULE_DEVICE_TABLE(pci, k10temp_id_table);
Signature · 1 line
2.7.4
Tested-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] hwmon: (k10temp) Use API function to access System Management Network

2018-04-29 3:54 GMT+02:00 Guenter Roeck <[email protected]>:

Quoted 59 lines

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, 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.

---
 drivers/hwmon/k10temp.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/hwmon/k10temp.c +6 -6
index b06bb1f90853..00e785afae0d 100644
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <asm/amd_nb.h>
 #include <asm/processor.h>
 
 MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor");
@@ -40,8 +41,8 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
 #define PCI_DEVICE_ID_AMD_17H_DF_F3    0x1463
 #endif
 
-#ifndef PCI_DEVICE_ID_AMD_17H_RR_NB
-#define PCI_DEVICE_ID_AMD_17H_RR_NB    0x15d0
+#ifndef PCI_DEVICE_ID_AMD_17H_RR_DF_F3
+#define PCI_DEVICE_ID_AMD_17H_RR_DF_F3 0x14eb
 #endif
 
 /* CPUID function 0x80000001, ebx */
@@ -136,8 +137,8 @@ static void read_tempreg_nb_f15(struct pci_dev *pdev, u32 *regval)
 
 static void read_tempreg_nb_f17(struct pci_dev *pdev, u32 *regval)
 {
-       amd_nb_index_read(pdev, PCI_DEVFN(0, 0), 0x60,
-                         F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval);
+       amd_smn_read(amd_pci_dev_to_node_id(pdev),
+                    F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval);
 }
 
 static ssize_t temp1_input_show(struct device *dev,
@@ -323,7 +324,7 @@ static const struct pci_device_id k10temp_id_table[] = {
        { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
        { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
        { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
-       { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_RR_NB) },
+       { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_RR_DF_F3) },
        {}
 };
 MODULE_DEVICE_TABLE(pci, k10temp_id_table);
--
Quoted 2 lines

2.7.4

Works fine for me on top stable and on top v4.17-rc2-398-gcdface520934

Regards

author maintainer
#3 lore raw

Re: [PATCH 2/2] hwmon: (k10temp) Use API function to access System Management Network

In reply to Guenter Roeck
Quoted 28 lines · Guenter Roeck

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, 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.

---
  drivers/hwmon/k10temp.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)
drivers/hwmon/k10temp.c +1 -0
index b06bb1f90853..00e785afae0d 100644
@@ -23,6 +23,7 @@
  #include <linux/init.h>
  #include <linux/module.h>
  #include <linux/pci.h>
+#include <asm/amd_nb.h>
  #include <asm/processor.h>
 
  MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor");

drivers/hwmon/k10temp.c static DEFINE_MUTEX(nb_smu_ind_mutex); · line 45

Quoted 7 lines
drivers/hwmon/k10temp.c +2 -2
@@ -40,8 +41,8 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
  #define PCI_DEVICE_ID_AMD_17H_DF_F3	0x1463
  #endif
 
-#ifndef PCI_DEVICE_ID_AMD_17H_RR_NB
-#define PCI_DEVICE_ID_AMD_17H_RR_NB	0x15d0
+#ifndef PCI_DEVICE_ID_AMD_17H_RR_DF_F3
+#define PCI_DEVICE_ID_AMD_17H_RR_DF_F3	0x14eb

This should have been 0x15eb. I'll resend after a week or so, waiting for more feedback.

Guenter

Quoted 24 lines
drivers/hwmon/k10temp.c +3 -3
  #endif
 
  /* CPUID function 0x80000001, ebx */
@@ -136,8 +137,8 @@ static void read_tempreg_nb_f15(struct pci_dev *pdev, u32 *regval)
 
  static void read_tempreg_nb_f17(struct pci_dev *pdev, u32 *regval)
  {
-	amd_nb_index_read(pdev, PCI_DEVFN(0, 0), 0x60,
-			  F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval);
+	amd_smn_read(amd_pci_dev_to_node_id(pdev),
+		     F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval);
  }
 
  static ssize_t temp1_input_show(struct device *dev,
@@ -323,7 +324,7 @@ static const struct pci_device_id k10temp_id_table[] = {
  	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
  	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
  	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
-	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_RR_NB) },
+	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_RR_DF_F3) },
  	{}
  };
  MODULE_DEVICE_TABLE(pci, k10temp_id_table);
#4 lore raw

Re: [PATCH 2/2] hwmon: (k10temp) Use API function to access System Management Network

2018-04-29 19:46 GMT+02:00 Guenter Roeck <[email protected]>:

Quoted 32 lines · Guenter Roeck
Quoted 31 lines

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, 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.

---
  drivers/hwmon/k10temp.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)
drivers/hwmon/k10temp.c +1 -0
index b06bb1f90853..00e785afae0d 100644
@@ -23,6 +23,7 @@
  #include <linux/init.h>
  #include <linux/module.h>
  #include <linux/pci.h>
+#include <asm/amd_nb.h>
  #include <asm/processor.h>
    MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor");
@@ -40,8 +41,8 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
  #define PCI_DEVICE_ID_AMD_17H_DF_F3   0x1463
  #endif
Quoted 8 lines

drivers/hwmon/k10temp.c static DEFINE_MUTEX(nb_smu_ind_mutex); · line 45

Quoted 4 lines
drivers/hwmon/k10temp.c +2 -1
  -#ifndef PCI_DEVICE_ID_AMD_17H_RR_NB
-#define PCI_DEVICE_ID_AMD_17H_RR_NB    0x15d0
+#ifndef PCI_DEVICE_ID_AMD_17H_RR_DF_F3
+#define PCI_DEVICE_ID_AMD_17H_RR_DF_F3 0x14eb

This should have been 0x15eb. I'll resend after a week or so, waiting for more feedback.

re-tested with that too .. Doesn't seems to matter here ..

with original patch:

crazy@ant:~/Work/Linux/linux$ sensors
k10temp-pci-00f3
Adapter: PCI adapter
Tdie:         +22.2°C  (high = +70.0°C)
Tctl:         +22.2°C

k10temp-pci-00e3

Adapter: PCI adapter
Tdie:         +23.8°C  (high = +70.0°C)
Tctl:         +23.8°C

k10temp-pci-00d3

Adapter: PCI adapter
Tdie:         +23.0°C  (high = +70.0°C)
Tctl:         +23.0°C

k10temp-pci-00c3

Adapter: PCI adapter
Tdie:         +25.0°C  (high = +70.0°C)
Tctl:         +25.0°C

k10temp-pci-00fb

Adapter: PCI adapter
Tdie:         +22.8°C  (high = +70.0°C)
Tctl:         +22.8°C

k10temp-pci-00eb

Adapter: PCI adapter
Tdie:         +23.2°C  (high = +70.0°C)
Tctl:         +23.2°C

k10temp-pci-00db

Adapter: PCI adapter
Tdie:         +22.8°C  (high = +70.0°C)
Tctl:         +22.8°C

k10temp-pci-00cb

Adapter: PCI adapter
Tdie:         +22.6°C  (high = +70.0°C)
Tctl:         +22.6°C

now with 0x15eb

crazy@ant:~/Work/Linux/linux$ sudo rmmod k10temp
crazy@ant:~/Work/Linux/linux$ git grep -w PCI_DEVICE_ID_AMD_17H_RR_DF_F3
arch/x86/kernel/amd_nb.c:#define PCI_DEVICE_ID_AMD_17H_RR_DF_F3 0x15eb
arch/x86/kernel/amd_nb.c:       { PCI_DEVICE(PCI_VENDOR_ID_AMD,
PCI_DEVICE_ID_AMD_17H_RR_DF_F3) },
drivers/hwmon/k10temp.c:#ifndef PCI_DEVICE_ID_AMD_17H_RR_DF_F3
drivers/hwmon/k10temp.c:#define PCI_DEVICE_ID_AMD_17H_RR_DF_F3  0x15eb
drivers/hwmon/k10temp.c:        { PCI_VDEVICE(AMD,
PCI_DEVICE_ID_AMD_17H_RR_DF_F3) },
crazy@ant:~/Work/Linux/linux$ sudo insmod ./drivers/hwmon/k10temp.ko
crazy@ant:~/Work/Linux/linux$ sensors
k10temp-pci-00f3
Adapter: PCI adapter
Tdie:         +22.2°C  (high = +70.0°C)
Tctl:         +22.2°C

k10temp-pci-00e3

Adapter: PCI adapter
Tdie:         +23.8°C  (high = +70.0°C)
Tctl:         +23.8°C

k10temp-pci-00d3

Adapter: PCI adapter
Tdie:         +23.0°C  (high = +70.0°C)
Tctl:         +23.0°C

k10temp-pci-00c3

Adapter: PCI adapter
Tdie:         +25.0°C  (high = +70.0°C)
Tctl:         +25.0°C

k10temp-pci-00fb

Adapter: PCI adapter
Tdie:         +22.9°C  (high = +70.0°C)
Tctl:         +22.9°C

k10temp-pci-00eb

Adapter: PCI adapter
Tdie:         +23.2°C  (high = +70.0°C)
Tctl:         +23.2°C

k10temp-pci-00db

Adapter: PCI adapter
Tdie:         +22.8°C  (high = +70.0°C)
Tctl:         +22.8°C

k10temp-pci-00cb

Adapter: PCI adapter
Tdie:         +22.8°C  (high = +70.0°C)
Tctl:         +22.8°C
Quoted 25 lines
Quoted 24 lines
drivers/hwmon/k10temp.c +3 -3
  #endif
    /* CPUID function 0x80000001, ebx */
@@ -136,8 +137,8 @@ static void read_tempreg_nb_f15(struct pci_dev *pdev,
 u32 *regval)
    static void read_tempreg_nb_f17(struct pci_dev *pdev, u32 *regval)
  {
-       amd_nb_index_read(pdev, PCI_DEVFN(0, 0), 0x60,
-                         F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval);
+       amd_smn_read(amd_pci_dev_to_node_id(pdev),
+                    F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval);
  }
    static ssize_t temp1_input_show(struct device *dev,
@@ -323,7 +324,7 @@ static const struct pci_device_id k10temp_id_table[] =
 {
        { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
        { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
        { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
-       { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_RR_NB) },
+       { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_RR_DF_F3) },
        {}
  };
  MODULE_DEVICE_TABLE(pci, k10temp_id_table);
author maintainer
#5 lore raw

Re: [PATCH 2/2] hwmon: (k10temp) Use API function to access System Management Network

Quoted 43 lines · Gabriel C

2018-04-29 19:46 GMT+02:00 Guenter Roeck <[email protected]>:

Quoted 32 lines · Guenter Roeck
Quoted 31 lines

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, 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.

---
   drivers/hwmon/k10temp.c | 11 ++++++-----
   1 file changed, 6 insertions(+), 5 deletions(-)
drivers/hwmon/k10temp.c +1 -0
index b06bb1f90853..00e785afae0d 100644
@@ -23,6 +23,7 @@
   #include <linux/init.h>
   #include <linux/module.h>
   #include <linux/pci.h>
+#include <asm/amd_nb.h>
   #include <asm/processor.h>
     MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor");
@@ -40,8 +41,8 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
   #define PCI_DEVICE_ID_AMD_17H_DF_F3   0x1463
   #endif
Quoted 8 lines

drivers/hwmon/k10temp.c static DEFINE_MUTEX(nb_smu_ind_mutex); · line 45

Quoted 4 lines
drivers/hwmon/k10temp.c +2 -1
   -#ifndef PCI_DEVICE_ID_AMD_17H_RR_NB
-#define PCI_DEVICE_ID_AMD_17H_RR_NB    0x15d0
+#ifndef PCI_DEVICE_ID_AMD_17H_RR_DF_F3
+#define PCI_DEVICE_ID_AMD_17H_RR_DF_F3 0x14eb

This should have been 0x15eb. I'll resend after a week or so, waiting for more feedback.

Quoted 2 lines

re-tested with that too .. Doesn't seems to matter here ..

Yes, that only matters for Raven Ridge CPUs (eg 2200G, 2400G).

Thanks,
Guenter

Quoted 123 lines

with original patch:

crazy@ant:~/Work/Linux/linux$ sensors
k10temp-pci-00f3
Adapter: PCI adapter
Tdie:         +22.2°C  (high = +70.0°C)
Tctl:         +22.2°C

k10temp-pci-00e3

Adapter: PCI adapter
Tdie:         +23.8°C  (high = +70.0°C)
Tctl:         +23.8°C

k10temp-pci-00d3

Adapter: PCI adapter
Tdie:         +23.0°C  (high = +70.0°C)
Tctl:         +23.0°C

k10temp-pci-00c3

Adapter: PCI adapter
Tdie:         +25.0°C  (high = +70.0°C)
Tctl:         +25.0°C

k10temp-pci-00fb

Adapter: PCI adapter
Tdie:         +22.8°C  (high = +70.0°C)
Tctl:         +22.8°C

k10temp-pci-00eb

Adapter: PCI adapter
Tdie:         +23.2°C  (high = +70.0°C)
Tctl:         +23.2°C

k10temp-pci-00db

Adapter: PCI adapter
Tdie:         +22.8°C  (high = +70.0°C)
Tctl:         +22.8°C

k10temp-pci-00cb

Adapter: PCI adapter
Tdie:         +22.6°C  (high = +70.0°C)
Tctl:         +22.6°C

now with 0x15eb

crazy@ant:~/Work/Linux/linux$ sudo rmmod k10temp
crazy@ant:~/Work/Linux/linux$ git grep -w PCI_DEVICE_ID_AMD_17H_RR_DF_F3
arch/x86/kernel/amd_nb.c:#define PCI_DEVICE_ID_AMD_17H_RR_DF_F3 0x15eb
arch/x86/kernel/amd_nb.c:       { PCI_DEVICE(PCI_VENDOR_ID_AMD,
PCI_DEVICE_ID_AMD_17H_RR_DF_F3) },
drivers/hwmon/k10temp.c:#ifndef PCI_DEVICE_ID_AMD_17H_RR_DF_F3
drivers/hwmon/k10temp.c:#define PCI_DEVICE_ID_AMD_17H_RR_DF_F3  0x15eb
drivers/hwmon/k10temp.c:        { PCI_VDEVICE(AMD,
PCI_DEVICE_ID_AMD_17H_RR_DF_F3) },
crazy@ant:~/Work/Linux/linux$ sudo insmod ./drivers/hwmon/k10temp.ko
crazy@ant:~/Work/Linux/linux$ sensors
k10temp-pci-00f3
Adapter: PCI adapter
Tdie:         +22.2°C  (high = +70.0°C)
Tctl:         +22.2°C

k10temp-pci-00e3

Adapter: PCI adapter
Tdie:         +23.8°C  (high = +70.0°C)
Tctl:         +23.8°C

k10temp-pci-00d3

Adapter: PCI adapter
Tdie:         +23.0°C  (high = +70.0°C)
Tctl:         +23.0°C

k10temp-pci-00c3

Adapter: PCI adapter
Tdie:         +25.0°C  (high = +70.0°C)
Tctl:         +25.0°C

k10temp-pci-00fb

Adapter: PCI adapter
Tdie:         +22.9°C  (high = +70.0°C)
Tctl:         +22.9°C

k10temp-pci-00eb

Adapter: PCI adapter
Tdie:         +23.2°C  (high = +70.0°C)
Tctl:         +23.2°C

k10temp-pci-00db

Adapter: PCI adapter
Tdie:         +22.8°C  (high = +70.0°C)
Tctl:         +22.8°C

k10temp-pci-00cb

Adapter: PCI adapter
Tdie:         +22.8°C  (high = +70.0°C)
Tctl:         +22.8°C
Quoted 25 lines
Quoted 24 lines
drivers/hwmon/k10temp.c +3 -3
   #endif
     /* CPUID function 0x80000001, ebx */
@@ -136,8 +137,8 @@ static void read_tempreg_nb_f15(struct pci_dev *pdev,
 u32 *regval)
     static void read_tempreg_nb_f17(struct pci_dev *pdev, u32 *regval)
   {
-       amd_nb_index_read(pdev, PCI_DEVFN(0, 0), 0x60,
-                         F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval);
+       amd_smn_read(amd_pci_dev_to_node_id(pdev),
+                    F17H_M01H_REPORTED_TEMP_CTRL_OFFSET, regval);
   }
     static ssize_t temp1_input_show(struct device *dev,
@@ -323,7 +324,7 @@ static const struct pci_device_id k10temp_id_table[] =
 {
         { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
         { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
         { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
-       { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_RR_NB) },
+       { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_RR_DF_F3) },
         {}
   };
   MODULE_DEVICE_TABLE(pci, k10temp_id_table);
Tested-by on v1 1/2
#6 lore raw
In reply to Guenter Roeck

2018-04-29 3:54 GMT+02:00 Guenter Roeck <[email protected]>:

Quoted 57 lines

Add Raven Ridge root bridge and data fabric PCI IDs. This is required for amd_pci_dev_to_node_id() and amd_smn_read().

---
This patch is a prerequisite for the second patch in the series. I'll be happy to apply both patches through hwmon if that is acceptable (and Cc: stable for 4.16+). If not, I'll be happy to wait for this patch to be available upstream.

Since that there is no public documentation available for Raven Ridge, PCI IDs are derived from output of lspci.

 arch/x86/kernel/amd_nb.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/kernel/amd_nb.c +6 -1
index c88e0b127810..bd33613ecb7c 100644
@@ -14,8 +14,11 @@
 #include <asm/amd_nb.h>
 
 #define PCI_DEVICE_ID_AMD_17H_ROOT     0x1450
+#define PCI_DEVICE_ID_AMD_17H_RR_ROOT  0x15d0
 #define PCI_DEVICE_ID_AMD_17H_DF_F3    0x1463
 #define PCI_DEVICE_ID_AMD_17H_DF_F4    0x1464
+#define PCI_DEVICE_ID_AMD_17H_RR_DF_F3 0x15eb
+#define PCI_DEVICE_ID_AMD_17H_RR_DF_F4 0x15ec
 
 /* Protect the PCI config register pairs used for SMN and DF indirect access. */
 static DEFINE_MUTEX(smn_mutex);
@@ -24,6 +27,7 @@ static u32 *flush_words;
 
 static const struct pci_device_id amd_root_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_ROOT) },
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_RR_ROOT) },
        {}
 };
 
@@ -39,6 +43,7 @@ const struct pci_device_id amd_nb_misc_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_RR_DF_F3) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) },
        {}
 };
@@ -51,6 +56,7 @@ static const struct pci_device_id amd_nb_link_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F4) },
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_RR_DF_F4) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F4) },
        {}
 };
--
Quoted 2 lines

2.7.4

Works fine for me on top stable and on top v4.17-rc2-398-gcdface520934

Regards

Tested-by on v1 1/2
#7 lore raw
In reply to Guenter Roeck

2018-04-29 3:54 GMT+02:00 Guenter Roeck <[email protected]>:

Quoted 57 lines

Add Raven Ridge root bridge and data fabric PCI IDs. This is required for amd_pci_dev_to_node_id() and amd_smn_read().

---
This patch is a prerequisite for the second patch in the series. I'll be happy to apply both patches through hwmon if that is acceptable (and Cc: stable for 4.16+). If not, I'll be happy to wait for this patch to be available upstream.

Since that there is no public documentation available for Raven Ridge, PCI IDs are derived from output of lspci.

 arch/x86/kernel/amd_nb.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/kernel/amd_nb.c +6 -1
index c88e0b127810..bd33613ecb7c 100644
@@ -14,8 +14,11 @@
 #include <asm/amd_nb.h>
 
 #define PCI_DEVICE_ID_AMD_17H_ROOT     0x1450
+#define PCI_DEVICE_ID_AMD_17H_RR_ROOT  0x15d0
 #define PCI_DEVICE_ID_AMD_17H_DF_F3    0x1463
 #define PCI_DEVICE_ID_AMD_17H_DF_F4    0x1464
+#define PCI_DEVICE_ID_AMD_17H_RR_DF_F3 0x15eb
+#define PCI_DEVICE_ID_AMD_17H_RR_DF_F4 0x15ec
 
 /* Protect the PCI config register pairs used for SMN and DF indirect access. */
 static DEFINE_MUTEX(smn_mutex);
@@ -24,6 +27,7 @@ static u32 *flush_words;
 
 static const struct pci_device_id amd_root_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_ROOT) },
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_RR_ROOT) },
        {}
 };
 
@@ -39,6 +43,7 @@ const struct pci_device_id amd_nb_misc_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_RR_DF_F3) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) },
        {}
 };
@@ -51,6 +56,7 @@ static const struct pci_device_id amd_nb_link_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F4) },
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_RR_DF_F4) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F4) },
        {}
 };
--
Quoted 2 lines

2.7.4

Works fine for me on top stable and on top v4.17-rc2-398-gcdface520934

Regards

#8 lore raw
In reply to Guenter Roeck
Quoted 21 lines · Guenter Roeck

Add Raven Ridge root bridge and data fabric PCI IDs. This is required for amd_pci_dev_to_node_id() and amd_smn_read().

---
This patch is a prerequisite for the second patch in the series. I'll be happy to apply both patches through hwmon if that is acceptable (and Cc: stable for 4.16+). If not, I'll be happy to wait for this patch to be available upstream.

Since that there is no public documentation available for Raven Ridge, PCI IDs are derived from output of lspci.

 arch/x86/kernel/amd_nb.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/kernel/amd_nb.c +0 -0
index c88e0b127810..bd33613ecb7c 100644

arch/x86/kernel/amd_nb.c line 17

Quoted 4 lines
arch/x86/kernel/amd_nb.c +1 -0
@@ -14,8 +14,11 @@
 #include <asm/amd_nb.h>
 
 #define PCI_DEVICE_ID_AMD_17H_ROOT	0x1450
+#define PCI_DEVICE_ID_AMD_17H_RR_ROOT	0x15d0

I think the nomenclature we decided upon at the time was

...AMD_<family>H_M<model>H...

PCI_DEVICE_ID_AMD_15H_M10H_F3, for example.

And in this case, it should be

PCI_DEVICE_ID_AMD_17H_M<which model is RV>H_F<PCI function number>

Yazen, which is the first model of Raven Ridge?

Thx.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
author maintainer
#9 lore raw
Quoted 29 lines · Borislav Petkov
Quoted 21 lines · Guenter Roeck

Add Raven Ridge root bridge and data fabric PCI IDs. This is required for amd_pci_dev_to_node_id() and amd_smn_read().

---
This patch is a prerequisite for the second patch in the series. I'll be happy to apply both patches through hwmon if that is acceptable (and Cc: stable for 4.16+). If not, I'll be happy to wait for this patch to be available upstream.

Since that there is no public documentation available for Raven Ridge, PCI IDs are derived from output of lspci.

  arch/x86/kernel/amd_nb.c | 6 ++++++
  1 file changed, 6 insertions(+)
arch/x86/kernel/amd_nb.c +0 -0
index c88e0b127810..bd33613ecb7c 100644

arch/x86/kernel/amd_nb.c line 17

Quoted 4 lines
arch/x86/kernel/amd_nb.c +1 -0
@@ -14,8 +14,11 @@
  #include <asm/amd_nb.h>
 
  #define PCI_DEVICE_ID_AMD_17H_ROOT	0x1450
+#define PCI_DEVICE_ID_AMD_17H_RR_ROOT	0x15d0

I think the nomenclature we decided upon at the time was

Quoted 8 lines

...AMD_<family>H_M<model>H...

PCI_DEVICE_ID_AMD_15H_M10H_F3, for example.

And in this case, it should be

PCI_DEVICE_ID_AMD_17H_M<which model is RV>H_F<PCI function number>

Makes sense.

Quoted 2 lines

Yazen, which is the first model of Raven Ridge?

2400G is model 17 (0x11). I was unable to find information if there are other chips/models using the same set of PCI IDs.

I'll wait for additional feedback before resending.

Thanks,
Guenter

#10 lore raw
Quoted 53 lines

-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: Sunday, April 29, 2018 2:24 PM
To: Borislav Petkov <[email protected]>; Ghannam, Yazen <[email protected]>
Cc: Thomas Gleixner <[email protected]>; Clemens Ladisch <[email protected]>; [email protected]; Jean Delvare <[email protected]>; [email protected]; [email protected]; Woods, Brian <[email protected]>
Subject: Re: [PATCH 1/2] x86/amd_nb: Add support for Raven Ridge CPUs

Quoted 29 lines · Borislav Petkov
Quoted 21 lines · Guenter Roeck

Add Raven Ridge root bridge and data fabric PCI IDs. This is required for amd_pci_dev_to_node_id() and amd_smn_read().

---
This patch is a prerequisite for the second patch in the series. I'll be happy to apply both patches through hwmon if that is acceptable (and Cc: stable for 4.16+). If not, I'll be happy to wait for this patch to be available upstream.

Since that there is no public documentation available for Raven Ridge, PCI IDs are derived from output of lspci.

  arch/x86/kernel/amd_nb.c | 6 ++++++
  1 file changed, 6 insertions(+)
arch/x86/kernel/amd_nb.c +0 -0
index c88e0b127810..bd33613ecb7c 100644

arch/x86/kernel/amd_nb.c line 17

Quoted 4 lines
arch/x86/kernel/amd_nb.c +1 -0
@@ -14,8 +14,11 @@
  #include <asm/amd_nb.h>
 
  #define PCI_DEVICE_ID_AMD_17H_ROOT	0x1450
+#define PCI_DEVICE_ID_AMD_17H_RR_ROOT	0x15d0

I think the nomenclature we decided upon at the time was

Quoted 7 lines

...AMD_<family>H_M<model>H...

PCI_DEVICE_ID_AMD_15H_M10H_F3, for example.

And in this case, it should be

PCI_DEVICE_ID_AMD_17H_M<which model is RV>H_F<PCI function

number>

Quoted 1 line

Makes sense.

Quoted 7 lines
Quoted 2 lines

Yazen, which is the first model of Raven Ridge?

2400G is model 17 (0x11). I was unable to find information if there are other chips/models using the same set of PCI IDs.

I'll wait for additional feedback before resending.

There are other models using the same set of IDs, but the first is 10h.

Also, the F3 IDs for Fam17h and Fam17hMod10h are used in both amd_nb.c and k10temp.c. Can you please delete the F3 IDs from these files and add them to "include/linux/pci_ids.h"?

Thanks!

-Yazen

author maintainer
#11 lore raw
Quoted 56 lines · Yazen
Quoted 56 lines

-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: Sunday, April 29, 2018 2:24 PM
To: Borislav Petkov <[email protected]>; Ghannam, Yazen <[email protected]>
Cc: Thomas Gleixner <[email protected]>; Clemens Ladisch <[email protected]>; [email protected]; Jean Delvare <[email protected]>; [email protected]; [email protected]; Woods, Brian <[email protected]>
Subject: Re: [PATCH 1/2] x86/amd_nb: Add support for Raven Ridge CPUs

Quoted 29 lines · Borislav Petkov
Quoted 21 lines · Guenter Roeck

Add Raven Ridge root bridge and data fabric PCI IDs. This is required for amd_pci_dev_to_node_id() and amd_smn_read().

---
This patch is a prerequisite for the second patch in the series. I'll be happy to apply both patches through hwmon if that is acceptable (and Cc: stable for 4.16+). If not, I'll be happy to wait for this patch to be available upstream.

Since that there is no public documentation available for Raven Ridge, PCI IDs are derived from output of lspci.

  arch/x86/kernel/amd_nb.c | 6 ++++++
  1 file changed, 6 insertions(+)
arch/x86/kernel/amd_nb.c +0 -0
index c88e0b127810..bd33613ecb7c 100644

arch/x86/kernel/amd_nb.c line 17

Quoted 4 lines
arch/x86/kernel/amd_nb.c +1 -0
@@ -14,8 +14,11 @@
  #include <asm/amd_nb.h>
 
  #define PCI_DEVICE_ID_AMD_17H_ROOT	0x1450
+#define PCI_DEVICE_ID_AMD_17H_RR_ROOT	0x15d0

I think the nomenclature we decided upon at the time was

Quoted 7 lines

...AMD_<family>H_M<model>H...

PCI_DEVICE_ID_AMD_15H_M10H_F3, for example.

And in this case, it should be

PCI_DEVICE_ID_AMD_17H_M<which model is RV>H_F<PCI function

number>

Quoted 1 line

Makes sense.

Quoted 2 lines

Yazen, which is the first model of Raven Ridge?

Quoted 7 lines
Quoted 4 lines

2400G is model 17 (0x11). I was unable to find information if there are other chips/models using the same set of PCI IDs.

I'll wait for additional feedback before resending.

There are other models using the same set of IDs, but the first is 10h.

Ok, I'll make it PCI_DEVICE_ID_AMD_17H_M10H_ROOT and PCI_DEVICE_ID_AMD_17H_M10H_DF_F{3,4}.

Quoted 4 lines

Also, the F3 IDs for Fam17h and Fam17hMod10h are used in both amd_nb.c and k10temp.c. Can you please delete the F3 IDs from these files and add them to "include/linux/pci_ids.h"?

I'll be happy to do that. However, my preference would be to do that in a separate patch. I would like to see this patch and patch 2/2 applied to 4.16+ since together they fix a potential race condition as well as temperature reporting problems with multi-die Zen chips (Threadripper and EPYC). The pci_id.h changes are not bug fixes and would be more appropriate for v4.18.

Thanks,
Guenter

Quoted 3 lines

Thanks!

-Yazen