public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
@ 2009-05-22  8:04 Jaswinder Singh Rajput
  2009-05-22  8:16 ` Rudolf Marek
  0 siblings, 1 reply; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-05-22  8:04 UTC (permalink / raw)
  To: Ingo Molnar, Rudolf Marek, x86 maintainers, LKML


Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
---
 drivers/hwmon/k8temp.c |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
index 1fe9951..831cd84 100644
--- a/drivers/hwmon/k8temp.c
+++ b/drivers/hwmon/k8temp.c
@@ -1,5 +1,6 @@
 /*
  * k8temp.c - Linux kernel module for hardware monitoring
+ * 	      for AMD K8 and derivates
  *
  * Copyright (C) 2006 Rudolf Marek <r.marek@assembler.cz>
  *
@@ -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
@@ -52,6 +53,14 @@ struct k8temp_data {
 	u32 temp_offset;
 };
 
+static unsigned long temp_from_reg(unsigned long val)
+{
+	if (boot_cpu_data.x86 > 0xf)
+		return ((val) >> 21) * 125;
+	else
+		return ((((val) >> 16) & 0xff) - 49) * 1000;
+}
+
 static struct k8temp_data *k8temp_update_device(struct device *dev)
 {
 	struct k8temp_data *data = dev_get_drvdata(dev);
@@ -62,6 +71,11 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
 
 	if (!data->valid
 	    || time_after(jiffies, data->last_updated + HZ)) {
+		if (boot_cpu_data.x86 > 0xf) {
+			pci_read_config_dword(pdev, REG_TCTL,
+					      &data->temp[0][0]);
+			goto update_done;
+		}
 		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);
@@ -89,6 +103,7 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
 			}
 		}
 
+update_done:
 		data->last_updated = jiffies;
 		data->valid = 1;
 	}
@@ -123,7 +138,7 @@ static ssize_t show_temp(struct device *dev,
 	if (data->swap_core_select)
 		core = core ? 0 : 1;
 
-	temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;
+	temp = temp_from_reg(data->temp[core][place]) + data->temp_offset;
 
 	return sprintf(buf, "%d\n", temp);
 }
@@ -138,6 +153,8 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
 
 static struct pci_device_id k8temp_ids[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) },
 	{ 0 },
 };
 
@@ -157,6 +174,9 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
 		goto exit;
 	}
 
+	if (boot_cpu_data.x86 > 0xf)
+		goto probe_done;
+
 	model = boot_cpu_data.x86_model;
 	stepping = boot_cpu_data.x86_mask;
 
@@ -226,6 +246,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
 			data->sensorsp &= ~SEL_CORE;
 	}
 
+probe_done:
 	data->name = "k8temp";
 	mutex_init(&data->update_lock);
 	dev_set_drvdata(&pdev->dev, data);
-- 
1.6.0.6




^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
  2009-05-22  8:04 [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H Jaswinder Singh Rajput
@ 2009-05-22  8:16 ` Rudolf Marek
  2009-05-22  8:42   ` Jaswinder Singh Rajput
  0 siblings, 1 reply; 21+ messages in thread
From: Rudolf Marek @ 2009-05-22  8:16 UTC (permalink / raw)
  To: Jaswinder Singh Rajput; +Cc: Ingo Molnar, x86 maintainers, LKML, LM Sensors

Hi,

The reason why there is no support is that the both 10h and 11h and all of them 
have still the errata which tells that measurements is unreliable. Has it changed?

Thanks,

Rudolf

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
  2009-05-22  8:16 ` Rudolf Marek
@ 2009-05-22  8:42   ` Jaswinder Singh Rajput
  2009-05-22  9:30     ` Jaswinder Singh Rajput
  0 siblings, 1 reply; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-05-22  8:42 UTC (permalink / raw)
  To: Rudolf Marek; +Cc: Ingo Molnar, x86 maintainers, LKML, LM Sensors

On Fri, 2009-05-22 at 10:16 +0200, Rudolf Marek wrote:
> Hi,
> 
> The reason why there is no support is that the both 10h and 11h and all of them 
> have still the errata which tells that measurements is unreliable. Has it changed?
> 

On my 11h laptop I am getting reading from 56-70 degree C and it seems
to correct and reliable to me.

Can you share the problem you faced with 10h and 11h, so that I can
check on my side.

Thanks,
--
JSR


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
  2009-05-22  8:42   ` Jaswinder Singh Rajput
@ 2009-05-22  9:30     ` Jaswinder Singh Rajput
  2009-05-23 16:59       ` Rudolf Marek
  2009-05-25 13:45       ` [lm-sensors] [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H Jean Delvare
  0 siblings, 2 replies; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-05-22  9:30 UTC (permalink / raw)
  To: Rudolf Marek; +Cc: Ingo Molnar, x86 maintainers, LKML, LM Sensors

On Fri, 2009-05-22 at 14:12 +0530, Jaswinder Singh Rajput wrote:
> On Fri, 2009-05-22 at 10:16 +0200, Rudolf Marek wrote:
> > Hi,
> > 
> > The reason why there is no support is that the both 10h and 11h and all of them 
> > have still the errata which tells that measurements is unreliable. Has it changed?
> > 
> 
> On my 11h laptop I am getting reading from 56-70 degree C and it seems
> to correct and reliable to me.
> 
> Can you share the problem you faced with 10h and 11h, so that I can
> check on my side.

On further testing I am getting 52 - 88 degree C and I am quite happy
with these readings.

Atleast something is better than nothing ;-)

Thanks,
--
JSR


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
  2009-05-22  9:30     ` Jaswinder Singh Rajput
@ 2009-05-23 16:59       ` Rudolf Marek
  2009-05-24 12:19         ` Jaswinder Singh Rajput
  2009-05-26 12:10         ` Jaswinder Singh Rajput
  2009-05-25 13:45       ` [lm-sensors] [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H Jean Delvare
  1 sibling, 2 replies; 21+ messages in thread
From: Rudolf Marek @ 2009-05-23 16:59 UTC (permalink / raw)
  To: Jaswinder Singh Rajput; +Cc: Ingo Molnar, x86 maintainers, LKML, LM Sensors

Hi,

Yes it works for most CPUs, but for unlucky users we might get complains from 
them - and false alarms.

I'm talking about:

http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf

Errata #319

So far all CPUs have the issue.

Rudolf


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
  2009-05-23 16:59       ` Rudolf Marek
@ 2009-05-24 12:19         ` Jaswinder Singh Rajput
  2009-05-26 12:10         ` Jaswinder Singh Rajput
  1 sibling, 0 replies; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-05-24 12:19 UTC (permalink / raw)
  To: Rudolf Marek; +Cc: Ingo Molnar, x86 maintainers, LKML, LM Sensors

On Sat, 2009-05-23 at 18:59 +0200, Rudolf Marek wrote:
> Hi,
> 
> Yes it works for most CPUs, but for unlucky users we might get complains from 
> them - and false alarms.
> 
> I'm talking about:
> 
> http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
> 
> Errata #319
> 
> So far all CPUs have the issue.

>From manual :

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
319 Inaccurate Temperature Measurement
Description
The internal thermal sensor used for CurTmp (F3xA4[31:21]), hardware thermal control (HTC),
software thermal control (STC) thermal zone, and the sideband temperature sensor interface (SB-TSI)
may report inconsistent values.
Potential Effect on System
HTC, STC thermal zone, and SB-TSI do not provide reliable thermal protection. This does not affect
THERMTRIP or the use of the STC-active state through StcPstateLimit or StcPstateEn
(F3x68[30:28, 5]).
Suggested Workaround
None. Systems should be designed with conventional thermal control and throttling methods or
utilize PROCHOT_L functionality based on temperature measurements from an analog thermal diode
(THERMDA/THERMDC).
Systems should not rely on the HTC features, STC thermal zone features, or use SB-TSI.
Software should not modify HtcTmpLmt (F3x64[22:16]) or enable any of the STC thermal zone
features by setting StcApcTmpLoEn, StcApcTmpHiEn, StcSbcTmpLoEn, or StcSpcTmpHiEn
(F3x68[3:0]).

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

It seems that this problem is for some K10 processors.
And K11 is OK, right ?

I think our patch is safe enough and we will fix the problem for some
K10 processors or in the worst case we will remove support for that
particular cpu.

Ingo: do you mind to applying this patch on -tip and lets see its
feedback and fix the problem.

Thanks
--
JSR



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [lm-sensors] [PATCH-tip] x86: hwmon/k8temp.c Add support for  AMD 10H and 11H
  2009-05-22  9:30     ` Jaswinder Singh Rajput
  2009-05-23 16:59       ` Rudolf Marek
@ 2009-05-25 13:45       ` Jean Delvare
  2009-05-25 14:17         ` Jaswinder Singh Rajput
  1 sibling, 1 reply; 21+ messages in thread
From: Jean Delvare @ 2009-05-25 13:45 UTC (permalink / raw)
  To: Jaswinder Singh Rajput
  Cc: Rudolf Marek, Ingo Molnar, x86 maintainers, LKML, LM Sensors

Hi Jaswinder,

On Fri, 22 May 2009 15:00:48 +0530, Jaswinder Singh Rajput wrote:
> Atleast something is better than nothing ;-)

