]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.32.17/hwmon-coretemp-skip-duplicate-cpu-entries.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.17 / hwmon-coretemp-skip-duplicate-cpu-entries.patch
1 From d883b9f0977269d519469da72faec6a7f72cb489 Mon Sep 17 00:00:00 2001
2 From: Jean Delvare <khali@linux-fr.org>
3 Date: Fri, 9 Jul 2010 16:22:49 +0200
4 Subject: hwmon: (coretemp) Skip duplicate CPU entries
5
6 From: Jean Delvare <khali@linux-fr.org>
7
8 commit d883b9f0977269d519469da72faec6a7f72cb489 upstream.
9
10 On hyper-threaded CPUs, each core appears twice in the CPU list. Skip
11 the second entry to avoid duplicate sensors.
12
13 Signed-off-by: Jean Delvare <khali@linux-fr.org>
14 Acked-by: Huaxu Wan <huaxu.wan@intel.com>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
16
17 ---
18 drivers/hwmon/coretemp.c | 26 +++++++++++++++++++++++++-
19 1 file changed, 25 insertions(+), 1 deletion(-)
20
21 --- a/drivers/hwmon/coretemp.c
22 +++ b/drivers/hwmon/coretemp.c
23 @@ -356,6 +356,10 @@ struct pdev_entry {
24 struct list_head list;
25 struct platform_device *pdev;
26 unsigned int cpu;
27 +#ifdef CONFIG_SMP
28 + u16 phys_proc_id;
29 + u16 cpu_core_id;
30 +#endif
31 };
32
33 static LIST_HEAD(pdev_list);
34 @@ -366,6 +370,22 @@ static int __cpuinit coretemp_device_add
35 int err;
36 struct platform_device *pdev;
37 struct pdev_entry *pdev_entry;
38 +#ifdef CONFIG_SMP
39 + struct cpuinfo_x86 *c = &cpu_data(cpu);
40 +#endif
41 +
42 + mutex_lock(&pdev_list_mutex);
43 +
44 +#ifdef CONFIG_SMP
45 + /* Skip second HT entry of each core */
46 + list_for_each_entry(pdev_entry, &pdev_list, list) {
47 + if (c->phys_proc_id == pdev_entry->phys_proc_id &&
48 + c->cpu_core_id == pdev_entry->cpu_core_id) {
49 + err = 0; /* Not an error */
50 + goto exit;
51 + }
52 + }
53 +#endif
54
55 pdev = platform_device_alloc(DRVNAME, cpu);
56 if (!pdev) {
57 @@ -389,7 +409,10 @@ static int __cpuinit coretemp_device_add
58
59 pdev_entry->pdev = pdev;
60 pdev_entry->cpu = cpu;
61 - mutex_lock(&pdev_list_mutex);
62 +#ifdef CONFIG_SMP
63 + pdev_entry->phys_proc_id = c->phys_proc_id;
64 + pdev_entry->cpu_core_id = c->cpu_core_id;
65 +#endif
66 list_add_tail(&pdev_entry->list, &pdev_list);
67 mutex_unlock(&pdev_list_mutex);
68
69 @@ -400,6 +423,7 @@ exit_device_free:
70 exit_device_put:
71 platform_device_put(pdev);
72 exit:
73 + mutex_unlock(&pdev_list_mutex);
74 return err;
75 }
76