[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190614124125.124181-6-christian.koenig@amd.com>
Date: Fri, 14 Jun 2019 14:41:24 +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 5/6] drm/lima: 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/lima/lima_gem.c | 41 +++++++++------------------------
1 file changed, 11 insertions(+), 30 deletions(-)
diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c
index 477c0f766663..6a51f100c29e 100644
--- a/drivers/gpu/drm/lima/lima_gem.c
+++ b/drivers/gpu/drm/lima/lima_gem.c
@@ -151,43 +151,24 @@ static int lima_gem_sync_bo(struct lima_sched_task *task, struct lima_bo *bo,
static int lima_gem_lock_bos(struct lima_bo **bos, u32 nr_bos,
struct ww_acquire_ctx *ctx)
{
- int i, ret = 0, contended, slow_locked = -1;
+ struct ww_mutex *contended;
+ int i, ret = 0;
ww_acquire_init(ctx, &reservation_ww_class);
-retry:
- for (i = 0; i < nr_bos; i++) {
- if (i == slow_locked) {
- slow_locked = -1;
- continue;
- }
-
- ret = ww_mutex_lock_interruptible(&bos[i]->gem.resv->lock, ctx);
- if (ret < 0) {
- contended = i;
- goto err;
- }
- }
+ ww_mutex_lock_for_each(for (i = 0; i < nr_bos; i++),
+ &bos[i]->gem.resv->lock, contended, ret, true,
+ ctx)
+ if (ret)
+ goto error;
ww_acquire_done(ctx);
- return 0;
-err:
- for (i--; i >= 0; i--)
- ww_mutex_unlock(&bos[i]->gem.resv->lock);
-
- if (slow_locked >= 0)
- ww_mutex_unlock(&bos[slow_locked]->gem.resv->lock);
+ return 0;
- if (ret == -EDEADLK) {
- /* we lost out in a seqno race, lock and retry.. */
- ret = ww_mutex_lock_slow_interruptible(
- &bos[contended]->gem.resv->lock, ctx);
- if (!ret) {
- slow_locked = contended;
- goto retry;
- }
- }
+error:
+ ww_mutex_unlock_for_each(for (i = 0; i < nr_bos; i++),
+ &bos[i]->gem.resv->lock, contended);
ww_acquire_fini(ctx);
return ret;
--
2.17.1
Powered by blists - more mailing lists