linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI/P2PDMA: Root complex whitelist should not apply when an IOMMU is present
@ 2019-05-22 20:12 Logan Gunthorpe
  2019-06-18 20:40 ` Bjorn Helgaas
  0 siblings, 1 reply; 23+ messages in thread
From: Logan Gunthorpe @ 2019-05-22 20:12 UTC (permalink / raw)
  To: linux-pci; +Cc: Logan Gunthorpe, Christian König, Bjorn Helgaas

Presently, there is no path to DMA map P2PDMA memory, so if a TLP
targeting this memory hits the root complex and an IOMMU is present,
the IOMMU will reject the transaction, even if the RC would support
P2PDMA.

So until the kernel knows to map these DMA addresses in the IOMMU,
we should not enable the whitelist when an IOMMU is present.

While we are at it, remove the comment mentioning future work
to add a white list.

Fixes: 0f97da831026 ("PCI/P2PDMA: Allow P2P DMA between any devices under AMD ZEN Root Complex")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/p2pdma.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Hey,

I realized recently that I missed this issue between the IOMMU and
the whitelist when reviewing Christian's patch.

Unless there are any objections, I think this should be squashed
with the commit marked in the Fixes tag (from pci-v5.2-changes).

Thanks,

Logan

diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
index 742928d0053e..4d2f6a44cba3 100644
--- a/drivers/pci/p2pdma.c
+++ b/drivers/pci/p2pdma.c
@@ -18,6 +18,7 @@
 #include <linux/percpu-refcount.h>
 #include <linux/random.h>
 #include <linux/seq_buf.h>
+#include <linux/iommu.h>

 struct pci_p2pdma {
 	struct percpu_ref devmap_ref;
@@ -284,6 +285,9 @@ static bool root_complex_whitelist(struct pci_dev *dev)
 	struct pci_dev *root = pci_get_slot(host->bus, PCI_DEVFN(0, 0));
 	unsigned short vendor, device;

+	if (iommu_present(dev->dev.bus))
+		return false;
+
 	if (!root)
 		return false;

@@ -453,8 +457,7 @@ static int upstream_bridge_distance_warn(struct pci_dev *provider,
  *
  * For now, "compatible" means the provider and the clients are all behind
  * the same PCI root port. This cuts out cases that may work but is safest
- * for the user. Future work can expand this to white-list root complexes that
- * can safely forward between each ports.
+ * for the user.
  */
 int pci_p2pdma_distance_many(struct pci_dev *provider, struct device **clients,
 			     int num_clients, bool verbose)
--
2.20.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread
[parent not found: <a98bff67-a76e-4ddc-a317-96f2bdc9af72@email.android.com>]

end of thread, other threads:[~2019-06-19  9:39 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22 20:12 [PATCH] PCI/P2PDMA: Root complex whitelist should not apply when an IOMMU is present Logan Gunthorpe
2019-06-18 20:40 ` Bjorn Helgaas
2019-06-18 20:51   ` Logan Gunthorpe
2019-06-18 23:50     ` Logan Gunthorpe
2019-06-19  9:26       ` Koenig, Christian
2019-06-19  9:29         ` Christoph Hellwig
2019-06-19  9:39           ` Koenig, Christian
     [not found] <a98bff67-a76e-4ddc-a317-96f2bdc9af72@email.android.com>
2019-05-22 20:41 ` Logan Gunthorpe
2019-05-23  8:12   ` Koenig, Christian
2019-05-23  9:43     ` Christoph Hellwig
2019-05-23  9:48       ` Koenig, Christian
2019-05-23  9:50         ` Christoph Hellwig
2019-05-23 10:06           ` Koenig, Christian
2019-05-23 10:26             ` Christoph Hellwig
2019-05-23 15:59               ` Logan Gunthorpe
2019-05-23 15:53           ` Logan Gunthorpe
2019-05-23 15:59             ` Christoph Hellwig
2019-05-24 12:40               ` Koenig, Christian
2019-05-24 14:12                 ` Christoph Hellwig
2019-05-24 16:18                   ` Logan Gunthorpe
2019-05-24 16:06                 ` Logan Gunthorpe
2019-05-23 16:14         ` Logan Gunthorpe
2019-05-23 15:47     ` Logan Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).