From: Qiang Yu <yuq825@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: lima@lists.freedesktop.org,
Maxime Ripard <maxime.ripard@bootlin.com>,
David Airlie <airlied@linux.ie>, Qiang Yu <yuq825@gmail.com>,
Sean Paul <sean@poorly.run>
Subject: [PATCH v2 5/6] drm/lima: use drm_gem_(un)lock_reservations
Date: Fri, 27 Sep 2019 21:46:15 +0800 [thread overview]
Message-ID: <20190927134616.21899-6-yuq825@gmail.com> (raw)
In-Reply-To: <20190927134616.21899-1-yuq825@gmail.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
---
drivers/gpu/drm/lima/lima_gem.c | 64 ++++-----------------------------
1 file changed, 6 insertions(+), 58 deletions(-)
diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c
index eb70e4429588..3cc1870862c3 100644
--- a/drivers/gpu/drm/lima/lima_gem.c
+++ b/drivers/gpu/drm/lima/lima_gem.c
@@ -166,61 +166,6 @@ static int lima_gem_sync_bo(struct lima_sched_task *task, struct lima_bo *bo,
return drm_gem_fence_array_add_implicit(&task->deps, &bo->base.base, write);
}
-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;
-
- 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(&lima_bo_resv(bos[i])->lock, ctx);
- if (ret < 0) {
- contended = i;
- goto err;
- }
- }
-
- ww_acquire_done(ctx);
- return 0;
-
-err:
- for (i--; i >= 0; i--)
- ww_mutex_unlock(&lima_bo_resv(bos[i])->lock);
-
- if (slow_locked >= 0)
- ww_mutex_unlock(&lima_bo_resv(bos[slow_locked])->lock);
-
- if (ret == -EDEADLK) {
- /* we lost out in a seqno race, lock and retry.. */
- ret = ww_mutex_lock_slow_interruptible(
- &lima_bo_resv(bos[contended])->lock, ctx);
- if (!ret) {
- slow_locked = contended;
- goto retry;
- }
- }
- ww_acquire_fini(ctx);
-
- return ret;
-}
-
-static void lima_gem_unlock_bos(struct lima_bo **bos, u32 nr_bos,
- struct ww_acquire_ctx *ctx)
-{
- int i;
-
- for (i = 0; i < nr_bos; i++)
- ww_mutex_unlock(&lima_bo_resv(bos[i])->lock);
- ww_acquire_fini(ctx);
-}
-
static int lima_gem_add_deps(struct drm_file *file, struct lima_submit *submit)
{
int i, err;
@@ -280,7 +225,8 @@ int lima_gem_submit(struct drm_file *file, struct lima_submit *submit)
}
}
- err = lima_gem_lock_bos(bos, submit->nr_bos, &ctx);
+ err = drm_gem_lock_reservations((struct drm_gem_object **)bos,
+ submit->nr_bos, &ctx);
if (err)
goto err_out2;
@@ -313,7 +259,8 @@ int lima_gem_submit(struct drm_file *file, struct lima_submit *submit)
dma_resv_add_shared_fence(lima_bo_resv(bos[i]), fence);
}
- lima_gem_unlock_bos(bos, submit->nr_bos, &ctx);
+ drm_gem_unlock_reservations((struct drm_gem_object **)bos,
+ submit->nr_bos, &ctx);
for (i = 0; i < submit->nr_bos; i++)
drm_gem_object_put_unlocked(&bos[i]->base.base);
@@ -330,7 +277,8 @@ int lima_gem_submit(struct drm_file *file, struct lima_submit *submit)
err_out4:
lima_sched_task_fini(submit->task);
err_out3:
- lima_gem_unlock_bos(bos, submit->nr_bos, &ctx);
+ drm_gem_unlock_reservations((struct drm_gem_object **)bos,
+ submit->nr_bos, &ctx);
err_out2:
for (i = 0; i < submit->nr_bos; i++)
lima_vm_bo_del(vm, bos[i]);
--
2.17.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-09-27 13:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 13:46 [PATCH v2 0/6] drm/lima: simplify driver by using more drm helpers Qiang Yu
2019-09-27 13:46 ` [PATCH v2 1/6] drm/gem: refine drm_gem_objects_lookup Qiang Yu
2019-09-27 13:57 ` Steven Price
2019-09-29 6:07 ` Qiang Yu
2019-10-09 15:07 ` Daniel Vetter
2019-10-09 16:05 ` Rob Herring
2019-10-09 16:22 ` Daniel Vetter
2019-09-27 13:46 ` [PATCH v2 2/6] drm/v3d: use drm_gem_objects_lookup_user Qiang Yu
2019-09-27 13:57 ` Steven Price
2019-09-27 13:46 ` [PATCH v2 3/6] drm/lima: use drm_gem_objects_lookup Qiang Yu
2019-09-27 13:46 ` [PATCH v2 4/6] drm/lima: use drm_gem_shmem_helpers Qiang Yu
2019-09-27 13:46 ` Qiang Yu [this message]
2019-09-27 13:46 ` [PATCH v2 6/6] drm/lima: add __GFP_NOWARN flag to all dma_alloc_wc Qiang Yu
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=20190927134616.21899-6-yuq825@gmail.com \
--to=yuq825@gmail.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=lima@lists.freedesktop.org \
--cc=maxime.ripard@bootlin.com \
--cc=sean@poorly.run \
/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