iommu: Explicitly skip bus address marked segments in __iommu_map_sg()
authorLogan Gunthorpe <logang@deltatee.com>
Fri, 8 Jul 2022 16:50:58 +0000 (10:50 -0600)
committerChristoph Hellwig <hch@lst.de>
Tue, 26 Jul 2022 11:27:48 +0000 (07:27 -0400)
In order to support PCI P2PDMA mappings with dma-iommu, explicitly skip
any segments marked with sg_dma_mark_bus_address() in __iommu_map_sg().

These segments should not be mapped into the IOVA and will be handled
separately in as subsequent patch for dma-iommu.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/iommu/iommu.c

index 847ad47a2dfd38f49085c07b9113130db30733b4..2844a3e02a89ecb25be723b5d3f305649580ff2b 100644 (file)
@@ -2457,6 +2457,9 @@ static ssize_t __iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
                        len = 0;
                }
 
+               if (sg_is_dma_bus_address(sg))
+                       goto next;
+
                if (len) {
                        len += sg->length;
                } else {
@@ -2464,6 +2467,7 @@ static ssize_t __iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
                        start = s_phys;
                }
 
+next:
                if (++i < nents)
                        sg = sg_next(sg);
        }