Sorry but you are wrong here. When it comes to hardware monitoring (or
monitoring in general), potentially wrong data is _worse_ than no data
at all, unless you additionally carry the information that the data
value may be wrong, and display it in a very visible manner. As our
sysfs interface doesn't provide any way to pass reliability information
to the reader (and I don't think it would make sense to add one), it is
better to not export data that we know can't be trusted.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [lm-sensors] [PATCH-tip] x86: hwmon/k8temp.c Add support for  AMD 10H and 11H
  2009-05-25 13:45       ` [lm-sensors] [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H Jean Delvare
@ 2009-05-25 14:17         ` Jaswinder Singh Rajput
  0 siblings, 0 replies; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-05-25 14:17 UTC (permalink / raw)
  To: Jean Delvare; +Cc: Rudolf Marek, Ingo Molnar, x86 maintainers, LKML, LM Sensors

Hello Jean,

On Mon, 2009-05-25 at 15:45 +0200, Jean Delvare wrote:
> Hi Jaswinder,
> 
> On Fri, 22 May 2009 15:00:48 +0530, Jaswinder Singh Rajput wrote:
> > Atleast something is better than nothing ;-)
> 
> Sorry but you are wrong here. When it comes to hardware monitoring (or
> monitoring in general), potentially wrong data is _worse_ than no data
> at all, unless you additionally carry the information that the data
> value may be wrong, and display it in a very visible manner. As our
> sysfs interface doesn't provide any way to pass reliability information
> to the reader (and I don't think it would make sense to add one), it is
> better to not export data that we know can't be trusted.
> 

As I said in my previous email that it seems problem is with few 10H
cpus and 11H are OK.

So better we will fix wrong information or suppress information for
those specific cpus.

On my 11H laptop monitoring seems very reliable. So in the worst case we
drop support for 10H.

Thanks,
--
JSR




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
  2009-05-23 16:59       ` Rudolf Marek
  2009-05-24 12:19         ` Jaswinder Singh Rajput
@ 2009-05-26 12:10         ` Jaswinder Singh Rajput
  2009-05-26 15:20           ` Rudolf Marek
  1 sibling, 1 reply; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-05-26 12:10 UTC (permalink / raw)
  To: Rudolf Marek; +Cc: Ingo Molnar, x86 maintainers, LKML, LM Sensors

On Sat, 2009-05-23 at 18:59 +0200, Rudolf Marek wrote:
> Hi,
> 
> Yes it works for most CPUs, but for unlucky users we might get complains from 
> them - and false alarms.
> 
> I'm talking about:
> 
> http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
> 
> Errata #319
> 
> So far all CPUs have the issue.
> 
> Rudolf
> 

Here is the patch which will prepare the report for Inaccurate
Temperature Measurement to fix/suppress inaccurate Monitoring.

[PATCH] x86: hwmon/k8temp.c Add support for AMD 10H and 11H

Some AMD 10H cpus reports Inaccurate Temperature Measurement:
http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
Errata #319

So Added report message to fix/suppress inaccurate Monitoring.

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
---
 drivers/hwmon/k8temp.c |   38 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
index 1fe9951..1e9594a 100644
--- a/drivers/hwmon/k8temp.c
+++ b/drivers/hwmon/k8temp.c
@@ -1,5 +1,6 @@
 /*
  * k8temp.c - Linux kernel module for hardware monitoring
+ * 	      for AMD K8 and derivates
  *
  * Copyright (C) 2006 Rudolf Marek <r.marek@assembler.cz>
  *
@@ -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
@@ -52,6 +53,20 @@ struct k8temp_data {
 	u32 temp_offset;
 };
 
+static const char report[] = "Please send below message to: "
+			     "LKML <linux-kernel@vger.kernel.org>, "
+			     "Rudolf Marek <r.marek@assembler.cz>, "
+			     "Jaswinder Singh Rajput <jaswinder@kernel.org>"
+			     "\n\"Invalid temperature:";
+
+static unsigned long temp_from_reg(unsigned long val)
+{
+	if (boot_cpu_data.x86 > 0xf)
+		return ((val) >> 21) * 125;
+	else
+		return ((((val) >> 16) & 0xff) - 49) * 1000;
+}
+
 static struct k8temp_data *k8temp_update_device(struct device *dev)
 {
 	struct k8temp_data *data = dev_get_drvdata(dev);
@@ -62,6 +77,11 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
 
 	if (!data->valid
 	    || time_after(jiffies, data->last_updated + HZ)) {
+		if (boot_cpu_data.x86 > 0xf) {
+			pci_read_config_dword(pdev, REG_TCTL,
+					      &data->temp[0][0]);
+			goto update_done;
+		}
 		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);
@@ -89,6 +109,7 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
 			}
 		}
 
+update_done:
 		data->last_updated = jiffies;
 		data->valid = 1;
 	}
@@ -123,7 +144,14 @@ static ssize_t show_temp(struct device *dev,
 	if (data->swap_core_select)
 		core = core ? 0 : 1;
 
-	temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;
+	temp = temp_from_reg(data->temp[core][place]) + data->temp_offset;
+
+	/* Some AMD 10H cpus reports Inaccurate Temperature Measurement */
+	if ((temp < 21000) || (temp > 90000))
+		WARN_ONCE(1, "%s reg 0x%x temp %d for %d:%d:%d:%d\"\n",
+			  report, data->temp[core][place], temp,
+			  boot_cpu_data.x86_vendor, boot_cpu_data.x86,
+			  boot_cpu_data.x86_model, boot_cpu_data.x86_mask);
 
 	return sprintf(buf, "%d\n", temp);
 }
@@ -138,6 +166,8 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
 
 static struct pci_device_id k8temp_ids[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) },
 	{ 0 },
 };
 
@@ -157,6 +187,9 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
 		goto exit;
 	}
 
+	if (boot_cpu_data.x86 > 0xf)
+		goto probe_done;
+
 	model = boot_cpu_data.x86_model;
 	stepping = boot_cpu_data.x86_mask;
 
@@ -226,6 +259,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
 			data->sensorsp &= ~SEL_CORE;
 	}
 
+probe_done:
 	data->name = "k8temp";
 	mutex_init(&data->update_lock);
 	dev_set_drvdata(&pdev->dev, data);
-- 
1.6.0.6




^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
  2009-05-26 12:10         ` Jaswinder Singh Rajput
@ 2009-05-26 15:20           ` Rudolf Marek
  2009-05-26 15:44             ` Jaswinder Singh Rajput
  0 siblings, 1 reply; 21+ messages in thread
From: Rudolf Marek @ 2009-05-26 15:20 UTC (permalink / raw)
  To: Jaswinder Singh Rajput; +Cc: Ingo Molnar, x86 maintainers, LKML, LM Sensors

Hello,

Sorry I disagree. Lets skip whole 10H. I failed many times to get some useful 
info from AMD about this issue. I'm strongly against to impose some limits which 
might indicate what is OK and what is not.

Rudolf



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
  2009-05-26 15:20           ` Rudolf Marek
@ 2009-05-26 15:44             ` Jaswinder Singh Rajput
  2009-05-28 11:57               ` Jaswinder Singh Rajput
                                 ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-05-26 15:44 UTC (permalink / raw)
  To: Rudolf Marek; +Cc: Ingo Molnar, x86 maintainers, LKML, LM Sensors

On Tue, 2009-05-26 at 17:20 +0200, Rudolf Marek wrote:
> Hello,
> 
> Sorry I disagree. Lets skip whole 10H. I failed many times to get some useful 
> info from AMD about this issue. I'm strongly against to impose some limits which 
> might indicate what is OK and what is not.
> 

OK, So here is new patch after skipping 10H. I hope I will get ack
now ;-)

Subject: [PATCH] x86: hwmon/k8temp.c Add support for AMD 11H

This patch will also work for AMD 10H. But we are skipping it as :

AMD 10H cpus reports Inaccurate Temperature Measurement:
http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
Errata #319

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
---
 drivers/hwmon/k8temp.c |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
