[02/18] drm/cma-helper: Fix locking in drm_fb_cma_debugfs_show
diff mbox

Message ID 1436477570-4936-3-git-send-email-daniel.vetter@ffwll.ch
State New
Headers show

Commit Message

Daniel Vetter July 9, 2015, 9:32 p.m. UTC
This function takes two locks, both of them the wrong ones. This
wasn't an oversight from my fb locking rework since both patches
landed in parallel. We really only need fb_lock when walking that
list, since everything we can reach from that is refcounted properly
already.

Cc: Rob Clark <robdclark@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_fb_cma_helper.c  | 16 ++--------------
 drivers/gpu/drm/drm_gem_cma_helper.c |  2 --
 2 files changed, 2 insertions(+), 16 deletions(-)

Comments

Thierry Reding Aug. 10, 2015, 10:41 a.m. UTC | #1
On Thu, Jul 09, 2015 at 11:32:34PM +0200, Daniel Vetter wrote:
> This function takes two locks, both of them the wrong ones. This
> wasn't an oversight from my fb locking rework since both patches
> landed in parallel. We really only need fb_lock when walking that
> list, since everything we can reach from that is refcounted properly
> already.
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/drm_fb_cma_helper.c  | 16 ++--------------
>  drivers/gpu/drm/drm_gem_cma_helper.c |  2 --
>  2 files changed, 2 insertions(+), 16 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

Patch
diff mbox

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index 5c1aca443e54..46c4e6ee1cb1 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -209,23 +209,11 @@  int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg)
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct drm_framebuffer *fb;
-	int ret;
-
-	ret = mutex_lock_interruptible(&dev->mode_config.mutex);
-	if (ret)
-		return ret;
-
-	ret = mutex_lock_interruptible(&dev->struct_mutex);
-	if (ret) {
-		mutex_unlock(&dev->mode_config.mutex);
-		return ret;
-	}
 
+	mutex_lock(&dev->mode_config.fb_lock);
 	list_for_each_entry(fb, &dev->mode_config.fb_list, head)
 		drm_fb_cma_describe(fb, m);
-
-	mutex_unlock(&dev->struct_mutex);
-	mutex_unlock(&dev->mode_config.mutex);
+	mutex_unlock(&dev->mode_config.fb_lock);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
index bd75f303da63..ca2ed7e7b595 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -384,8 +384,6 @@  void drm_gem_cma_describe(struct drm_gem_cma_object *cma_obj,
 	struct drm_device *dev = obj->dev;
 	uint64_t off;
 
-	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
-
 	off = drm_vma_node_start(&obj->vma_node);
 
 	seq_printf(m, "%2d (%2d) %08llx %pad %p %zu",