Skip to content

Commit

Permalink
dma-buf/reservation: Wrap ww_mutex_trylock
Browse files Browse the repository at this point in the history
In a similar fashion to reservation_object_lock() and
reservation_object_unlock(), ww_mutex_trylock is also useful and so is
worth wrapping for consistency.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
[danvet: Add __must_check Joonas wants.]
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20170221093000.22802-1-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson authored and Daniel Vetter committed Feb 26, 2017
1 parent 5f15257 commit 2955b73
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions include/linux/reservation.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,26 @@ reservation_object_lock(struct reservation_object *obj,
return ww_mutex_lock(&obj->lock, ctx);
}

/**
* reservation_object_trylock - trylock the reservation object
* @obj: the reservation object
*
* Tries to lock the reservation object for exclusive access and modification.
* Note, that the lock is only against other writers, readers will run
* concurrently with a writer under RCU. The seqlock is used to notify readers
* if they overlap with a writer.
*
* Also note that since no context is provided, no deadlock protection is
* possible.
*
* Returns true if the lock was acquired, false otherwise.
*/
static inline bool __must_check
reservation_object_trylock(struct reservation_object *obj)
{
return ww_mutex_trylock(&obj->lock);
}

/**
* reservation_object_unlock - unlock the reservation object
* @obj: the reservation object
Expand Down

0 comments on commit 2955b73

Please sign in to comment.