dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: DRI Development <dri-devel@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 14/27] drm/vc4: Use drm_gem_object_unreference_unlocked
Date: Mon, 30 May 2016 19:53:06 +0200	[thread overview]
Message-ID: <1464630800-30786-15-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <1464630800-30786-1-git-send-email-daniel.vetter@ffwll.ch>

Since my last struct_mutex crusade someone escaped!

This already has the advantage that for the common case when someone
else holds a ref the unref won't even acquire dev->struct_mutex. And
I'm working on code to allow drivers to completely opt-out of any and
all dev->struct_mutex usage, but that only works if they use the
_unlocked variants everywhere.

v2: Drop comment too.

v3: Drop the other comment too.

Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/vc4/vc4_bo.c  |  2 --
 drivers/gpu/drm/vc4/vc4_gem.c | 11 +++--------
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
index e5a9d3aaf45f..59adcf8532dd 100644
--- a/drivers/gpu/drm/vc4/vc4_bo.c
+++ b/drivers/gpu/drm/vc4/vc4_bo.c
@@ -291,8 +291,6 @@ static void vc4_bo_cache_free_old(struct drm_device *dev)
 
 /* Called on the last userspace/kernel unreference of the BO.  Returns
  * it to the BO cache if possible, otherwise frees it.
- *
- * Note that this is called with the struct_mutex held.
  */
 void vc4_free_object(struct drm_gem_object *gem_bo)
 {
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index 46899d6de675..6155e8aca1c6 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -53,10 +53,8 @@ vc4_free_hang_state(struct drm_device *dev, struct vc4_hang_state *state)
 {
 	unsigned int i;
 
-	mutex_lock(&dev->struct_mutex);
 	for (i = 0; i < state->user_state.bo_count; i++)
-		drm_gem_object_unreference(state->bo[i]);
-	mutex_unlock(&dev->struct_mutex);
+		drm_gem_object_unreference_unlocked(state->bo[i]);
 
 	kfree(state);
 }
@@ -687,11 +685,9 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
 	unsigned i;
 
-	/* Need the struct lock for drm_gem_object_unreference(). */
-	mutex_lock(&dev->struct_mutex);
 	if (exec->bo) {
 		for (i = 0; i < exec->bo_count; i++)
-			drm_gem_object_unreference(&exec->bo[i]->base);
+			drm_gem_object_unreference_unlocked(&exec->bo[i]->base);
 		kfree(exec->bo);
 	}
 
@@ -699,9 +695,8 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
 		struct vc4_bo *bo = list_first_entry(&exec->unref_list,
 						     struct vc4_bo, unref_head);
 		list_del(&bo->unref_head);
-		drm_gem_object_unreference(&bo->base.base);
+		drm_gem_object_unreference_unlocked(&bo->base.base);
 	}
-	mutex_unlock(&dev->struct_mutex);
 
 	mutex_lock(&vc4->power_lock);
 	if (--vc4->power_refcount == 0)
-- 
2.8.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2016-05-30 17:53 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-30 17:52 [PATCH 00/27] locklesss gem BO free driver patches Daniel Vetter
2016-05-30 17:52 ` [PATCH 01/27] drm/armada: Use lockless gem BO free callback Daniel Vetter
2016-06-01 16:26   ` Russell King - ARM Linux
2016-05-30 17:52 ` [PATCH 02/27] drm/ast: " Daniel Vetter
2016-05-30 17:52 ` [PATCH 03/27] drm/atmel: " Daniel Vetter
2016-06-07 11:22   ` Boris Brezillon
2016-05-30 17:52 ` [PATCH 04/27] drm/bochs: " Daniel Vetter
2016-05-30 17:52 ` [PATCH 05/27] drm/cirrus: " Daniel Vetter
2016-05-30 17:52 ` [PATCH 06/27] drm/fls-dcu: " Daniel Vetter
2016-05-30 17:52 ` [PATCH 07/27] drm/mga200g: " Daniel Vetter
2016-05-30 17:53 ` [PATCH 08/27] drm/nouveau: " Daniel Vetter
2016-05-30 17:53 ` [PATCH 09/27] drm/qxl: " Daniel Vetter
2016-05-30 17:53 ` [PATCH 10/27] drm/rcar-du: " Daniel Vetter
2016-06-02 22:49   ` Laurent Pinchart
2016-05-30 17:53 ` [PATCH 11/27] drm/rockchip: " Daniel Vetter
2016-05-30 17:53 ` [PATCH 12/27] drm/shmob: " Daniel Vetter
2016-06-02 22:50   ` Laurent Pinchart
2016-05-30 17:53 ` [PATCH 13/27] drm/tilcdc: " Daniel Vetter
2016-05-30 17:53 ` Daniel Vetter [this message]
2016-05-30 17:53 ` [PATCH 15/27] drm/vc4: " Daniel Vetter
2016-05-31 17:23   ` Eric Anholt
2016-05-31 19:14     ` Daniel Vetter
2016-05-30 17:53 ` [PATCH 16/27] drm/vgem: " Daniel Vetter
2016-05-31 13:20   ` Sean Paul
2016-05-31 13:29     ` Daniel Vetter
2016-05-30 17:53 ` [PATCH 17/27] drm/virtio: " Daniel Vetter
2016-05-30 17:53 ` [PATCH 18/27] drm: sti: remove useless call to dev->struct_mutex Daniel Vetter
2016-05-30 17:53 ` [PATCH 19/27] drm/virtio: Use lockless gem BO free callback Daniel Vetter
2016-05-30 17:53 ` [PATCH 20/27] drm/rockchip: Use cma gem vm ops Daniel Vetter
2016-05-30 17:53 ` [PATCH 21/27] drm/msm: Nuke dummy fb->dirty callback Daniel Vetter
2016-05-30 17:53 ` [PATCH 22/27] drm/omapdrm: " Daniel Vetter
2016-06-02 22:52   ` Laurent Pinchart
2016-05-30 17:53 ` [PATCH 23/27] drm/sun4i: Use lockless gem BO free callback Daniel Vetter
2016-06-01 16:19   ` Maxime Ripard
2016-05-30 17:53 ` [PATCH 24/27] drm/arcpgu: " Daniel Vetter
2016-05-30 17:53 ` [PATCH 25/27] drm/hlcd: " Daniel Vetter
2016-05-31  9:08   ` Liviu Dudau
2016-05-30 17:53 ` [PATCH 26/27] drm/hisilicon: " Daniel Vetter
2016-05-31  1:14   ` Xinliang Liu
2016-06-12  9:48   ` Xinliang Liu
2016-05-30 17:53 ` [PATCH 27/27] drm/mediatek: " Daniel Vetter
2016-05-31  6:22   ` Philipp Zabel
2016-05-31  6:58     ` Daniel Vetter
2016-05-31 13:33 ` [PATCH 00/27] locklesss gem BO free driver patches Sumit Semwal

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=1464630800-30786-15-git-send-email-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox