All of lore.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 10/10] dma-buf/resv: add other operations
Date: Wed, 21 Aug 2019 14:31:47 +0200	[thread overview]
Message-ID: <20190821123147.110736-11-christian.koenig@amd.com> (raw)
In-Reply-To: <20190821123147.110736-1-christian.koenig@amd.com>

Additional to readers and writers add another class of operations
which never participate in implicit synchronization.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/dma-buf/dma-resv.c | 27 ++++++++++++++++++++++++---
 include/linux/dma-resv.h   |  2 ++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
index 8ef7dbc7fd8e..c6dd6c36dba2 100644
--- a/drivers/dma-buf/dma-resv.c
+++ b/drivers/dma-buf/dma-resv.c
@@ -280,6 +280,7 @@ void dma_resv_init(struct dma_resv *obj)
 
 	dma_resv_fences_init(&obj->writers);
 	dma_resv_fences_init(&obj->readers);
+	dma_resv_fences_init(&obj->others);
 }
 EXPORT_SYMBOL(dma_resv_init);
 
@@ -295,6 +296,7 @@ void dma_resv_fini(struct dma_resv *obj)
 	 */
 	dma_resv_fences_fini(&obj->writers);
 	dma_resv_fences_fini(&obj->readers);
+	dma_resv_fences_fini(&obj->others);
 	ww_mutex_destroy(&obj->lock);
 }
 EXPORT_SYMBOL(dma_resv_fini);
@@ -334,6 +336,10 @@ void dma_resv_prune_fences(struct dma_resv *obj)
 	fence = dma_resv_fences_deref(obj, &obj->readers);
 	if (dma_fence_is_signaled(fence))
 		dma_resv_fences_set(obj, &obj->readers, NULL);
+
+	fence = dma_resv_fences_deref(obj, &obj->others);
+	if (dma_fence_is_signaled(fence))
+		dma_resv_fences_set(obj, &obj->others, NULL);
 }
 EXPORT_SYMBOL(dma_resv_prune_fences);
 
@@ -346,17 +352,19 @@ EXPORT_SYMBOL(dma_resv_prune_fences);
 */
 int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src)
 {
-	struct dma_fence *writers, *readers;
+	struct dma_fence *writers, *readers, *others;
 
 	dma_resv_assert_held(dst);
 
 	rcu_read_lock();
 	writers = dma_resv_fences_get_rcu(&src->writers);
 	readers = dma_resv_fences_get_rcu(&src->readers);
+	others = dma_resv_fences_get_rcu(&src->others);
 	rcu_read_unlock();
 
 	dma_resv_fences_set(dst, &dst->writers, writers);
 	dma_resv_fences_set(dst, &dst->readers, readers);
+	dma_resv_fences_set(dst, &dst->readers, others);
 
 	return 0;
 }
