diff mbox series

[3/3] jz4740_fb: fix DMA API abuse

Message ID 20190509173849.11825-4-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/3] au1100fb: fix DMA API abuse | expand

Commit Message

Christoph Hellwig May 9, 2019, 5:38 p.m. UTC
Virtual addresses return from dma(m)_alloc_coherent are opaque in what
backs then, and drivers must not poke into them.  Switch the driver
to use the generic DMA API mmap helper to avoid these problems.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/video/fbdev/jz4740_fb.c | 7 -------
 1 file changed, 7 deletions(-)

Comments

Bartlomiej Zolnierkiewicz June 7, 2019, 12:21 p.m. UTC | #1
On 5/9/19 7:38 PM, Christoph Hellwig wrote:
> Virtual addresses return from dma(m)_alloc_coherent are opaque in what
> backs then, and drivers must not poke into them.  Switch the driver
> to use the generic DMA API mmap helper to avoid these problems.
Change itself looks fine but the patch description doesn't match what
the patch is actually doing (there is no conversion to DMA API helper
because the driver is already using it). Please correct it. Thank you.

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/video/fbdev/jz4740_fb.c | 7 -------
>  1 file changed, 7 deletions(-)
> diff --git a/drivers/video/fbdev/jz4740_fb.c b/drivers/video/fbdev/jz4740_fb.c
> index b57df83fdbd3..b95cdfa9e0a1 100644
> --- a/drivers/video/fbdev/jz4740_fb.c
> +++ b/drivers/video/fbdev/jz4740_fb.c
> @@ -466,7 +466,6 @@ static int jzfb_alloc_devmem(struct jzfb *jzfb)
>  {
>  	int max_videosize = 0;
>  	struct fb_videomode *mode = jzfb->pdata->modes;
> -	void *page;
>  	int i;
>  
>  	for (i = 0; i < jzfb->pdata->num_modes; ++mode, ++i) {
> @@ -491,12 +490,6 @@ static int jzfb_alloc_devmem(struct jzfb *jzfb)
>  	if (!jzfb->vidmem)
>  		goto err_free_framedesc;
>  
> -	for (page = jzfb->vidmem;
> -		 page < jzfb->vidmem + PAGE_ALIGN(jzfb->vidmem_size);
> -		 page += PAGE_SIZE) {
> -		SetPageReserved(virt_to_page(page));
> -	}
> -
>  	jzfb->framedesc->next = jzfb->framedesc_phys;
>  	jzfb->framedesc->addr = jzfb->vidmem_phys;
>  	jzfb->framedesc->id = 0xdeafbead;

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Bartlomiej Zolnierkiewicz June 21, 2019, 11:32 a.m. UTC | #2
Hi,

On 6/7/19 2:21 PM, Bartlomiej Zolnierkiewicz wrote:
> 
> On 5/9/19 7:38 PM, Christoph Hellwig wrote:
>> Virtual addresses return from dma(m)_alloc_coherent are opaque in what
>> backs then, and drivers must not poke into them.  Switch the driver
>> to use the generic DMA API mmap helper to avoid these problems.
> Change itself looks fine but the patch description doesn't match what
> the patch is actually doing (there is no conversion to DMA API helper
> because the driver is already using it). Please correct it. Thank you.

I've just removed the "Switch the driver.." sentence myself from
the patch description and applied the change, thanks!

>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>> ---
>>  drivers/video/fbdev/jz4740_fb.c | 7 -------
>>  1 file changed, 7 deletions(-)
>> diff --git a/drivers/video/fbdev/jz4740_fb.c b/drivers/video/fbdev/jz4740_fb.c
>> index b57df83fdbd3..b95cdfa9e0a1 100644
>> --- a/drivers/video/fbdev/jz4740_fb.c
>> +++ b/drivers/video/fbdev/jz4740_fb.c
>> @@ -466,7 +466,6 @@ static int jzfb_alloc_devmem(struct jzfb *jzfb)
>>  {
>>  	int max_videosize = 0;
>>  	struct fb_videomode *mode = jzfb->pdata->modes;
>> -	void *page;
>>  	int i;
>>  
>>  	for (i = 0; i < jzfb->pdata->num_modes; ++mode, ++i) {
>> @@ -491,12 +490,6 @@ static int jzfb_alloc_devmem(struct jzfb *jzfb)
>>  	if (!jzfb->vidmem)
>>  		goto err_free_framedesc;
>>  
>> -	for (page = jzfb->vidmem;
>> -		 page < jzfb->vidmem + PAGE_ALIGN(jzfb->vidmem_size);
>> -		 page += PAGE_SIZE) {
>> -		SetPageReserved(virt_to_page(page));
>> -	}
>> -
>>  	jzfb->framedesc->next = jzfb->framedesc_phys;
>>  	jzfb->framedesc->addr = jzfb->vidmem_phys;
>>  	jzfb->framedesc->id = 0xdeafbead;
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Christoph Hellwig June 25, 2019, 12:09 p.m. UTC | #3
On Fri, Jun 21, 2019 at 01:32:16PM +0200, Bartlomiej Zolnierkiewicz wrote:
> I've just removed the "Switch the driver.." sentence myself from
> the patch description and applied the change, thanks!

Sorry for not getting back to you earlier and thanks for fixing this
up and applying the patch.
diff mbox series

Patch

diff --git a/drivers/video/fbdev/jz4740_fb.c b/drivers/video/fbdev/jz4740_fb.c
index b57df83fdbd3..b95cdfa9e0a1 100644
--- a/drivers/video/fbdev/jz4740_fb.c
+++ b/drivers/video/fbdev/jz4740_fb.c
@@ -466,7 +466,6 @@  static int jzfb_alloc_devmem(struct jzfb *jzfb)
 {
 	int max_videosize = 0;
 	struct fb_videomode *mode = jzfb->pdata->modes;
-	void *page;
 	int i;
 
 	for (i = 0; i < jzfb->pdata->num_modes; ++mode, ++i) {
@@ -491,12 +490,6 @@  static int jzfb_alloc_devmem(struct jzfb *jzfb)
 	if (!jzfb->vidmem)
 		goto err_free_framedesc;
 
-	for (page = jzfb->vidmem;
-		 page < jzfb->vidmem + PAGE_ALIGN(jzfb->vidmem_size);
-		 page += PAGE_SIZE) {
-		SetPageReserved(virt_to_page(page));
-	}
-
 	jzfb->framedesc->next = jzfb->framedesc_phys;
 	jzfb->framedesc->addr = jzfb->vidmem_phys;
 	jzfb->framedesc->id = 0xdeafbead;