OMAP: DSS2: OMAPFB: Convert the memory region locking to rwsem
R/W semaphore is a good fit for the memory region locking pattern. So use it. Signed-off-by: Ville Syrjälä <ville.syrjala@nokia.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@nokia.com>
This commit is contained in:
parent
430571d59a
commit
2f642a1750
|
@ -198,13 +198,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
|
||||||
|
|
||||||
rg = ofbi->region;
|
rg = ofbi->region;
|
||||||
|
|
||||||
/* FIXME probably should be a rwsem ... */
|
down_write(&rg->lock);
|
||||||
mutex_lock(&rg->mtx);
|
|
||||||
while (rg->ref) {
|
|
||||||
mutex_unlock(&rg->mtx);
|
|
||||||
schedule();
|
|
||||||
mutex_lock(&rg->mtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (atomic_read(&rg->map_count)) {
|
if (atomic_read(&rg->map_count)) {
|
||||||
r = -EBUSY;
|
r = -EBUSY;
|
||||||
|
@ -235,7 +229,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&rg->mtx);
|
up_write(&rg->lock);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1930,7 +1930,7 @@ static int omapfb_create_framebuffers(struct omapfb2_device *fbdev)
|
||||||
|
|
||||||
ofbi->region = &fbdev->regions[i];
|
ofbi->region = &fbdev->regions[i];
|
||||||
ofbi->region->id = i;
|
ofbi->region->id = i;
|
||||||
mutex_init(&ofbi->region->mtx);
|
init_rwsem(&ofbi->region->lock);
|
||||||
|
|
||||||
/* assign these early, so that fb alloc can use them */
|
/* assign these early, so that fb alloc can use them */
|
||||||
ofbi->rotation_type = def_vrfb ? OMAP_DSS_ROT_VRFB :
|
ofbi->rotation_type = def_vrfb ? OMAP_DSS_ROT_VRFB :
|
||||||
|
|
|
@ -452,13 +452,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr,
|
||||||
|
|
||||||
rg = ofbi->region;
|
rg = ofbi->region;
|
||||||
|
|
||||||
/* FIXME probably should be a rwsem ... */
|
down_write(&rg->lock);
|
||||||
mutex_lock(&rg->mtx);
|
|
||||||
while (rg->ref) {
|
|
||||||
mutex_unlock(&rg->mtx);
|
|
||||||
schedule();
|
|
||||||
mutex_lock(&rg->mtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (atomic_read(&rg->map_count)) {
|
if (atomic_read(&rg->map_count)) {
|
||||||
r = -EBUSY;
|
r = -EBUSY;
|
||||||
|
@ -490,7 +484,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr,
|
||||||
|
|
||||||
r = count;
|
r = count;
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&rg->mtx);
|
up_write(&rg->lock);
|
||||||
|
|
||||||
unlock_fb_info(fbi);
|
unlock_fb_info(fbi);
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <linux/rwsem.h>
|
||||||
|
|
||||||
#include <plat/display.h>
|
#include <plat/display.h>
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -52,9 +54,8 @@ struct omapfb2_mem_region {
|
||||||
u8 type; /* OMAPFB_PLANE_MEM_* */
|
u8 type; /* OMAPFB_PLANE_MEM_* */
|
||||||
bool alloc; /* allocated by the driver */
|
bool alloc; /* allocated by the driver */
|
||||||
bool map; /* kernel mapped by the driver */
|
bool map; /* kernel mapped by the driver */
|
||||||
struct mutex mtx;
|
|
||||||
unsigned int ref;
|
|
||||||
atomic_t map_count;
|
atomic_t map_count;
|
||||||
|
struct rw_semaphore lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* appended to fb_info */
|
/* appended to fb_info */
|
||||||
|
@ -164,17 +165,13 @@ 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)
|
||||||
{
|
{
|
||||||
mutex_lock(&rg->mtx);
|
down_read(&rg->lock);
|
||||||
rg->ref++;
|
|
||||||
mutex_unlock(&rg->mtx);
|
|
||||||
return rg;
|
return rg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void omapfb_put_mem_region(struct omapfb2_mem_region *rg)
|
static inline void omapfb_put_mem_region(struct omapfb2_mem_region *rg)
|
||||||
{
|
{
|
||||||
mutex_lock(&rg->mtx);
|
up_read(&rg->lock);
|
||||||
rg->ref--;
|
|
||||||
mutex_unlock(&rg->mtx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue