Skip to contentSkip to conversation

hwmon: k8temp.c Add support for AMD 11h

PATCH In review Jaswinder Singh Rajput 3 participants 6 messages Jul 7, 2009 – Jul 9, 2009

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

PATCH 1/1 hwmon: k8temp.c Add support for AMD 11h

Quoted 13 lines · Rudolf Marek

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

It seems mine emails are arriving multiple times. I'm sorry about that. Axel, is it doing mine ISP?

Quoted 2 lines

I totally agree with you that's why I removed the support for 10h as per your suggestion.

Quoted 9 lines

Ok fine.

Quoted 3 lines
Quoted 2 lines

I'm perfectly fine if you come up with a patch for fam 11h because the Errata

is still waiting for your approval.

Aha sorry I forgot about this one. Please can you re-structure it so there are not a goto's I think kernel codingstyle allows them only for error paths.

Ok, I also removed goto and here is updated patch :

[PATCH] hwmon: k8temp.c Add support for AMD 11h

Added AMD 11h support in k8temp. Thanks to Rudolf Marek for help.

---
 drivers/hwmon/Kconfig  |    4 +-
 drivers/hwmon/k8temp.c |   75 ++++++++++++++++++++++++++++++-----------------
 2 files changed, 50 insertions(+), 29 deletions(-)
drivers/hwmon/Kconfig +2 -2
index 2d50166..e7b4941 100644
@@ -200,11 +200,11 @@ config SENSORS_ADT7475
 	  will be called adt7475.
 
 config SENSORS_K8TEMP
-	tristate "AMD Athlon64/FX or Opteron temperature sensor"
+	tristate "AMD Athlon64/FX or Opteron or 11h temperature sensor"
 	depends on X86 && PCI && EXPERIMENTAL
 	help
 	  If you say yes here you get support for the temperature
-	  sensor(s) inside your CPU. Supported is whole AMD K8
+	  sensor(s) inside your CPU. Supported is whole AMD K8 and 11h
 	  microarchitecture. Please note that you will need at least
 	  lm-sensors 2.10.1 for proper userspace support.
 
drivers/hwmon/k8temp.c +48 -27

115 lines not on this page · raw message

Signature · 8 lines
1.6.0.6



_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
maintainer
#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I think Jean will have some comments too. Here is quick review.

Quoted 14 lines

Added AMD 11h support in k8temp. Thanks to Rudolf Marek for help.

---
 drivers/hwmon/Kconfig  |    4 +-
 drivers/hwmon/k8temp.c |   75 ++++++++++++++++++++++++++++++-----------------
 2 files changed, 50 insertions(+), 29 deletions(-)
drivers/hwmon/Kconfig +0 -0
index 2d50166..e7b4941 100644

drivers/hwmon/Kconfig config SENSORS_ADT7475 · line 203

Quoted 5 lines
drivers/hwmon/Kconfig +1 -1
@@ -200,11 +200,11 @@ config SENSORS_ADT7475
 	  will be called adt7475.
 
 config SENSORS_K8TEMP
-	tristate "AMD Athlon64/FX or Opteron temperature sensor"
+	tristate "AMD Athlon64/FX or Opteron or 11h temperature sensor"

maybe something else? like fam11h All it sounds too technical. Maybe we can leave it and fix the help. Also the documentation/hwmon/k8temp should be updated.

drivers/hwmon/Kconfig config SENSORS_ADT7475 · line 209

Quoted 7 lines
drivers/hwmon/Kconfig +1 -1
 	depends on X86 && PCI && EXPERIMENTAL
 	help
 	  If you say yes here you get support for the temperature
-	  sensor(s) inside your CPU. Supported is whole AMD K8
+	  sensor(s) inside your CPU. Supported is whole AMD K8 and 11h
 	  microarchitecture. Please note that you will need at least
 	  lm-sensors 2.10.1 for proper userspace support.

Maybe we can add note why fam10h is not supported, and also to a readme. Best it would be with another patch.

