Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4e0bcf0 authored by Guenter Roeck's avatar Guenter Roeck Committed by Linus Torvalds
Browse files

hwmon: (coretemp) Add comments describing the handling of HT CPUs



The coretemp driver provides a single set of device attributes for each
physical core of a HT CPU to avoid duplicate sensors.  This
functionality was introduced with commit d883b9f0 ("hwmon:
(coretemp) Skip duplicate CPU entries").

Commit e40cc4bd ("x86/hwmon: register alternate sibling upon CPU
removal") extends this functionality to register the HT sibling of a CPU
which is taken offline, to ensure that sensor attributes are provided if
at least one HT sibling of a core is online.

Add comments into the code describing the functionality in some more
detail.

Signed-off-by: default avatarGuenter Roeck <guenter.roeck@ericsson.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Durgadoss R <durgadoss.r@intel.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5f2e8e2b
Loading
Loading
Loading
Loading
+18 −2
Original line number Original line Diff line number Diff line
@@ -506,7 +506,13 @@ static int create_core_data(struct platform_data *pdata,
	if (attr_no > MAX_CORE_DATA - 1)
	if (attr_no > MAX_CORE_DATA - 1)
		return -ERANGE;
		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)
	if (pdata->core_data[attr_no] != NULL)
		return 0;
		return 0;


@@ -763,10 +769,20 @@ static void __cpuinit put_core_offline(unsigned int cpu)
	if (pdata->core_data[indx] && pdata->core_data[indx]->cpu == cpu)
	if (pdata->core_data[indx] && pdata->core_data[indx]->cpu == cpu)
		coretemp_remove_core(pdata, &pdev->dev, indx);
		coretemp_remove_core(pdata, &pdev->dev, indx);


	/* Online the HT version of this core, if any */
	/*
	 * 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) {
	for_each_sibling(i, cpu) {
		if (i != cpu) {
		if (i != cpu) {
			get_core_online(i);
			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;
			break;
		}
		}
	}
	}