提交 3d84b65a 编写于 作者: V Ville Syrjälä 提交者: Tomi Valkeinen

OMAP: DSS2: OMAPFB: Make lockdep happy

When more than one memory region needs to be lockd at the same time use
the memory region id to fix the order in which the locks are taken. Also
one needs to use the _nested() versions of the locking primitives. The
memory region id can serve as the lock class there as well.
Signed-off-by: NVille Syrjälä <ville.syrjala@nokia.com>
Signed-off-by: NTomi Valkeinen <tomi.valkeinen@nokia.com>
上级 2f642a17
...@@ -55,7 +55,7 @@ static struct omapfb2_mem_region *get_mem_region(struct omapfb_info *ofbi, ...@@ -55,7 +55,7 @@ static struct omapfb2_mem_region *get_mem_region(struct omapfb_info *ofbi,
if (mem_idx >= fbdev->num_fbs) if (mem_idx >= fbdev->num_fbs)
return NULL; return NULL;
return omapfb_get_mem_region(&fbdev->regions[mem_idx]); return &fbdev->regions[mem_idx];
} }
static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi) static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi)
...@@ -77,20 +77,30 @@ static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi) ...@@ -77,20 +77,30 @@ static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi)
/* XXX uses only the first overlay */ /* XXX uses only the first overlay */
ovl = ofbi->overlays[0]; ovl = ofbi->overlays[0];
old_rg = omapfb_get_mem_region(ofbi->region); old_rg = ofbi->region;
new_rg = get_mem_region(ofbi, pi->mem_idx); new_rg = get_mem_region(ofbi, pi->mem_idx);
if (!new_rg) { if (!new_rg) {
r = -EINVAL; r = -EINVAL;
goto put_old; goto out;
} }
/* Take the locks in a specific order to keep lockdep happy */
if (old_rg->id < new_rg->id) {
omapfb_get_mem_region(old_rg);
omapfb_get_mem_region(new_rg);
} else if (new_rg->id < old_rg->id) {
omapfb_get_mem_region(new_rg);
omapfb_get_mem_region(old_rg);
} else
omapfb_get_mem_region(old_rg);
if (pi->enabled && !new_rg->size) { if (pi->enabled && !new_rg->size) {
/* /*
* This plane's memory was freed, can't enable it * This plane's memory was freed, can't enable it
* until it's reallocated. * until it's reallocated.
*/ */
r = -EINVAL; r = -EINVAL;
goto put_new; goto put_mem;
} }
ovl->get_overlay_info(ovl, &old_info); ovl->get_overlay_info(ovl, &old_info);
...@@ -135,8 +145,15 @@ static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi) ...@@ -135,8 +145,15 @@ static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi)
if (ovl->manager) if (ovl->manager)
ovl->manager->apply(ovl->manager); ovl->manager->apply(ovl->manager);
omapfb_put_mem_region(new_rg); /* Release the locks in a specific order to keep lockdep happy */
omapfb_put_mem_region(old_rg); if (old_rg->id > new_rg->id) {
omapfb_put_mem_region(old_rg);
omapfb_put_mem_region(new_rg);
} else if (new_rg->id > old_rg->id) {
omapfb_put_mem_region(new_rg);
omapfb_put_mem_region(old_rg);
} else
omapfb_put_mem_region(old_rg);
return 0; return 0;
...@@ -147,10 +164,16 @@ static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi) ...@@ -147,10 +164,16 @@ static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi)
} }
ovl->set_overlay_info(ovl, &old_info); ovl->set_overlay_info(ovl, &old_info);
put_new: put_mem:
omapfb_put_mem_region(new_rg); /* Release the locks in a specific order to keep lockdep happy */
put_old: if (old_rg->id > new_rg->id) {
omapfb_put_mem_region(old_rg); omapfb_put_mem_region(old_rg);
omapfb_put_mem_region(new_rg);
} else if (new_rg->id > old_rg->id) {
omapfb_put_mem_region(new_rg);
omapfb_put_mem_region(old_rg);
} else
omapfb_put_mem_region(old_rg);
out: out:
dev_err(fbdev->dev, "setup_plane failed\n"); dev_err(fbdev->dev, "setup_plane failed\n");
...@@ -198,7 +221,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) ...@@ -198,7 +221,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
rg = ofbi->region; rg = ofbi->region;
down_write(&rg->lock); down_write_nested(&rg->lock, rg->id);
if (atomic_read(&rg->map_count)) { if (atomic_read(&rg->map_count)) {
r = -EBUSY; r = -EBUSY;
......
...@@ -452,7 +452,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr, ...@@ -452,7 +452,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr,
rg = ofbi->region; rg = ofbi->region;
down_write(&rg->lock); down_write_nested(&rg->lock, rg->id);
if (atomic_read(&rg->map_count)) { if (atomic_read(&rg->map_count)) {
r = -EBUSY; r = -EBUSY;
......
...@@ -165,7 +165,7 @@ static inline int omapfb_overlay_enable(struct omap_overlay *ovl, ...@@ -165,7 +165,7 @@ static inline int omapfb_overlay_enable(struct omap_overlay *ovl,
static inline struct omapfb2_mem_region * static inline struct omapfb2_mem_region *
omapfb_get_mem_region(struct omapfb2_mem_region *rg) omapfb_get_mem_region(struct omapfb2_mem_region *rg)
{ {
down_read(&rg->lock); down_read_nested(&rg->lock, rg->id);
return rg; return rg;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册