diff options
| author | Sergio Aguirre <saaguirre@ti.com> | 2009-10-05 16:31:46 -0400 |
|---|---|---|
| committer | Tony Lindgren <tony@atomide.com> | 2009-10-06 11:31:50 -0400 |
| commit | 03bb2b493cf58edf11e5966f8469534259d2fffe (patch) | |
| tree | 6141e8f6e990e9cf917ceffab2948a1fa4985078 | |
| parent | 265489003c463f3d78d622fba60d56d16b3009dd (diff) | |
omapfb: Condition mutex acquisition
This fixes a bug introduced by this commit ID:
commit 537a1bf059fa312355696fa6db80726e655e7f17
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: Sergio Aguirre <saaguirre@ti.com>
Acked-by: Tomi Valkeinen <tomi.valkeinen@nokia.com>
Acked-by: Imre Deak <imre.deak@nokia.com>
Tested-by: Cory Maccarrone <darkstar6262@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
| -rw-r--r-- | drivers/video/omap/omapfb_main.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/video/omap/omapfb_main.c b/drivers/video/omap/omapfb_main.c index 125e605b8c68..0d0c8c8b9b56 100644 --- a/drivers/video/omap/omapfb_main.c +++ b/drivers/video/omap/omapfb_main.c | |||
| @@ -393,7 +393,7 @@ static void omapfb_sync(struct fb_info *fbi) | |||
| 393 | * Set fb_info.fix fields and also updates fbdev. | 393 | * Set fb_info.fix fields and also updates fbdev. |
| 394 | * When calling this fb_info.var must be set up already. | 394 | * When calling this fb_info.var must be set up already. |
| 395 | */ | 395 | */ |
| 396 | static void set_fb_fix(struct fb_info *fbi) | 396 | static void set_fb_fix(struct fb_info *fbi, int from_init) |
| 397 | { | 397 | { |
| 398 | struct fb_fix_screeninfo *fix = &fbi->fix; | 398 | struct fb_fix_screeninfo *fix = &fbi->fix; |
| 399 | struct fb_var_screeninfo *var = &fbi->var; | 399 | struct fb_var_screeninfo *var = &fbi->var; |
| @@ -403,10 +403,16 @@ static void set_fb_fix(struct fb_info *fbi) | |||
| 403 | 403 | ||
| 404 | rg = &plane->fbdev->mem_desc.region[plane->idx]; | 404 | rg = &plane->fbdev->mem_desc.region[plane->idx]; |
| 405 | fbi->screen_base = rg->vaddr; | 405 | fbi->screen_base = rg->vaddr; |
| 406 | mutex_lock(&fbi->mm_lock); | 406 | |
| 407 | fix->smem_start = rg->paddr; | 407 | if (!from_init) { |
| 408 | fix->smem_len = rg->size; | 408 | mutex_lock(&fbi->mm_lock); |
| 409 | mutex_unlock(&fbi->mm_lock); | 409 | fix->smem_start = rg->paddr; |
| 410 | fix->smem_len = rg->size; | ||
| 411 | mutex_unlock(&fbi->mm_lock); | ||
| 412 | } else { | ||
| 413 | fix->smem_start = rg->paddr; | ||
| 414 | fix->smem_len = rg->size; | ||
| 415 | } | ||
| 410 | 416 | ||
| 411 | fix->type = FB_TYPE_PACKED_PIXELS; | 417 | fix->type = FB_TYPE_PACKED_PIXELS; |
| 412 | bpp = var->bits_per_pixel; | 418 | bpp = var->bits_per_pixel; |
| @@ -704,7 +710,7 @@ static int omapfb_set_par(struct fb_info *fbi) | |||
| 704 | int r = 0; | 710 | int r = 0; |
| 705 | 711 | ||
| 706 | omapfb_rqueue_lock(fbdev); | 712 | omapfb_rqueue_lock(fbdev); |
| 707 | set_fb_fix(fbi); | 713 | set_fb_fix(fbi, 0); |
| 708 | r = ctrl_change_mode(fbi); | 714 | r = ctrl_change_mode(fbi); |
| 709 | omapfb_rqueue_unlock(fbdev); | 715 | omapfb_rqueue_unlock(fbdev); |
| 710 | 716 | ||
| @@ -904,7 +910,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) | |||
| 904 | if (old_size != size) { | 910 | if (old_size != size) { |
| 905 | if (size) { | 911 | if (size) { |
| 906 | memcpy(&fbi->var, new_var, sizeof(fbi->var)); | 912 | memcpy(&fbi->var, new_var, sizeof(fbi->var)); |
| 907 | set_fb_fix(fbi); | 913 | set_fb_fix(fbi, 0); |
| 908 | } else { | 914 | } else { |
| 909 | /* | 915 | /* |
| 910 | * Set these explicitly to indicate that the | 916 | * Set these explicitly to indicate that the |
| @@ -1504,7 +1510,7 @@ static int fbinfo_init(struct omapfb_device *fbdev, struct fb_info *info) | |||
| 1504 | var->bits_per_pixel = fbdev->panel->bpp; | 1510 | var->bits_per_pixel = fbdev->panel->bpp; |
| 1505 | 1511 | ||
| 1506 | set_fb_var(info, var); | 1512 | set_fb_var(info, var); |
| 1507 | set_fb_fix(info); | 1513 | set_fb_fix(info, 1); |
| 1508 | 1514 | ||
| 1509 | r = fb_alloc_cmap(&info->cmap, 16, 0); | 1515 | r = fb_alloc_cmap(&info->cmap, 16, 0); |
| 1510 | if (r != 0) | 1516 | if (r != 0) |
