[Lima] [PATCH 4/6] drm/etnaviv: use new ww_mutex_(un)lock_for_each macros

Christian König ckoenig.leichtzumerken at gmail.com
Fri Jun 14 12:41:23 UTC 2019


Use the provided macros instead of implementing deadlock handling on our own.

Signed-off-by: Christian König <christian.koenig at amd.com>
---
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 55 +++++---------------
 1 file changed, 14 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index e054f09ac828..923b8a71f80d 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -118,55 +118,28 @@ static void submit_unlock_object(struct etnaviv_gem_submit *submit, int i)
 static int submit_lock_objects(struct etnaviv_gem_submit *submit,
 		struct ww_acquire_ctx *ticket)
 {
-	int contended, slow_locked = -1, i, ret = 0;
-
-retry:
-	for (i = 0; i < submit->nr_bos; i++) {
-		struct drm_gem_object *obj = &submit->bos[i].obj->base;
-
-		if (slow_locked == i)
-			slow_locked = -1;
-
-		contended = i;
+	struct ww_mutex *contended;
+	int i, ret = 0;
 
-		if (!(submit->bos[i].flags & BO_LOCKED)) {
-			ret = ww_mutex_lock_interruptible(&obj->resv->lock,
-							  ticket);
-			if (ret == -EALREADY)
-				DRM_ERROR("BO at index %u already on submit list\n",
-					  i);
-			if (ret)
-				goto fail;
-			submit->bos[i].flags |= BO_LOCKED;
-		}
+	ww_mutex_lock_for_each(for (i = 0; i < submit->nr_bos; i++),
+			       &submit->bos[i].obj->base.resv->lock,
+			       contended, ret, true, ticket) {
+		if (ret == -EALREADY)
+			DRM_ERROR("BO at index %u already on submit list\n", i);
+		if (ret)
+			goto fail;
 	}
 
+	for (i = 0; i < submit->nr_bos; i++)
+		submit->bos[i].flags |= BO_LOCKED;
 	ww_acquire_done(ticket);
 
 	return 0;
 
 fail:
-	for (; i >= 0; i--)
-		submit_unlock_object(submit, i);
-
-	if (slow_locked > 0)
-		submit_unlock_object(submit, slow_locked);
-
-	if (ret == -EDEADLK) {
-		struct drm_gem_object *obj;
-
-		obj = &submit->bos[contended].obj->base;
-
-		/* we lost out in a seqno race, lock and retry.. */
-		ret = ww_mutex_lock_slow_interruptible(&obj->resv->lock,
-						       ticket);
-		if (!ret) {
-			submit->bos[contended].flags |= BO_LOCKED;
-			slow_locked = contended;
-			goto retry;
-		}
-	}
-
+	ww_mutex_unlock_for_each(for (i = 0; i < submit->nr_bos; i++),
+				 &submit->bos[i].obj->base.resv->lock,
+				 contended);
 	return ret;
 }
 
-- 
2.17.1



More information about the lima mailing list