aboutsummaryrefslogtreecommitdiff
path: root/drivers/hwmon/coretemp.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/coretemp.c')
-rw-r--r--drivers/hwmon/coretemp.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 5c7cd60d5f9d..9577c432e77f 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -51,10 +51,12 @@
#define TO_PHYS_ID(cpu) cpu_data(cpu).phys_proc_id
#define TO_CORE_ID(cpu) cpu_data(cpu).cpu_core_id
#define TO_ATTR_NO(cpu) (TO_CORE_ID(cpu) + BASE_SYSFS_ATTR_NO)
+#define for_each_sibling(i, cpu) for_each_cpu(i, cpu_sibling_mask(cpu))
#else
#define TO_PHYS_ID(cpu) (cpu)
#define TO_CORE_ID(cpu) (cpu)
#define TO_ATTR_NO(cpu) (cpu)
+#define for_each_sibling(i, cpu) for (i = 0; false; )
#endif
/*
@@ -504,7 +506,13 @@ static int create_core_data(struct platform_data *pdata,
if (attr_no > MAX_CORE_DATA - 1)
return -ERANGE;
- /* Skip if it is a HT core, Not an error */
+ /*
+ * Provide a single set of attributes for all HT siblings of a core
+ * to avoid duplicate sensors (the processor ID and core ID of all
+ * HT siblings of a core is the same).
+ * Skip if a HT sibling of this core is already online.
+ * This is not an error.
+ */
if (pdata->core_data[attr_no] != NULL)
return 0;
@@ -761,10 +769,20 @@ static void __cpuinit put_core_offline(unsigned int cpu)
if (pdata->core_data[indx] && pdata->core_data[indx]->cpu == cpu)
coretemp_remove_core(pdata, &pdev->dev, indx);
- /* Online the HT version of this core, if any */
- for_each_cpu(i, cpu_sibling_mask(cpu)) {
+ /*
+ * If a core is taken offline, but a HT sibling of the same core is
+ * still online, register the alternate sibling. This ensures that
+ * exactly one set of attributes is provided as long as at least one
+ * HT sibling of a core is online.
+ */
+ for_each_sibling(i, cpu) {
if (i != cpu) {
get_core_online(i);
+ /*
+ * Display temperature sensor data for one HT sibling
+ * per core only, so abort the loop after one such
+ * sibling has been found.
+ */
break;
}
}