Skip to contentSkip to conversation

dma-iommu: remove __iommu_dma_mmap

PATCH Applied Christoph Hellwig 3 participants 3 messages Dec 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-iommu: remove __iommu_dma_mmap

The function has a single caller, so open code it there and take advantage of the precalculated page count variable.

---
 drivers/iommu/dma-iommu.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
drivers/iommu/dma-iommu.c +1 -16
index 0cbcd3fc3e7e8d..f6ea1dabc6a894 100644
@@ -655,21 +655,6 @@ static void *iommu_dma_alloc_remap(struct device *dev, size_t size,
 	return NULL;
 }
 
-/**
- * __iommu_dma_mmap - Map a buffer into provided user VMA
- * @pages: Array representing buffer from __iommu_dma_alloc()
- * @size: Size of buffer in bytes
- * @vma: VMA describing requested userspace mapping
- *
- * Maps the pages of the buffer in @pages into @vma. The caller is responsible
- * for verifying the correct size and protection of @vma beforehand.
- */
-static int __iommu_dma_mmap(struct page **pages, size_t size,
-		struct vm_area_struct *vma)
-{
-	return vm_map_pages(vma, pages, PAGE_ALIGN(size) >> PAGE_SHIFT);
-}
-
 static void iommu_dma_sync_single_for_cpu(struct device *dev,
 		dma_addr_t dma_handle, size_t size, enum dma_data_direction dir)
 {
@@ -1102,7 +1087,7 @@ static int iommu_dma_mmap(struct device *dev, struct vm_area_struct *vma,
 		struct page **pages = dma_common_find_pages(cpu_addr);
 
 		if (pages)
-			return __iommu_dma_mmap(pages, size, vma);
+			return vm_map_pages(vma, pages, nr_pages);
 		pfn = vmalloc_to_pfn(cpu_addr);
 	} else {
 		pfn = page_to_pfn(virt_to_page(cpu_addr));
Signature · 6 lines
2.29.2

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Christoph Hellwig

The function has a single caller, so open code it there and take advantage of the precalculated page count variable.

I can't shake the feeling that we've written this patch at least twice before through all the refactoring, so definitely no objection from me to an obvious cleanup:

Quoted 33 lines
---
  drivers/iommu/dma-iommu.c | 17 +----------------
  1 file changed, 1 insertion(+), 16 deletions(-)
drivers/iommu/dma-iommu.c +0 -15
index 0cbcd3fc3e7e8d..f6ea1dabc6a894 100644
@@ -655,21 +655,6 @@ static void *iommu_dma_alloc_remap(struct device *dev, size_t size,
  	return NULL;
  }
 
-/**
- * __iommu_dma_mmap - Map a buffer into provided user VMA
- * @pages: Array representing buffer from __iommu_dma_alloc()
- * @size: Size of buffer in bytes
- * @vma: VMA describing requested userspace mapping
- *
- * Maps the pages of the buffer in @pages into @vma. The caller is responsible
- * for verifying the correct size and protection of @vma beforehand.
- */
-static int __iommu_dma_mmap(struct page **pages, size_t size,
-		struct vm_area_struct *vma)
-{
-	return vm_map_pages(vma, pages, PAGE_ALIGN(size) >> PAGE_SHIFT);
-}
-
  static void iommu_dma_sync_single_for_cpu(struct device *dev,
  		dma_addr_t dma_handle, size_t size, enum dma_data_direction dir)
  {

drivers/iommu/dma-iommu.c static int iommu_dma_mmap(struct device *dev, struct vm_area_struct *vma, · line 1093

Quoted 8 lines
drivers/iommu/dma-iommu.c +1 -1
@@ -1102,7 +1087,7 @@ static int iommu_dma_mmap(struct device *dev, struct vm_area_struct *vma,
  		struct page **pages = dma_common_find_pages(cpu_addr);
 
  		if (pages)
-			return __iommu_dma_mmap(pages, size, vma);
+			return vm_map_pages(vma, pages, nr_pages);
  		pfn = vmalloc_to_pfn(cpu_addr);
  	} else {
  		pfn = page_to_pfn(virt_to_page(cpu_addr));

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

maintainer Applied
#2 lore raw
In reply to Christoph Hellwig
Quoted 2 lines · Christoph Hellwig

The function has a single caller, so open code it there and take advantage of the precalculated page count variable.

Applied to arm64 (for-next/iommu/core), thanks!

[1/1] dma-iommu: remove __iommu_dma_mmap

      https://git.kernel.org/arm64/c/71fe89ceb55b

Cheers,

Signature · 9 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu