Skip to contentSkip to conversation

hwmon, k10temp: Add support for F15h M60h

PATCH In review Aravind Gopalakrishnan 5 participants 7 messages Aug 14, 2014 – Aug 15, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 hwmon, k10temp: Add support for F15h M60h

This patch adds temperature monitoring support for F15h M60h processor.
- Add new pci device id for the relevant processor
- The functionality of REG_REPORTED_TEMPERATURE is moved to D0F0xBC_xD820_0CA4 [Reported Temperature Control]
- So, use this to get CUR_TEMP value
- Since we need an indirect register access, protect this with a mutex lock
- Add Kconfig, Doc entries to indicate support for this processor.

---
Changes in V3:
- Move helper function that protects indirect register access locally until a time when others outside k10temp may need it

Changes in V2:
- Prevent race with other code that may require indirect NB_SMU_REG access
- Fix some minor style issues

 Documentation/hwmon/k10temp |  2 +-
 drivers/hwmon/Kconfig       |  4 ++--
 drivers/hwmon/k10temp.c     | 35 ++++++++++++++++++++++++++++++++---
 3 files changed, 35 insertions(+), 6 deletions(-)
Documentation/hwmon/k10temp +1 -1
index ee6d30e..254d2f5 100644
@@ -11,7 +11,7 @@ Supported chips:
   Socket S1G2: Athlon (X2), Sempron (X2), Turion X2 (Ultra)
 * AMD Family 12h processors: "Llano" (E2/A4/A6/A8-Series)
 * AMD Family 14h processors: "Brazos" (C/E/G/Z-Series)
-* AMD Family 15h processors: "Bulldozer" (FX-Series), "Trinity", "Kaveri"
+* AMD Family 15h processors: "Bulldozer" (FX-Series), "Trinity", "Kaveri", "Carrizo"
 * AMD Family 16h processors: "Kabini", "Mullins"
 
   Prefix: 'k10temp'
drivers/hwmon/Kconfig +2 -2
index 02d3d85..57ba400 100644
@@ -280,8 +280,8 @@ config SENSORS_K10TEMP
 	  If you say yes here you get support for the temperature
 	  sensor(s) inside your CPU. Supported are later revisions of
 	  the AMD Family 10h and all revisions of the AMD Family 11h,
-	  12h (Llano), 14h (Brazos), 15h (Bulldozer/Trinity/Kaveri) and
-	  16h (Kabini/Mullins) microarchitectures.
+	  12h (Llano), 14h (Brazos), 15h (Bulldozer/Trinity/Kaveri/Carrizo)
+	  and 16h (Kabini/Mullins) microarchitectures.
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called k10temp.
drivers/hwmon/k10temp.c +32 -3
index f7b46f6..36ea152 100644
@@ -33,6 +33,9 @@ static bool force;
 module_param(force, bool, 0444);
 MODULE_PARM_DESC(force, "force loading on processors with erratum 319");
 
+/* Provide lock for writing to NB_SMU_IND_ADDR */
+DEFINE_MUTEX(nb_smu_ind_mutex);
+
 /* CPUID function 0x80000001, ebx */
 #define CPUID_PKGTYPE_MASK	0xf0000000
 #define CPUID_PKGTYPE_F		0x00000000
@@ -51,13 +54,38 @@ MODULE_PARM_DESC(force, "force loading on processors with erratum 319");
 #define REG_NORTHBRIDGE_CAPABILITIES	0xe8
 #define  NB_CAP_HTC			0x00000400
 
+/*
+ * For F15h M60h, functionality of REG_REPORTED_TEMPERATURE
+ * has been moved to D0F0xBC_xD820_0CA4 [Reported Temperature
+ * Control]
+ */
+#define F15H_M60H_REPORTED_TEMP_CTRL_OFFSET	0xd8200ca4
+#define PCI_DEVICE_ID_AMD_15H_M60H_NB_F3	0x1573
+
+void amd_nb_smu_index_read(struct pci_dev *pdev, unsigned int devfn,
+			   int offset, u32 *val)
+{
+	mutex_lock(&nb_smu_ind_mutex);
+	pci_bus_write_config_dword(pdev->bus, devfn,
+				   0xb8, offset);
+	pci_bus_read_config_dword(pdev->bus, devfn,
+				  0xbc, val);
+	mutex_unlock(&nb_smu_ind_mutex);
+}
+
 static ssize_t show_temp(struct device *dev,
 			 struct device_attribute *attr, char *buf)
 {
 	u32 regval;
-
-	pci_read_config_dword(to_pci_dev(dev),
-			      REG_REPORTED_TEMPERATURE, &regval);
+	struct pci_dev *pdev = to_pci_dev(dev);
+
+	if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model == 0x60) {
+		amd_nb_smu_index_read(pdev, PCI_DEVFN(0, 0),
+				      F15H_M60H_REPORTED_TEMP_CTRL_OFFSET,
+				      &regval);
+	} else {
+		pci_read_config_dword(pdev, REG_REPORTED_TEMPERATURE, &regval);
+	}
 	return sprintf(buf, "%u\n", (regval >> 21) * 125);
 }
 
@@ -211,6 +239,7 @@ static const struct pci_device_id k10temp_id_table[] = {
 	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F3) },
 	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M10H_F3) },
 	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M30H_NB_F3) },
