Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal/x86_pkg_temp_thermal: Support multi-die/package

Package temperature sensors are actually implemented in hardware per-die.
Thus, the new multi-die/package systems sport mulitple package thermal
zones for each package.

Update the x86_pkg_temp_thermal to be "multi-die-aware", so it can expose
multiple zones per package, instead of just one.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/281695c854d38d3bdec803480c3049c36198ca44.1557769318.git.len.brown@intel.com

authored by

Zhang Rui and committed by
Thomas Gleixner
724adec3 32fb480e

+4 -4
+4 -4
drivers/thermal/intel/x86_pkg_temp_thermal.c
··· 122 122 */ 123 123 static struct pkg_device *pkg_temp_thermal_get_dev(unsigned int cpu) 124 124 { 125 - int pkgid = topology_logical_package_id(cpu); 125 + int pkgid = topology_logical_die_id(cpu); 126 126 127 127 if (pkgid >= 0 && pkgid < max_packages) 128 128 return packages[pkgid]; ··· 353 353 354 354 static int pkg_temp_thermal_device_add(unsigned int cpu) 355 355 { 356 - int pkgid = topology_logical_package_id(cpu); 356 + int pkgid = topology_logical_die_id(cpu); 357 357 u32 tj_max, eax, ebx, ecx, edx; 358 358 struct pkg_device *pkgdev; 359 359 int thres_count, err; ··· 449 449 * worker will see the package anymore. 450 450 */ 451 451 if (lastcpu) { 452 - packages[topology_logical_package_id(cpu)] = NULL; 452 + packages[topology_logical_die_id(cpu)] = NULL; 453 453 /* After this point nothing touches the MSR anymore. */ 454 454 wrmsr(MSR_IA32_PACKAGE_THERM_INTERRUPT, 455 455 pkgdev->msr_pkg_therm_low, pkgdev->msr_pkg_therm_high); ··· 515 515 if (!x86_match_cpu(pkg_temp_thermal_ids)) 516 516 return -ENODEV; 517 517 518 - max_packages = topology_max_packages(); 518 + max_packages = topology_max_packages() * topology_max_die_per_package(); 519 519 packages = kcalloc(max_packages, sizeof(struct pkg_device *), 520 520 GFP_KERNEL); 521 521 if (!packages)