[PATCH v2 1/5] PCI/P2PDMA: Don't enforce ACS check for functions of same device
Vivek Kasireddy
vivek.kasireddy at intel.com
Mon Oct 21 05:21:29 UTC 2024
Functions of the same PCI device (such as a PF and a VF) share the
same bus and have a common root port and typically, the PF provisions
resources for the VF. Therefore, they can be considered compatible
as far as P2P access is considered.
Currently, although the distance (2) is correctly calculated for
functions of the same device, an ACS check failure prevents P2P DMA
access between them. Therefore, introduce a small function named
pci_devs_are_p2pdma_compatible() to determine if the provider and
client belong to the same device and facilitate P2P DMA between
them by not enforcing the ACS check.
v2:
- Relax the enforcment of ACS check only for Intel GPU functions
as they are P2PDMA compatible given the way the PF provisions
the resources among multiple VFs.
Cc: Bjorn Helgaas <bhelgaas at google.com>
Cc: Logan Gunthorpe <logang at deltatee.com>
Cc: <linux-pci at vger.kernel.org>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy at intel.com>
---
drivers/pci/p2pdma.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
index 4f47a13cb500..a230e661f939 100644
--- a/drivers/pci/p2pdma.c
+++ b/drivers/pci/p2pdma.c
@@ -535,6 +535,17 @@ static unsigned long map_types_idx(struct pci_dev *client)
return (pci_domain_nr(client->bus) << 16) | pci_dev_id(client);
}
+static bool pci_devs_are_p2pdma_compatible(struct pci_dev *provider,
+ struct pci_dev *client)
+{
+ if (provider->vendor == PCI_VENDOR_ID_INTEL) {
+ if (pci_is_vga(provider) && pci_is_vga(client))
+ return pci_physfn(provider) == pci_physfn(client);
+ }
+
+ return false;
+}
+
/*
* Calculate the P2PDMA mapping type and distance between two PCI devices.
*
@@ -634,7 +645,7 @@ calc_map_type_and_dist(struct pci_dev *provider, struct pci_dev *client,
*dist = dist_a + dist_b;
- if (!acs_cnt) {
+ if (!acs_cnt || pci_devs_are_p2pdma_compatible(provider, client)) {
map_type = PCI_P2PDMA_MAP_BUS_ADDR;
goto done;
}
@@ -696,7 +707,9 @@ int pci_p2pdma_distance_many(struct pci_dev *provider, struct device **clients,
return -1;
for (i = 0; i < num_clients; i++) {
- pci_client = find_parent_pci_dev(clients[i]);
+ pci_client = dev_is_pf(clients[i]) ?
+ pci_dev_get(to_pci_dev(clients[i])) :
+ find_parent_pci_dev(clients[i]);
if (!pci_client) {
if (verbose)
dev_warn(clients[i],
--
2.45.1
More information about the Intel-xe
mailing list