index 1fe9951..4459dbf 100644
--- a/drivers/hwmon/k8temp.c
+++ b/drivers/hwmon/k8temp.c
@@ -1,5 +1,6 @@
 /*
  * k8temp.c - Linux kernel module for hardware monitoring
+ * 	      for AMD K8 and derivatives
  *
  * Copyright (C) 2006 Rudolf Marek <r.marek@assembler.cz>
  *
@@ -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
@@ -52,6 +53,14 @@ struct k8temp_data {
 	u32 temp_offset;
 };
 
+static unsigned long temp_from_reg(unsigned long val)
+{
+	if (boot_cpu_data.x86 > 0xf)
+		return ((val) >> 21) * 125;
+	else
+		return ((((val) >> 16) & 0xff) - 49) * 1000;
+}
+
 static struct k8temp_data *k8temp_update_device(struct device *dev)
 {
 	struct k8temp_data *data = dev_get_drvdata(dev);
@@ -62,6 +71,11 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
 
 	if (!data->valid
 	    || time_after(jiffies, data->last_updated + HZ)) {
+		if (boot_cpu_data.x86 > 0xf) {
+			pci_read_config_dword(pdev, REG_TCTL,
+					      &data->temp[0][0]);
+			goto update_done;
+		}
 		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);
@@ -89,6 +103,7 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
 			}
 		}
 
+update_done:
 		data->last_updated = jiffies;
 		data->valid = 1;
 	}
@@ -123,7 +138,7 @@ static ssize_t show_temp(struct device *dev,
 	if (data->swap_core_select)
 		core = core ? 0 : 1;
 
-	temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;
+	temp = temp_from_reg(data->temp[core][place]) + data->temp_offset;
 
 	return sprintf(buf, "%d\n", temp);
 }
@@ -138,6 +153,14 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
 
 static struct pci_device_id k8temp_ids[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
+	/*
+	 * AMD 10H cpus reports Inaccurate Temperature Measurement :
+	 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
+	 *     Errata #319
+	 * So skipping 10H
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
+	 */
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) },
 	{ 0 },
 };
 
@@ -157,6 +180,9 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
 		goto exit;
 	}
 
+	if (boot_cpu_data.x86 > 0xf)
+		goto probe_done;
+
 	model = boot_cpu_data.x86_model;
 	stepping = boot_cpu_data.x86_mask;
 
@@ -226,6 +252,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
 			data->sensorsp &= ~SEL_CORE;
 	}
 
+probe_done:
 	data->name = "k8temp";
 	mutex_init(&data->update_lock);
 	dev_set_drvdata(&pdev->dev, data);
-- 
1.6.0.6




^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
  2009-05-26 15:44             ` Jaswinder Singh Rajput
@ 2009-05-28 11:57               ` Jaswinder Singh Rajput
  2009-05-28 12:28                 ` [lm-sensors] " Jean Delvare
  2009-06-06 10:36               ` Jaswinder Singh Rajput
  2009-06-20  7:56               ` [HWMON] x86: hwmon/k8temp.c Add support for AMD 11H Jaswinder Singh Rajput
  2 siblings, 1 reply; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-05-28 11:57 UTC (permalink / raw)
  To: Andrew Morton, Greg KH, stable, Ingo Molnar
  Cc: x86 maintainers, LKML, LM Sensors, Rudolf Marek

Hello Andrew, Greg and Ingo:

Do you think this patch should go to stable and latest git.

Thanks,
--
JSR

On Tue, 2009-05-26 at 21:14 +0530, Jaswinder Singh Rajput wrote:
> On Tue, 2009-05-26 at 17:20 +0200, Rudolf Marek wrote:
> > Hello,
> > 
> > Sorry I disagree. Lets skip whole 10H. I failed many times to get some useful 
> > info from AMD about this issue. I'm strongly against to impose some limits which 
> > might indicate what is OK and what is not.
> > 
> 
> OK, So here is new patch after skipping 10H. I hope I will get ack
> now ;-)
> 
> Subject: [PATCH] x86: hwmon/k8temp.c Add support for AMD 11H
> 
> This patch will also work for AMD 10H. But we are skipping it as :
> 
> AMD 10H cpus reports Inaccurate Temperature Measurement:
> http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
> Errata #319
> 
> Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
> ---
>  drivers/hwmon/k8temp.c |   31 +++++++++++++++++++++++++++++--
>  1 files changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
> index 1fe9951..4459dbf 100644
> --- a/drivers/hwmon/k8temp.c
> +++ b/drivers/hwmon/k8temp.c
> @@ -1,5 +1,6 @@
>  /*
>   * k8temp.c - Linux kernel module for hardware monitoring
> + * 	      for AMD K8 and derivatives
>   *
>   * Copyright (C) 2006 Rudolf Marek <r.marek@assembler.cz>
>   *
> @@ -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
> @@ -52,6 +53,14 @@ struct k8temp_data {
>  	u32 temp_offset;
>  };
>  
> +static unsigned long temp_from_reg(unsigned long val)
> +{
> +	if (boot_cpu_data.x86 > 0xf)
> +		return ((val) >> 21) * 125;
> +	else
> +		return ((((val) >> 16) & 0xff) - 49) * 1000;
> +}
> +
>  static struct k8temp_data *k8temp_update_device(struct device *dev)
>  {
>  	struct k8temp_data *data = dev_get_drvdata(dev);
> @@ -62,6 +71,11 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
>  
>  	if (!data->valid
>  	    || time_after(jiffies, data->last_updated + HZ)) {
> +		if (boot_cpu_data.x86 > 0xf) {
> +			pci_read_config_dword(pdev, REG_TCTL,
> +					      &data->temp[0][0]);
> +			goto update_done;
> +		}
>  		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);
> @@ -89,6 +103,7 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
>  			}
>  		}
>  
> +update_done:
>  		data->last_updated = jiffies;
>  		data->valid = 1;
>  	}
> @@ -123,7 +138,7 @@ static ssize_t show_temp(struct device *dev,
>  	if (data->swap_core_select)
>  		core = core ? 0 : 1;
>  
> -	temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;
> +	temp = temp_from_reg(data->temp[core][place]) + data->temp_offset;
>  
>  	return sprintf(buf, "%d\n", temp);
>  }
> @@ -138,6 +153,14 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
>  
>  static struct pci_device_id k8temp_ids[] = {
>  	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
> +	/*
> +	 * AMD 10H cpus reports Inaccurate Temperature Measurement :
> +	 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
> +	 *     Errata #319
> +	 * So skipping 10H
> +	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
> +	 */
> +	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) },
>  	{ 0 },
>  };
>  
> @@ -157,6 +180,9 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
>  		goto exit;
>  	}
>  
> +	if (boot_cpu_data.x86 > 0xf)
> +		goto probe_done;
> +
>  	model = boot_cpu_data.x86_model;
>  	stepping = boot_cpu_data.x86_mask;
>  
> @@ -226,6 +252,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
>  			data->sensorsp &= ~SEL_CORE;
>  	}
>  
> +probe_done:
>  	data->name = "k8temp";
>  	mutex_init(&data->update_lock);
>  	dev_set_drvdata(&pdev->dev, data);


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [lm-sensors] [PATCH-tip] x86: hwmon/k8temp.c Add support for  AMD 10H and 11H
  2009-05-28 11:57               ` Jaswinder Singh Rajput
