public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: dri-devel@lists.freedesktop.org, chris@chris-wilson.co.uk,
	daniel.vetter@ffwll.ch, sumit.semwal@linaro.org,
	linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org
Subject: [PATCH 9/9] dma-buf/resv: drop the sequence count
Date: Mon, 26 Aug 2019 16:57:31 +0200	[thread overview]
Message-ID: <20190826145731.1725-10-christian.koenig@amd.com> (raw)
In-Reply-To: <20190826145731.1725-1-christian.koenig@amd.com>

We can now grab a reference to all the fences in question,
no need for the sequence counter any more.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/dma-buf/dma-resv.c               | 22 ++--------------------
 drivers/gpu/drm/i915/gem/i915_gem_busy.c | 13 ++++---------
 include/linux/dma-resv.h                 |  3 ---
 3 files changed, 6 insertions(+), 32 deletions(-)

diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
index 7fa0e86b4e75..51067edff930 100644
--- a/drivers/dma-buf/dma-resv.c
+++ b/drivers/dma-buf/dma-resv.c
@@ -50,12 +50,6 @@
 DEFINE_WD_CLASS(reservation_ww_class);
 EXPORT_SYMBOL(reservation_ww_class);
 
-struct lock_class_key reservation_seqcount_class;
-EXPORT_SYMBOL(reservation_seqcount_class);
-
-const char reservation_seqcount_string[] = "reservation_seqcount";
-EXPORT_SYMBOL(reservation_seqcount_string);
-
 static void dma_resv_fences_init(struct dma_resv_fences *fences)
 {
 	RCU_INIT_POINTER(fences->fence, NULL);
@@ -244,8 +238,6 @@ void dma_resv_init(struct dma_resv *obj)
 {
 	ww_mutex_init(&obj->lock, &reservation_ww_class);
 
-	__seqcount_init(&obj->seq, reservation_seqcount_string,
-			&reservation_seqcount_class);
 	RCU_INIT_POINTER(obj->fence_excl, NULL);
 	dma_resv_fences_init(&obj->shared);
 }
@@ -321,13 +313,8 @@ void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence)
 
 	dma_fence_get(fence);
 
-	preempt_disable();
-	write_seqcount_begin(&obj->seq);
-	/* write_seqcount_begin provides the necessary memory barrier */
-	RCU_INIT_POINTER(obj->fence_excl, fence);
+	rcu_assign_pointer(obj->fence_excl, fence);
 	dma_resv_fences_set(obj, &obj->shared, NULL);
-	write_seqcount_end(&obj->seq);
-	preempt_enable();
 
 	dma_fence_put(old_fence);
 }
@@ -377,13 +364,8 @@ int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src)
 
 	old = dma_resv_get_excl(dst);
 
-	preempt_disable();
-	write_seqcount_begin(&dst->seq);
-	/* write_seqcount_begin provides the necessary memory barrier */
-	RCU_INIT_POINTER(dst->fence_excl, excl);
+	rcu_assign_pointer(dst->fence_excl, excl);
 	dma_resv_fences_set(dst, &dst->shared, shared);
-	write_seqcount_end(&dst->seq);
-	preempt_enable();
 
 	dma_fence_put(old);
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_busy.c b/drivers/gpu/drm/i915/gem/i915_gem_busy.c
index 0ef338a8cd9f..34256fff1f90 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_busy.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_busy.c
@@ -86,7 +86,6 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
 	struct dma_fence_array_cursor cursor;
 	struct dma_fence *fence, *shared;
 	struct drm_i915_gem_object *obj;
-	unsigned int seq;
 	int err;
 
 	err = -ENOENT;
@@ -112,22 +111,18 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
 	 * to report the overall busyness. This is what the wait-ioctl does.
 	 *
 	 */
-retry:
-	seq = raw_read_seqcount(&obj->base.resv->seq);
+	shared = dma_resv_fences_get_rcu(&obj->base.resv->shared);
+	fence = dma_fence_get_rcu_safe(&obj->base.resv->fence_excl);
 
 	/* Translate the exclusive fence to the READ *and* WRITE engine */
-	args->busy =
-		busy_check_writer(rcu_dereference(obj->base.resv->fence_excl));
+	args->busy = busy_check_writer(fence);
+	dma_fence_put(fence);
 
 	/* Translate shared fences to READ set of engines */
-	shared = dma_resv_fences_get_rcu(&obj->base.resv->shared);
 	dma_fence_array_for_each(fence, cursor, shared)
 		args->busy |= busy_check_reader(fence);
 	dma_fence_put(shared);
 
-	if (args->busy && read_seqcount_retry(&obj->base.resv->seq, seq))
-		goto retry;
-
 	err = 0;
 out:
 	rcu_read_unlock();
diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
index 040e3f04a8ad..44f975d772e8 100644
--- a/include/linux/dma-resv.h
+++ b/include/linux/dma-resv.h
@@ -48,8 +48,6 @@
 struct dma_resv;
 
 extern struct ww_class reservation_ww_class;
-extern struct lock_class_key reservation_seqcount_class;
-extern const char reservation_seqcount_string[];
 
 /**
  * struct dma_resv_fences - fences inside a reservation object
@@ -81,7 +79,6 @@ void dma_resv_fences_commit(struct dma_resv *obj,
  */
 struct dma_resv {
 	struct ww_mutex lock;
-	seqcount_t seq;
 
 	struct dma_fence __rcu *fence_excl;
 	struct dma_resv_fences	shared;
-- 
2.17.1


  parent reply	other threads:[~2019-08-26 14:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26 14:57 Use dma_fence_array for implementing shared dma_resv fences Christian König
2019-08-26 14:57 ` [PATCH 1/9] dma-buf: fix dma_fence_array_signaled Christian König
2019-08-27 11:44   ` Chris Wilson
2019-08-26 14:57 ` [PATCH 2/9] dma-buf: make to_dma_fence_array NULL safe Christian König
2019-08-30 16:07   ` Ruhl, Michael J
2019-08-26 14:57 ` [PATCH 3/9] dma-buf: add dma_fence_array_alloc/free Christian König
2019-08-26 14:57 ` [PATCH 4/9] dma-buf: add dma_fence_array_recycle v2 Christian König
2019-08-26 14:57 ` [PATCH 5/9] dma-buf: add dma_fence_array_for_each Christian König
2019-08-26 14:57 ` [PATCH 6/9] dma-buf/resv: add dma_resv_prune_fences v2 Christian König
2019-08-26 14:57 ` [PATCH 7/9] dma-buf/resv: add new fences container implementation Christian König
2019-08-26 14:57 ` [PATCH 8/9] dma-buf/resv: use new dma_fence_array based implementation Christian König
2019-08-26 14:57 ` Christian König [this message]
2019-08-27 16:37 ` Use dma_fence_array for implementing shared dma_resv fences Daniel Vetter

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=20190826145731.1725-10-christian.koenig@amd.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-media@vger.kernel.org \
    --cc=sumit.semwal@linaro.org \
    /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