linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] video: mxsfb: Fix framebuffer corruption on mx6sx
@ 2016-08-26 14:30 Marek Vasut
  2016-08-26 14:38 ` Lucas Stach
  2016-08-26 15:28 ` Marek Vasut
  0 siblings, 2 replies; 3+ messages in thread
From: Marek Vasut @ 2016-08-26 14:30 UTC (permalink / raw)
  To: linux-fbdev

Allocate the framebuffer memory as coherent, otherwise the framebuffer
will suffer from artifacts when displaying scrolling text or video.
This can be replicated on i.MX6SX (armv7), which has more complex memory
architecture compared to the i.MX23/28 (armv5).

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Shawn Guo <shawnguo@kernel.org>
---
 drivers/video/fbdev/mxsfb.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c
index 4e6608c..bd1a310 100644
--- a/drivers/video/fbdev/mxsfb.c
+++ b/drivers/video/fbdev/mxsfb.c
@@ -800,6 +800,7 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host,
 			struct fb_videomode *vmode)
 {
 	int ret;
+	struct device *dev = &host->pdev->dev;
 	struct fb_info *fb_info = &host->fb_info;
 	struct fb_var_screeninfo *var = &fb_info->var;
 	dma_addr_t fb_phys;
@@ -825,12 +826,11 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host,
 
 	/* Memory allocation for framebuffer */
 	fb_size = SZ_2M;
-	fb_virt = alloc_pages_exact(fb_size, GFP_DMA);
+	fb_virt = dma_alloc_coherent(dev, PAGE_ALIGN(fb_size), &fb_phys,
+				     GFP_KERNEL);
 	if (!fb_virt)
 		return -ENOMEM;
 
-	fb_phys = virt_to_phys(fb_virt);
-
 	fb_info->fix.smem_start = fb_phys;
 	fb_info->screen_base = fb_virt;
 	fb_info->screen_size = fb_info->fix.smem_len = fb_size;
@@ -843,9 +843,11 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host,
 
 static void mxsfb_free_videomem(struct mxsfb_info *host)
 {
+	struct device *dev = &host->pdev->dev;
 	struct fb_info *fb_info = &host->fb_info;
 
-	free_pages_exact(fb_info->screen_base, fb_info->fix.smem_len);
+	dma_free_coherent(dev, fb_info->screen_size, fb_info->screen_base,
+			  fb_info->fix.smem_start);
 }
 
 static const struct platform_device_id mxsfb_devtype[] = {
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] video: mxsfb: Fix framebuffer corruption on mx6sx
  2016-08-26 14:30 [PATCH] video: mxsfb: Fix framebuffer corruption on mx6sx Marek Vasut
@ 2016-08-26 14:38 ` Lucas Stach
  2016-08-26 15:28 ` Marek Vasut
  1 sibling, 0 replies; 3+ messages in thread
From: Lucas Stach @ 2016-08-26 14:38 UTC (permalink / raw)
  To: linux-fbdev

Am Freitag, den 26.08.2016, 16:30 +0200 schrieb Marek Vasut:
> Allocate the framebuffer memory as coherent, otherwise the framebuffer
> will suffer from artifacts when displaying scrolling text or video.
> This can be replicated on i.MX6SX (armv7), which has more complex memory
> architecture compared to the i.MX23/28 (armv5).
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: Fabio Estevam <fabio.estevam@nxp.com>
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Cc: Shawn Guo <shawnguo@kernel.org>
> ---
>  drivers/video/fbdev/mxsfb.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c
> index 4e6608c..bd1a310 100644
> --- a/drivers/video/fbdev/mxsfb.c
> +++ b/drivers/video/fbdev/mxsfb.c
> @@ -800,6 +800,7 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host,
>  			struct fb_videomode *vmode)
>  {
>  	int ret;
> +	struct device *dev = &host->pdev->dev;
>  	struct fb_info *fb_info = &host->fb_info;
>  	struct fb_var_screeninfo *var = &fb_info->var;
>  	dma_addr_t fb_phys;
> @@ -825,12 +826,11 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host,
>  
>  	/* Memory allocation for framebuffer */
>  	fb_size = SZ_2M;
> -	fb_virt = alloc_pages_exact(fb_size, GFP_DMA);
> +	fb_virt = dma_alloc_coherent(dev, PAGE_ALIGN(fb_size), &fb_phys,
> +				     GFP_KERNEL);

You probably want writecombined memory here instead of coherent. Using
coherent memory for framebuffers sucks performance wise.

>  	if (!fb_virt)
>  		return -ENOMEM;
>  
> -	fb_phys = virt_to_phys(fb_virt);
> -
>  	fb_info->fix.smem_start = fb_phys;
>  	fb_info->screen_base = fb_virt;
>  	fb_info->screen_size = fb_info->fix.smem_len = fb_size;
> @@ -843,9 +843,11 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host,
>  
>  static void mxsfb_free_videomem(struct mxsfb_info *host)
>  {
> +	struct device *dev = &host->pdev->dev;
>  	struct fb_info *fb_info = &host->fb_info;
>  
> -	free_pages_exact(fb_info->screen_base, fb_info->fix.smem_len);
> +	dma_free_coherent(dev, fb_info->screen_size, fb_info->screen_base,
> +			  fb_info->fix.smem_start);
>  }
>  
>  static const struct platform_device_id mxsfb_devtype[] = {



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] video: mxsfb: Fix framebuffer corruption on mx6sx
  2016-08-26 14:30 [PATCH] video: mxsfb: Fix framebuffer corruption on mx6sx Marek Vasut
  2016-08-26 14:38 ` Lucas Stach
@ 2016-08-26 15:28 ` Marek Vasut
  1 sibling, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2016-08-26 15:28 UTC (permalink / raw)
  To: linux-fbdev

On 08/26/2016 04:38 PM, Lucas Stach wrote:
> Am Freitag, den 26.08.2016, 16:30 +0200 schrieb Marek Vasut:
>> Allocate the framebuffer memory as coherent, otherwise the framebuffer
>> will suffer from artifacts when displaying scrolling text or video.
>> This can be replicated on i.MX6SX (armv7), which has more complex memory
>> architecture compared to the i.MX23/28 (armv5).
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
>> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> Cc: Fabio Estevam <fabio.estevam@nxp.com>
>> Cc: Lucas Stach <l.stach@pengutronix.de>
>> Cc: Shawn Guo <shawnguo@kernel.org>
>> ---
>>  drivers/video/fbdev/mxsfb.c | 10 ++++++----
>>  1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c
>> index 4e6608c..bd1a310 100644
>> --- a/drivers/video/fbdev/mxsfb.c
>> +++ b/drivers/video/fbdev/mxsfb.c
>> @@ -800,6 +800,7 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host,
>>  			struct fb_videomode *vmode)
>>  {
>>  	int ret;
>> +	struct device *dev = &host->pdev->dev;
>>  	struct fb_info *fb_info = &host->fb_info;
>>  	struct fb_var_screeninfo *var = &fb_info->var;
>>  	dma_addr_t fb_phys;
>> @@ -825,12 +826,11 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host,
>>  
>>  	/* Memory allocation for framebuffer */
>>  	fb_size = SZ_2M;
>> -	fb_virt = alloc_pages_exact(fb_size, GFP_DMA);
>> +	fb_virt = dma_alloc_coherent(dev, PAGE_ALIGN(fb_size), &fb_phys,
>> +				     GFP_KERNEL);
> 
> You probably want writecombined memory here instead of coherent. Using
> coherent memory for framebuffers sucks performance wise.

Ah, true. That'd be dma_{alloc,free}_wc() , right ?

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-26 15:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-26 14:30 [PATCH] video: mxsfb: Fix framebuffer corruption on mx6sx Marek Vasut
2016-08-26 14:38 ` Lucas Stach
2016-08-26 15:28 ` Marek Vasut

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).