@ 2009-05-28 12:28                 ` Jean Delvare
  2009-05-28 14:13                   ` Jaswinder Singh Rajput
  0 siblings, 1 reply; 21+ messages in thread
From: Jean Delvare @ 2009-05-28 12:28 UTC (permalink / raw)
  To: Jaswinder Singh Rajput
  Cc: Andrew Morton, Greg KH, stable, Ingo Molnar, x86 maintainers,
	LKML, LM Sensors

On Thu, 28 May 2009 17:27:29 +0530, Jaswinder Singh Rajput wrote:
> Hello Andrew, Greg and Ingo:
> 
> Do you think this patch should go to stable and latest git.

Definitely not to stable, it's not fixing any bug.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [lm-sensors] [PATCH-tip] x86: hwmon/k8temp.c Add support for  AMD 10H and 11H
  2009-05-28 12:28                 ` [lm-sensors] " Jean Delvare
@ 2009-05-28 14:13                   ` Jaswinder Singh Rajput
  2009-05-28 14:49                     ` [stable] " Greg KH
  0 siblings, 1 reply; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-05-28 14:13 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Andrew Morton, Greg KH, stable, Ingo Molnar, x86 maintainers,
	LKML, LM Sensors

On Thu, 2009-05-28 at 14:28 +0200, Jean Delvare wrote:
> On Thu, 28 May 2009 17:27:29 +0530, Jaswinder Singh Rajput wrote:
> > Hello Andrew, Greg and Ingo:
> > 
> > Do you think this patch should go to stable and latest git.
> 
> Definitely not to stable, it's not fixing any bug.
> 

Ok, so you suggested this should go to latest git.

I proposed for stable because I was using AMD 11H from last 6 months and
I was missing temperature monitor badly because my earlier Laptop was
broken by overheating. So I thought if it goes to stable then users will
start getting benefit of it, but if you want that users should wait for
another 2 years. Then it is OK ;-)

Thanks,
--
JSR


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [stable] [lm-sensors] [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
  2009-05-28 14:13                   ` Jaswinder Singh Rajput
@ 2009-05-28 14:49                     ` Greg KH
  2009-05-29  5:42                       ` Jaswinder Singh Rajput
  0 siblings, 1 reply; 21+ messages in thread
From: Greg KH @ 2009-05-28 14:49 UTC (permalink / raw)
  To: Jaswinder Singh Rajput
  Cc: Jean Delvare, x86 maintainers, LKML, stable, Andrew Morton,
	LM Sensors, Ingo Molnar

On Thu, May 28, 2009 at 07:43:34PM +0530, Jaswinder Singh Rajput wrote:
> On Thu, 2009-05-28 at 14:28 +0200, Jean Delvare wrote:
> > On Thu, 28 May 2009 17:27:29 +0530, Jaswinder Singh Rajput wrote:
> > > Hello Andrew, Greg and Ingo:
> > > 
> > > Do you think this patch should go to stable and latest git.
> > 
> > Definitely not to stable, it's not fixing any bug.
> > 
> 
> Ok, so you suggested this should go to latest git.
> 
> I proposed for stable because I was using AMD 11H from last 6 months and
> I was missing temperature monitor badly because my earlier Laptop was
> broken by overheating. So I thought if it goes to stable then users will
> start getting benefit of it, but if you want that users should wait for
> another 2 years. Then it is OK ;-)

