All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carsten Emde <Carsten.Emde@osadl.org>
To: Huaxu Wan <huaxu.wan@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org,
	Huaxu Wan <huaxu.wan@intel.com>
Subject: Re: [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from
Date: Fri, 07 May 2010 13:29:28 +0000	[thread overview]
Message-ID: <4BE415B8.1010400@osadl.org> (raw)
In-Reply-To: <20100507095945.GB12190@owl>

[-- Attachment #1: Type: text/plain, Size: 435 bytes --]

Hi Huaxu,

> The MSR IA32_TEMPERATURE_TARGET contains the TjMax value in the newer
> processers.
I took the liberty to make some very minor changes to your patch:
- Unified and adapted messages and comments
- Added a definition of MSR_IA32_TEMPERATURE_TARGET to the arch header
- Replaced 0x1a2 by MSR_IA32_TEMPERATURE_TARGET
- Applied changes suggested by checkpatch

Hope you like it.

Signed-off-by: Carsten Emde <C.Emde@osadl.org>

[-- Attachment #2: coretemp-add-tjmax-method-for-i-series-processors.patch --]
[-- Type: text/x-patch, Size: 3105 bytes --]

---
 arch/x86/include/asm/msr-index.h |    3 ++
 drivers/hwmon/coretemp.c         |   54 ++++++++++++++++++++++++++++++++++++---
 2 files changed, 53 insertions(+), 4 deletions(-)

Index: head/arch/x86/include/asm/msr-index.h
===================================================================
--- head.orig/arch/x86/include/asm/msr-index.h
+++ head/arch/x86/include/asm/msr-index.h
@@ -277,6 +277,9 @@
 #define MSR_IA32_MCG_EIP		0x00000189
 #define MSR_IA32_MCG_RESERVED		0x0000018a
 
+/* Specific to i series processors */
+#define MSR_IA32_TEMPERATURE_TARGET	0x000001a2
+
 /* Pentium IV performance counter MSRs */
 #define MSR_P4_BPU_PERFCTR0		0x00000300
 #define MSR_P4_BPU_PERFCTR1		0x00000301
Index: head/drivers/hwmon/coretemp.c
===================================================================
--- head.orig/drivers/hwmon/coretemp.c
+++ head/drivers/hwmon/coretemp.c
@@ -153,7 +153,8 @@ static struct coretemp_data *coretemp_up
 	return data;
 }
 
-static int __devinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
+static int __devinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id,
+				  struct device *dev)
 {
 	/* The 100C is default for both mobile and non mobile CPUs */
 
@@ -241,6 +242,51 @@ static int __devinit adjust_tjmax(struct
 	return tjmax;
 }
 
+static int __devinit get_tjmax(struct cpuinfo_x86 *c, u32 id,
+			       struct device *dev)
+{
+	int err;
+	u32 eax, edx;
+	u32 val;
+
+	err = rdmsr_safe_on_cpu(id, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx);
+	if (err)
+		dev_warn(dev, "Unable to read TjMax from CPU.\n");
+	else {
+		val = (eax >> 16) & 0xff;
+		if (val > 80 && val < 120) {
+			dev_info(dev, "TjMax is %dC.\n", val);
+			return val * 1000;
+		} else {
+			dev_warn(dev, "TjMax of %dC not plausible,"
+			    " using 100C instead." , val);
+			return 100000;
+		}
+	}
+
+	/*
+	 * An assumption is made for early CPUs and unreadable MSR.
+	 * NOTE: the given value may not be correct.
+	 */
+	switch (c->x86_model) {
+	case 0x0e:
+	case 0x0f:
+	case 0x16:
+	case 0x1a:
+		dev_warn(dev, "TjMax is assumed as 100C!\n");
+		return 100000;
+		break;
+	case 0x17:
+	case 0x1c: /* Atom CPUs */
+		return adjust_tjmax(c, id, dev);
+		break;
+	default:
+		dev_warn(dev, "CPU (model=0x%x) is not supported yet,"
+		    " using default TjMax of 100C.\n", c->x86_model);
+		return 100000;
+	}
+}
+
 static int __devinit coretemp_probe(struct platform_device *pdev)
 {
 	struct coretemp_data *data;
@@ -283,14 +329,14 @@ static int __devinit coretemp_probe(stru
 		}
 	}
 
-	data->tjmax = adjust_tjmax(c, data->id, &pdev->dev);
+	data->tjmax = get_tjmax(c, data->id, &pdev->dev);
 	platform_set_drvdata(pdev, data);
 
 	/* read the still undocumented IA32_TEMPERATURE_TARGET it exists
 	   on older CPUs but not in this register, Atoms don't have it either */
-
 	if ((c->x86_model > 0xe) && (c->x86_model != 0x1c)) {
-		err = rdmsr_safe_on_cpu(data->id, 0x1a2, &eax, &edx);
+		err = rdmsr_safe_on_cpu(data->id, MSR_IA32_TEMPERATURE_TARGET,
+		     &eax, &edx);
 		if (err) {
 			dev_warn(&pdev->dev, "Unable to read"
 					" IA32_TEMPERATURE_TARGET MSR\n");

[-- Attachment #3: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

WARNING: multiple messages have this Message-ID (diff)
From: Carsten Emde <Carsten.Emde@osadl.org>
To: Huaxu Wan <huaxu.wan@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org,
	Huaxu Wan <huaxu.wan@intel.com>
Subject: Re: [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR
Date: Fri, 07 May 2010 15:29:28 +0200	[thread overview]
Message-ID: <4BE415B8.1010400@osadl.org> (raw)
In-Reply-To: <20100507095945.GB12190@owl>

[-- Attachment #1: Type: text/plain, Size: 435 bytes --]

Hi Huaxu,

> The MSR IA32_TEMPERATURE_TARGET contains the TjMax value in the newer
> processers.
I took the liberty to make some very minor changes to your patch:
- Unified and adapted messages and comments
- Added a definition of MSR_IA32_TEMPERATURE_TARGET to the arch header
- Replaced 0x1a2 by MSR_IA32_TEMPERATURE_TARGET
- Applied changes suggested by checkpatch

Hope you like it.

Signed-off-by: Carsten Emde <C.Emde@osadl.org>

[-- Attachment #2: coretemp-add-tjmax-method-for-i-series-processors.patch --]
[-- Type: text/x-patch, Size: 3105 bytes --]

---
 arch/x86/include/asm/msr-index.h |    3 ++
 drivers/hwmon/coretemp.c         |   54 ++++++++++++++++++++++++++++++++++++---
 2 files changed, 53 insertions(+), 4 deletions(-)

Index: head/arch/x86/include/asm/msr-index.h
===================================================================
--- head.orig/arch/x86/include/asm/msr-index.h
+++ head/arch/x86/include/asm/msr-index.h
@@ -277,6 +277,9 @@
 #define MSR_IA32_MCG_EIP		0x00000189
 #define MSR_IA32_MCG_RESERVED		0x0000018a
 
+/* Specific to i series processors */
+#define MSR_IA32_TEMPERATURE_TARGET	0x000001a2
+
 /* Pentium IV performance counter MSRs */
 #define MSR_P4_BPU_PERFCTR0		0x00000300
 #define MSR_P4_BPU_PERFCTR1		0x00000301
Index: head/drivers/hwmon/coretemp.c
===================================================================
--- head.orig/drivers/hwmon/coretemp.c
+++ head/drivers/hwmon/coretemp.c
@@ -153,7 +153,8 @@ static struct coretemp_data *coretemp_up
 	return data;
 }
 
-static int __devinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
+static int __devinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id,
+				  struct device *dev)
 {
 	/* The 100C is default for both mobile and non mobile CPUs */
 
@@ -241,6 +242,51 @@ static int __devinit adjust_tjmax(struct
 	return tjmax;
 }
 
+static int __devinit get_tjmax(struct cpuinfo_x86 *c, u32 id,
+			       struct device *dev)
+{
+	int err;
+	u32 eax, edx;
+	u32 val;
+
+	err = rdmsr_safe_on_cpu(id, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx);
+	if (err)
+		dev_warn(dev, "Unable to read TjMax from CPU.\n");
+	else {
+		val = (eax >> 16) & 0xff;
+		if (val > 80 && val < 120) {
+			dev_info(dev, "TjMax is %dC.\n", val);
+			return val * 1000;
+		} else {
+			dev_warn(dev, "TjMax of %dC not plausible,"
+			    " using 100C instead." , val);
+			return 100000;
+		}
+	}
+
+	/*
+	 * An assumption is made for early CPUs and unreadable MSR.
+	 * NOTE: the given value may not be correct.
+	 */
+	switch (c->x86_model) {
+	case 0x0e:
+	case 0x0f:
+	case 0x16:
+	case 0x1a:
+		dev_warn(dev, "TjMax is assumed as 100C!\n");
+		return 100000;
+		break;
+	case 0x17:
+	case 0x1c: /* Atom CPUs */
+		return adjust_tjmax(c, id, dev);
+		break;
+	default:
+		dev_warn(dev, "CPU (model=0x%x) is not supported yet,"
+		    " using default TjMax of 100C.\n", c->x86_model);
+		return 100000;
+	}
+}
+
 static int __devinit coretemp_probe(struct platform_device *pdev)
 {
 	struct coretemp_data *data;
@@ -283,14 +329,14 @@ static int __devinit coretemp_probe(stru
 		}
 	}
 
-	data->tjmax = adjust_tjmax(c, data->id, &pdev->dev);
+	data->tjmax = get_tjmax(c, data->id, &pdev->dev);
 	platform_set_drvdata(pdev, data);
 
 	/* read the still undocumented IA32_TEMPERATURE_TARGET it exists
 	   on older CPUs but not in this register, Atoms don't have it either */
-
 	if ((c->x86_model > 0xe) && (c->x86_model != 0x1c)) {
-		err = rdmsr_safe_on_cpu(data->id, 0x1a2, &eax, &edx);
+		err = rdmsr_safe_on_cpu(data->id, MSR_IA32_TEMPERATURE_TARGET,
+		     &eax, &edx);
 		if (err) {
 			dev_warn(&pdev->dev, "Unable to read"
 					" IA32_TEMPERATURE_TARGET MSR\n");

  reply	other threads:[~2010-05-07 13:29 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-05 15:38 [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Huaxu Wan
2010-03-05 16:19 ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Luca Tettamanti
2010-03-08 14:44 ` Huaxu Wan
2010-05-07  9:59 ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Huaxu Wan
2010-05-07  9:59   ` Huaxu Wan
2010-05-07 13:29   ` Carsten Emde [this message]
2010-05-07 13:29     ` [lm-sensors] " Carsten Emde
2010-05-10  3:09     ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Huaxu Wan
2010-05-10  3:09       ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Huaxu Wan
2010-05-10  3:50   ` [lm-sensors] [PATCH 2/2 V2] hwmon: (coretemp) Get TjMax value from Huaxu Wan
2010-05-10  3:50     ` [PATCH 2/2 V2] hwmon: (coretemp) Get TjMax value from MSR Huaxu Wan
2010-05-29  5:39   ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Maxim Levitsky
2010-05-29  5:39     ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Maxim Levitsky
2010-05-30 14:43     ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Maxim Levitsky
2010-05-30 14:43       ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Maxim Levitsky
2010-05-31  1:39     ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Huaxu Wan
2010-05-31  1:39       ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Huaxu Wan
2010-06-02 16:34       ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Maxim Levitsky
2010-06-02 16:34         ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Maxim Levitsky
2010-06-02 20:10         ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Maxim Levitsky
2010-06-02 20:10           ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Maxim Levitsky
2010-06-12 13:03           ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Maxim Levitsky
2010-06-12 13:03             ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Maxim Levitsky
2010-06-13  2:27             ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Wan, Huaxu
2010-06-13  2:27               ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Wan, Huaxu
2010-07-26  8:16               ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Maxim Levitsky
2010-07-26  8:16                 ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Maxim Levitsky
2010-08-30  1:42                 ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Huaxu Wan
2010-08-30  1:42                   ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Huaxu Wan
2010-08-31 21:01                   ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Fenghua Yu
2010-08-31 21:01                     ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Fenghua Yu
  -- strict thread matches above, loose matches on Subject: below --
2010-03-05 15:28 [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal Huaxu Wan
2010-05-07  9:54 ` Huaxu Wan
2010-05-07  9:54   ` [PATCH 1/2] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-07 12:43   ` [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal Jean Delvare
2010-05-07 12:43     ` [PATCH 1/2] hwmon: (coretemp) Detect the thermal sensors by CPUID Jean Delvare
2010-05-07 13:21   ` [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal Carsten Emde
2010-05-07 13:21     ` [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal sensors by CPUID Carsten Emde
2010-05-10  2:35     ` [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal Huaxu Wan
2010-05-10  2:35       ` [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-10  3:35   ` [lm-sensors] [PATCH 1/2 V2] hwmon: (coretemp) Detect the thermal Huaxu Wan
2010-05-10  3:35     ` [PATCH 1/2 V2] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-10 12:45     ` [lm-sensors] [PATCH 1/2 V2] hwmon: (coretemp) Detect the Valdis.Kletnieks
2010-05-10 12:45       ` [PATCH 1/2 V2] hwmon: (coretemp) Detect the thermal sensors by CPUID Valdis.Kletnieks
2010-05-11  3:41       ` [lm-sensors] [PATCH 1/2 V2] hwmon: (coretemp) Detect the Huaxu Wan
2010-05-11  3:41         ` [PATCH 1/2 V2] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-11  7:55     ` [lm-sensors] [PATCH 1/2 V3] hwmon: (coretemp) Detect the thermal Huaxu Wan
2010-05-11  8:01       ` [PATCH 1/2 V3] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-11 21:45       ` [lm-sensors] [PATCH 1/2 V3] hwmon: (coretemp) Detect the Valdis.Kletnieks
2010-05-11 21:45         ` [PATCH 1/2 V3] hwmon: (coretemp) Detect the thermal sensors by CPUID Valdis.Kletnieks
2010-05-14  3:20       ` [lm-sensors] [PATCH 1/2 V3] hwmon: (coretemp) Detect the Henrique de Moraes Holschuh
2010-05-14  3:20         ` [lm-sensors] [PATCH 1/2 V3] hwmon: (coretemp) Detect the thermal sensors by CPUID Henrique de Moraes Holschuh
2010-05-14  6:58         ` [lm-sensors] [PATCH 1/2 V3 minor change] hwmon: (coretemp) Detect Huaxu Wan
2010-05-14  6:58           ` [PATCH 1/2 V3 minor change] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-17  9:41           ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel Carsten Emde
2010-05-17  9:41             ` [PATCH 0/2] hwmon: Update coretemp to current Intel processors Carsten Emde
2010-05-17  9:41             ` [lm-sensors] [PATCH 1/2] Detect the thermal sensors by CPUID Carsten Emde
2010-05-17  9:41               ` Carsten Emde
2010-05-17  9:41             ` [lm-sensors] [PATCH 2/2] Get TjMax value from MSR Carsten Emde
2010-05-17  9:41               ` Carsten Emde
2010-05-18  4:47             ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Dmitry Gromov
2010-05-18  7:01               ` Carsten Emde
2010-05-18  7:01                 ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Carsten Emde
2010-05-18 12:03                 ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Dmitry Gromov
2010-05-18 12:03                   ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Dmitry Gromov
2010-05-19  1:27                 ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Huaxu Wan
2010-05-19  1:27                   ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Huaxu Wan
2010-05-18  5:07             ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Wan, Huaxu
2010-05-18  6:45             ` Dmitry Gromov
2010-05-18  7:13               ` Carsten Emde
2010-05-18  7:13                 ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Carsten Emde
2010-05-19  0:50               ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Huaxu Wan
2010-05-19  0:50                 ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Huaxu Wan
2010-05-19  3:12                 ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Dmitry Gromov
2010-05-19  3:12                   ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Dmitry Gromov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BE415B8.1010400@osadl.org \
    --to=carsten.emde@osadl.org \
    --cc=huaxu.wan@intel.com \
    --cc=huaxu.wan@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.