@@ -440,12 +448,13 @@ long dma_resv_wait_timeout_rcu(struct dma_resv *obj,
 			       bool wait_all, bool intr,
 			       unsigned long timeout)
 {
-	struct dma_fence *writers, *readers;
+	struct dma_fence *writers, *readers, *others;
 	long ret = timeout ? timeout : 1;
 
 	rcu_read_lock();
 	writers = dma_resv_fences_get_rcu(&obj->writers);
 	readers = dma_resv_fences_get_rcu(&obj->readers);
+	others = dma_resv_fences_get_rcu(&obj->others);
 	rcu_read_unlock();
 
 	if (wait_all && readers) {
@@ -454,12 +463,19 @@ long dma_resv_wait_timeout_rcu(struct dma_resv *obj,
 			goto out;
 	}
 
+	if (wait_all && others) {
+		ret = dma_fence_wait_timeout(others, intr, ret);
+		if (ret <= 0)
+			goto out;
+	}
+
 	if (writers)
 		ret = dma_fence_wait_timeout(writers, intr, ret);
 
 out:
 	dma_fence_put(writers);
 	dma_fence_put(readers);
+	dma_fence_put(others);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(dma_resv_wait_timeout_rcu);
@@ -476,12 +492,13 @@ EXPORT_SYMBOL_GPL(dma_resv_wait_timeout_rcu);
  */
 bool dma_resv_test_signaled_rcu(struct dma_resv *obj, bool test_all)
 {
-	struct dma_fence *writers, *readers;
+	struct dma_fence *writers, *readers, *others;
 	bool ret = true;
 
 	rcu_read_lock();
 	writers = dma_resv_fences_get_rcu(&obj->writers);
 	readers = dma_resv_fences_get_rcu(&obj->readers);
+	others = dma_resv_fences_get_rcu(&obj->others);
 	rcu_read_unlock();
 
 	if (writers)
@@ -490,8 +507,12 @@ bool dma_resv_test_signaled_rcu(struct dma_resv *obj, bool test_all)
 	if (test_all && readers)
 		ret &= dma_fence_is_signaled(readers);
 
+	if (test_all && others)
+		ret &= dma_fence_is_signaled(others);
+
 	dma_fence_put(writers);
 	dma_fence_put(readers);
+	dma_fence_put(others);
 
 	return ret;
 }
diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
index 72c3c4f99711..bf8d21cc7720 100644
--- a/include/linux/dma-resv.h
+++ b/include/linux/dma-resv.h
@@ -76,12 +76,14 @@ void dma_resv_fences_commit(struct dma_resv *obj,
  * @seq: sequence count for managing RCU read-side synchronization
  * @writers: array of write operations for implicit sync
  * @readers: array of read operations for implicit sync
+ * @others: other operations not participating in implicit sync
  */
 struct dma_resv {
 	struct ww_mutex lock;
 
 	struct dma_resv_fences writers;
 	struct dma_resv_fences readers;
+	struct dma_resv_fences others;
 };
 
 #define dma_resv_held(obj) lockdep_is_held(&(obj)->lock.base)
-- 
2.17.1


WARNING: multiple messages have this Message-ID (diff)
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 10/10] dma-buf/resv: add other operations
Date: Wed, 21 Aug 2019 14:31:47 +0200	[thread overview]
Message-ID: <20190821123147.110736-11-christian.koenig@amd.com> (raw)
In-Reply-To: <20190821123147.110736-1-christian.koenig@amd.com>

Additional to readers and writers add another class of operations
which never participate in implicit synchronization.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/dma-buf/dma-resv.c | 27 ++++++++++++++++++++++++---
 include/linux/dma-resv.h   |  2 ++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
index 8ef7dbc7fd8e..c6dd6c36dba2 100644
--- a/drivers/dma-buf/dma-resv.c
+++ b/drivers/dma-buf/dma-resv.c
@@ -280,6 +280,7 @@ void dma_resv_init(struct dma_resv *obj)
 
 	dma_resv_fences_init(&obj->writers);
 	dma_resv_fences_init(&obj->readers);
+	dma_resv_fences_init(&obj->others);
 }
 EXPORT_SYMBOL(dma_resv_init);
 
@@ -295,6 +296,7 @@ void dma_resv_fini(struct dma_resv *obj)
 	 */
 	dma_resv_fences_fini(&obj->writers);
 	dma_resv_fences_fini(&obj->readers);
+	dma_resv_fences_fini(&obj->others);
 	ww_mutex_destroy(&obj->lock);
 }
 EXPORT_SYMBOL(dma_resv_fini);
@@ -334,6 +336,10 @@ void dma_resv_prune_fences(struct dma_resv *obj)
 	fence = dma_resv_fences_deref(obj, &obj->readers);
 	if (dma_fence_is_signaled(fence))
 		dma_resv_fences_set(obj, &obj->readers, NULL);
+
+	fence = dma_resv_fences_deref(obj, &obj->others);
+	if (dma_fence_is_signaled(fence))
+		dma_resv_fences_set(obj, &obj->others, NULL);
 }
 EXPORT_SYMBOL(dma_resv_prune_fences);
 
