summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2019-07-12 17:08:27 -0500
committerBjorn Helgaas <bhelgaas@google.com>2019-07-12 17:08:27 -0500
commit3306e99edf70e9f7f9839c0c680136f098ebb1ed (patch)
tree057e78c23be211f3b8090d2d3a1eaa2fa4904efc /drivers
parente09977285c1929867c9f251d28bda9aed78fe331 (diff)
parent9c002bb66f5bd8b8f470926489a115b7f486f501 (diff)
downloadlinux-3306e99edf70e9f7f9839c0c680136f098ebb1ed.tar.bz2
Merge branch 'pci/peer-to-peer'
- Prevent drivers that use dma_virt_ops from using peer-to-peer DMA (Logan Gunthorpe) * pci/peer-to-peer: PCI/P2PDMA: Fix missing check for dma_virt_ops
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/p2pdma.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
index 742928d0053e..1940a7a0a684 100644
--- a/drivers/pci/p2pdma.c
+++ b/drivers/pci/p2pdma.c
@@ -468,6 +468,14 @@ int pci_p2pdma_distance_many(struct pci_dev *provider, struct device **clients,
return -1;
for (i = 0; i < num_clients; i++) {
+ if (IS_ENABLED(CONFIG_DMA_VIRT_OPS) &&
+ clients[i]->dma_ops == &dma_virt_ops) {
+ if (verbose)
+ dev_warn(clients[i],
+ "cannot be used for peer-to-peer DMA because the driver makes use of dma_virt_ops\n");
+ return -1;
+ }
+
pci_client = find_parent_pci_dev(clients[i]);
if (!pci_client) {
if (verbose)
@@ -732,7 +740,7 @@ int pci_p2pdma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
* p2pdma mappings are not compatible with devices that use
* dma_virt_ops. If the upper layers do the right thing
* this should never happen because it will be prevented
- * by the check in pci_p2pdma_add_client()
+ * by the check in pci_p2pdma_distance_many()
*/
if (WARN_ON_ONCE(IS_ENABLED(CONFIG_DMA_VIRT_OPS) &&
dev->dma_ops == &dma_virt_ops))