Skip to contentSkip to conversation

hwmon: (k8temp) fix temperature reporting

PATCH In review Andreas Herrmann 2 participants 4 messages Dec 5, 2008 – Dec 15, 2008

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

PATCH 4/4 hwmon: (k8temp) fix temperature reporting

Current Temperature for K8 RevG desktop CPUs is a "normalized value" which can be below ambient temperature.

As a consequence lots of RevG systems report temperatures like:

sensors
k8temp-pci-00c3
Adapter: PCI adapter
Core0 Temp:

              +17C
 Core0 Temp:
               +3C
 Core1 Temp:
              +21C
 Core1 Temp:
               +5C

being quite below ambient temperature.
There are even reports of negative temperature values.

This patch corrects the temperature reporting of k8temp for RevG desktop CPUs.

---
 drivers/hwmon/k8temp.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
drivers/hwmon/k8temp.c +13 -2
index 102f3ad..e37eeb5 100644
@@ -50,6 +50,7 @@ struct k8temp_data {
 	u8 sensorsp;		/* sensor presence bits - SEL_CORE & SEL_PLACE */
 	u32 temp[2][2];		/* core, place */
 	u8 swap_core_select;    /* meaning of SEL_CORE is inverted */
+	u32 temp_offset;
 };
 
 static struct k8temp_data *k8temp_update_device(struct device *dev)
@@ -117,13 +118,14 @@ static ssize_t show_temp(struct device *dev,
 	    to_sensor_dev_attr_2(devattr);
 	int core = attr->nr;
 	int place = attr->index;
+	u32 temp;
 	struct k8temp_data *data = k8temp_update_device(dev);
 
 	if (data->swap_core_select)
 		core = core ? 0 : 1;
 
-	return sprintf(buf, "%d\n",
-		       TEMP_FROM_REG(data->temp[core][place]));
+	temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;
+	return sprintf(buf, "%d\n", temp);
 }
 
 /* core, place */
@@ -175,6 +177,15 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
 				 "wrong - check erratum #141\n");
 		}
 
+		if (((model >= 0x68) && (model != 0xc1)) &&
+		    !(model = 0x68) && !(model = 0x6c) &&
+		    !(model = 0x7c))
+			/*
+			 * RevG desktop CPUs (i.e. no socket S1G1 parts)
+			 * need additional offset, otherwise reported
+			 * temperature is below ambient temperature
+			 */
+			data->temp_offset = 21000;
 
 		break;
 	}
Signature · 9 lines
1.6.0.4




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

Re: [lm-sensors] [PATCH 4/4] hwmon: (k8temp) fix temperature

Huh interesting stuff. Any pointers to documentation please?

Andreas Herrmann napsal(a):

Quoted 43 lines

Current Temperature for K8 RevG desktop CPUs is a "normalized value" which can be below ambient temperature.

As a consequence lots of RevG systems report temperatures like:

sensors
k8temp-pci-00c3
Adapter: PCI adapter
Core0 Temp:

              +17C
 Core0 Temp:
               +3C
 Core1 Temp:
              +21C
 Core1 Temp:
               +5C

being quite below ambient temperature.
There are even reports of negative temperature values.

This patch corrects the temperature reporting of k8temp for RevG desktop CPUs.

---
 drivers/hwmon/k8temp.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
drivers/hwmon/k8temp.c +1 -0
index 102f3ad..e37eeb5 100644
@@ -50,6 +50,7 @@ struct k8temp_data {
 	u8 sensorsp;		/* sensor presence bits - SEL_CORE & SEL_PLACE */
 	u32 temp[2][2];		/* core, place */
 	u8 swap_core_select;    /* meaning of SEL_CORE is inverted */
+	u32 temp_offset;
 };
 
 static struct k8temp_data *k8temp_update_device(struct device *dev)
@@ -117,13 +118,14 @@ static ssize_t show_temp(struct device *dev,
 	    to_sensor_dev_attr_2(devattr);
 	int core = attr->nr;

drivers/hwmon/k8temp.c static ssize_t show_temp(struct device *dev, · line 127

Quoted 10 lines
drivers/hwmon/k8temp.c +2 -2
 	int place = attr->index;
+	u32 temp;
 	struct k8temp_data *data = k8temp_update_device(dev);
 
 	if (data->swap_core_select)
 		core = core ? 0 : 1;
 
-	return sprintf(buf, "%d\n",
-		       TEMP_FROM_REG(data->temp[core][place]));
+	temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;

What if TEMP_FROM_REG is -3 ? temp should be imho signed.

drivers/hwmon/k8temp.c static int __devinit k8temp_probe(struct pci_dev *pdev, · line 179

Quoted 8 lines
drivers/hwmon/k8temp.c +1 -0
+	return sprintf(buf, "%d\n", temp);
 }
 
 /* core, place */
@@ -175,6 +177,15 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
 				 "wrong - check erratum #141\n");
 		}
 

maybe to comment what CPU model is what

drivers/hwmon/k8temp.c static int __devinit k8temp_probe(struct pci_dev *pdev, · line 191

Quoted 12 lines
drivers/hwmon/k8temp.c +9 -0
+		if (((model >= 0x68) && (model != 0xc1)) &&
+		    !(model = 0x68) && !(model = 0x6c) &&
+		    !(model = 0x7c))
+			/*
+			 * RevG desktop CPUs (i.e. no socket S1G1 parts)
+			 * need additional offset, otherwise reported
+			 * temperature is below ambient temperature
+			 */
+			data->temp_offset = 21000;
 
 		break;
 	}

Thanks,
Rudolf

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

#2 lore raw

Re: [lm-sensors] [PATCH 4/4] hwmon: (k8temp) fix temperature

In reply to Andreas Herrmann
Quoted 1 line · Rudolf Marek

Huh interesting stuff. Any pointers to documentation please?

No pointer, sorry.

The AMD family 0Fh BKDG is incorrect wrt K8 RevG desktop CPUs. I'll try to address this but I am not sure whether the documentation will be updated.

Regards,
Andreas

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

maintainer
#3 lore raw

Re: [lm-sensors] [PATCH 4/4] hwmon: (k8temp) fix temperature

In reply to Andreas Herrmann

Andreas Herrmann napsal(a):

Quoted 8 lines · Rudolf Marek
Quoted 1 line

Huh interesting stuff. Any pointers to documentation please?

No pointer, sorry.

The AMD family 0Fh BKDG is incorrect wrt K8 RevG desktop CPUs. I'll try to address this but I am not sure whether the documentation will be updated.

OK thank you very much.

Rudolf

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