sparc/iommu: use sbus_iommu_unmap_page in sbus_iommu_unmap_sg
authorChristoph Hellwig <hch@lst.de>
Tue, 16 Apr 2019 18:23:40 +0000 (20:23 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 9 May 2019 00:11:56 +0000 (17:11 -0700)
Use the page-level helper instead of duplicating the logic, while also
fixing the incorrect handling of larger than page sized offsets in
the sg variant.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc/mm/iommu.c

index dcdadac03fdfe3177a16761fb1a467846a059162..f47a6ce0acaa08846d25027a7421813d9686630d 100644 (file)
@@ -321,11 +321,11 @@ static void sbus_iommu_unmap_sg(struct device *dev, struct scatterlist *sgl,
                int nents, enum dma_data_direction dir, unsigned long attrs)
 {
        struct scatterlist *sg;
-       int i, n;
+       int i;
 
        for_each_sg(sgl, sg, nents, i) {
-               n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
-               iommu_release_one(dev, sg->dma_address & PAGE_MASK, n);
+               sbus_iommu_unmap_page(dev, sg->dma_address, sg->length, dir,
+                               attrs);
                sg->dma_address = 0x21212121;
        }
 }