Commit 03bb2b49 authored by Sergio Aguirre's avatar Sergio Aguirre Committed by Tony Lindgren

omapfb: Condition mutex acquisition

This fixes a bug introduced by this commit ID:

  commit 537a1bf0
  Author: Krzysztof Helt <krzysztof.h1@wp.pl>
  Date:   Tue Jun 30 11:41:29 2009 -0700

    fbdev: add mutex for fb_mmap locking

In which a mutex was added when changing smem_start and smem_len fields,
so the mutex inside the fb_mmap() call is actually used.

The problem was that set_fb_fix, which modifies the above 2 fields,
was called before and after registering the framebuffer,
which when used before registration, lead to a failed attempt to
use an uninitialized mutex.

Solution: Don't use mutex before framebuffer registration.
Signed-off-by: default avatarSergio Aguirre <saaguirre@ti.com>
Acked-by: default avatarTomi Valkeinen <tomi.valkeinen@nokia.com>
Acked-by: default avatarImre Deak <imre.deak@nokia.com>
Tested-by: default avatarCory Maccarrone <darkstar6262@gmail.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 26548900
...@@ -393,7 +393,7 @@ static void omapfb_sync(struct fb_info *fbi) ...@@ -393,7 +393,7 @@ static void omapfb_sync(struct fb_info *fbi)
* Set fb_info.fix fields and also updates fbdev. * Set fb_info.fix fields and also updates fbdev.
* When calling this fb_info.var must be set up already. * When calling this fb_info.var must be set up already.
*/ */
static void set_fb_fix(struct fb_info *fbi) static void set_fb_fix(struct fb_info *fbi, int from_init)
{ {
struct fb_fix_screeninfo *fix = &fbi->fix; struct fb_fix_screeninfo *fix = &fbi->fix;
struct fb_var_screeninfo *var = &fbi->var; struct fb_var_screeninfo *var = &fbi->var;
...@@ -403,10 +403,16 @@ static void set_fb_fix(struct fb_info *fbi) ...@@ -403,10 +403,16 @@ static void set_fb_fix(struct fb_info *fbi)
rg = &plane->fbdev->mem_desc.region[plane->idx]; rg = &plane->fbdev->mem_desc.region[plane->idx];
fbi->screen_base = rg->vaddr; fbi->screen_base = rg->vaddr;
if (!from_init) {
mutex_lock(&fbi->mm_lock); mutex_lock(&fbi->mm_lock);
fix->smem_start = rg->paddr; fix->smem_start = rg->paddr;
fix->smem_len = rg->size; fix->smem_len = rg->size;
mutex_unlock(&fbi->mm_lock); mutex_unlock(&fbi->mm_lock);
} else {
fix->smem_start = rg->paddr;
fix->smem_len = rg->size;
}
fix->type = FB_TYPE_PACKED_PIXELS; fix->type = FB_TYPE_PACKED_PIXELS;
bpp = var->bits_per_pixel; bpp = var->bits_per_pixel;
...@@ -704,7 +710,7 @@ static int omapfb_set_par(struct fb_info *fbi) ...@@ -704,7 +710,7 @@ static int omapfb_set_par(struct fb_info *fbi)
int r = 0; int r = 0;
omapfb_rqueue_lock(fbdev); omapfb_rqueue_lock(fbdev);
set_fb_fix(fbi); set_fb_fix(fbi, 0);
r = ctrl_change_mode(fbi); r = ctrl_change_mode(fbi);
omapfb_rqueue_unlock(fbdev); omapfb_rqueue_unlock(fbdev);
...@@ -904,7 +910,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) ...@@ -904,7 +910,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
if (old_size != size) { if (old_size != size) {
if (size) { if (size) {
memcpy(&fbi->var, new_var, sizeof(fbi->var)); memcpy(&fbi->var, new_var, sizeof(fbi->var));
set_fb_fix(fbi); set_fb_fix(fbi, 0);
} else { } else {
/* /*
* Set these explicitly to indicate that the * Set these explicitly to indicate that the
...@@ -1504,7 +1510,7 @@ static int fbinfo_init(struct omapfb_device *fbdev, struct fb_info *info) ...@@ -1504,7 +1510,7 @@ static int fbinfo_init(struct omapfb_device *fbdev, struct fb_info *info)
var->bits_per_pixel = fbdev->panel->bpp; var->bits_per_pixel = fbdev->panel->bpp;
set_fb_var(info, var); set_fb_var(info, var);
set_fb_fix(info); set_fb_fix(info, 1);
r = fb_alloc_cmap(&info->cmap, 16, 0); r = fb_alloc_cmap(&info->cmap, 16, 0);
if (r != 0) if (r != 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment