staging: imgu: Use vmap() instead of __get_vm_area() and map_vm_area()
Subsystems (3)
Sakari Ailus
maintainerPATCH 1/1 staging: imgu: Use vmap() instead of __get_vm_area() and map_vm_area()
Switch to vmap() instead of using both __get_vm_area() and map_vm_area().
While at it, also assign vm_struct.nr_pages field.
---
This is just compile tested but reasonably trivial.
drivers/staging/media/ipu3/ipu3-dmamap.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/staging/media/ipu3/ipu3-dmamap.c +2 -9
@@ -123,16 +123,12 @@ void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map, iovaddr +=PAGE_SIZE ; } -/* Now grab a virtual region */ - map->vma =__get_vm_area (size,VM_USERMAP ,VMALLOC_START ,VMALLOC_END ); + map->vma =vmap (pages, size /PAGE_SIZE ,VM_USERMAP ,PAGE_KERNEL );if (!map->vma) goto out_unmap; map->vma->pages = pages; -/* And map it in KVA */ -if (map_vm_area (map->vma,PAGE_KERNEL , pages)) - goto out_vunmap; - + map->vma->nr_pages = size /PAGE_SIZE ; map->size = size; map->daddr =iova_dma_addr (&imgu->iova_domain, iova); map->vaddr = map->vma->addr;
@@ -142,9 +138,6 @@ void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map,return map->vma->addr; -out_vunmap: -vunmap (map->vma->addr); - out_unmap:imgu_dmamap_free_buffer (pages, size); imgu_mmu_unmap(imgu->mmu, iova_dma_addr(&imgu->iova_domain, iova),
Signature · 1 line
2.20.1
Hi, Sakari
Quoted 17 lines · Sakari Ailus
Switch to
vmap()instead of using both__get_vm_area()andmap_vm_area().While at it, also assign vm_struct.nr_pages field.
Reported-by Christoph Hellwig <[email protected]>Signed-off-by Sakari Ailus <[email protected]>---
This is just compile tested but reasonably trivial.drivers/staging/media/ipu3/ipu3-dmamap.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)drivers/staging/media/ipu3/ipu3-dmamap.c +0
-0
drivers/staging/media/ipu3/ipu3-dmamap.c void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map, · line 126
Quoted 6 lines
drivers/staging/media/ipu3/ipu3-dmamap.c +1
-2@@ -123,16 +123,12 @@ void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map, iovaddr +=PAGE_SIZE ; } -/* Now grab a virtual region */ - map->vma =__get_vm_area (size,VM_USERMAP ,VMALLOC_START ,VMALLOC_END ); + map->vma =vmap (pages, size /PAGE_SIZE ,VM_USERMAP ,PAGE_KERNEL );
vmap() returns the address of virtual area not the area itself, right?
Quoted 23 lines
drivers/staging/media/ipu3/ipu3-dmamap.c +1
-7if (!map->vma) goto out_unmap; map->vma->pages = pages; -/* And map it in KVA */ -if (map_vm_area (map->vma,PAGE_KERNEL , pages)) - goto out_vunmap; - + map->vma->nr_pages = size /PAGE_SIZE ; map->size = size; map->daddr =iova_dma_addr (&imgu->iova_domain, iova); map->vaddr = map->vma->addr;@@ -142,9 +138,6 @@ void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map,return map->vma->addr; -out_vunmap: -vunmap (map->vma->addr); - out_unmap:imgu_dmamap_free_buffer (pages, size); imgu_mmu_unmap(imgu->mmu, iova_dma_addr(&imgu->iova_domain, iova),
Signature · 2 lines
Best regards, Bingbu Cao
Sakari Ailus
maintainerHi Bingbu,
Quoted 23 lines · Bingbu Cao
Hi, Sakari
Quoted 20 lines · Sakari Ailus
Switch to
vmap()instead of using both__get_vm_area()andmap_vm_area().While at it, also assign vm_struct.nr_pages field.
Reported-by Christoph Hellwig <[email protected]>Signed-off-by Sakari Ailus <[email protected]>---
This is just compile tested but reasonably trivial.drivers/staging/media/ipu3/ipu3-dmamap.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)drivers/staging/media/ipu3/ipu3-dmamap.c +0
-0@@ -123,16 +123,12 @@ void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map, iovaddr +=PAGE_SIZE ; }
Quoted 5 lines
drivers/staging/media/ipu3/ipu3-dmamap.c void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map, · line 126
Quoted 3 lines
drivers/staging/media/ipu3/ipu3-dmamap.c +1
-2-/* Now grab a virtual region */ - map->vma =__get_vm_area (size,VM_USERMAP ,VMALLOC_START ,VMALLOC_END ); + map->vma =vmap (pages, size /PAGE_SIZE ,VM_USERMAP ,PAGE_KERNEL );
vmap()returns the address of virtual area not the area itself, right?
Yes. But there's a cleaner patches from Christoph here:
<URL:https://lore.kernel.org/lkml/[email protected]/>
So I've dropped mine.
Quoted 25 lines
Quoted 24 lines
drivers/staging/media/ipu3/ipu3-dmamap.c +1
-7if (!map->vma) goto out_unmap; map->vma->pages = pages; -/* And map it in KVA */ -if (map_vm_area (map->vma,PAGE_KERNEL , pages)) - goto out_vunmap; - + map->vma->nr_pages = size /PAGE_SIZE ; map->size = size; map->daddr =iova_dma_addr (&imgu->iova_domain, iova); map->vaddr = map->vma->addr;@@ -142,9 +138,6 @@ void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map,return map->vma->addr; -out_vunmap: -vunmap (map->vma->addr); - out_unmap:imgu_dmamap_free_buffer (pages, size); imgu_mmu_unmap(imgu->mmu, iova_dma_addr(&imgu->iova_domain, iova),
Signature · 3 lines
Kind regards, Sakari Ailus
Quoted 32 lines · Sakari Ailus
Hi Bingbu,
Quoted 23 lines · Bingbu Cao
Hi, Sakari
Quoted 20 lines · Sakari Ailus
Switch to
vmap()instead of using both__get_vm_area()andmap_vm_area().While at it, also assign vm_struct.nr_pages field.
Reported-by Christoph Hellwig <[email protected]>Signed-off-by Sakari Ailus <[email protected]>---
This is just compile tested but reasonably trivial.drivers/staging/media/ipu3/ipu3-dmamap.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)drivers/staging/media/ipu3/ipu3-dmamap.c +0
-0@@ -123,16 +123,12 @@ void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map, iovaddr +=PAGE_SIZE ; }Quoted 5 lines
drivers/staging/media/ipu3/ipu3-dmamap.c void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map, · line 126
Quoted 3 lines
drivers/staging/media/ipu3/ipu3-dmamap.c +1
-2-/* Now grab a virtual region */ - map->vma =__get_vm_area (size,VM_USERMAP ,VMALLOC_START ,VMALLOC_END ); + map->vma =vmap (pages, size /PAGE_SIZE ,VM_USERMAP ,PAGE_KERNEL );
vmap()returns the address of virtual area not the area itself, right?
Quoted 3 lines
Yes. But there's a cleaner patches from Christoph here:
Thanks, I just did a simple test with Christoph's patch, the basic camera functions are OK.
Quoted 29 lines
So I've dropped mine.
Quoted 25 lines
Quoted 24 lines
drivers/staging/media/ipu3/ipu3-dmamap.c +1
-7if (!map->vma) goto out_unmap; map->vma->pages = pages; -/* And map it in KVA */ -if (map_vm_area (map->vma,PAGE_KERNEL , pages)) - goto out_vunmap; - + map->vma->nr_pages = size /PAGE_SIZE ; map->size = size; map->daddr =iova_dma_addr (&imgu->iova_domain, iova); map->vaddr = map->vma->addr;@@ -142,9 +138,6 @@ void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map,return map->vma->addr; -out_vunmap: -vunmap (map->vma->addr); - out_unmap:imgu_dmamap_free_buffer (pages, size); imgu_mmu_unmap(imgu->mmu, iova_dma_addr(&imgu->iova_domain, iova),
Signature · 2 lines
Best regards, Bingbu Cao