MLK-11765 video: mxsfb: change the fb buffer managment
authorFancy Fang <chen.fang@freescale.com>
Wed, 28 Oct 2015 09:16:01 +0000 (17:16 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:49:13 +0000 (14:49 -0500)
The previous fb buffer management has two problems:

1. After reallocate a bigger buffer and free the old buffer,
   user space app doesn't know this and may continue accessing
   the old buffer.
2. The freed buffer contents will be lost.

So, this patch allocates a big enough fb buffer(32MB) from the
beginning and never reallocates it.

Signed-off-by: Fancy Fang <chen.fang@freescale.com>
(cherry picked from commit c76a37e342369675aa9ef2efde6373d288c2f013)

Conflicts:
drivers/video/mxsfb.c

drivers/video/fbdev/mxsfb.c

index 4c4273c..329a569 100644 (file)
@@ -662,6 +662,15 @@ static int mxsfb_set_par(struct fb_info *fb_info)
        if (host->cur_blank != FB_BLANK_UNBLANK)
                return 0;
 
+       line_size =  fb_info->var.xres * (fb_info->var.bits_per_pixel >> 3);
+       fb_info->fix.line_length = line_size;
+       fb_size = fb_info->var.yres_virtual * line_size;
+
+       if (fb_size > fb_info->fix.smem_len) {
+               dev_err(&host->pdev->dev, "exceeds the fb buffer size limit!\n");
+               return -ENOMEM;
+       }
+
        /*
         * It seems, you can't re-program the controller if it is still running.
         * This may lead into shifted pictures (FIFO issue?).
@@ -675,19 +684,6 @@ static int mxsfb_set_par(struct fb_info *fb_info)
        /* clear the FIFOs */
        writel(CTRL1_FIFO_CLEAR, host->base + LCDC_CTRL1 + REG_SET);
 
-       line_size =  fb_info->var.xres * (fb_info->var.bits_per_pixel >> 3);
-       fb_info->fix.line_length = line_size;
-       fb_size = fb_info->var.yres_virtual * line_size;
-
-       /* Reallocate memory */
-       if (!fb_info->fix.smem_start || (fb_size > fb_info->fix.smem_len)) {
-               if (fb_info->fix.smem_start)
-                       mxsfb_unmap_videomem(fb_info);
-
-               if (mxsfb_map_videomem(fb_info) < 0)
-                       return -ENOMEM;
-       }
-
        ctrl = CTRL_BYPASS_COUNT | CTRL_MASTER |
                CTRL_SET_BUS_WIDTH(host->ld_intf_width);
 
@@ -1248,6 +1244,7 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host)
 
        fb_info->fix.line_length =
                fb_info->var.xres * (fb_info->var.bits_per_pixel >> 3);
+       fb_info->fix.smem_len = SZ_32M;
 
        /* Memory allocation for framebuffer */
        if (mxsfb_map_videomem(fb_info) < 0)