From: Chris Wilson Date: Tue, 21 Feb 2017 09:30:00 +0000 (+0000) Subject: dma-buf/reservation: Wrap ww_mutex_trylock X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2955b73def6712b693fc7ad82b34b3831faaa146;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git dma-buf/reservation: Wrap ww_mutex_trylock 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 Cc: Sumit Semwal Cc: Joonas Lahtinen Cc: Daniel Vetter [danvet: Add __must_check Joonas wants.] Reviewed-by: Joonas Lahtinen Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/20170221093000.22802-1-chris@chris-wilson.co.uk --- diff --git a/include/linux/reservation.h b/include/linux/reservation.h index 2b5a4679daea..156cfd330b66 100644 --- a/include/linux/reservation.h +++ b/include/linux/reservation.h @@ -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