@@ -346,17 +352,19 @@ EXPORT_SYMBOL(dma_resv_prune_fences);
 */
 int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src)
 {
-	struct dma_fence *writers, *readers;
+	struct dma_fence *writers, *readers, *others;
 
 	dma_resv_assert_held(dst);
 
 	rcu_read_lock();
 	writers = dma_resv_fences_get_rcu(&src->writers);
 	readers = dma_resv_fences_get_rcu(&src->readers);
+	others = dma_resv_fences_get_rcu(&src->others);
 	rcu_read_unlock();
 
 	dma_resv_fences_set(dst, &dst->writers, writers);
 	dma_resv_fences_set(dst, &dst->readers, readers);
+	dma_resv_fences_set(dst, &dst->readers, others);
 
 	return 0;
 }
@@ -440,12 +448,13 @@ long dma_resv_wait_timeout_rcu(struct dma_resv *obj,
 			       bool wait_all, bool intr,
 			       unsigned long timeout)
 {
-	struct dma_fence *writers, *readers;
+	struct dma_fence *writers, *readers, *others;
 	long ret = timeout ? timeout : 1;
 
 	rcu_read_lock();
 	writers = dma_resv_fences_get_rcu(&obj->writers);
 	readers = dma_resv_fences_get_rcu(&obj->readers);
+	others = dma_resv_fences_get_rcu(&obj->others);
 	rcu_read_unlock();
 
 	if (wait_all && readers) {
@@ -454,12 +463,19 @@ long dma_resv_wait_timeout_rcu(struct dma_resv *obj,
 			goto out;
 	}
 
+	if (wait_all && others) {
+		ret = dma_fence_wait_timeout(others, intr, ret);
+		if (ret <= 0)
+			goto out;
+	}
+
 	if (writers)
 		ret = dma_fence_wait_timeout(writers, intr, ret);
 
 out:
 	dma_fence_put(writers);
 	dma_fence_put(readers);
+	dma_fence_put(others);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(dma_resv_wait_timeout_rcu);
@@ -476,12 +492,13 @@ EXPORT_SYMBOL_GPL(dma_resv_wait_timeout_rcu);
  */
 bool dma_resv_test_signaled_rcu(struct dma_resv *obj, bool test_all)
 {
-	struct dma_fence *writers, *readers;
+	struct dma_fence *writers, *readers, *others;
 	bool ret = true;
 
 	rcu_read_lock();
 	writers = dma_resv_fences_get_rcu(&obj->writers);
 	readers = dma_resv_fences_get_rcu(&obj->readers);
+	others = dma_resv_fences_get_rcu(&obj->others);
 	rcu_read_unlock();
 
 	if (writers)
@@ -490,8 +507,12 @@ bool dma_resv_test_signaled_rcu(struct dma_resv *obj, bool test_all)
 	if (test_all && readers)
 		ret &= dma_fence_is_signaled(readers);
 
+	if (test_all && others)
+		ret &= dma_fence_is_signaled(others);
+
 	dma_fence_put(writers);
 	dma_fence_put(readers);
+	dma_fence_put(others);
 
 	return ret;
 }
diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
index 72c3c4f99711..bf8d21cc7720 100644
--- a/include/linux/dma-resv.h
+++ b/include/linux/dma-resv.h
@@ -76,12 +76,14 @@ void dma_resv_fences_commit(struct dma_resv *obj,
  * @seq: sequence count for managing RCU read-side synchronization
  * @writers: array of write operations for implicit sync
  * @readers: array of read operations for implicit sync
+ * @others: other operations not participating in implicit sync
  */
 struct dma_resv {
 	struct ww_mutex lock;
 
 	struct dma_resv_fences writers;
 	struct dma_resv_fences readers;
+	struct dma_resv_fences others;
 };
 
 #define dma_resv_held(obj) lockdep_is_held(&(obj)->lock.base)
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-08-21 12:32 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-21 12:31 [RFC] replacing dma_resv API Christian König
2019-08-21 12:31 ` Christian König
2019-08-21 12:31 ` [PATCH 01/10] dma-buf: make to_dma_fence_array NULL safe Christian König
2019-08-21 12:31   ` Christian König
2019-08-21 12:31 ` [PATCH 02/10] dma-buf: add dma_fence_array_alloc/free Christian König
2019-08-21 12:31   ` Christian König
2019-08-21 12:31 ` [PATCH 03/10] dma-buf: add dma_fence_array_recycle Christian König
2019-08-21 12:31   ` Christian König
2019-08-21 16:24   ` Chris Wilson
2019-08-21 16:24     ` Chris Wilson
2019-08-22  8:38     ` Christian König
2019-08-22  8:38       ` Christian König
2019-08-21 12:31 ` [PATCH 04/10] dma-buf: add dma_fence_array_for_each Christian König
2019-08-21 12:31   ` Christian König
2019-08-21 12:31 ` [PATCH 05/10] dma-buf/resv: add dma_resv_prune_fences Christian König
2019-08-21 12:31   ` Christian König
2019-08-21 14:55   ` Chris Wilson
2019-08-21 14:55     ` Chris Wilson
2019-08-21 14:56     ` Chris Wilson
2019-08-21 14:56       ` Chris Wilson
2019-08-21 12:31 ` [PATCH 06/10] dma-buf/resv: stop pruning shared fences when exclusive is added Christian König
2019-08-21 12:31   ` Christian König
2019-08-21 12:31 ` [PATCH 07/10] dma-buf/resv: add new fences container implementation Christian König
2019-08-21 12:31   ` Christian König
2019-08-21 16:04   ` Daniel Vetter
2019-08-21 16:04     ` Daniel Vetter
2019-08-22  8:23     ` Christian König
2019-08-22  8:23       ` Christian König
2019-08-22 13:02       ` Daniel Vetter
2019-08-22 13:02         ` Daniel Vetter
2019-08-22 13:53         ` Koenig, Christian
2019-08-22 13:53           ` Koenig, Christian
2019-08-21 12:31 ` [PATCH 08/10] dma-buf/resv: replace shared fence with new fences container Christian König
2019-08-21 12:31   ` Christian König
2019-08-21 15:24   ` Chris Wilson
2019-08-21 15:24     ` Chris Wilson
2019-08-21 17:35     ` Chris Wilson
2019-08-21 17:35       ` Chris Wilson
2019-08-22  8:37       ` Christian König
2019-08-22  8:37         ` Christian König
2019-08-22  9:16         ` Christian König
2019-08-22  9:16           ` Christian König
2019-08-21 16:21   ` Chris Wilson
2019-08-21 16:21     ` Chris Wilson
2019-08-24 13:22   ` Chris Wilson
2019-08-24 13:22     ` Chris Wilson
2019-08-21 12:31 ` [PATCH 09/10] dma-buf/resv: replace exclusive " Christian König
2019-08-21 12:31   ` Christian König
2019-08-21 12:31 ` Christian König [this message]
2019-08-21 12:31   ` [PATCH 10/10] dma-buf/resv: add other operations Christian König
2019-08-22 12:28   ` Ville Syrjälä
2019-08-22 12:28     ` Ville Syrjälä
2019-08-21 16:13 ` [RFC] replacing dma_resv API Daniel Vetter
2019-08-21 16:13   ` Daniel Vetter
2019-08-21 20:05   ` Daniel Vetter
2019-08-21 20:05     ` Daniel Vetter
2019-08-22  9:27     ` Christian König
2019-08-22  9:27       ` Christian König
2019-08-21 20:11 ` Chris Wilson
2019-08-21 20:11   ` Chris Wilson
2019-08-21 20:22   ` Daniel Vetter
2019-08-21 20:22     ` Daniel Vetter
2019-08-22  9:14     ` Christian König
2019-08-22  9:14       ` Christian König
2019-08-22 10:00       ` Daniel Vetter
2019-08-22 10:00         ` 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=20190821123147.110736-11-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.