From 16cabf65c79c631695ac65df47f4084b24620ffb Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Thu, 1 Apr 2021 14:09:26 -0700 Subject: [PATCH] BACKPORT: FROMLIST: iommu: Add a map_pages() op for IOMMU drivers Add a callback for IOMMU drivers to provide a path for the IOMMU framework to call into an IOMMU driver, which can call into the io-pgtable code, to map a physically contiguous rnage of pages of the same size. For IOMMU drivers that do not specify a map_pages() callback, the existing logic of mapping memory one page block at a time will be used. Bug: 178537788 Change-Id: I907b346558dcc4127a9769c66940e324aaa48d3e Link: https://lore.kernel.org/linux-iommu/20210408171402.12607-1-isaacm@codeaurora.org/T/#t Signed-off-by: Isaac J. Manjarres Suggested-by: Will Deacon Acked-by: Lu Baolu --- include/linux/iommu.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 64074ed78544..aec35aa690e6 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -203,6 +203,8 @@ struct iommu_iotlb_gather { * @attach_dev: attach device to an iommu domain * @detach_dev: detach device from an iommu domain * @map: map a physically contiguous memory region to an iommu domain + * @map_pages: map a physically contiguous set of pages of the same size to + * an iommu domain. * @map_sg: map a scatter-gather list of physically contiguous chunks to * an iommu domain. * @unmap: unmap a physically contiguous memory region from an iommu domain @@ -257,6 +259,9 @@ struct iommu_ops { void (*detach_dev)(struct iommu_domain *domain, struct device *dev); int (*map)(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot, gfp_t gfp); + int (*map_pages)(struct iommu_domain *domain, unsigned long iova, + phys_addr_t paddr, size_t pgsize, size_t pgcount, + int prot, gfp_t gfp, size_t *mapped); int (*map_sg)(struct iommu_domain *domain, unsigned long iova, struct scatterlist *sg, unsigned int nents, int prot, gfp_t gfp, size_t *mapped);