From patchwork Wed Mar 17 22:46:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ville.syrjala@nokia.com X-Patchwork-Id: 86571 X-Patchwork-Delegate: tomi.valkeinen@nokia.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2HMl1rl022461 for ; Wed, 17 Mar 2010 22:47:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756279Ab0CQWq7 (ORCPT ); Wed, 17 Mar 2010 18:46:59 -0400 Received: from smtp.nokia.com ([192.100.105.134]:63360 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756274Ab0CQWq6 (ORCPT ); Wed, 17 Mar 2010 18:46:58 -0400 Received: from esebh105.NOE.Nokia.com (esebh105.ntc.nokia.com [172.21.138.211]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o2HMkrZv002157; Wed, 17 Mar 2010 17:46:58 -0500 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Mar 2010 00:46:54 +0200 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Mar 2010 00:46:52 +0200 Received: from stinkpad (esdhcp04093.research.nokia.com [172.21.40.93]) by mgw-da02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with SMTP id o2HMkkBF011323; Thu, 18 Mar 2010 00:46:47 +0200 Received: by stinkpad (sSMTP sendmail emulation); Thu, 18 Mar 2010 00:46:46 +0200 From: ville.syrjala@nokia.com To: "Tomi Valkeinen" Cc: "Imre Deak" , linux-fbdev@vger.kernel.org, linux-omap@vger.kernel.org, =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Subject: [PATCH v4 6/8] DSS2: OMAPFB: Convert the memory region locking to rwsem Date: Thu, 18 Mar 2010 00:46:21 +0200 Message-Id: <1268865983-16270-7-git-send-email-ville.syrjala@nokia.com> X-Mailer: git-send-email 1.6.4.4 In-Reply-To: <1268865983-16270-1-git-send-email-ville.syrjala@nokia.com> References: <1268865983-16270-1-git-send-email-ville.syrjala@nokia.com> MIME-Version: 1.0 X-OriginalArrivalTime: 17 Mar 2010 22:46:53.0336 (UTC) FILETIME=[BD2B3180:01CAC623] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 17 Mar 2010 22:47:01 +0000 (UTC) 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 + #include #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