* [PATCH 1/1] staging: imgu: Use vmap() instead of __get_vm_area() and map_vm_area()
@ 2020-04-17 12:54 Sakari Ailus
2020-04-24 7:52 ` Bingbu Cao
0 siblings, 1 reply; 4+ messages in thread
From: Sakari Ailus @ 2020-04-17 12:54 UTC (permalink / raw)
To: linux-media; +Cc: Christoph Hellwig, bingbu.cao, tfiga, rajmohan.mani
Switch to vmap() instead of using both __get_vm_area() and map_vm_area().
While at it, also assign vm_struct.nr_pages field.
Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
This is just compile tested but reasonably trivial.
drivers/staging/media/ipu3/ipu3-dmamap.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-dmamap.c b/drivers/staging/media/ipu3/ipu3-dmamap.c
index 7431322379f6..58e6683e5770 100644
--- a/drivers/staging/media/ipu3/ipu3-dmamap.c
+++ b/drivers/staging/media/ipu3/ipu3-dmamap.c
@@ -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),
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] staging: imgu: Use vmap() instead of __get_vm_area() and map_vm_area()
2020-04-17 12:54 [PATCH 1/1] staging: imgu: Use vmap() instead of __get_vm_area() and map_vm_area() Sakari Ailus
@ 2020-04-24 7:52 ` Bingbu Cao
2020-04-24 9:56 ` Sakari Ailus
0 siblings, 1 reply; 4+ messages in thread
From: Bingbu Cao @ 2020-04-24 7:52 UTC (permalink / raw)
To: Sakari Ailus, linux-media
Cc: Christoph Hellwig, bingbu.cao, tfiga, rajmohan.mani
Hi, Sakari
On 4/17/20 8:54 PM, Sakari Ailus wrote:
> Switch to vmap() instead of using both __get_vm_area() and map_vm_area().
>
> While at it, also assign vm_struct.nr_pages field.
>
> Reported-by: Christoph Hellwig <hch@infradead.org>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> This is just compile tested but reasonably trivial.
>
> drivers/staging/media/ipu3/ipu3-dmamap.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/media/ipu3/ipu3-dmamap.c b/drivers/staging/media/ipu3/ipu3-dmamap.c
> index 7431322379f6..58e6683e5770 100644
> --- a/drivers/staging/media/ipu3/ipu3-dmamap.c
> +++ b/drivers/staging/media/ipu3/ipu3-dmamap.c
> @@ -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?
> 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),
>
--
Best regards,
Bingbu Cao
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] staging: imgu: Use vmap() instead of __get_vm_area() and map_vm_area()
2020-04-24 7:52 ` Bingbu Cao
@ 2020-04-24 9:56 ` Sakari Ailus
2020-04-26 2:39 ` Bingbu Cao
0 siblings, 1 reply; 4+ messages in thread
From: Sakari Ailus @ 2020-04-24 9:56 UTC (permalink / raw)
To: Bingbu Cao
Cc: linux-media, Christoph Hellwig, bingbu.cao, tfiga, rajmohan.mani
Hi Bingbu,
On Fri, Apr 24, 2020 at 03:52:22PM +0800, Bingbu Cao wrote:
> Hi, Sakari
>
> On 4/17/20 8:54 PM, Sakari Ailus wrote:
> > Switch to vmap() instead of using both __get_vm_area() and map_vm_area().
> >
> > While at it, also assign vm_struct.nr_pages field.
> >
> > Reported-by: Christoph Hellwig <hch@infradead.org>
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> > This is just compile tested but reasonably trivial.
> >
> > drivers/staging/media/ipu3/ipu3-dmamap.c | 11 ++---------
> > 1 file changed, 2 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/staging/media/ipu3/ipu3-dmamap.c b/drivers/staging/media/ipu3/ipu3-dmamap.c
> > index 7431322379f6..58e6683e5770 100644
> > --- a/drivers/staging/media/ipu3/ipu3-dmamap.c
> > +++ b/drivers/staging/media/ipu3/ipu3-dmamap.c
> > @@ -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?
Yes. But there's a cleaner patches from Christoph here:
<URL:https://lore.kernel.org/lkml/20200414131348.444715-5-hch@lst.de/>
So I've dropped mine.
>
> > 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),
> >
>
--
Kind regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] staging: imgu: Use vmap() instead of __get_vm_area() and map_vm_area()
2020-04-24 9:56 ` Sakari Ailus
@ 2020-04-26 2:39 ` Bingbu Cao
0 siblings, 0 replies; 4+ messages in thread
From: Bingbu Cao @ 2020-04-26 2:39 UTC (permalink / raw)
To: Sakari Ailus
Cc: linux-media, Christoph Hellwig, bingbu.cao, tfiga, rajmohan.mani
On 4/24/20 5:56 PM, Sakari Ailus wrote:
> Hi Bingbu,
>
> On Fri, Apr 24, 2020 at 03:52:22PM +0800, Bingbu Cao wrote:
>> Hi, Sakari
>>
>> On 4/17/20 8:54 PM, Sakari Ailus wrote:
>>> Switch to vmap() instead of using both __get_vm_area() and map_vm_area().
>>>
>>> While at it, also assign vm_struct.nr_pages field.
>>>
>>> Reported-by: Christoph Hellwig <hch@infradead.org>
>>> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
>>> ---
>>> This is just compile tested but reasonably trivial.
>>>
>>> drivers/staging/media/ipu3/ipu3-dmamap.c | 11 ++---------
>>> 1 file changed, 2 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/drivers/staging/media/ipu3/ipu3-dmamap.c b/drivers/staging/media/ipu3/ipu3-dmamap.c
>>> index 7431322379f6..58e6683e5770 100644
>>> --- a/drivers/staging/media/ipu3/ipu3-dmamap.c
>>> +++ b/drivers/staging/media/ipu3/ipu3-dmamap.c
>>> @@ -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?
>
> Yes. But there's a cleaner patches from Christoph here:
>
> <URL:https://lore.kernel.org/lkml/20200414131348.444715-5-hch@lst.de/>
Thanks, I just did a simple test with Christoph's patch, the basic camera
functions are OK.
>
> So I've dropped mine.
>
>>
>>> 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),
>>>
>>
>
--
Best regards,
Bingbu Cao
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-26 2:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-17 12:54 [PATCH 1/1] staging: imgu: Use vmap() instead of __get_vm_area() and map_vm_area() Sakari Ailus
2020-04-24 7:52 ` Bingbu Cao
2020-04-24 9:56 ` Sakari Ailus
2020-04-26 2:39 ` Bingbu Cao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).