+	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M60H_NB_F3) },
 	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
 	{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
 	{}
Signature · 1 line
2.0.3
Acked-by on v3 1/1
#1 lore raw
Quoted 15 lines · Aravind Gopalakrishnan

This patch adds temperature monitoring support for F15h M60h processor.
- Add new pci device id for the relevant processor
- The functionality of REG_REPORTED_TEMPERATURE is moved to D0F0xBC_xD820_0CA4 [Reported Temperature Control]
- So, use this to get CUR_TEMP value
- Since we need an indirect register access, protect this with a mutex lock
- Add Kconfig, Doc entries to indicate support for this processor.

---
Changes in V3:
- Move helper function that protects indirect register access locally until a time when others outside k10temp may need it

Quoted 8 lines

Changes in V2:
- Prevent race with other code that may require indirect NB_SMU_REG access
- Fix some minor style issues

 Documentation/hwmon/k10temp |  2 +-
 drivers/hwmon/Kconfig       |  4 ++--
 drivers/hwmon/k10temp.c     | 35 ++++++++++++++++++++++++++++++++---
 3 files changed, 35 insertions(+), 6 deletions(-)

Looks good to me.

Signature · 10 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
maintainer Acked-by on v3 1/1
#2 lore raw
In reply to Aravind Gopalakrishnan
Quoted 15 lines · Aravind Gopalakrishnan

This patch adds temperature monitoring support for F15h M60h processor.
- Add new pci device id for the relevant processor
- The functionality of REG_REPORTED_TEMPERATURE is moved to D0F0xBC_xD820_0CA4 [Reported Temperature Control]
- So, use this to get CUR_TEMP value
- Since we need an indirect register access, protect this with a mutex lock
- Add Kconfig, Doc entries to indicate support for this processor.

---
Changes in V3:
- Move helper function that protects indirect register access locally until a time when others outside k10temp may need it

Quoted 8 lines

Changes in V2:
- Prevent race with other code that may require indirect NB_SMU_REG access
- Fix some minor style issues

 Documentation/hwmon/k10temp |  2 +-
 drivers/hwmon/Kconfig       |  4 ++--
 drivers/hwmon/k10temp.c     | 35 ++++++++++++++++++++++++++++++++---
 3 files changed, 35 insertions(+), 6 deletions(-)

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

maintainer
#3 lore raw
In reply to Aravind Gopalakrishnan
Quoted 9 lines · Aravind Gopalakrishnan

This patch adds temperature monitoring support for F15h M60h processor.
- Add new pci device id for the relevant processor
- The functionality of REG_REPORTED_TEMPERATURE is moved to D0F0xBC_xD820_0CA4 [Reported Temperature Control]
- So, use this to get CUR_TEMP value
- Since we need an indirect register access, protect this with a mutex lock
- Add Kconfig, Doc entries to indicate support for this processor.

Quoted 6 lines

---
Changes in V3:
- Move helper function that protects indirect register access locally until a time when others outside k10temp may need it

Applied, with a small change: I made the mutex and the new function static. That can be changed if/when needed, and declaring it static now ensures that we'll notice it. Likely the "next" user won't use the function anyway, but that is a problem to sort out after it happens.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#4 lore raw
Quoted 17 lines · Guenter Roeck
Quoted 9 lines · Aravind Gopalakrishnan

This patch adds temperature monitoring support for F15h M60h processor.
- Add new pci device id for the relevant processor
- The functionality of REG_REPORTED_TEMPERATURE is moved to D0F0xBC_xD820_0CA4 [Reported Temperature Control]
- So, use this to get CUR_TEMP value
- Since we need an indirect register access, protect this with a mutex lock
- Add Kconfig, Doc entries to indicate support for this processor.

Quoted 6 lines

---
Changes in V3:
- Move helper function that protects indirect register access locally until a time when others outside k10temp may need it

Quoted 8 lines

Applied, with a small change: I made the mutex and the new function static.
That can be changed if/when needed, and declaring it static now ensures that
we'll notice it. Likely the "next" user won't use the function anyway, but
that is a problem to sort out after it happens.

Ok, Thanks!
-Aravind.

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#5 lore raw
In reply to Aravind Gopalakrishnan
Quoted 12 lines · Aravind Gopalakrishnan
Quoted 11 lines
Quoted 9 lines

This patch adds temperature monitoring support for F15h M60h processor.
- Add new pci device id for the relevant processor
- The functionality of REG_REPORTED_TEMPERATURE is moved to D0F0xBC_xD820_0CA4 [Reported Temperature Control]
- So, use this to get CUR_TEMP value
- Since we need an indirect register access, protect this with a mutex lock

What about making this a new driver forked from k10temp.

AMD has changed how they report temperatures and the very different method of getting these temps suggests that it is no longer reasonable to add support to this driver for these new chips. Particular attention to the mutex required to protect the indirect register suggests that this would benefit from focus in its own driver now that there are multiple members of the "k15temp" family.

Anyone else have thoughts?

Signature · 8 lines
Philip Pokorny, RHCE
Chief Technical Officer
PENGUIN COMPUTING, Inc
www.penguincomputing.com
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
maintainer
#6 lore raw
Quoted 12 lines · Phil Pokorny

On 08/14/2014 04:15 PM, Aravind Gopalakrishnan wrote:

This patch adds temperature monitoring support for F15h M60h processor.
- Add new pci device id for the relevant processor
- The functionality of REG_REPORTED_TEMPERATURE is moved to D0F0xBC_xD820_0CA4 [Reported Temperature Control]
- So, use this to get CUR_TEMP value
- Since we need an indirect register access, protect this with a mutex lock

Quoted 6 lines

What about making this a new driver forked from k10temp.

AMD has changed how they report temperatures and the very different method of getting these temps suggests that it is no longer reasonable to add support to this driver for these new chips. Particular attention to the mutex required to protect the indirect register suggests that this would benefit from focus in its own driver now that there are multiple members of the "k15temp" family.

Anyone else have thoughts?

Everything in that new driver except for reading the actual temperature would be exactly the same. That doesn't make sense to me.

Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors