diff options
author | Ville Syrjälä <ville.syrjala@nokia.com> | 2010-03-17 14:58:03 -0400 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@nokia.com> | 2010-08-03 08:18:46 -0400 |
commit | 2f642a17503838e256b8b7e9f1153512e2efc38b (patch) | |
tree | cdf6fb1fb815543d7adb0ce78db87ddc68a822c7 /drivers | |
parent | 430571d59a0b51c6541c153ad8b08e72fef26098 (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/video/omap2/omapfb/omapfb-ioctl.c | 10 | ||||
-rw-r--r-- | drivers/video/omap2/omapfb/omapfb-main.c | 2 | ||||
-rw-r--r-- | drivers/video/omap2/omapfb/omapfb-sysfs.c | 10 | ||||
-rw-r--r-- | drivers/video/omap2/omapfb/omapfb.h | 13 |
4 files changed, 10 insertions, 25 deletions
diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c index 69bcbfca47f6..3a10146dc120 100644 --- a/drivers/video/omap2/omapfb/omapfb-ioctl.c +++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c | |||
@@ -198,13 +198,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) | |||
198 | 198 | ||
199 | rg = ofbi->region; | 199 | rg = ofbi->region; |
200 | 200 | ||
201 | /* FIXME probably should be a rwsem ... */ | 201 | down_write(&rg->lock); |
202 | mutex_lock(&rg->mtx); | ||
203 | while (rg->ref) { | ||
204 | mutex_unlock(&rg->mtx); | ||
205 | schedule(); | ||
206 | mutex_lock(&rg->mtx); | ||
207 | } | ||
208 | 202 | ||
209 | if (atomic_read(&rg->map_count)) { | 203 | if (atomic_read(&rg->map_count)) { |
210 | r = -EBUSY; | 204 | r = -EBUSY; |
@@ -235,7 +229,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) | |||
235 | } | 229 | } |
236 | 230 | ||
237 | out: | 231 | out: |
238 | mutex_unlock(&rg->mtx); | 232 | up_write(&rg->lock); |
239 | 233 | ||
240 | return r; | 234 | return r; |
241 | } | 235 | } |
diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c index eb4338bbaa2b..a3f72ba79958 100644 --- a/drivers/video/omap2/omapfb/omapfb-main.c +++ b/drivers/video/omap2/omapfb/omapfb-main.c | |||
@@ -1930,7 +1930,7 @@ static int omapfb_create_framebuffers(struct omapfb2_device *fbdev) | |||
1930 | 1930 | ||
1931 | ofbi->region = &fbdev->regions[i]; | 1931 | ofbi->region = &fbdev->regions[i]; |
1932 | ofbi->region->id = i; | 1932 | ofbi->region->id = i; |
1933 | mutex_init(&ofbi->region->mtx); | 1933 | init_rwsem(&ofbi->region->lock); |
1934 | 1934 | ||
1935 | /* assign these early, so that fb alloc can use them */ | 1935 | /* assign these early, so that fb alloc can use them */ |
1936 | ofbi->rotation_type = def_vrfb ? OMAP_DSS_ROT_VRFB : | 1936 | ofbi->rotation_type = def_vrfb ? OMAP_DSS_ROT_VRFB : |
diff --git a/drivers/video/omap2/omapfb/omapfb-sysfs.c b/drivers/video/omap2/omapfb/omapfb-sysfs.c index 74c11b243100..724b760404f2 100644 --- a/drivers/video/omap2/omapfb/omapfb-sysfs.c +++ b/drivers/video/omap2/omapfb/omapfb-sysfs.c | |||
@@ -452,13 +452,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr, | |||
452 | 452 | ||
453 | rg = ofbi->region; | 453 | rg = ofbi->region; |
454 | 454 | ||
455 | /* FIXME probably should be a rwsem ... */ | 455 | down_write(&rg->lock); |
456 | mutex_lock(&rg->mtx); | ||
457 | while (rg->ref) { | ||
458 | mutex_unlock(&rg->mtx); | ||
459 | schedule(); | ||
460 | mutex_lock(&rg->mtx); | ||
461 | } | ||
462 | 456 | ||
463 | if (atomic_read(&rg->map_count)) { | 457 | if (atomic_read(&rg->map_count)) { |
464 | r = -EBUSY; | 458 | r = -EBUSY; |
@@ -490,7 +484,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr, | |||
490 | 484 | ||
491 | r = count; | 485 | r = count; |
492 | out: | 486 | out: |
493 | mutex_unlock(&rg->mtx); | 487 | up_write(&rg->lock); |
494 | 488 | ||
495 | unlock_fb_info(fbi); | 489 | unlock_fb_info(fbi); |
496 | 490 | ||
diff --git a/drivers/video/omap2/omapfb/omapfb.h b/drivers/video/omap2/omapfb/omapfb.h index db3aef5172c5..195a760eef54 100644 --- a/drivers/video/omap2/omapfb/omapfb.h +++ b/drivers/video/omap2/omapfb/omapfb.h | |||
@@ -27,6 +27,8 @@ | |||
27 | #define DEBUG | 27 | #define DEBUG |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include <linux/rwsem.h> | ||
31 | |||
30 | #include <plat/display.h> | 32 | #include <plat/display.h> |
31 | 33 | ||
32 | #ifdef DEBUG | 34 | #ifdef DEBUG |
@@ -52,9 +54,8 @@ struct omapfb2_mem_region { | |||
52 | u8 type; /* OMAPFB_PLANE_MEM_* */ | 54 | u8 type; /* OMAPFB_PLANE_MEM_* */ |
53 | bool alloc; /* allocated by the driver */ | 55 | bool alloc; /* allocated by the driver */ |
54 | bool map; /* kernel mapped by the driver */ | 56 | bool map; /* kernel mapped by the driver */ |
55 | struct mutex mtx; | ||
56 | unsigned int ref; | ||
57 | atomic_t map_count; | 57 | atomic_t map_count; |
58 | struct rw_semaphore lock; | ||
58 | }; | 59 | }; |
59 | 60 | ||
60 | /* appended to fb_info */ | 61 | /* appended to fb_info */ |
@@ -164,17 +165,13 @@ static inline int omapfb_overlay_enable(struct omap_overlay *ovl, | |||
164 | static inline struct omapfb2_mem_region * | 165 | static inline struct omapfb2_mem_region * |
165 | omapfb_get_mem_region(struct omapfb2_mem_region *rg) | 166 | omapfb_get_mem_region(struct omapfb2_mem_region *rg) |
166 | { | 167 | { |
167 | mutex_lock(&rg->mtx); | 168 | down_read(&rg->lock); |
168 | rg->ref++; | ||
169 | mutex_unlock(&rg->mtx); | ||
170 | return rg; | 169 | return rg; |
171 | } | 170 | } |
172 | 171 | ||
173 | static inline void omapfb_put_mem_region(struct omapfb2_mem_region *rg) | 172 | static inline void omapfb_put_mem_region(struct omapfb2_mem_region *rg) |
174 | { | 173 | { |
175 | mutex_lock(&rg->mtx); | 174 | up_read(&rg->lock); |
176 | rg->ref--; | ||
177 | mutex_unlock(&rg->mtx); | ||
178 | } | 175 | } |
179 | 176 | ||
180 | #endif | 177 | #endif |