All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH] x86/hwmon: fix initialization of coretemp
@ 2010-09-13 10:17 ` Jan Beulich
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2010-09-13 10:17 UTC (permalink / raw)
  To: fenghua.yu, khali; +Cc: r.marek, mingo, tglx, lm-sensors, linux-kernel, hpa

Using cpuid_eax() to determine feature availability on other than
the current CPU is invalid. And feature availability should also be
checked in the hotplug code path.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: Rudolf Marek <r.marek@assembler.cz>

---
 arch/x86/include/asm/cpufeature.h |    1 +
 arch/x86/kernel/cpu/scattered.c   |    1 +
 drivers/hwmon/coretemp.c          |   29 +++++++++++++----------------
 3 files changed, 15 insertions(+), 16 deletions(-)

--- linux-2.6.36-rc4/arch/x86/include/asm/cpufeature.h	2010-09-13 08:44:55.000000000 +0200
+++ 2.6.36-rc4-x86-coretemp-feature-check/arch/x86/include/asm/cpufeature.h	2010-09-01 09:18:17.000000000 +0200
@@ -168,6 +168,7 @@
 #define X86_FEATURE_XSAVEOPT	(7*32+ 4) /* Optimized Xsave */
 #define X86_FEATURE_PLN		(7*32+ 5) /* Intel Power Limit Notification */
 #define X86_FEATURE_PTS		(7*32+ 6) /* Intel Package Thermal Status */
+#define X86_FEATURE_DTS		(7*32+ 7) /* Digital Thermal Sensor */
 
 /* Virtualization flags: Linux defined, word 8 */
 #define X86_FEATURE_TPR_SHADOW  (8*32+ 0) /* Intel TPR Shadow */
--- linux-2.6.36-rc4/arch/x86/kernel/cpu/scattered.c	2010-09-13 08:44:55.000000000 +0200
+++ 2.6.36-rc4-x86-coretemp-feature-check/arch/x86/kernel/cpu/scattered.c	2010-09-01 09:19:38.000000000 +0200
@@ -31,6 +31,7 @@ void __cpuinit init_scattered_cpuid_feat
 	const struct cpuid_bit *cb;
 
 	static const struct cpuid_bit __cpuinitconst cpuid_bits[] = {
+		{ X86_FEATURE_DTS,		CR_EAX, 0, 0x00000006, 0 },
 		{ X86_FEATURE_IDA,		CR_EAX, 1, 0x00000006, 0 },
 		{ X86_FEATURE_ARAT,		CR_EAX, 2, 0x00000006, 0 },
 		{ X86_FEATURE_PLN,		CR_EAX, 4, 0x00000006, 0 },
--- linux-2.6.36-rc4/drivers/hwmon/coretemp.c	2010-09-13 08:45:02.000000000 +0200
+++ 2.6.36-rc4-x86-coretemp-feature-check/drivers/hwmon/coretemp.c	2010-09-03 17:54:14.000000000 +0200
@@ -423,9 +423,18 @@ static int __cpuinit coretemp_device_add
 	int err;
 	struct platform_device *pdev;
 	struct pdev_entry *pdev_entry;
-#ifdef CONFIG_SMP
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
-#endif
+
+	/*
+	 * CPUID.06H.EAX[0] indicates whether the CPU has thermal
+	 * sensors. We check this bit only, all the early CPUs
+	 * without thermal sensors will be filtered out.
+	 */
+	if (!cpu_has(c, X86_FEATURE_DTS)) {
+		printk(KERN_INFO DRVNAME ": CPU (model=0x%x)"
+		       " has no thermal sensor.\n", c->x86_model);
+		return 0;
+	}
 
 	mutex_lock(&pdev_list_mutex);
 
@@ -527,20 +536,8 @@ static int __init coretemp_init(void)
 	if (err)
 		goto exit;
 
-	for_each_online_cpu(i) {
-		struct cpuinfo_x86 *c = &cpu_data(i);
-		/*
-		 * CPUID.06H.EAX[0] indicates whether the CPU has thermal
-		 * sensors. We check this bit only, all the early CPUs
-		 * without thermal sensors will be filtered out.
-		 */
-		if (c->cpuid_level >= 6 && (cpuid_eax(0x06) & 0x01))
-			coretemp_device_add(i);
-		else {
-			printk(KERN_INFO DRVNAME ": CPU (model=0x%x)"
-				" has no thermal sensor.\n", c->x86_model);
-		}
-	}
+	for_each_online_cpu(i)
+		coretemp_device_add(i);
 	if (list_empty(&pdev_list)) {
 		err = -ENODEV;
 		goto exit_driver_unreg;




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

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

* [PATCH] x86/hwmon: fix initialization of coretemp
@ 2010-09-13 10:17 ` Jan Beulich
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2010-09-13 10:17 UTC (permalink / raw)
  To: fenghua.yu, khali; +Cc: r.marek, mingo, tglx, lm-sensors, linux-kernel, hpa

Using cpuid_eax() to determine feature availability on other than
the current CPU is invalid. And feature availability should also be
checked in the hotplug code path.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: Rudolf Marek <r.marek@assembler.cz>

---
 arch/x86/include/asm/cpufeature.h |    1 +
 arch/x86/kernel/cpu/scattered.c   |    1 +
 drivers/hwmon/coretemp.c          |   29 +++++++++++++----------------
 3 files changed, 15 insertions(+), 16 deletions(-)

--- linux-2.6.36-rc4/arch/x86/include/asm/cpufeature.h	2010-09-13 08:44:55.000000000 +0200
+++ 2.6.36-rc4-x86-coretemp-feature-check/arch/x86/include/asm/cpufeature.h	2010-09-01 09:18:17.000000000 +0200
@@ -168,6 +168,7 @@
 #define X86_FEATURE_XSAVEOPT	(7*32+ 4) /* Optimized Xsave */
 #define X86_FEATURE_PLN		(7*32+ 5) /* Intel Power Limit Notification */
 #define X86_FEATURE_PTS		(7*32+ 6) /* Intel Package Thermal Status */
+#define X86_FEATURE_DTS		(7*32+ 7) /* Digital Thermal Sensor */
 
 /* Virtualization flags: Linux defined, word 8 */
 #define X86_FEATURE_TPR_SHADOW  (8*32+ 0) /* Intel TPR Shadow */
--- linux-2.6.36-rc4/arch/x86/kernel/cpu/scattered.c	2010-09-13 08:44:55.000000000 +0200
+++ 2.6.36-rc4-x86-coretemp-feature-check/arch/x86/kernel/cpu/scattered.c	2010-09-01 09:19:38.000000000 +0200
@@ -31,6 +31,7 @@ void __cpuinit init_scattered_cpuid_feat
 	const struct cpuid_bit *cb;
 
 	static const struct cpuid_bit __cpuinitconst cpuid_bits[] = {
+		{ X86_FEATURE_DTS,		CR_EAX, 0, 0x00000006, 0 },
 		{ X86_FEATURE_IDA,		CR_EAX, 1, 0x00000006, 0 },
 		{ X86_FEATURE_ARAT,		CR_EAX, 2, 0x00000006, 0 },
 		{ X86_FEATURE_PLN,		CR_EAX, 4, 0x00000006, 0 },
--- linux-2.6.36-rc4/drivers/hwmon/coretemp.c	2010-09-13 08:45:02.000000000 +0200
+++ 2.6.36-rc4-x86-coretemp-feature-check/drivers/hwmon/coretemp.c	2010-09-03 17:54:14.000000000 +0200
@@ -423,9 +423,18 @@ static int __cpuinit coretemp_device_add
 	int err;
 	struct platform_device *pdev;
 	struct pdev_entry *pdev_entry;
-#ifdef CONFIG_SMP
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
-#endif
+
+	/*
+	 * CPUID.06H.EAX[0] indicates whether the CPU has thermal
+	 * sensors. We check this bit only, all the early CPUs
+	 * without thermal sensors will be filtered out.
+	 */
+	if (!cpu_has(c, X86_FEATURE_DTS)) {
+		printk(KERN_INFO DRVNAME ": CPU (model=0x%x)"
+		       " has no thermal sensor.\n", c->x86_model);
+		return 0;
+	}
 
 	mutex_lock(&pdev_list_mutex);
 
@@ -527,20 +536,8 @@ static int __init coretemp_init(void)
 	if (err)
 		goto exit;
 
-	for_each_online_cpu(i) {
-		struct cpuinfo_x86 *c = &cpu_data(i);
-		/*
-		 * CPUID.06H.EAX[0] indicates whether the CPU has thermal
-		 * sensors. We check this bit only, all the early CPUs
-		 * without thermal sensors will be filtered out.
-		 */
-		if (c->cpuid_level >= 6 && (cpuid_eax(0x06) & 0x01))
-			coretemp_device_add(i);
-		else {
-			printk(KERN_INFO DRVNAME ": CPU (model=0x%x)"
-				" has no thermal sensor.\n", c->x86_model);
-		}
-	}
+	for_each_online_cpu(i)
+		coretemp_device_add(i);
 	if (list_empty(&pdev_list)) {
 		err = -ENODEV;
 		goto exit_driver_unreg;




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

* [lm-sensors] [PATCH] x86/hwmon: fix initialization of pkgtemp
@ 2010-09-13 10:18   ` Jan Beulich
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2010-09-13 10:18 UTC (permalink / raw)
  To: khali; +Cc: fenghua.yu, lm-sensors, linux-kernel

Feature availability should also be checked in the hotplug code path.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>

---
 drivers/hwmon/pkgtemp.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

--- linux-2.6.36-rc4/drivers/hwmon/pkgtemp.c	2010-09-13 08:45:03.000000000 +0200
+++ 2.6.36-rc4-x86-pkgtemp-feature-check/drivers/hwmon/pkgtemp.c	2010-09-03 17:54:30.000000000 +0200
@@ -281,9 +281,10 @@ static int __cpuinit pkgtemp_device_add(
 	int err;
 	struct platform_device *pdev;
 	struct pdev_entry *pdev_entry;
-#ifdef CONFIG_SMP
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
-#endif
+
+	if (!cpu_has(c, X86_FEATURE_PTS))
+		return 0;
 
 	mutex_lock(&pdev_list_mutex);
 
@@ -399,11 +400,6 @@ static int __init pkgtemp_init(void)
 		goto exit;
 
 	for_each_online_cpu(i) {
-		struct cpuinfo_x86 *c = &cpu_data(i);
-
-		if (!cpu_has(c, X86_FEATURE_PTS))
-			continue;
-
 		err = pkgtemp_device_add(i);
 		if (err)
 			goto exit_devices_unreg;




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

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

* [PATCH] x86/hwmon: fix initialization of pkgtemp
@ 2010-09-13 10:18   ` Jan Beulich
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2010-09-13 10:18 UTC (permalink / raw)
  To: khali; +Cc: fenghua.yu, lm-sensors, linux-kernel

Feature availability should also be checked in the hotplug code path.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>

---
 drivers/hwmon/pkgtemp.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

--- linux-2.6.36-rc4/drivers/hwmon/pkgtemp.c	2010-09-13 08:45:03.000000000 +0200
+++ 2.6.36-rc4-x86-pkgtemp-feature-check/drivers/hwmon/pkgtemp.c	2010-09-03 17:54:30.000000000 +0200
@@ -281,9 +281,10 @@ static int __cpuinit pkgtemp_device_add(
 	int err;
 	struct platform_device *pdev;
 	struct pdev_entry *pdev_entry;
-#ifdef CONFIG_SMP
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
-#endif
+
+	if (!cpu_has(c, X86_FEATURE_PTS))
+		return 0;
 
 	mutex_lock(&pdev_list_mutex);
 
@@ -399,11 +400,6 @@ static int __init pkgtemp_init(void)
 		goto exit;
 
 	for_each_online_cpu(i) {
-		struct cpuinfo_x86 *c = &cpu_data(i);
-
-		if (!cpu_has(c, X86_FEATURE_PTS))
-			continue;
-
 		err = pkgtemp_device_add(i);
 		if (err)
 			goto exit_devices_unreg;




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

* Re: [lm-sensors] [PATCH] x86/hwmon: fix initialization of coretemp
  2010-09-13 10:17 ` Jan Beulich
@ 2010-09-14  6:34   ` Chen Gong
  -1 siblings, 0 replies; 8+ messages in thread
From: Chen Gong @ 2010-09-14  6:34 UTC (permalink / raw)
  To: Jan Beulich; +Cc: fenghua.yu, khali, linux-kernel, lm-sensors, hpa, mingo, tglx

于 9/13/2010 6:17 PM, Jan Beulich 写道:
> Using cpuid_eax() to determine feature availability on other than
> the current CPU is invalid. And feature availability should also be
> checked in the hotplug code path.
>
> Signed-off-by: Jan Beulich<jbeulich@novell.com>
> Cc: Rudolf Marek<r.marek@assembler.cz>
>
> ---
>   arch/x86/include/asm/cpufeature.h |    1 +
>   arch/x86/kernel/cpu/scattered.c   |    1 +
>   drivers/hwmon/coretemp.c          |   29 +++++++++++++----------------
>   3 files changed, 15 insertions(+), 16 deletions(-)
>
> --- linux-2.6.36-rc4/arch/x86/include/asm/cpufeature.h	2010-09-13 08:44:55.000000000 +0200
> +++ 2.6.36-rc4-x86-coretemp-feature-check/arch/x86/include/asm/cpufeature.h	2010-09-01 09:18:17.000000000 +0200
> @@ -168,6 +168,7 @@
>   #define X86_FEATURE_XSAVEOPT	(7*32+ 4) /* Optimized Xsave */
>   #define X86_FEATURE_PLN		(7*32+ 5) /* Intel Power Limit Notification */
>   #define X86_FEATURE_PTS		(7*32+ 6) /* Intel Package Thermal Status */
> +#define X86_FEATURE_DTS		(7*32+ 7) /* Digital Thermal Sensor */

Do we really need a new CPU flag ?

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

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

* Re: [lm-sensors] [PATCH] x86/hwmon: fix initialization of coretemp
@ 2010-09-14  6:34   ` Chen Gong
  0 siblings, 0 replies; 8+ messages in thread
From: Chen Gong @ 2010-09-14  6:34 UTC (permalink / raw)
  To: Jan Beulich; +Cc: fenghua.yu, khali, linux-kernel, lm-sensors, hpa, mingo, tglx

于 9/13/2010 6:17 PM, Jan Beulich 写道:
> Using cpuid_eax() to determine feature availability on other than
> the current CPU is invalid. And feature availability should also be
> checked in the hotplug code path.
>
> Signed-off-by: Jan Beulich<jbeulich@novell.com>
> Cc: Rudolf Marek<r.marek@assembler.cz>
>
> ---
>   arch/x86/include/asm/cpufeature.h |    1 +
>   arch/x86/kernel/cpu/scattered.c   |    1 +
>   drivers/hwmon/coretemp.c          |   29 +++++++++++++----------------
>   3 files changed, 15 insertions(+), 16 deletions(-)
>
> --- linux-2.6.36-rc4/arch/x86/include/asm/cpufeature.h	2010-09-13 08:44:55.000000000 +0200
> +++ 2.6.36-rc4-x86-coretemp-feature-check/arch/x86/include/asm/cpufeature.h	2010-09-01 09:18:17.000000000 +0200
> @@ -168,6 +168,7 @@
>   #define X86_FEATURE_XSAVEOPT	(7*32+ 4) /* Optimized Xsave */
>   #define X86_FEATURE_PLN		(7*32+ 5) /* Intel Power Limit Notification */
>   #define X86_FEATURE_PTS		(7*32+ 6) /* Intel Package Thermal Status */
> +#define X86_FEATURE_DTS		(7*32+ 7) /* Digital Thermal Sensor */

Do we really need a new CPU flag ?

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

* Re: [lm-sensors] [PATCH] x86/hwmon: fix initialization of  coretemp
  2010-09-14  6:34   ` Chen Gong
@ 2010-09-14  6:44     ` Jan Beulich
  -1 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2010-09-14  6:44 UTC (permalink / raw)
  To: Chen Gong; +Cc: mingo, fenghua.yu, tglx, khali, lm-sensors, linux-kernel, hpa

>>> On 14.09.10 at 08:34, Chen Gong <gong.chen@linux.intel.com> wrote:
> 于 9/13/2010 6:17 PM, Jan Beulich 写道:
>> Using cpuid_eax() to determine feature availability on other than
>> the current CPU is invalid. And feature availability should also be
>> checked in the hotplug code path.
>>
>> Signed-off-by: Jan Beulich<jbeulich@novell.com>
>> Cc: Rudolf Marek<r.marek@assembler.cz>
>>
>> ---
>>   arch/x86/include/asm/cpufeature.h |    1 +
>>   arch/x86/kernel/cpu/scattered.c   |    1 +
>>   drivers/hwmon/coretemp.c          |   29 +++++++++++++----------------
>>   3 files changed, 15 insertions(+), 16 deletions(-)
>>
>> --- linux-2.6.36-rc4/arch/x86/include/asm/cpufeature.h	2010-09-13 
> 08:44:55.000000000 +0200
>> +++ 
> 2.6.36-rc4-x86-coretemp-feature-check/arch/x86/include/asm/cpufeature.h	20
> 10-09-01 09:18:17.000000000 +0200
>> @@ -168,6 +168,7 @@
>>   #define X86_FEATURE_XSAVEOPT	(7*32+ 4) /* Optimized Xsave */
>>   #define X86_FEATURE_PLN		(7*32+ 5) /* Intel Power Limit Notification */
>>   #define X86_FEATURE_PTS		(7*32+ 6) /* Intel Package Thermal Status */
>> +#define X86_FEATURE_DTS		(7*32+ 7) /* Digital Thermal Sensor */
> 
> Do we really need a new CPU flag ?

We don't strictly need one, but for one it parallels X86_FEATURE_PTS,
and it allows easy identification of the feature's availability from user
space.

Jan

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

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

* Re: [lm-sensors] [PATCH] x86/hwmon: fix initialization of coretemp
@ 2010-09-14  6:44     ` Jan Beulich
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2010-09-14  6:44 UTC (permalink / raw)
  To: Chen Gong; +Cc: mingo, fenghua.yu, tglx, khali, lm-sensors, linux-kernel, hpa

>>> On 14.09.10 at 08:34, Chen Gong <gong.chen@linux.intel.com> wrote:
> 于 9/13/2010 6:17 PM, Jan Beulich 写道:
>> Using cpuid_eax() to determine feature availability on other than
>> the current CPU is invalid. And feature availability should also be
>> checked in the hotplug code path.
>>
>> Signed-off-by: Jan Beulich<jbeulich@novell.com>
>> Cc: Rudolf Marek<r.marek@assembler.cz>
>>
>> ---
>>   arch/x86/include/asm/cpufeature.h |    1 +
>>   arch/x86/kernel/cpu/scattered.c   |    1 +
>>   drivers/hwmon/coretemp.c          |   29 +++++++++++++----------------
>>   3 files changed, 15 insertions(+), 16 deletions(-)
>>
>> --- linux-2.6.36-rc4/arch/x86/include/asm/cpufeature.h	2010-09-13 
> 08:44:55.000000000 +0200
>> +++ 
> 2.6.36-rc4-x86-coretemp-feature-check/arch/x86/include/asm/cpufeature.h	20
> 10-09-01 09:18:17.000000000 +0200
>> @@ -168,6 +168,7 @@
>>   #define X86_FEATURE_XSAVEOPT	(7*32+ 4) /* Optimized Xsave */
>>   #define X86_FEATURE_PLN		(7*32+ 5) /* Intel Power Limit Notification */
>>   #define X86_FEATURE_PTS		(7*32+ 6) /* Intel Package Thermal Status */
>> +#define X86_FEATURE_DTS		(7*32+ 7) /* Digital Thermal Sensor */
> 
> Do we really need a new CPU flag ?

We don't strictly need one, but for one it parallels X86_FEATURE_PTS,
and it allows easy identification of the feature's availability from user
space.

Jan

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

end of thread, other threads:[~2010-09-14  6:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-13 10:17 [lm-sensors] [PATCH] x86/hwmon: fix initialization of coretemp Jan Beulich
2010-09-13 10:17 ` Jan Beulich
2010-09-13 10:18 ` [lm-sensors] [PATCH] x86/hwmon: fix initialization of pkgtemp Jan Beulich
2010-09-13 10:18   ` Jan Beulich
2010-09-14  6:34 ` [lm-sensors] [PATCH] x86/hwmon: fix initialization of coretemp Chen Gong
2010-09-14  6:34   ` Chen Gong
2010-09-14  6:44   ` Jan Beulich
2010-09-14  6:44     ` Jan Beulich

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.