diff mbox series

[11/11] hwmon/coretemp: Support multi-die/package

Message ID 8ce75b95ef6105ebe5fb8c9e43b33f06516e3c16.1550545163.git.len.brown@intel.com (mailing list archive)
State Not Applicable
Headers show
Series None | expand

Commit Message

Len Brown Feb. 19, 2019, 3:22 a.m. UTC
From: Zhang Rui <rui.zhang@intel.com>

This patch introduces coretemp driver support
for new dual-die/package systems.

On the new dual-die/package systems, the package temperature MSRs becomes
die-scope. Thus instead of one hwmon device per physical package, now
there should be one hwmon device for each die on these systems.

On the hardwares that do not have multi-die support,
topology_unique_die_id() equals topology_physical_package_id(), thus the
only difference is that physical package id is used as the coretemp
platform device id, instead of logical package id on these systems.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-hwmon@vger.kernel.org
Signed-off-by: Len Brown <len.brown@intel.com>
---
 drivers/hwmon/coretemp.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Guenter Roeck Feb. 19, 2019, 3:08 p.m. UTC | #1
On 2/18/19 7:22 PM, Len Brown wrote:
> From: Zhang Rui <rui.zhang@intel.com>
> 
> This patch introduces coretemp driver support
> for new dual-die/package systems.
> 
> On the new dual-die/package systems, the package temperature MSRs becomes
> die-scope. Thus instead of one hwmon device per physical package, now
> there should be one hwmon device for each die on these systems.
> 
> On the hardwares that do not have multi-die support,
> topology_unique_die_id() equals topology_physical_package_id(), thus the
> only difference is that physical package id is used as the coretemp
> platform device id, instead of logical package id on these systems.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> Signed-off-by: Len Brown <len.brown@intel.com>
> Cc: linux-pm@vger.kernel.org
> Cc: linux-hwmon@vger.kernel.org
> Signed-off-by: Len Brown <len.brown@intel.com>

Acked-by: Guenter Roeck <linux@roeck-us.net>

I assume this will be pushed together with the rest of the series.

Thanks,
Guenter

> ---
>   drivers/hwmon/coretemp.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
> index 5d34f7271e67..a0b6b2247c3a 100644
> --- a/drivers/hwmon/coretemp.c
> +++ b/drivers/hwmon/coretemp.c
> @@ -435,7 +435,7 @@ static int chk_ucode_version(unsigned int cpu)
>   
>   static struct platform_device *coretemp_get_pdev(unsigned int cpu)
>   {
> -	int pkgid = topology_logical_package_id(cpu);
> +	int pkgid = topology_unique_die_id(cpu);
>   
>   	if (pkgid >= 0 && pkgid < max_packages)
>   		return pkg_devices[pkgid];
> @@ -579,7 +579,7 @@ static struct platform_driver coretemp_driver = {
>   
>   static struct platform_device *coretemp_device_add(unsigned int cpu)
>   {
> -	int err, pkgid = topology_logical_package_id(cpu);
> +	int err, pkgid = topology_unique_die_id(cpu);
>   	struct platform_device *pdev;
>   
>   	if (pkgid < 0)
> @@ -703,7 +703,7 @@ static int coretemp_cpu_offline(unsigned int cpu)
>   	 * the rest.
>   	 */
>   	if (cpumask_empty(&pd->cpumask)) {
> -		pkg_devices[topology_logical_package_id(cpu)] = NULL;
> +		pkg_devices[topology_unique_die_id(cpu)] = NULL;
>   		platform_device_unregister(pdev);
>   		return 0;
>   	}
> @@ -732,6 +732,7 @@ static enum cpuhp_state coretemp_hp_online;
>   static int __init coretemp_init(void)
>   {
>   	int err;
> +	struct cpuinfo_x86 *c = &cpu_data(0);
>   
>   	/*
>   	 * CPUID.06H.EAX[0] indicates whether the CPU has thermal
> @@ -741,7 +742,7 @@ static int __init coretemp_init(void)
>   	if (!x86_match_cpu(coretemp_ids))
>   		return -ENODEV;
>   
> -	max_packages = topology_max_packages();
> +	max_packages = topology_max_packages() * c->x86_max_dies;
>   	pkg_devices = kcalloc(max_packages, sizeof(struct platform_device *),
>   			      GFP_KERNEL);
>   	if (!pkg_devices)
>
Guenter Roeck Feb. 19, 2019, 4:46 p.m. UTC | #2
On 2/18/19 7:40 PM, Len Brown wrote:
> From: Zhang Rui <rui.zhang@intel.com>
> 
> This patch introduces coretemp driver support
> for new dual-die/package systems.
> 
> On the new dual-die/package systems, the package temperature MSRs becomes
> die-scope. Thus instead of one hwmon device per physical package, now
> there should be one hwmon device for each die on these systems.
> 
> On the hardwares that do not have multi-die support,
> topology_unique_die_id() equals topology_physical_package_id(), thus the
> only difference is that physical package id is used as the coretemp
> platform device id, instead of logical package id on these systems.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> Signed-off-by: Len Brown <len.brown@intel.com>
> Cc: linux-pm@vger.kernel.org
> Cc: linux-hwmon@vger.kernel.org
> Signed-off-by: Len Brown <len.brown@intel.com>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/hwmon/coretemp.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
> index 5d34f7271e67..a0b6b2247c3a 100644
> --- a/drivers/hwmon/coretemp.c
> +++ b/drivers/hwmon/coretemp.c
> @@ -435,7 +435,7 @@ static int chk_ucode_version(unsigned int cpu)
>   
>   static struct platform_device *coretemp_get_pdev(unsigned int cpu)
>   {
> -	int pkgid = topology_logical_package_id(cpu);
> +	int pkgid = topology_unique_die_id(cpu);
>   
>   	if (pkgid >= 0 && pkgid < max_packages)
>   		return pkg_devices[pkgid];
> @@ -579,7 +579,7 @@ static struct platform_driver coretemp_driver = {
>   
>   static struct platform_device *coretemp_device_add(unsigned int cpu)
>   {
> -	int err, pkgid = topology_logical_package_id(cpu);
> +	int err, pkgid = topology_unique_die_id(cpu);
>   	struct platform_device *pdev;
>   
>   	if (pkgid < 0)
> @@ -703,7 +703,7 @@ static int coretemp_cpu_offline(unsigned int cpu)
>   	 * the rest.
>   	 */
>   	if (cpumask_empty(&pd->cpumask)) {
> -		pkg_devices[topology_logical_package_id(cpu)] = NULL;
> +		pkg_devices[topology_unique_die_id(cpu)] = NULL;
>   		platform_device_unregister(pdev);
>   		return 0;
>   	}
> @@ -732,6 +732,7 @@ static enum cpuhp_state coretemp_hp_online;
>   static int __init coretemp_init(void)
>   {
>   	int err;
> +	struct cpuinfo_x86 *c = &cpu_data(0);
>   
>   	/*
>   	 * CPUID.06H.EAX[0] indicates whether the CPU has thermal
> @@ -741,7 +742,7 @@ static int __init coretemp_init(void)
>   	if (!x86_match_cpu(coretemp_ids))
>   		return -ENODEV;
>   
> -	max_packages = topology_max_packages();
> +	max_packages = topology_max_packages() * c->x86_max_dies;
>   	pkg_devices = kcalloc(max_packages, sizeof(struct platform_device *),
>   			      GFP_KERNEL);
>   	if (!pkg_devices)
>
diff mbox series

Patch

diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 5d34f7271e67..a0b6b2247c3a 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -435,7 +435,7 @@  static int chk_ucode_version(unsigned int cpu)
 
 static struct platform_device *coretemp_get_pdev(unsigned int cpu)
 {
-	int pkgid = topology_logical_package_id(cpu);
+	int pkgid = topology_unique_die_id(cpu);
 
 	if (pkgid >= 0 && pkgid < max_packages)
 		return pkg_devices[pkgid];
@@ -579,7 +579,7 @@  static struct platform_driver coretemp_driver = {
 
 static struct platform_device *coretemp_device_add(unsigned int cpu)
 {
-	int err, pkgid = topology_logical_package_id(cpu);
+	int err, pkgid = topology_unique_die_id(cpu);
 	struct platform_device *pdev;
 
 	if (pkgid < 0)
@@ -703,7 +703,7 @@  static int coretemp_cpu_offline(unsigned int cpu)
 	 * the rest.
 	 */
 	if (cpumask_empty(&pd->cpumask)) {
-		pkg_devices[topology_logical_package_id(cpu)] = NULL;
+		pkg_devices[topology_unique_die_id(cpu)] = NULL;
 		platform_device_unregister(pdev);
 		return 0;
 	}
@@ -732,6 +732,7 @@  static enum cpuhp_state coretemp_hp_online;
 static int __init coretemp_init(void)
 {
 	int err;
+	struct cpuinfo_x86 *c = &cpu_data(0);
 
 	/*
 	 * CPUID.06H.EAX[0] indicates whether the CPU has thermal
@@ -741,7 +742,7 @@  static int __init coretemp_init(void)
 	if (!x86_match_cpu(coretemp_ids))
 		return -ENODEV;
 
-	max_packages = topology_max_packages();
+	max_packages = topology_max_packages() * c->x86_max_dies;
 	pkg_devices = kcalloc(max_packages, sizeof(struct platform_device *),
 			      GFP_KERNEL);
 	if (!pkg_devices)