Re: [PATCH 7/8] dma-buf: add reservation_object_fences helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 06.08.19 um 21:24 schrieb Chris Wilson:
Quoting Christian König (2019-08-06 16:01:33)
Add a new helper to get a consistent set of pointers from the reservation
object. While at it group all access helpers together in the header file.
Ah, needs to be earlier :)

Ah, crap. That got incorrectly reordered while moving the fixes to the beginning of the set.

+/**
+ * reservation_object_fences - read consistent fence pointers
+ * @obj: reservation object where we get the fences from
+ * @excl: pointer for the exclusive fence
+ * @list: pointer for the shared fence list
+ *
+ * Make sure we have a consisten exclusive fence and shared fence list.
+ * Must be called with rcu read side lock held.
+ */
+static inline void
+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));
+}
I would personally prefer return excl rather than have it as a second
outparam, but I'd leave that to gcc to decide.

Having stared at this, I agree this does the right thing. The important
point from all callers' perspective is that the combination of pointers
is consistent for this rcu_read_lock. And rcu_dereference enforces the
callers do hold rcu_read_lock.

I didn't check all the conversions, just stared at the heart of the
problem.

Reviewed-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>

Thanks.

Going to fix that up,
Christian.

-Chris

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux