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

platform/x86/amd/hsmp: Replace amd_num_nodes() with topology_max_packages()

The amd_num_nodes() function returns the number of data fabrics present.
On older EPYC processors, there was one data fabric per socket.
However, newer EPYC processors have more than one data fabric per
socket, leading to a situation where the number of sockets is not equal
to the number of data fabrics. Therefore, it is appropriate to use
topology_max_packages() to know the number of sockets in the system.

Also remove node.h header inclusion and socket number comparison against
data fabric nodes.

plat.c is supported only for legacy platforms where socket number and
data fabric numbers are same. So it can remain unchanged.

Signed-off-by: Suma Hegde <suma.hegde@amd.com>
Link: https://patch.msgid.link/20250916043736.3279947-1-suma.hegde@amd.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Suma Hegde and committed by
Ilpo Järvinen
0bd0f983 64400456

+4 -5
+4 -5
drivers/platform/x86/amd/hsmp/acpi.c
··· 22 22 #include <linux/module.h> 23 23 #include <linux/platform_device.h> 24 24 #include <linux/sysfs.h> 25 + #include <linux/topology.h> 25 26 #include <linux/uuid.h> 26 27 27 28 #include <uapi/asm-generic/errno-base.h> 28 - 29 - #include <asm/amd/node.h> 30 29 31 30 #include "hsmp.h" 32 31 ··· 585 586 return -ENOMEM; 586 587 587 588 if (!hsmp_pdev->is_probed) { 588 - hsmp_pdev->num_sockets = amd_num_nodes(); 589 - if (hsmp_pdev->num_sockets == 0 || hsmp_pdev->num_sockets > MAX_AMD_NUM_NODES) { 590 - dev_err(&pdev->dev, "Wrong number of sockets\n"); 589 + hsmp_pdev->num_sockets = topology_max_packages(); 590 + if (!hsmp_pdev->num_sockets) { 591 + dev_err(&pdev->dev, "No CPU sockets detected\n"); 591 592 return -ENODEV; 592 593 } 593 594