Commit 9a1aac8a authored by Srinivas Pandruvada's avatar Srinivas Pandruvada Committed by Hans de Goede

platform/x86: ISST: PUNIT device mapping with Sub-NUMA clustering

On a multiple package system using Sub-NUMA clustering, there is an issue
in mapping Linux CPU number to PUNIT PCI device when manufacturer decided
to reuse the PCI bus number across packages. Bus number can be reused as
long as they are in different domain or segment. In this case some CPU
will fail to find a PCI device to issue SST requests.

When bus numbers are reused across CPU packages, we are using proximity
information by matching CPU numa node id to PUNIT PCI device numa node
id. But on a package there can be only one PUNIT PCI device, but multiple
numa nodes (one for each sub cluster). So, the numa node ID of the PUNIT
PCI device can only match with one numa node id of CPUs in a sub cluster
in the package.

Since there can be only one PUNIT PCI device per package, if we match
with numa node id of any sub cluster in that package, we can use that
mapping for any CPU in that package. So, store the match information
in a per package data structure and return the information when there
is no match.

While here, use defines for max bus number instead of hardcoding.
Signed-off-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20220629194817.2418240-1-srinivas.pandruvada@linux.intel.comReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 221756e6
...@@ -277,29 +277,38 @@ static int isst_if_get_platform_info(void __user *argp) ...@@ -277,29 +277,38 @@ static int isst_if_get_platform_info(void __user *argp)
return 0; return 0;
} }
#define ISST_MAX_BUS_NUMBER 2
struct isst_if_cpu_info { struct isst_if_cpu_info {
/* For BUS 0 and BUS 1 only, which we need for PUNIT interface */ /* For BUS 0 and BUS 1 only, which we need for PUNIT interface */
int bus_info[2]; int bus_info[ISST_MAX_BUS_NUMBER];
struct pci_dev *pci_dev[2]; struct pci_dev *pci_dev[ISST_MAX_BUS_NUMBER];
int punit_cpu_id; int punit_cpu_id;
int numa_node; int numa_node;
}; };
struct isst_if_pkg_info {
struct pci_dev *pci_dev[ISST_MAX_BUS_NUMBER];
};
static struct isst_if_cpu_info *isst_cpu_info; static struct isst_if_cpu_info *isst_cpu_info;
static struct isst_if_pkg_info *isst_pkg_info;
#define ISST_MAX_PCI_DOMAINS 8 #define ISST_MAX_PCI_DOMAINS 8
static struct pci_dev *_isst_if_get_pci_dev(int cpu, int bus_no, int dev, int fn) static struct pci_dev *_isst_if_get_pci_dev(int cpu, int bus_no, int dev, int fn)
{ {
struct pci_dev *matched_pci_dev = NULL; struct pci_dev *matched_pci_dev = NULL;
struct pci_dev *pci_dev = NULL; struct pci_dev *pci_dev = NULL;
int no_matches = 0; int no_matches = 0, pkg_id;
int i, bus_number; int i, bus_number;
if (bus_no < 0 || bus_no > 1 || cpu < 0 || cpu >= nr_cpu_ids || if (bus_no < 0 || bus_no >= ISST_MAX_BUS_NUMBER || cpu < 0 ||
cpu >= num_possible_cpus()) cpu >= nr_cpu_ids || cpu >= num_possible_cpus())
return NULL; return NULL;
pkg_id = topology_physical_package_id(cpu);
bus_number = isst_cpu_info[cpu].bus_info[bus_no]; bus_number = isst_cpu_info[cpu].bus_info[bus_no];
if (bus_number < 0) if (bus_number < 0)
return NULL; return NULL;
...@@ -324,6 +333,8 @@ static struct pci_dev *_isst_if_get_pci_dev(int cpu, int bus_no, int dev, int fn ...@@ -324,6 +333,8 @@ static struct pci_dev *_isst_if_get_pci_dev(int cpu, int bus_no, int dev, int fn
} }
if (node == isst_cpu_info[cpu].numa_node) { if (node == isst_cpu_info[cpu].numa_node) {
isst_pkg_info[pkg_id].pci_dev[bus_no] = _pci_dev;
pci_dev = _pci_dev; pci_dev = _pci_dev;
break; break;
} }
...@@ -342,6 +353,10 @@ static struct pci_dev *_isst_if_get_pci_dev(int cpu, int bus_no, int dev, int fn ...@@ -342,6 +353,10 @@ static struct pci_dev *_isst_if_get_pci_dev(int cpu, int bus_no, int dev, int fn
if (!pci_dev && no_matches == 1) if (!pci_dev && no_matches == 1)
pci_dev = matched_pci_dev; pci_dev = matched_pci_dev;
/* Return pci_dev pointer for any matched CPU in the package */
if (!pci_dev)
pci_dev = isst_pkg_info[pkg_id].pci_dev[bus_no];
return pci_dev; return pci_dev;
} }
...@@ -361,8 +376,8 @@ struct pci_dev *isst_if_get_pci_dev(int cpu, int bus_no, int dev, int fn) ...@@ -361,8 +376,8 @@ struct pci_dev *isst_if_get_pci_dev(int cpu, int bus_no, int dev, int fn)
{ {
struct pci_dev *pci_dev; struct pci_dev *pci_dev;
if (bus_no < 0 || bus_no > 1 || cpu < 0 || cpu >= nr_cpu_ids || if (bus_no < 0 || bus_no >= ISST_MAX_BUS_NUMBER || cpu < 0 ||
cpu >= num_possible_cpus()) cpu >= nr_cpu_ids || cpu >= num_possible_cpus())
return NULL; return NULL;
pci_dev = isst_cpu_info[cpu].pci_dev[bus_no]; pci_dev = isst_cpu_info[cpu].pci_dev[bus_no];
...@@ -417,10 +432,19 @@ static int isst_if_cpu_info_init(void) ...@@ -417,10 +432,19 @@ static int isst_if_cpu_info_init(void)
if (!isst_cpu_info) if (!isst_cpu_info)
return -ENOMEM; return -ENOMEM;
isst_pkg_info = kcalloc(topology_max_packages(),
sizeof(*isst_pkg_info),
GFP_KERNEL);
if (!isst_pkg_info) {
kfree(isst_cpu_info);
return -ENOMEM;
}
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
"platform/x86/isst-if:online", "platform/x86/isst-if:online",
isst_if_cpu_online, NULL); isst_if_cpu_online, NULL);
if (ret < 0) { if (ret < 0) {
kfree(isst_pkg_info);
kfree(isst_cpu_info); kfree(isst_cpu_info);
return ret; return ret;
} }
...@@ -433,6 +457,7 @@ static int isst_if_cpu_info_init(void) ...@@ -433,6 +457,7 @@ static int isst_if_cpu_info_init(void)
static void isst_if_cpu_info_exit(void) static void isst_if_cpu_info_exit(void)
{ {
cpuhp_remove_state(isst_if_online_id); cpuhp_remove_state(isst_if_online_id);
kfree(isst_pkg_info);
kfree(isst_cpu_info); kfree(isst_cpu_info);
}; };
......
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