2 years?  The next kernel release will be out in 3 months, we have a
very predictable release schedule.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [stable] [lm-sensors] [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
  2009-05-28 14:49                     ` [stable] " Greg KH
@ 2009-05-29  5:42                       ` Jaswinder Singh Rajput
  2009-05-29  6:05                         ` Jean Delvare
  0 siblings, 1 reply; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-05-29  5:42 UTC (permalink / raw)
  To: Greg KH
  Cc: Jean Delvare, x86 maintainers, LKML, stable, Andrew Morton,
	LM Sensors, Ingo Molnar

Hi Greg,

On Thu, 2009-05-28 at 07:49 -0700, Greg KH wrote:
> On Thu, May 28, 2009 at 07:43:34PM +0530, Jaswinder Singh Rajput wrote:
> > On Thu, 2009-05-28 at 14:28 +0200, Jean Delvare wrote:
> > > On Thu, 28 May 2009 17:27:29 +0530, Jaswinder Singh Rajput wrote:
> > > > Hello Andrew, Greg and Ingo:
> > > > 
> > > > Do you think this patch should go to stable and latest git.
> > > 
> > > Definitely not to stable, it's not fixing any bug.
> > > 
> > 
> > Ok, so you suggested this should go to latest git.
> > 
> > I proposed for stable because I was using AMD 11H from last 6 months and
> > I was missing temperature monitor badly because my earlier Laptop was
> > broken by overheating. So I thought if it goes to stable then users will
> > start getting benefit of it, but if you want that users should wait for
> > another 2 years. Then it is OK ;-)
> 
> 2 years?  The next kernel release will be out in 3 months, we have a
> very predictable release schedule.
> 

I am sorry for being unclear. I meant for linux distros. Even one of the
most active Fedora 10 is using vmlinuz-2.6.27.24-170.2.68.fc10.x86_64 is
almost 7 months behind the linus git. And another linux distro are still
using 2.6.22 or so which are almost 2 years behind linus git.

Thanks,
--
JSR


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH-tip] x86: hwmon/k8temp.c Add  support for AMD 10H and 11H
  2009-05-29  5:42                       ` Jaswinder Singh Rajput
@ 2009-05-29  6:05                         ` Jean Delvare
  0 siblings, 0 replies; 21+ messages in thread
From: Jean Delvare @ 2009-05-29  6:05 UTC (permalink / raw)
  To: Jaswinder Singh Rajput
  Cc: Greg KH, x86 maintainers, LKML, stable, Andrew Morton, LM Sensors,
	Ingo Molnar

On Fri, 29 May 2009 11:12:15 +0530, Jaswinder Singh Rajput wrote:
> Hi Greg,
> 
> On Thu, 2009-05-28 at 07:49 -0700, Greg KH wrote:
> > On Thu, May 28, 2009 at 07:43:34PM +0530, Jaswinder Singh Rajput wrote:
> > > I proposed for stable because I was using AMD 11H from last 6 months and
> > > I was missing temperature monitor badly because my earlier Laptop was
> > > broken by overheating. So I thought if it goes to stable then users will
> > > start getting benefit of it, but if you want that users should wait for
> > > another 2 years. Then it is OK ;-)
> > 
> > 2 years?  The next kernel release will be out in 3 months, we have a
> > very predictable release schedule.
> 
> I am sorry for being unclear. I meant for linux distros. Even one of the
> most active Fedora 10 is using vmlinuz-2.6.27.24-170.2.68.fc10.x86_64 is
> almost 7 months behind the linus git. And another linux distro are still
> using 2.6.22 or so which are almost 2 years behind linus git.

Distributions are free to backport any patch they like to their kernel
tree, at any time.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H
  2009-05-26 15:44             ` Jaswinder Singh Rajput
  2009-05-28 11:57               ` Jaswinder Singh Rajput
@ 2009-06-06 10:36               ` Jaswinder Singh Rajput
  2009-06-20  7:56               ` [HWMON] x86: hwmon/k8temp.c Add support for AMD 11H Jaswinder Singh Rajput
  2 siblings, 0 replies; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-06-06 10:36 UTC (permalink / raw)
  To: Rudolf Marek; +Cc: Ingo Molnar, x86 maintainers, LKML, LM Sensors

Hello Rudolf,

On Tue, 2009-05-26 at 21:14 +0530, Jaswinder Singh Rajput wrote:
> On Tue, 2009-05-26 at 17:20 +0200, Rudolf Marek wrote:
> > Hello,
> > 
> > Sorry I disagree. Lets skip whole 10H. I failed many times to get some useful 
> > info from AMD about this issue. I'm strongly against to impose some limits which 
> > might indicate what is OK and what is not.
> > 
> 
> OK, So here is new patch after skipping 10H. I hope I will get ack
> now ;-)
> 
> Subject: [PATCH] x86: hwmon/k8temp.c Add support for AMD 11H
> 
> This patch will also work for AMD 10H. But we are skipping it as :
> 
> AMD 10H cpus reports Inaccurate Temperature Measurement:
> http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
> Errata #319
> 
> Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
> ---

As per your suggestion I skipped whole 10H. Have you queued this patch
or there is still some issues left.

Thanks,
--
JSR


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [HWMON] x86: hwmon/k8temp.c Add support for AMD 11H
  2009-05-26 15:44             ` Jaswinder Singh Rajput
  2009-05-28 11:57               ` Jaswinder Singh Rajput
  2009-06-06 10:36               ` Jaswinder Singh Rajput
@ 2009-06-20  7:56               ` Jaswinder Singh Rajput
  2009-06-25 14:09                 ` Jaswinder Singh Rajput
  2 siblings, 1 reply; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-06-20  7:56 UTC (permalink / raw)
  To: Rudolf Marek
  Cc: Ingo Molnar, x86 maintainers, LKML, LM Sensors, Chuck Ebbert,
	fedora-kernel-owner, Jean Delvare


This patch will also work for AMD 10H. But we are skipping it as :

AMD 10H cpus reports Inaccurate Temperature Measurement:
http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
Errata #319

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
---
 drivers/hwmon/k8temp.c |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
index 1fe9951..4459dbf 100644
--- a/drivers/hwmon/k8temp.c
+++ b/drivers/hwmon/k8temp.c
@@ -1,5 +1,6 @@
 /*
  * k8temp.c - Linux kernel module for hardware monitoring
+ * 	      for AMD K8 and derivatives
  *
  * Copyright (C) 2006 Rudolf Marek <r.marek@assembler.cz>
  *
@@ -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
@@ -52,6 +53,14 @@ struct k8temp_data {
 	u32 temp_offset;
 };
 
+static unsigned long temp_from_reg(unsigned long val)
+{
+	if (boot_cpu_data.x86 > 0xf)
+		return ((val) >> 21) * 125;
+	else
+		return ((((val) >> 16) & 0xff) - 49) * 1000;
+}
+
 static struct k8temp_data *k8temp_update_device(struct device *dev)
 {
 	struct k8temp_data *data = dev_get_drvdata(dev);
@@ -62,6 +71,11 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
 
 	if (!data->valid
 	    || time_after(jiffies, data->last_updated + HZ)) {
+		if (boot_cpu_data.x86 > 0xf) {
+			pci_read_config_dword(pdev, REG_TCTL,
+					      &data->temp[0][0]);
+			goto update_done;
+		}
 		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);
@@ -89,6 +103,7 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
 			}
 		}
 
+update_done:
 		data->last_updated = jiffies;
 		data->valid = 1;
 	}
@@ -123,7 +138,7 @@ static ssize_t show_temp(struct device *dev,
 	if (data->swap_core_select)
 		core = core ? 0 : 1;
 
-	temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;
+	temp = temp_from_reg(data->temp[core][place]) + data->temp_offset;
 
 	return sprintf(buf, "%d\n", temp);
 }
@@ -138,6 +153,14 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
 
 static struct pci_device_id k8temp_ids[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
+	/*
+	 * AMD 10H cpus reports Inaccurate Temperature Measurement :
+	 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
+	 *     Errata #319
+	 * So skipping 10H
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
+	 */
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) },
 	{ 0 },
 };
 
