From ba575b2222418c85ab2b473674e9cad1fb84fefe Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Thu, 1 Apr 2021 13:33:01 -0700 Subject: [PATCH] BACKPORT: FROMLIST: iommu/io-pgtable: Introduce map_pages() as a page table op Mapping memory into io-pgtables follows the same semantics that unmapping memory used to follow (i.e. a buffer will be mapped one page block per call to the io-pgtable code). This means that it can be optimized in the same way that unmapping memory was, so add a map_pages() callback to the io-pgtable ops structure, so that a range of pages of the same size can be mapped within the same call. Bug: 178537788 Change-Id: I5f2a86f21216f26b2cc2f70904c2968467c5363a 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 --- include/linux/io-pgtable.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h index fc9c3a7f4561..df71703450a9 100644 --- a/include/linux/io-pgtable.h +++ b/include/linux/io-pgtable.h @@ -138,6 +138,7 @@ struct io_pgtable_cfg { * struct io_pgtable_ops - Page table manipulation API for IOMMU drivers. * * @map: Map a physically contiguous memory region. + * @map_pages: Map a physically contiguous range of pages of the same size. * @map_sg: Map a scatter-gather list of physically contiguous memory * chunks. The mapped pointer argument is used to store how * many bytes are mapped. @@ -151,6 +152,9 @@ struct io_pgtable_cfg { struct io_pgtable_ops { int (*map)(struct io_pgtable_ops *ops, unsigned long iova, phys_addr_t paddr, size_t size, int prot, gfp_t gfp); + int (*map_pages)(struct io_pgtable_ops *ops, 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 io_pgtable_ops *ops, unsigned long iova, struct scatterlist *sg, unsigned int nents, int prot, gfp_t gfp, size_t *mapped);