diff mbox

[01/11] reservation: add reservation_object_get_excl_unlocked()

Message ID 1459455831-16085-1-git-send-email-robdclark@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rob Clark March 31, 2016, 8:23 p.m. UTC
In the atomic modesetting path, each driver simply wants to grab a ref
to the exclusive fence from a reservation object to store in the incoming
drm_plane_state, without doing the whole RCU dance.  Since each driver
will need to do this, lets make a helper.

v2: rename to _rcu instead of _unlocked to be more consistent

Signed-off-by: Rob Clark <robdclark@gmail.com>
---
Note that danvet also suggested addition of headerdoc.  But it was a
trap!  In the process I discovered that some files were missing from
the DocBook tmpl, some fixup needed, and complete lack of reservation
related headerdoc.

So the patchset to fixup all that will follow in a few minutes.  But
danvet's punishment for tricking me into fixing that all up is that
the headerdoc he wants applies on top of the patch that I want ;-)

 include/linux/reservation.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Maarten Lankhorst April 4, 2016, 9:02 a.m. UTC | #1
Op 31-03-16 om 22:23 schreef Rob Clark:
> In the atomic modesetting path, each driver simply wants to grab a ref
> to the exclusive fence from a reservation object to store in the incoming
> drm_plane_state, without doing the whole RCU dance.  Since each driver
> will need to do this, lets make a helper.
>
> v2: rename to _rcu instead of _unlocked to be more consistent
>
Forgot to update commit message. :)
Rob Clark April 4, 2016, 6:11 p.m. UTC | #2
On Mon, Apr 4, 2016 at 5:02 AM, Maarten Lankhorst
<maarten.lankhorst@linux.intel.com> wrote:
> Op 31-03-16 om 22:23 schreef Rob Clark:
>> In the atomic modesetting path, each driver simply wants to grab a ref
>> to the exclusive fence from a reservation object to store in the incoming
>> drm_plane_state, without doing the whole RCU dance.  Since each driver
>> will need to do this, lets make a helper.
>>
>> v2: rename to _rcu instead of _unlocked to be more consistent
>>
> Forgot to update commit message. :)

oh, whoops.. Sumit, want me to resend or can you just fixup the commit
msg when you apply the patch?

BR,
-R
Sumit Semwal April 5, 2016, 10:54 a.m. UTC | #3
On 4 April 2016 at 23:41, Rob Clark <robdclark@gmail.com> wrote:
> On Mon, Apr 4, 2016 at 5:02 AM, Maarten Lankhorst
> <maarten.lankhorst@linux.intel.com> wrote:
>> Op 31-03-16 om 22:23 schreef Rob Clark:
>>> In the atomic modesetting path, each driver simply wants to grab a ref
>>> to the exclusive fence from a reservation object to store in the incoming
>>> drm_plane_state, without doing the whole RCU dance.  Since each driver
>>> will need to do this, lets make a helper.
>>>
>>> v2: rename to _rcu instead of _unlocked to be more consistent
>>>
>> Forgot to update commit message. :)
>
> oh, whoops.. Sumit, want me to resend or can you just fixup the commit
> msg when you apply the patch?
>

No worries Rob, I can take care while applying.
> BR,
> -R
diff mbox

Patch

diff --git a/include/linux/reservation.h b/include/linux/reservation.h
index 5a0b64c..49d0576 100644
--- a/include/linux/reservation.h
+++ b/include/linux/reservation.h
@@ -120,6 +120,24 @@  reservation_object_get_excl(struct reservation_object *obj)
 					 reservation_object_held(obj));
 }
 
+static inline struct fence *
+reservation_object_get_excl_rcu(struct reservation_object *obj)
+{
+	struct fence *fence;
+	unsigned seq;
+retry:
+	seq = read_seqcount_begin(&obj->seq);
+	rcu_read_lock();
+	fence = rcu_dereference(obj->fence_excl);
+	if (read_seqcount_retry(&obj->seq, seq)) {
+		rcu_read_unlock();
+		goto retry;
+	}
+	fence = fence_get(fence);
+	rcu_read_unlock();
+	return fence;
+}
+
 int reservation_object_reserve_shared(struct reservation_object *obj);
 void reservation_object_add_shared_fence(struct reservation_object *obj,
 					 struct fence *fence);