@@ -157,6 +180,9 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
 		goto exit;
 	}
 
+	if (boot_cpu_data.x86 > 0xf)
+		goto probe_done;
+
 	model = boot_cpu_data.x86_model;
 	stepping = boot_cpu_data.x86_mask;
 
@@ -226,6 +252,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
 			data->sensorsp &= ~SEL_CORE;
 	}
 
+probe_done:
 	data->name = "k8temp";
 	mutex_init(&data->update_lock);
 	dev_set_drvdata(&pdev->dev, data);
-- 
1.6.0.6




^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [HWMON] x86: hwmon/k8temp.c Add support for AMD 11H
  2009-06-20  7:56               ` [HWMON] x86: hwmon/k8temp.c Add support for AMD 11H Jaswinder Singh Rajput
@ 2009-06-25 14:09                 ` Jaswinder Singh Rajput
  2009-07-19  5:03                   ` Jaswinder Singh Rajput
  0 siblings, 1 reply; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-06-25 14:09 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Rudolf Marek, x86 maintainers, LKML, LM Sensors, Chuck Ebbert,
	fedora-kernel-owner, Jean Delvare

Ingo,

I need to apply and then revert this patch each and every time I fetch
-tip tree. And I need to do this many times like 20-30 times in a day.

I need this patch to monitor the temperature for AMD 11H box as it is
very hot here temp is around 47 C and my CPU temp goes high upto 87 C.
My one AMD box is already broken due to high temperature.

By using this patch I breaks building of the kernel as temperature
reaches 80 C.

I hope you understand my problem.

If possible, can you please apply this patch in tip:out-of-tree 
(not-for-upstream)

Thanks,
--
JSR

On Sat, 2009-06-20 at 13:26 +0530, Jaswinder Singh Rajput wrote:
> This patch will also work for AMD 10H. But we are skipping it as :
> 
> AMD 10H cpus reports Inaccurate Temperature Measurement:
> http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
> Errata #319
> 
> Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
> ---
>  drivers/hwmon/k8temp.c |   31 +++++++++++++++++++++++++++++--
>  1 files changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
> index 1fe9951..4459dbf 100644
> --- a/drivers/hwmon/k8temp.c
> +++ b/drivers/hwmon/k8temp.c
> @@ -1,5 +1,6 @@
>  /*
>   * k8temp.c - Linux kernel module for hardware monitoring
> + * 	      for AMD K8 and derivatives
>   *
>   * Copyright (C) 2006 Rudolf Marek <r.marek@assembler.cz>
>   *
> @@ -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
> @@ -52,6 +53,14 @@ struct k8temp_data {
>  	u32 temp_offset;
>  };
>  
> +static unsigned long temp_from_reg(unsigned long val)
> +{
> +	if (boot_cpu_data.x86 > 0xf)
> +		return ((val) >> 21) * 125;
> +	else
> +		return ((((val) >> 16) & 0xff) - 49) * 1000;
> +}
> +
>  static struct k8temp_data *k8temp_update_device(struct device *dev)
>  {
>  	struct k8temp_data *data = dev_get_drvdata(dev);
> @@ -62,6 +71,11 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
>  
>  	if (!data->valid
>  	    || time_after(jiffies, data->last_updated + HZ)) {
> +		if (boot_cpu_data.x86 > 0xf) {
> +			pci_read_config_dword(pdev, REG_TCTL,
> +					      &data->temp[0][0]);
> +			goto update_done;
> +		}
>  		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);
> @@ -89,6 +103,7 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
>  			}
>  		}
>  
> +update_done:
>  		data->last_updated = jiffies;
>  		data->valid = 1;
>  	}
> @@ -123,7 +138,7 @@ static ssize_t show_temp(struct device *dev,
>  	if (data->swap_core_select)
>  		core = core ? 0 : 1;
>  
> -	temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;
> +	temp = temp_from_reg(data->temp[core][place]) + data->temp_offset;
>  
>  	return sprintf(buf, "%d\n", temp);
>  }
> @@ -138,6 +153,14 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
>  
>  static struct pci_device_id k8temp_ids[] = {
>  	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
> +	/*
> +	 * AMD 10H cpus reports Inaccurate Temperature Measurement :
> +	 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
> +	 *     Errata #319
> +	 * So skipping 10H
> +	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
> +	 */
> +	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) },
>  	{ 0 },
>  };
>  
> @@ -157,6 +180,9 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
>  		goto exit;
>  	}
>  
> +	if (boot_cpu_data.x86 > 0xf)
> +		goto probe_done;
> +
>  	model = boot_cpu_data.x86_model;
>  	stepping = boot_cpu_data.x86_mask;
>  
> @@ -226,6 +252,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
>  			data->sensorsp &= ~SEL_CORE;
>  	}
>  
> +probe_done:
>  	data->name = "k8temp";
>  	mutex_init(&data->update_lock);
>  	dev_set_drvdata(&pdev->dev, data);


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [HWMON] x86: hwmon/k8temp.c Add support for AMD 11H
  2009-06-25 14:09                 ` Jaswinder Singh Rajput
