From: ville.syrjala@nokia.com To: Tomi Valkeinen <tomi.valkeinen@nokia.com> Cc: "Imre Deak" <imre.deak@nokia.com>, linux-fbdev@vger.kernel.org, linux-omap@vger.kernel.org, "Ville Syrjälä" <ville.syrjala@nokia.com> Subject: [PATCH v4 6/8] DSS2: OMAPFB: Convert the memory region locking to rwsem Date: Wed, 17 Mar 2010 22:46:21 +0000 [thread overview] Message-ID: <1268865983-16270-7-git-send-email-ville.syrjala@nokia.com> (raw) In-Reply-To: <1268865983-16270-1-git-send-email-ville.syrjala@nokia.com> From: Ville Syrj채l채 <ville.syrjala@nokia.com> R/W semaphore is a goof fit for the memory region locking pattern. So use it. Signed-off-by: Ville Syrj채l채 <ville.syrjala@nokia.com> --- drivers/video/omap2/omapfb/omapfb-ioctl.c | 10 ++-------- drivers/video/omap2/omapfb/omapfb-main.c | 2 +- drivers/video/omap2/omapfb/omapfb-sysfs.c | 10 ++-------- 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 f02b1b0..4d5e5af 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) rg = ofbi->region; - /* FIXME probably should be a rwsem ... */ - mutex_lock(&rg->mtx); - while (rg->ref) { - mutex_unlock(&rg->mtx); - schedule(); - mutex_lock(&rg->mtx); - } + down_write(&rg->lock); if (atomic_read(&rg->map_count)) { r = -EBUSY; @@ -235,7 +229,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) } out: - mutex_unlock(&rg->mtx); + up_write(&rg->lock); return r; } diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c index d330032..2bd5b42 100644 --- a/drivers/video/omap2/omapfb/omapfb-main.c +++ b/drivers/video/omap2/omapfb/omapfb-main.c @@ -1929,7 +1929,7 @@ static int omapfb_create_framebuffers(struct omapfb2_device *fbdev) ofbi->region = &fbdev->regions[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 */ 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 6aee279..aa22f7b 100644 --- a/drivers/video/omap2/omapfb/omapfb-sysfs.c +++ b/drivers/video/omap2/omapfb/omapfb-sysfs.c @@ -445,13 +445,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr, rg = ofbi->region; - /* FIXME probably should be a rwsem ... */ - mutex_lock(&rg->mtx); - while (rg->ref) { - mutex_unlock(&rg->mtx); - schedule(); - mutex_lock(&rg->mtx); - } + down_write(&rg->lock); if (atomic_read(&rg->map_count)) { r = -EBUSY; @@ -483,7 +477,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr, r = count; out: - mutex_unlock(&rg->mtx); + up_write(&rg->lock); unlock_fb_info(fbi); diff --git a/drivers/video/omap2/omapfb/omapfb.h b/drivers/video/omap2/omapfb/omapfb.h index db3aef5..195a760 100644 --- a/drivers/video/omap2/omapfb/omapfb.h +++ b/drivers/video/omap2/omapfb/omapfb.h @@ -27,6 +27,8 @@ #define DEBUG #endif +#include <linux/rwsem.h> + #include <plat/display.h> #ifdef DEBUG @@ -52,9 +54,8 @@ struct omapfb2_mem_region { u8 type; /* OMAPFB_PLANE_MEM_* */ bool alloc; /* allocated by the driver */ bool map; /* kernel mapped by the driver */ - struct mutex mtx; - unsigned int ref; atomic_t map_count; + struct rw_semaphore lock; }; /* appended to fb_info */ @@ -164,17 +165,13 @@ static inline int omapfb_overlay_enable(struct omap_overlay *ovl, static inline struct omapfb2_mem_region * omapfb_get_mem_region(struct omapfb2_mem_region *rg) { - mutex_lock(&rg->mtx); - rg->ref++; - mutex_unlock(&rg->mtx); + down_read(&rg->lock); return rg; } static inline void omapfb_put_mem_region(struct omapfb2_mem_region *rg) { - mutex_lock(&rg->mtx); - rg->ref--; - mutex_unlock(&rg->mtx); + up_read(&rg->lock); } #endif -- 1.6.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: ville.syrjala@nokia.com To: Tomi Valkeinen <tomi.valkeinen@nokia.com> Cc: "Imre Deak" <imre.deak@nokia.com>, linux-fbdev@vger.kernel.org, linux-omap@vger.kernel.org, "Ville Syrjälä" <ville.syrjala@nokia.com> Subject: [PATCH v4 6/8] DSS2: OMAPFB: Convert the memory region locking to rwsem Date: Thu, 18 Mar 2010 00:46:21 +0200 [thread overview] Message-ID: <1268865983-16270-7-git-send-email-ville.syrjala@nokia.com> (raw) In-Reply-To: <1268865983-16270-1-git-send-email-ville.syrjala@nokia.com> From: Ville Syrjälä <ville.syrjala@nokia.com> R/W semaphore is a goof fit for the memory region locking pattern. So use it. Signed-off-by: Ville Syrjälä <ville.syrjala@nokia.com> --- drivers/video/omap2/omapfb/omapfb-ioctl.c | 10 ++-------- drivers/video/omap2/omapfb/omapfb-main.c | 2 +- drivers/video/omap2/omapfb/omapfb-sysfs.c | 10 ++-------- 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 f02b1b0..4d5e5af 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) rg = ofbi->region; - /* FIXME probably should be a rwsem ... */ - mutex_lock(&rg->mtx); - while (rg->ref) { - mutex_unlock(&rg->mtx); - schedule(); - mutex_lock(&rg->mtx); - } + down_write(&rg->lock); if (atomic_read(&rg->map_count)) { r = -EBUSY; @@ -235,7 +229,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) } out: - mutex_unlock(&rg->mtx); + up_write(&rg->lock); return r; } diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c index d330032..2bd5b42 100644 --- a/drivers/video/omap2/omapfb/omapfb-main.c +++ b/drivers/video/omap2/omapfb/omapfb-main.c @@ -1929,7 +1929,7 @@ static int omapfb_create_framebuffers(struct omapfb2_device *fbdev) ofbi->region = &fbdev->regions[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 */ 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 6aee279..aa22f7b 100644 --- a/drivers/video/omap2/omapfb/omapfb-sysfs.c +++ b/drivers/video/omap2/omapfb/omapfb-sysfs.c @@ -445,13 +445,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr, rg = ofbi->region; - /* FIXME probably should be a rwsem ... */ - mutex_lock(&rg->mtx); - while (rg->ref) { - mutex_unlock(&rg->mtx); - schedule(); - mutex_lock(&rg->mtx); - } + down_write(&rg->lock); if (atomic_read(&rg->map_count)) { r = -EBUSY; @@ -483,7 +477,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr, r = count; out: - mutex_unlock(&rg->mtx); + up_write(&rg->lock); unlock_fb_info(fbi); diff --git a/drivers/video/omap2/omapfb/omapfb.h b/drivers/video/omap2/omapfb/omapfb.h index db3aef5..195a760 100644 --- a/drivers/video/omap2/omapfb/omapfb.h +++ b/drivers/video/omap2/omapfb/omapfb.h @@ -27,6 +27,8 @@ #define DEBUG #endif +#include <linux/rwsem.h> + #include <plat/display.h> #ifdef DEBUG @@ -52,9 +54,8 @@ struct omapfb2_mem_region { u8 type; /* OMAPFB_PLANE_MEM_* */ bool alloc; /* allocated by the driver */ bool map; /* kernel mapped by the driver */ - struct mutex mtx; - unsigned int ref; atomic_t map_count; + struct rw_semaphore lock; }; /* appended to fb_info */ @@ -164,17 +165,13 @@ static inline int omapfb_overlay_enable(struct omap_overlay *ovl, static inline struct omapfb2_mem_region * omapfb_get_mem_region(struct omapfb2_mem_region *rg) { - mutex_lock(&rg->mtx); - rg->ref++; - mutex_unlock(&rg->mtx); + down_read(&rg->lock); return rg; } static inline void omapfb_put_mem_region(struct omapfb2_mem_region *rg) { - mutex_lock(&rg->mtx); - rg->ref--; - mutex_unlock(&rg->mtx); + up_read(&rg->lock); } #endif -- 1.6.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-03-17 22:46 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-03-17 22:46 omapfb mem_idx patchset ville.syrjala 2010-03-17 22:46 ` ville.syrjala 2010-03-17 22:46 ` [PATCH v4 1/8] DSS2: OMAPFB: Refactor overlay address calculations ville.syrjala 2010-03-17 22:46 ` ville.syrjala 2010-03-17 22:46 ` [PATCH v4 2/8] DSS2: OMAPFB: Check var even if there isn't memory ville.syrjala 2010-03-17 22:46 ` ville.syrjala 2010-03-17 22:46 ` [PATCH v4 3/8] DSS2: OMAPFB: Skip unnecessary set_overlay_info() ville.syrjala 2010-03-17 22:46 ` ville.syrjala 2010-03-17 22:46 ` [PATCH v4 4/8] DSS2: OMAPFB: Add support for switching memory regions ville.syrjala 2010-03-17 22:46 ` ville.syrjala 2010-03-17 22:46 ` [PATCH v4 5/8] DSS2: OMAPFB: Add locking for " ville.syrjala 2010-03-17 22:46 ` ville.syrjala 2010-03-17 22:46 ` ville.syrjala [this message] 2010-03-17 22:46 ` [PATCH v4 6/8] DSS2: OMAPFB: Convert the memory region locking to rwsem ville.syrjala 2010-03-17 22:46 ` [PATCH v4 7/8] DSS2: OMAPFB: Make lockdep happy ville.syrjala 2010-03-17 22:46 ` ville.syrjala 2010-03-17 22:46 ` [PATCH v4 8/8] DSS2: OMAPFB: Add some locking debug checks ville.syrjala 2010-03-17 22:46 ` ville.syrjala
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1268865983-16270-7-git-send-email-ville.syrjala@nokia.com \ --to=ville.syrjala@nokia.com \ --cc=imre.deak@nokia.com \ --cc=linux-fbdev@vger.kernel.org \ --cc=linux-omap@vger.kernel.org \ --cc=tomi.valkeinen@nokia.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.