diff options
author | Christoph Hellwig <hch@lst.de> | 2019-05-20 09:29:28 +0200 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2019-05-27 17:31:10 +0200 |
commit | 23f88e0a7e9f084e91a40cc90a15968fb1e5d506 (patch) | |
tree | d26704de877676cf9bfa28ce016d7d9a74121a10 /drivers/iommu/dma-iommu.c | |
parent | af751d4308a7c80434b5f40fd44288d33dc1962f (diff) | |
download | blackbird-op-linux-23f88e0a7e9f084e91a40cc90a15968fb1e5d506.tar.gz blackbird-op-linux-23f88e0a7e9f084e91a40cc90a15968fb1e5d506.zip |
iommu/dma: Use for_each_sg in iommu_dma_alloc
arch_dma_prep_coherent can handle physically contiguous ranges larger
than PAGE_SIZE just fine, which means we don't need a page-based
iterator.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/dma-iommu.c')
-rw-r--r-- | drivers/iommu/dma-iommu.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index aac12433ffef..9b7f120d7381 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -606,15 +606,11 @@ struct page **iommu_dma_alloc(struct device *dev, size_t size, gfp_t gfp, goto out_free_iova; if (!(prot & IOMMU_CACHE)) { - struct sg_mapping_iter miter; - /* - * The CPU-centric flushing implied by SG_MITER_TO_SG isn't - * sufficient here, so skip it by using the "wrong" direction. - */ - sg_miter_start(&miter, sgt.sgl, sgt.orig_nents, SG_MITER_FROM_SG); - while (sg_miter_next(&miter)) - arch_dma_prep_coherent(miter.page, PAGE_SIZE); - sg_miter_stop(&miter); + struct scatterlist *sg; + int i; + + for_each_sg(sgt.sgl, sg, sgt.orig_nents, i) + arch_dma_prep_coherent(sg_page(sg), sg->length); } if (iommu_map_sg(domain, iova, sgt.sgl, sgt.orig_nents, prot) |