3535#include <linux/reservation.h>
3636#include <linux/export.h>
3737
38+ /**
39+ * DOC: Reservation Object Overview
40+ *
41+ * The reservation object provides a mechanism to manage shared and
42+ * exclusive fences associated with a buffer. A reservation object
43+ * can have attached one exclusive fence (normally associated with
44+ * write operations) or N shared fences (read operations). The RCU
45+ * mechanism is used to protect read access to fences from locked
46+ * write-side updates.
47+ */
48+
3849DEFINE_WW_CLASS (reservation_ww_class );
3950EXPORT_SYMBOL (reservation_ww_class );
4051
@@ -43,9 +54,17 @@ EXPORT_SYMBOL(reservation_seqcount_class);
4354
4455const char reservation_seqcount_string [] = "reservation_seqcount" ;
4556EXPORT_SYMBOL (reservation_seqcount_string );
46- /*
47- * Reserve space to add a shared fence to a reservation_object,
48- * must be called with obj->lock held.
57+
58+ /**
59+ * reservation_object_reserve_shared - Reserve space to add a shared
60+ * fence to a reservation_object.
61+ * @obj: reservation object
62+ *
63+ * Should be called before reservation_object_add_shared_fence(). Must
64+ * be called with obj->lock held.
65+ *
66+ * RETURNS
67+ * Zero for success, or -errno
4968 */
5069int reservation_object_reserve_shared (struct reservation_object * obj )
5170{
@@ -180,7 +199,11 @@ reservation_object_add_shared_replace(struct reservation_object *obj,
180199 fence_put (old_fence );
181200}
182201
183- /*
202+ /**
203+ * reservation_object_add_shared_fence - Add a fence to a shared slot
204+ * @obj: the reservation object
205+ * @fence: the shared fence to add
206+ *
184207 * Add a fence to a shared slot, obj->lock must be held, and
185208 * reservation_object_reserve_shared_fence has been called.
186209 */
@@ -200,6 +223,13 @@ void reservation_object_add_shared_fence(struct reservation_object *obj,
200223}
201224EXPORT_SYMBOL (reservation_object_add_shared_fence );
202225
226+ /**
227+ * reservation_object_add_excl_fence - Add an exclusive fence.
228+ * @obj: the reservation object
229+ * @fence: the shared fence to add
230+ *
231+ * Add a fence to the exclusive slot. The obj->lock must be held.
232+ */
203233void reservation_object_add_excl_fence (struct reservation_object * obj ,
204234 struct fence * fence )
205235{
@@ -233,6 +263,18 @@ void reservation_object_add_excl_fence(struct reservation_object *obj,
233263}
234264EXPORT_SYMBOL (reservation_object_add_excl_fence );
235265
266+ /**
267+ * reservation_object_get_fences_rcu - Get an object's shared and exclusive
268+ * fences without update side lock held
269+ * @obj: the reservation object
270+ * @pfence_excl: the returned exclusive fence (or NULL)
271+ * @pshared_count: the number of shared fences returned
272+ * @pshared: the array of shared fence ptrs returned (array is krealloc'd to
273+ * the required size, and must be freed by caller)
274+ *
275+ * RETURNS
276+ * Zero or -errno
277+ */
236278int reservation_object_get_fences_rcu (struct reservation_object * obj ,
237279 struct fence * * pfence_excl ,
238280 unsigned * pshared_count ,
@@ -319,6 +361,18 @@ int reservation_object_get_fences_rcu(struct reservation_object *obj,
319361}
320362EXPORT_SYMBOL_GPL (reservation_object_get_fences_rcu );
321363
364+ /**
365+ * reservation_object_wait_timeout_rcu - Wait on reservation's objects
366+ * shared and/or exclusive fences.
367+ * @obj: the reservation object
368+ * @wait_all: if true, wait on all fences, else wait on just exclusive fence
369+ * @intr: if true, do interruptible wait
370+ * @timeout: timeout value in jiffies or zero to return immediately
371+ *
372+ * RETURNS
373+ * Returns -ERESTARTSYS if interrupted, 0 if the wait timed out, or
374+ * greater than zer on success.
375+ */
322376long reservation_object_wait_timeout_rcu (struct reservation_object * obj ,
323377 bool wait_all , bool intr ,
324378 unsigned long timeout )
@@ -416,6 +470,16 @@ reservation_object_test_signaled_single(struct fence *passed_fence)
416470 return ret ;
417471}
418472
473+ /**
474+ * reservation_object_test_signaled_rcu - Test if a reservation object's
475+ * fences have been signaled.
476+ * @obj: the reservation object
477+ * @test_all: if true, test all fences, otherwise only test the exclusive
478+ * fence
479+ *
480+ * RETURNS
481+ * true if all fences signaled, else false
482+ */
419483bool reservation_object_test_signaled_rcu (struct reservation_object * obj ,
420484 bool test_all )
421485{
0 commit comments