All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: intel-gfx@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
	dri-devel@lists.freedesktop.org, chris@chris-wilson.co.uk
Subject: [PATCH 8/8] dma-buf: nuke reservation_object seq number
Date: Tue,  6 Aug 2019 17:01:34 +0200	[thread overview]
Message-ID: <20190806150134.104222-8-christian.koenig@amd.com> (raw)
In-Reply-To: <20190806150134.104222-1-christian.koenig@amd.com>

The only remaining use for this is to protect against setting a new exclusive
fence while we grab both exclusive and shared. That can also be archived by
looking if the exclusive fence has changed or not after completing the
operation.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/dma-buf/reservation.c | 20 +++-----------------
 include/linux/reservation.h   |  9 ++-------
 2 files changed, 5 insertions(+), 24 deletions(-)

diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
index 839d72af7ad8..43549a4d6658 100644
--- a/drivers/dma-buf/reservation.c
+++ b/drivers/dma-buf/reservation.c
@@ -49,12 +49,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);
-
 /**
  * reservation_object_list_alloc - allocate fence list
  * @shared_max: number of fences we need space for
@@ -103,9 +97,6 @@ static void reservation_object_list_free(struct reservation_object_list *list)
 void reservation_object_init(struct reservation_object *obj)
 {
 	ww_mutex_init(&obj->lock, &reservation_ww_class);
-
-	__seqcount_init(&obj->seq, reservation_seqcount_string,
-			&reservation_seqcount_class);
 	RCU_INIT_POINTER(obj->fence, NULL);
 	RCU_INIT_POINTER(obj->fence_excl, NULL);
 }
@@ -282,12 +273,10 @@ void reservation_object_add_excl_fence(struct reservation_object *obj,
 		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);
+	/* pointer update must be visible before we modify the shared_count */
 	if (old)
-		old->shared_count = 0;
-	write_seqcount_end(&obj->seq);
+		smp_store_mb(old->shared_count, 0);
 	preempt_enable();
 
 	/* inplace update, no shared fences */
@@ -370,11 +359,8 @@ int reservation_object_copy_fences(struct reservation_object *dst,
 	old = reservation_object_get_excl(dst);
 
 	preempt_disable();
-	write_seqcount_begin(&dst->seq);
-	/* write_seqcount_begin provides the necessary memory barrier */
 	RCU_INIT_POINTER(dst->fence_excl, new);
-	RCU_INIT_POINTER(dst->fence, dst_list);
-	write_seqcount_end(&dst->seq);
+	rcu_assign_pointer(dst->fence, dst_list);
 	preempt_enable();
 
 	reservation_object_list_free(src_list);
diff --git a/include/linux/reservation.h b/include/linux/reservation.h
index b8b8273eef00..1dfaf7b1f1da 100644
--- a/include/linux/reservation.h
+++ b/include/linux/reservation.h
@@ -46,8 +46,6 @@
 #include <linux/rcupdate.h>
 
 extern struct ww_class reservation_ww_class;
-extern struct lock_class_key reservation_seqcount_class;
-extern const char reservation_seqcount_string[];
 
 /**
  * struct reservation_object_list - a list of shared fences
@@ -71,7 +69,6 @@ struct reservation_object_list {
  */
 struct reservation_object {
 	struct ww_mutex lock;
-	seqcount_t seq;
 
 	struct dma_fence __rcu *fence_excl;
 	struct reservation_object_list __rcu *fence;
@@ -155,13 +152,11 @@ reservation_object_fences(struct reservation_object *obj,
 			  struct dma_fence **excl,
 			  struct reservation_object_list **list)
 {
-	unsigned int seq;
-
 	do {
-		seq = read_seqcount_begin(&obj->seq);
 		*excl = rcu_dereference(obj->fence_excl);
 		*list = rcu_dereference(obj->fence);
-	} while (read_seqcount_retry(&obj->seq, seq));
+		smp_rmb(); /* See reservation_object_add_excl_fence */
+	} while (rcu_access_pointer(obj->fence_excl) != *excl);
 }
 
 /**
-- 
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-06 15:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-06 15:01 [PATCH 1/8] dma-buf: fix busy wait for new shared fences Christian König
2019-08-06 15:01 ` [PATCH 2/8] dma-buf: fix shared fence list handling in reservation_object_copy_fences Christian König
2019-08-06 19:06   ` Chris Wilson
2019-08-07 10:43     ` Christian König
2019-08-06 15:01 ` [PATCH 3/8] drm/i915: stop using seqcount for fenc pruning Christian König
2019-08-06 19:07   ` Chris Wilson
2019-08-06 15:01 ` [PATCH 4/8] drm/i915: use new reservation_object_fences helper Christian König
2019-08-06 19:09   ` Chris Wilson
2019-08-06 15:01 ` [PATCH 5/8] dma-buf: further relax reservation_object_add_shared_fence Christian König
2019-08-06 19:25   ` Chris Wilson
2019-08-06 15:01 ` [PATCH 6/8] dma-buf: simplify reservation_object_get_fences_rcu a bit Christian König
2019-08-06 19:11   ` Chris Wilson
2019-08-06 15:01 ` [PATCH 7/8] dma-buf: add reservation_object_fences helper Christian König
2019-08-06 19:24   ` Chris Wilson
2019-08-07  9:06     ` Christian König
2019-08-06 15:01 ` Christian König [this message]
2019-08-06 19:57   ` [PATCH 8/8] dma-buf: nuke reservation_object seq number Chris Wilson
2019-08-07 12:08     ` Christian König
2019-08-07 12:19       ` Chris Wilson
2019-08-07 13:05         ` Koenig, Christian
2019-08-06 18:57 ` [PATCH 1/8] dma-buf: fix busy wait for new shared fences Chris Wilson
2019-08-09 13:27 ` ✗ Fi.CI.BAT: failure for series starting with [1/8] " Patchwork

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=20190806150134.104222-8-christian.koenig@amd.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.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.