From patchwork Wed Mar 17 22:46:22 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: 86569 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 o2HMkvMs022445 for ; Wed, 17 Mar 2010 22:46:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756262Ab0CQWq4 (ORCPT ); Wed, 17 Mar 2010 18:46:56 -0400 Received: from smtp.nokia.com ([192.100.105.134]:63357 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756226Ab0CQWqz (ORCPT ); Wed, 17 Mar 2010 18:46:55 -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 o2HMkrZp002157; Wed, 17 Mar 2010 17:46:54 -0500 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Mar 2010 00:46:52 +0200 Received: from mgw-sa01.ext.nokia.com ([147.243.1.47]) by vaebh104.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-sa01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with SMTP id o2HMknuY011443; Thu, 18 Mar 2010 00:46:50 +0200 Received: by stinkpad (sSMTP sendmail emulation); Thu, 18 Mar 2010 00:46:49 +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 7/8] DSS2: OMAPFB: Make lockdep happy Date: Thu, 18 Mar 2010 00:46:22 +0200 Message-Id: <1268865983-16270-8-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:52.0403 (UTC) FILETIME=[BC9CD430: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:46:58 +0000 (UTC) diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c index 4d5e5af..a3681da 100644 --- a/drivers/video/omap2/omapfb/omapfb-ioctl.c +++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c @@ -55,7 +55,7 @@ static struct omapfb2_mem_region *get_mem_region(struct omapfb_info *ofbi, if (mem_idx >= fbdev->num_fbs) return NULL; - return omapfb_get_mem_region(&fbdev->regions[mem_idx]); + return &fbdev->regions[mem_idx]; } static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi) @@ -77,20 +77,30 @@ static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi) /* XXX uses only the first overlay */ ovl = ofbi->overlays[0]; - old_rg = omapfb_get_mem_region(ofbi->region); + old_rg = ofbi->region; new_rg = get_mem_region(ofbi, pi->mem_idx); if (!new_rg) { r = -EINVAL; - goto put_old; + goto out; } + /* Take the locks in a specific order to keep lockdep happy */ + if (old_rg->id < new_rg->id) { + omapfb_get_mem_region(old_rg); + omapfb_get_mem_region(new_rg); + } else if (new_rg->id < old_rg->id) { + omapfb_get_mem_region(new_rg); + omapfb_get_mem_region(old_rg); + } else + omapfb_get_mem_region(old_rg); + if (pi->enabled && !new_rg->size) { /* * This plane's memory was freed, can't enable it * until it's reallocated. */ r = -EINVAL; - goto put_new; + goto put_mem; } ovl->get_overlay_info(ovl, &old_info); @@ -135,8 +145,15 @@ static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi) if (ovl->manager) ovl->manager->apply(ovl->manager); - omapfb_put_mem_region(new_rg); - omapfb_put_mem_region(old_rg); + /* Release the locks in a specific order to keep lockdep happy */ + if (old_rg->id > new_rg->id) { + omapfb_put_mem_region(old_rg); + omapfb_put_mem_region(new_rg); + } else if (new_rg->id > old_rg->id) { + omapfb_put_mem_region(new_rg); + omapfb_put_mem_region(old_rg); + } else + omapfb_put_mem_region(old_rg); return 0; @@ -147,10 +164,16 @@ static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi) } ovl->set_overlay_info(ovl, &old_info); - put_new: - omapfb_put_mem_region(new_rg); - put_old: - omapfb_put_mem_region(old_rg); + put_mem: + /* Release the locks in a specific order to keep lockdep happy */ + if (old_rg->id > new_rg->id) { + omapfb_put_mem_region(old_rg); + omapfb_put_mem_region(new_rg); + } else if (new_rg->id > old_rg->id) { + omapfb_put_mem_region(new_rg); + omapfb_put_mem_region(old_rg); + } else + omapfb_put_mem_region(old_rg); out: dev_err(fbdev->dev, "setup_plane failed\n"); @@ -198,7 +221,7 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi) rg = ofbi->region; - down_write(&rg->lock); + down_write_nested(&rg->lock, rg->id); if (atomic_read(&rg->map_count)) { r = -EBUSY; diff --git a/drivers/video/omap2/omapfb/omapfb-sysfs.c b/drivers/video/omap2/omapfb/omapfb-sysfs.c index aa22f7b..1b7cf57 100644 --- a/drivers/video/omap2/omapfb/omapfb-sysfs.c +++ b/drivers/video/omap2/omapfb/omapfb-sysfs.c @@ -445,7 +445,7 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr, rg = ofbi->region; - down_write(&rg->lock); + down_write_nested(&rg->lock, rg->id); if (atomic_read(&rg->map_count)) { r = -EBUSY; diff --git a/drivers/video/omap2/omapfb/omapfb.h b/drivers/video/omap2/omapfb/omapfb.h index 195a760..676b55d 100644 --- a/drivers/video/omap2/omapfb/omapfb.h +++ b/drivers/video/omap2/omapfb/omapfb.h @@ -165,7 +165,7 @@ 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) { - down_read(&rg->lock); + down_read_nested(&rg->lock, rg->id); return rg; }