[PATCH v2 2/6] iommu: Add iova and size as parameters in iommu_iotlb_map
Robin Murphy
robin.murphy at arm.com
Wed Nov 25 11:38:08 EST 2020
On 2020-11-19 06:18, Yong Wu wrote:
> 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.
Reviewed-by: Robin Murphy <robin.murphy at arm.com>
> Signed-off-by: Yong Wu <yong.wu at mediatek.com>
> ---
> drivers/iommu/iommu.c | 6 +++---
> drivers/iommu/tegra-gart.c | 3 ++-
> include/linux/iommu.h | 3 ++-
> 3 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index decef851fa3a..df87c8e825f7 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -2425,7 +2425,7 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
> might_sleep();
> 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;
> }
> @@ -2439,7 +2439,7 @@ int iommu_map_atomic(struct iommu_domain *domain, unsigned long iova,
>
> ret = __iommu_map(domain, iova, paddr, size, prot, GFP_ATOMIC);
> if (ret == 0 && ops->iotlb_sync_map)
> - ops->iotlb_sync_map(domain);
> + ops->iotlb_sync_map(domain, iova, size);
>
> return ret;
> }
> @@ -2557,7 +2557,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:
> diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
> index fac720273889..d15d13a98ed1 100644
> --- a/drivers/iommu/tegra-gart.c
> +++ b/drivers/iommu/tegra-gart.c
> @@ -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);
> }
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index b95a6f8db6ff..794d4085edd3 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -244,7 +244,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);
>
More information about the Linux-mediatek
mailing list