if (mem_idx >= fbdev->num_fbs)
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)
/* XXX uses only the first overlay */
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);
if (!new_rg) {
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) {
/*
* This plane's memory was freed, can't enable it
* until it's reallocated.
*/
r = -EINVAL;
- goto put_new;
+ goto put_mem;
}
ovl->get_overlay_info(ovl, &old_info);
if (ovl->manager)
ovl->manager->apply(ovl->manager);
- omapfb_put_mem_region(new_rg);
- omapfb_put_mem_region(old_rg);
+ /* Release the locks in a specific order to keep lockdep happy */
+ 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;
}
ovl->set_overlay_info(ovl, &old_info);
- put_new:
- omapfb_put_mem_region(new_rg);
- put_old:
- omapfb_put_mem_region(old_rg);
+ put_mem:
+ /* Release the locks in a specific order to keep lockdep happy */
+ 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);
out:
dev_err(fbdev->dev, "setup_plane failed\n");
rg = ofbi->region;
- down_write(&rg->lock);
+ down_write_nested(&rg->lock, rg->id);
if (atomic_read(&rg->map_count)) {
r = -EBUSY;