Commit cfcd82e6 authored by Zhang Rui's avatar Zhang Rui Committed by Thomas Gleixner

hwmon/coretemp: Support multi-die/package

Package temperature sensors are actually implemented in hardware per-die.

Update coretemp to be "die-aware", so it can expose mulitple sensors per
package, instead of just one.  No change to single-die/package systems.
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
Acked-by: default avatarGuenter Roeck <linux@roeck-us.net>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-hwmon@vger.kernel.org
Link: https://lkml.kernel.org/r/ec2868f35113a01ff72d9041e0b97fc6a1c7df84.1557769318.git.len.brown@intel.com
parent 9ea7612c
...@@ -435,7 +435,7 @@ static int chk_ucode_version(unsigned int cpu) ...@@ -435,7 +435,7 @@ static int chk_ucode_version(unsigned int cpu)
static struct platform_device *coretemp_get_pdev(unsigned int cpu) static struct platform_device *coretemp_get_pdev(unsigned int cpu)
{ {
int pkgid = topology_logical_package_id(cpu); int pkgid = topology_logical_die_id(cpu);
if (pkgid >= 0 && pkgid < max_packages) if (pkgid >= 0 && pkgid < max_packages)
return pkg_devices[pkgid]; return pkg_devices[pkgid];
...@@ -579,7 +579,7 @@ static struct platform_driver coretemp_driver = { ...@@ -579,7 +579,7 @@ static struct platform_driver coretemp_driver = {
static struct platform_device *coretemp_device_add(unsigned int cpu) static struct platform_device *coretemp_device_add(unsigned int cpu)
{ {
int err, pkgid = topology_logical_package_id(cpu); int err, pkgid = topology_logical_die_id(cpu);
struct platform_device *pdev; struct platform_device *pdev;
if (pkgid < 0) if (pkgid < 0)
...@@ -703,7 +703,7 @@ static int coretemp_cpu_offline(unsigned int cpu) ...@@ -703,7 +703,7 @@ static int coretemp_cpu_offline(unsigned int cpu)
* the rest. * the rest.
*/ */
if (cpumask_empty(&pd->cpumask)) { if (cpumask_empty(&pd->cpumask)) {
pkg_devices[topology_logical_package_id(cpu)] = NULL; pkg_devices[topology_logical_die_id(cpu)] = NULL;
platform_device_unregister(pdev); platform_device_unregister(pdev);
return 0; return 0;
} }
...@@ -741,7 +741,7 @@ static int __init coretemp_init(void) ...@@ -741,7 +741,7 @@ static int __init coretemp_init(void)
if (!x86_match_cpu(coretemp_ids)) if (!x86_match_cpu(coretemp_ids))
return -ENODEV; return -ENODEV;
max_packages = topology_max_packages(); max_packages = topology_max_packages() * topology_max_die_per_package();
pkg_devices = kcalloc(max_packages, sizeof(struct platform_device *), pkg_devices = kcalloc(max_packages, sizeof(struct platform_device *),
GFP_KERNEL); GFP_KERNEL);
if (!pkg_devices) if (!pkg_devices)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment