[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190614124125.124181-5-christian.koenig@amd.com>
Date: Fri, 14 Jun 2019 14:41:23 +0200
From: "Christian König"
<ckoenig.leichtzumerken@...il.com>
To: daniel@...ll.ch, l.stach@...gutronix.de,
linux+etnaviv@...linux.org.uk, christian.gmeiner@...il.com,
yuq825@...il.com, eric@...olt.net, peterz@...radead.org,
thellstrom@...are.com, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, etnaviv@...ts.freedesktop.org,
lima@...ts.freedesktop.org
Subject: [PATCH 4/6] drm/etnaviv: use new ww_mutex_(un)lock_for_each macros
Use the provided macros instead of implementing deadlock handling on our own.
Signed-off-by: Christian König <christian.koenig@....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
Powered by blists - more mailing lists