Quoted 22 lines
drivers/hwmon/k8temp.c +2 -1
index 1fe9951..f91da26 100644
@@ -1,5 +1,6 @@
 /*
  * k8temp.c - Linux kernel module for hardware monitoring
+ *	      for AMD K8 and 11h
  *
  * Copyright (C) 2006 Rudolf Marek <[email protected]>
  *
@@ -33,7 +34,7 @@
 #include <linux/mutex.h>
 #include <asm/processor.h>
 
-#define TEMP_FROM_REG(val)	(((((val) >> 16) & 0xff) - 49) * 1000)
+#define REG_TCTL	0xa4
 #define REG_TEMP	0xe4
 #define SEL_PLACE	0x40
 #define SEL_CORE	0x04

drivers/hwmon/k8temp.c struct k8temp_data { · line 57

Quoted 6 lines
drivers/hwmon/k8temp.c +1 -1
@@ -52,42 +53,61 @@ struct k8temp_data {
 	u32 temp_offset;
 };
 
-static struct k8temp_data *k8temp_update_device(struct device *dev)
 
+static inline unsigned long temp_from_reg(unsigned long val)

maybe the unsigned long val should be u32 so it is fixed - regs is also fixed size.

Quoted 80 lines
drivers/hwmon/k8temp.c +43 -24
+{
+	if (boot_cpu_data.x86 > 0xf)
+		return (val >> 21) * 125;
+	else
+		return (((val >> 16) & 0xff) - 49) * 1000;
+}
+
+static void update_11h_temp(struct pci_dev *pdev, struct k8temp_data *data)
+{
+	pci_read_config_dword(pdev, REG_TCTL, &data->temp[0][0]);
+}
+
+static void update_k8_temp(struct pci_dev *pdev, struct k8temp_data *data)
 {
-	struct k8temp_data *data = dev_get_drvdata(dev);
-	struct pci_dev *pdev = to_pci_dev(dev);
 	u8 tmp;
 
-	mutex_lock(&data->update_lock);
+	pci_read_config_byte(pdev, REG_TEMP, &tmp);
+	tmp &= ~(SEL_PLACE | SEL_CORE);		/* Select sensor 0, core0 */
+	pci_write_config_byte(pdev, REG_TEMP, tmp);
+	pci_read_config_dword(pdev, REG_TEMP, &data->temp[0][0]);
 
-	if (!data->valid
-	    || time_after(jiffies, data->last_updated + HZ)) {
-		pci_read_config_byte(pdev, REG_TEMP, &tmp);
-		tmp &= ~(SEL_PLACE | SEL_CORE);		/* Select sensor 0, core0 */
+	if (data->sensorsp & SEL_PLACE) {
+		tmp |= SEL_PLACE;		/* Select sensor 1, core0 */
 		pci_write_config_byte(pdev, REG_TEMP, tmp);
-		pci_read_config_dword(pdev, REG_TEMP, &data->temp[0][0]);
+		pci_read_config_dword(pdev, REG_TEMP, &data->temp[0][1]);
+	}
+
+	if (data->sensorsp & SEL_CORE) {
+		tmp &= ~SEL_PLACE;		/* Select sensor 0, core1 */
+		tmp |= SEL_CORE;
+		pci_write_config_byte(pdev, REG_TEMP, tmp);
+		pci_read_config_dword(pdev, REG_TEMP, &data->temp[1][0]);
 
 		if (data->sensorsp & SEL_PLACE) {
-			tmp |= SEL_PLACE;	/* Select sensor 1, core0 */
+			tmp |= SEL_PLACE;	/* Select sensor 1, core1 */
 			pci_write_config_byte(pdev, REG_TEMP, tmp);
 			pci_read_config_dword(pdev, REG_TEMP,
-					      &data->temp[0][1]);
+					      &data->temp[1][1]);
 		}
+	}
+}
 
-		if (data->sensorsp & SEL_CORE) {
-			tmp &= ~SEL_PLACE;	/* Select sensor 0, core1 */
-			tmp |= SEL_CORE;
-			pci_write_config_byte(pdev, REG_TEMP, tmp);
-			pci_read_config_dword(pdev, REG_TEMP,
-					      &data->temp[1][0]);
-
-			if (data->sensorsp & SEL_PLACE) {
-				tmp |= SEL_PLACE;	/* Select sensor 1, core1 */
-				pci_write_config_byte(pdev, REG_TEMP, tmp);
-				pci_read_config_dword(pdev, REG_TEMP,
-						      &data->temp[1][1]);
-			}
-		}
+static struct k8temp_data *k8temp_update_device(struct device *dev)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+	struct k8temp_data *data = dev_get_drvdata(dev);
+
+	mutex_lock(&data->update_lock);
+
+	if (!data->valid || time_after(jiffies, data->last_updated + HZ)) {
+		if (boot_cpu_data.x86 > 0xf)
+			update_11h_temp(pdev, data);
+		else
+			update_k8_temp(pdev, data);
 
 		data->last_updated = jiffies;
Quoted 1 line

data->valid = 1;

Rest looks ok. Anyone else can test?

Rudolf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpVDpgACgkQ3J9wPJqZRNUo9ACgnsmlkNYiCXnqmW18stl2T8Vb GAgAoJHlrO9BtGSEprPrAUMyZd/F/9Z3
=xlSR
-----END PGP SIGNATURE-----

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

#2 lore raw
In reply to Jaswinder Singh Rajput
Quoted 1 line · Rudolf Marek

I think Jean will have some comments too. Here is quick review.

No, I do not. I don't have the time to review this code and I have no hardware to test. I will not pick this patch, it should go upstream via someone else (maybe Andrew Morton.)

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#3 lore raw
In reply to Jaswinder Singh Rajput

Hello Rudolf,

Quoted 7 lines · Jean Delvare
Quoted 1 line · Rudolf Marek

I think Jean will have some comments too. Here is quick review.

No, I do not. I don't have the time to review this code and I have no hardware to test. I will not pick this patch, it should go upstream via someone else (maybe Andrew Morton.)

Ok, It seems Jean is quite busy.

If you are interested and want to send it to upstream then I will send updated patches otherwise we should wait for few more months for Jean availability.

Thanks,
--
JSR

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

#4 lore raw
In reply to Jaswinder Singh Rajput
Quoted 11 lines · Jaswinder Singh Rajput

Hello Rudolf,

Quoted 7 lines · Jean Delvare
Quoted 1 line · Rudolf Marek

I think Jean will have some comments too. Here is quick review.

No, I do not. I don't have the time to review this code and I have no hardware to test. I will not pick this patch, it should go upstream via someone else (maybe Andrew Morton.)

Quoted 5 lines

Ok, It seems Jean is quite busy.

If you are interested and want to send it to upstream then I will send updated patches otherwise we should wait for few more months for Jean availability.

No, do not wait for me. I have never said that I would take the patch later.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#5 lore raw
In reply to Jaswinder Singh Rajput
Quoted 12 lines · Jean Delvare
Quoted 11 lines · Jaswinder Singh Rajput

Hello Rudolf,

Quoted 7 lines · Jean Delvare
Quoted 1 line · Rudolf Marek

I think Jean will have some comments too. Here is quick review.

No, I do not. I don't have the time to review this code and I have no hardware to test. I will not pick this patch, it should go upstream via someone else (maybe Andrew Morton.)

Quoted 9 lines
Quoted 5 lines

Ok, It seems Jean is quite busy.

If you are interested and want to send it to upstream then I will send updated patches otherwise we should wait for few more months for Jean availability.

No, do not wait for me. I have never said that I would take the patch later.

Ok, thanks for your help.

Then it will be better we should wait for some one adopt "HARDWARE MONITORING" :

HARDWARE MONITORING

L:      [email protected]
W:      http://www.lm-sensors.org/
S:      Orphan
F:      drivers/hwmon/

Thanks,
--
JSR

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