From patchwork Wed Mar 17 22:46:23 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: 86572 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 o2HMl1rm022461 for ; Wed, 17 Mar 2010 22:47:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756300Ab0CQWrH (ORCPT ); Wed, 17 Mar 2010 18:47:07 -0400 Received: from smtp.nokia.com ([192.100.122.233]:28656 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756285Ab0CQWrE (ORCPT ); Wed, 17 Mar 2010 18:47:04 -0400 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o2HMl1Dt030967; Thu, 18 Mar 2010 00:47:01 +0200 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Mar 2010 00:47:00 +0200 Received: from mgw-da01.ext.nokia.com ([147.243.128.24]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Mar 2010 00:46:58 +0200 Received: from stinkpad (esdhcp04093.research.nokia.com [172.21.40.93]) by mgw-da01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with SMTP id o2HMkqsD017090; Thu, 18 Mar 2010 00:46:53 +0200 Received: by stinkpad (sSMTP sendmail emulation); Thu, 18 Mar 2010 00:46:52 +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 8/8] DSS2: OMAPFB: Add some locking debug checks Date: Thu, 18 Mar 2010 00:46:23 +0200 Message-Id: <1268865983-16270-9-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:59.0013 (UTC) FILETIME=[C08D6F50: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:08 +0000 (UTC) diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c index a3681da..64e70e0 100644 --- a/drivers/video/omap2/omapfb/omapfb-ioctl.c +++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c @@ -222,6 +222,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) rg = ofbi->region; down_write_nested(&rg->lock, rg->id); + atomic_inc(&rg->lock_count); if (atomic_read(&rg->map_count)) { r = -EBUSY; @@ -252,6 +253,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) } out: + atomic_dec(&rg->lock_count); 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 2bd5b42..ac7625d 100644 --- a/drivers/video/omap2/omapfb/omapfb-main.c +++ b/drivers/video/omap2/omapfb/omapfb-main.c @@ -667,6 +667,8 @@ int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var) DBG("check_fb_var %d\n", ofbi->id); + WARN_ON(!atomic_read(&ofbi->region->lock_count)); + r = fb_mode_to_dss_mode(var, &mode); if (r) { DBG("cannot convert var to omap dss mode\n"); @@ -872,6 +874,8 @@ int omapfb_setup_overlay(struct fb_info *fbi, struct omap_overlay *ovl, int rotation = var->rotate; int i; + WARN_ON(!atomic_read(&ofbi->region->lock_count)); + for (i = 0; i < ofbi->num_overlays; i++) { if (ovl != ofbi->overlays[i]) continue; @@ -965,6 +969,8 @@ int omapfb_apply_changes(struct fb_info *fbi, int init) fill_fb(fbi); #endif + WARN_ON(!atomic_read(&ofbi->region->lock_count)); + for (i = 0; i < ofbi->num_overlays; i++) { ovl = ofbi->overlays[i]; diff --git a/drivers/video/omap2/omapfb/omapfb-sysfs.c b/drivers/video/omap2/omapfb/omapfb-sysfs.c index 1b7cf57..cf2f478 100644 --- a/drivers/video/omap2/omapfb/omapfb-sysfs.c +++ b/drivers/video/omap2/omapfb/omapfb-sysfs.c @@ -446,6 +446,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr, rg = ofbi->region; down_write_nested(&rg->lock, rg->id); + atomic_inc(&rg->lock_count); if (atomic_read(&rg->map_count)) { r = -EBUSY; @@ -477,6 +478,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr, r = count; out: + atomic_dec(&rg->lock_count); 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 676b55d..1305fc9 100644 --- a/drivers/video/omap2/omapfb/omapfb.h +++ b/drivers/video/omap2/omapfb/omapfb.h @@ -56,6 +56,7 @@ struct omapfb2_mem_region { bool map; /* kernel mapped by the driver */ atomic_t map_count; struct rw_semaphore lock; + atomic_t lock_count; }; /* appended to fb_info */ @@ -166,11 +167,13 @@ static inline struct omapfb2_mem_region * omapfb_get_mem_region(struct omapfb2_mem_region *rg) { down_read_nested(&rg->lock, rg->id); + atomic_inc(&rg->lock_count); return rg; } static inline void omapfb_put_mem_region(struct omapfb2_mem_region *rg) { + atomic_dec(&rg->lock_count); up_read(&rg->lock); }