]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
iommu: Add iova and size as parameters in iotlb_sync_map
authorYong Wu <yong.wu@mediatek.com>
Thu, 7 Jan 2021 12:29:04 +0000 (20:29 +0800)
committerWill Deacon <will@kernel.org>
Wed, 27 Jan 2021 12:32:26 +0000 (12:32 +0000)
iotlb_sync_map allow IOMMU drivers tlb sync after completing the whole
mapping. This patch adds iova and size as the parameters in it. then the
IOMMU driver could flush tlb with the whole range once after iova mapping
to improve performance.

Signed-off-by: Yong Wu <yong.wu@mediatek.com>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20210107122909.16317-3-yong.wu@mediatek.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/iommu.c
drivers/iommu/tegra-gart.c
include/linux/iommu.h

index c304a6a30d42ef7a49d45db7c2dae279b0e51b51..3d099a31ddca963c330dd08380ed0dbbed8baca2 100644 (file)
@@ -2443,7 +2443,7 @@ static int _iommu_map(struct iommu_domain *domain, unsigned long iova,
 
        ret = __iommu_map(domain, iova, paddr, size, prot, GFP_KERNEL);
        if (ret == 0 && ops->iotlb_sync_map)
-               ops->iotlb_sync_map(domain);
+               ops->iotlb_sync_map(domain, iova, size);
 
        return ret;
 }
@@ -2575,7 +2575,7 @@ static size_t __iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
        }
 
        if (ops->iotlb_sync_map)
-               ops->iotlb_sync_map(domain);
+               ops->iotlb_sync_map(domain, iova, mapped);
        return mapped;
 
 out_err:
index fac720273889c3ed92fca3261360b77c3ae8145f..05e8e19b82697367e914d3bd806c755b1a212faf 100644 (file)
@@ -261,7 +261,8 @@ static int gart_iommu_of_xlate(struct device *dev,
        return 0;
 }
 
-static void gart_iommu_sync_map(struct iommu_domain *domain)
+static void gart_iommu_sync_map(struct iommu_domain *domain, unsigned long iova,
+                               size_t size)
 {
        FLUSH_GART_REGS(gart_handle);
 }
@@ -269,7 +270,9 @@ static void gart_iommu_sync_map(struct iommu_domain *domain)
 static void gart_iommu_sync(struct iommu_domain *domain,
                            struct iommu_iotlb_gather *gather)
 {
-       gart_iommu_sync_map(domain);
+       size_t length = gather->end - gather->start;
+
+       gart_iommu_sync_map(domain, gather->start, length);
 }
 
 static const struct iommu_ops gart_iommu_ops = {
index b3f0e2018c6238a67a2b1cda397c3dab00689755..9ce0aa9e236bf8c618794e49791d616eca74fc09 100644 (file)
@@ -246,7 +246,8 @@ struct iommu_ops {
        size_t (*unmap)(struct iommu_domain *domain, unsigned long iova,
                     size_t size, struct iommu_iotlb_gather *iotlb_gather);
        void (*flush_iotlb_all)(struct iommu_domain *domain);
-       void (*iotlb_sync_map)(struct iommu_domain *domain);
+       void (*iotlb_sync_map)(struct iommu_domain *domain, unsigned long iova,
+                              size_t size);
        void (*iotlb_sync)(struct iommu_domain *domain,
                           struct iommu_iotlb_gather *iotlb_gather);
        phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova);