Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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

authored by

Chris Wilson and committed by
Daniel Vetter
2955b73d 5f152576

+20
+20
include/linux/reservation.h
··· 167 167 } 168 168 169 169 /** 170 + * reservation_object_trylock - trylock the reservation object 171 + * @obj: the reservation object 172 + * 173 + * Tries to lock the reservation object for exclusive access and modification. 174 + * Note, that the lock is only against other writers, readers will run 175 + * concurrently with a writer under RCU. The seqlock is used to notify readers 176 + * if they overlap with a writer. 177 + * 178 + * Also note that since no context is provided, no deadlock protection is 179 + * possible. 180 + * 181 + * Returns true if the lock was acquired, false otherwise. 182 + */ 183 + static inline bool __must_check 184 + reservation_object_trylock(struct reservation_object *obj) 185 + { 186 + return ww_mutex_trylock(&obj->lock); 187 + } 188 + 189 + /** 170 190 * reservation_object_unlock - unlock the reservation object 171 191 * @obj: the reservation object 172 192 *