Skip to content

Commit 556e4c6

Browse files
BrianWoodsAMDsuryasaimadhu
authored andcommitted
x86/amd_nb: Add support for newer PCI topologies
Add support for new processors which have multiple PCI root complexes per data fabric/system management network interface. If there are (N) multiple PCI roots per DF/SMN interface, then the PCI roots are redundant (as far as SMN/DF access goes). For each DF/SMN interface: map to the first available PCI root and skip the next N-1 PCI roots so the following DF/SMN interface get mapped to a correct PCI root. Ex: DF/SMN 0 -> 60 40 20 00 DF/SMN 1 -> e0 c0 a0 80 Signed-off-by: Brian Woods <brian.woods@amd.com> Signed-off-by: Borislav Petkov <bp@suse.de> CC: Bjorn Helgaas <bhelgaas@google.com> CC: Clemens Ladisch <clemens@ladisch.de> CC: Guenter Roeck <linux@roeck-us.net> CC: "H. Peter Anvin" <hpa@zytor.com> CC: Ingo Molnar <mingo@redhat.com> CC: Jean Delvare <jdelvare@suse.com> CC: Jia Zhang <qianyue.zj@alibaba-inc.com> CC: <linux-hwmon@vger.kernel.org> CC: <linux-pci@vger.kernel.org> CC: Pu Wen <puwen@hygon.cn> CC: Thomas Gleixner <tglx@linutronix.de> CC: x86-ml <x86@kernel.org> Link: http://lkml.kernel.org/r/20181106200754.60722-3-brian.woods@amd.com
1 parent dedf7dc commit 556e4c6

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

arch/x86/kernel/amd_nb.c

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ int amd_cache_northbridges(void)
213213
const struct pci_device_id *root_ids = amd_root_ids;
214214
struct pci_dev *root, *misc, *link;
215215
struct amd_northbridge *nb;
216-
u16 i = 0;
216+
u16 roots_per_misc = 0;
217+
u16 misc_count = 0;
218+
u16 root_count = 0;
219+
u16 i, j;
217220

218221
if (amd_northbridges.num)
219222
return 0;
@@ -226,26 +229,55 @@ int amd_cache_northbridges(void)
226229

227230
misc = NULL;
228231
while ((misc = next_northbridge(misc, misc_ids)) != NULL)
229-
i++;
232+
misc_count++;
230233

231-
if (!i)
234+
if (!misc_count)
232235
return -ENODEV;
233236

234-
nb = kcalloc(i, sizeof(struct amd_northbridge), GFP_KERNEL);
237+
root = NULL;
238+
while ((root = next_northbridge(root, root_ids)) != NULL)
239+
root_count++;
240+
241+
if (root_count) {
242+
roots_per_misc = root_count / misc_count;
243+
244+
/*
245+
* There should be _exactly_ N roots for each DF/SMN
246+
* interface.
247+
*/
248+
if (!roots_per_misc || (root_count % roots_per_misc)) {
249+
pr_info("Unsupported AMD DF/PCI configuration found\n");
250+
return -ENODEV;
251+
}
252+
}
253+
254+
nb = kcalloc(misc_count, sizeof(struct amd_northbridge), GFP_KERNEL);
235255
if (!nb)
236256
return -ENOMEM;
237257

238258
amd_northbridges.nb = nb;
239-
amd_northbridges.num = i;
259+
amd_northbridges.num = misc_count;
240260

241261
link = misc = root = NULL;
242-
for (i = 0; i != amd_northbridges.num; i++) {
262+
for (i = 0; i < amd_northbridges.num; i++) {
243263
node_to_amd_nb(i)->root = root =
244264
next_northbridge(root, root_ids);
245265
node_to_amd_nb(i)->misc = misc =
246266
next_northbridge(misc, misc_ids);
247267
node_to_amd_nb(i)->link = link =
248268
next_northbridge(link, link_ids);
269+
270+
/*
271+
* If there are more PCI root devices than data fabric/
272+
* system management network interfaces, then the (N)
273+
* PCI roots per DF/SMN interface are functionally the
274+
* same (for DF/SMN access) and N-1 are redundant. N-1
275+
* PCI roots should be skipped per DF/SMN interface so
276+
* the following DF/SMN interfaces get mapped to
277+
* correct PCI roots.
278+
*/
279+
for (j = 1; j < roots_per_misc; j++)
280+
root = next_northbridge(root, root_ids);
249281
}
250282

251283
if (amd_gart_present())

0 commit comments

Comments
 (0)