Skip to content

Commit dea286b

Browse files
lsgunthbjorn-helgaas
authored andcommitted
PCI/P2PDMA: Allow P2PDMA on AMD Zen and newer CPUs
Allow P2PDMA if the CPU vendor is AMD and family is 0x17 (Zen) or greater. [bhelgaas: commit log, simplify #if/#else/#endif] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Logan Gunthorpe <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Cc: Christian König <[email protected]> Cc: Huang Rui <[email protected]>
1 parent b3a9e3b commit dea286b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

drivers/pci/p2pdma.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,18 +273,26 @@ static void seq_buf_print_bus_devfn(struct seq_buf *buf, struct pci_dev *pdev)
273273
seq_buf_printf(buf, "%s;", pci_name(pdev));
274274
}
275275

276+
static bool cpu_supports_p2pdma(void)
277+
{
278+
#ifdef CONFIG_X86
279+
struct cpuinfo_x86 *c = &cpu_data(0);
280+
281+
/* Any AMD CPU whose family ID is Zen or newer supports p2pdma */
282+
if (c->x86_vendor == X86_VENDOR_AMD && c->x86 >= 0x17)
283+
return true;
284+
#endif
285+
286+
return false;
287+
}
288+
276289
static const struct pci_p2pdma_whitelist_entry {
277290
unsigned short vendor;
278291
unsigned short device;
279292
enum {
280293
REQ_SAME_HOST_BRIDGE = 1 << 0,
281294
} flags;
282295
} pci_p2pdma_whitelist[] = {
283-
/* AMD ZEN */
284-
{PCI_VENDOR_ID_AMD, 0x1450, 0},
285-
{PCI_VENDOR_ID_AMD, 0x15d0, 0},
286-
{PCI_VENDOR_ID_AMD, 0x1630, 0},
287-
288296
/* Intel Xeon E5/Core i7 */
289297
{PCI_VENDOR_ID_INTEL, 0x3c00, REQ_SAME_HOST_BRIDGE},
290298
{PCI_VENDOR_ID_INTEL, 0x3c01, REQ_SAME_HOST_BRIDGE},
@@ -473,7 +481,8 @@ upstream_bridge_distance(struct pci_dev *provider, struct pci_dev *client,
473481
acs_redirects, acs_list);
474482

475483
if (map_type == PCI_P2PDMA_MAP_THRU_HOST_BRIDGE) {
476-
if (!host_bridge_whitelist(provider, client))
484+
if (!cpu_supports_p2pdma() &&
485+
!host_bridge_whitelist(provider, client))
477486
map_type = PCI_P2PDMA_MAP_NOT_SUPPORTED;
478487
}
479488

0 commit comments

Comments
 (0)