diff options
author | Christian König <christian.koenig@amd.com> | 2019-07-31 09:41:50 +0200 |
---|---|---|
committer | Christian König <christian.koenig@amd.com> | 2019-08-05 09:28:43 +0200 |
commit | 0dbd555a011c2d096a7b7e40c83c5776a7df367c (patch) | |
tree | 4399a2204760664daad1c91896aa3f8217744d43 /include | |
parent | 05103ea9a3159b9bb7004e9c0693948d4d6124f9 (diff) | |
download | linux-0dbd555a011c2d096a7b7e40c83c5776a7df367c.tar.bz2 |
dma-buf: add more reservation object locking wrappers
Complete the abstraction of the ww_mutex inside the reservation object.
This allows us to add more handling and debugging to the reservation
object in the future.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/320761/
Diffstat (limited to 'include')
-rw-r--r-- | include/drm/ttm/ttm_bo_driver.h | 6 | ||||
-rw-r--r-- | include/linux/reservation.h | 57 |
2 files changed, 60 insertions, 3 deletions
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index c9b8ba492f24..0e6a111bed0b 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -745,10 +745,10 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo, WARN_ON(!kref_read(&bo->kref)); if (interruptible) - ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock, - ticket); + ret = reservation_object_lock_slow_interruptible(bo->resv, + ticket); else - ww_mutex_lock_slow(&bo->resv->lock, ticket); + reservation_object_lock_slow(bo->resv, ticket); if (likely(ret == 0)) ttm_bo_del_sub_from_lru(bo); diff --git a/include/linux/reservation.h b/include/linux/reservation.h index 02866ee54d67..56b782fec49b 100644 --- a/include/linux/reservation.h +++ b/include/linux/reservation.h @@ -140,6 +140,38 @@ reservation_object_lock_interruptible(struct reservation_object *obj, return ww_mutex_lock_interruptible(&obj->lock, ctx); } +/** + * reservation_object_lock_slow - slowpath lock the reservation object + * @obj: the reservation object + * @ctx: the locking context + * + * Acquires the reservation object after a die case. This function + * will sleep until the lock becomes available. See reservation_object_lock() as + * well. + */ +static inline void +reservation_object_lock_slow(struct reservation_object *obj, + struct ww_acquire_ctx *ctx) +{ + ww_mutex_lock_slow(&obj->lock, ctx); +} + +/** + * reservation_object_lock_slow_interruptible - slowpath lock the reservation + * object, interruptible + * @obj: the reservation object + * @ctx: the locking context + * + * Acquires the reservation object interruptible after a die case. This function + * will sleep until the lock becomes available. See + * reservation_object_lock_interruptible() as well. + */ +static inline int +reservation_object_lock_slow_interruptible(struct reservation_object *obj, + struct ww_acquire_ctx *ctx) +{ + return ww_mutex_lock_slow_interruptible(&obj->lock, ctx); +} /** * reservation_object_trylock - trylock the reservation object @@ -162,6 +194,31 @@ reservation_object_trylock(struct reservation_object *obj) } /** + * reservation_object_is_locked - is the reservation object locked + * @obj: the reservation object + * + * Returns true if the mutex is locked, false if unlocked. + */ +static inline bool +reservation_object_is_locked(struct reservation_object *obj) +{ + return ww_mutex_is_locked(&obj->lock); +} + +/** + * reservation_object_locking_ctx - returns the context used to lock the object + * @obj: the reservation object + * + * Returns the context used to lock a reservation object or NULL if no context + * was used or the object is not locked at all. + */ +static inline struct ww_acquire_ctx * +reservation_object_locking_ctx(struct reservation_object *obj) +{ + return READ_ONCE(obj->lock.ctx); +} + +/** * reservation_object_unlock - unlock the reservation object * @obj: the reservation object * |