@ 2009-07-19  5:03                   ` Jaswinder Singh Rajput
  0 siblings, 0 replies; 21+ messages in thread
From: Jaswinder Singh Rajput @ 2009-07-19  5:03 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Rudolf Marek, x86 maintainers, LKML, LM Sensors, Chuck Ebbert,
	fedora-kernel-owner, Jean Delvare

Hello Ingo,

Now I do not use -tip tree, if you want you can remove this patch from
-tip (commit 318e6a08d340d85)

Thanks for your help and support.
--
JSR

On Thu, 2009-06-25 at 19:39 +0530, Jaswinder Singh Rajput wrote:
> Ingo,
> 
> I need to apply and then revert this patch each and every time I fetch
> -tip tree. And I need to do this many times like 20-30 times in a day.
> 
> I need this patch to monitor the temperature for AMD 11H box as it is
> very hot here temp is around 47 C and my CPU temp goes high upto 87 C.
> My one AMD box is already broken due to high temperature.
> 
> By using this patch I breaks building of the kernel as temperature
> reaches 80 C.
> 
> I hope you understand my problem.
> 
> If possible, can you please apply this patch in tip:out-of-tree 
> (not-for-upstream)
> 
> Thanks,
> --
> JSR
> 
> On Sat, 2009-06-20 at 13:26 +0530, Jaswinder Singh Rajput wrote:
> > This patch will also work for AMD 10H. But we are skipping it as :
> > 
> > AMD 10H cpus reports Inaccurate Temperature Measurement:
> > http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
> > Errata #319
> > 
> > Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
> > ---
> >  drivers/hwmon/k8temp.c |   31 +++++++++++++++++++++++++++++--
> >  1 files changed, 29 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
> > index 1fe9951..4459dbf 100644
> > --- a/drivers/hwmon/k8temp.c
> > +++ b/drivers/hwmon/k8temp.c
> > @@ -1,5 +1,6 @@
> >  /*
> >   * k8temp.c - Linux kernel module for hardware monitoring
> > + * 	      for AMD K8 and derivatives
> >   *
> >   * Copyright (C) 2006 Rudolf Marek <r.marek@assembler.cz>
> >   *
> > @@ -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
> > @@ -52,6 +53,14 @@ struct k8temp_data {
> >  	u32 temp_offset;
> >  };
> >  
> > +static unsigned long temp_from_reg(unsigned long val)
> > +{
> > +	if (boot_cpu_data.x86 > 0xf)
> > +		return ((val) >> 21) * 125;
> > +	else
> > +		return ((((val) >> 16) & 0xff) - 49) * 1000;
> > +}
> > +
> >  static struct k8temp_data *k8temp_update_device(struct device *dev)
> >  {
> >  	struct k8temp_data *data = dev_get_drvdata(dev);
> > @@ -62,6 +71,11 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
> >  
> >  	if (!data->valid
> >  	    || time_after(jiffies, data->last_updated + HZ)) {
> > +		if (boot_cpu_data.x86 > 0xf) {
> > +			pci_read_config_dword(pdev, REG_TCTL,
> > +					      &data->temp[0][0]);
> > +			goto update_done;
> > +		}
> >  		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);
> > @@ -89,6 +103,7 @@ static struct k8temp_data *k8temp_update_device(struct device *dev)
> >  			}
> >  		}
> >  
> > +update_done:
> >  		data->last_updated = jiffies;
> >  		data->valid = 1;
> >  	}
> > @@ -123,7 +138,7 @@ static ssize_t show_temp(struct device *dev,
> >  	if (data->swap_core_select)
> >  		core = core ? 0 : 1;
> >  
> > -	temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;
> > +	temp = temp_from_reg(data->temp[core][place]) + data->temp_offset;
> >  
> >  	return sprintf(buf, "%d\n", temp);
> >  }
> > @@ -138,6 +153,14 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
> >  
> >  static struct pci_device_id k8temp_ids[] = {
> >  	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
> > +	/*
> > +	 * AMD 10H cpus reports Inaccurate Temperature Measurement :
> > +	 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/41322.pdf
> > +	 *     Errata #319
> > +	 * So skipping 10H
> > +	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
> > +	 */
> > +	{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) },
> >  	{ 0 },
> >  };
> >  
> > @@ -157,6 +180,9 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
> >  		goto exit;
> >  	}
> >  
> > +	if (boot_cpu_data.x86 > 0xf)
> > +		goto probe_done;
> > +
> >  	model = boot_cpu_data.x86_model;
> >  	stepping = boot_cpu_data.x86_mask;
> >  
> > @@ -226,6 +252,7 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
> >  			data->sensorsp &= ~SEL_CORE;
> >  	}
> >  
> > +probe_done:
> >  	data->name = "k8temp";
> >  	mutex_init(&data->update_lock);
> >  	dev_set_drvdata(&pdev->dev, data);


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2009-07-19  5:07 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-22  8:04 [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H Jaswinder Singh Rajput
2009-05-22  8:16 ` Rudolf Marek
2009-05-22  8:42   ` Jaswinder Singh Rajput
2009-05-22  9:30     ` Jaswinder Singh Rajput
2009-05-23 16:59       ` Rudolf Marek
2009-05-24 12:19         ` Jaswinder Singh Rajput
2009-05-26 12:10         ` Jaswinder Singh Rajput
2009-05-26 15:20           ` Rudolf Marek
2009-05-26 15:44             ` Jaswinder Singh Rajput
2009-05-28 11:57               ` Jaswinder Singh Rajput
2009-05-28 12:28                 ` [lm-sensors] " Jean Delvare
2009-05-28 14:13                   ` Jaswinder Singh Rajput
2009-05-28 14:49                     ` [stable] " Greg KH
2009-05-29  5:42                       ` Jaswinder Singh Rajput
2009-05-29  6:05                         ` Jean Delvare
2009-06-06 10:36               ` Jaswinder Singh Rajput
2009-06-20  7:56               ` [HWMON] x86: hwmon/k8temp.c Add support for AMD 11H Jaswinder Singh Rajput
2009-06-25 14:09                 ` Jaswinder Singh Rajput
2009-07-19  5:03                   ` Jaswinder Singh Rajput
2009-05-25 13:45       ` [lm-sensors] [PATCH-tip] x86: hwmon/k8temp.c Add support for AMD 10H and 11H Jean Delvare
2009-05-25 14:17         ` Jaswinder Singh Rajput

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox