Use the provided macros instead of implementing deadlock handling on our own. Signed-off-by: Christian König <christian.koenig@xxxxxxx> --- 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 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel