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/
This commit is contained in:
Christian König
2019-07-31 09:41:50 +02:00
parent 05103ea9a3
commit 0dbd555a01
16 changed files with 100 additions and 40 deletions

View File

@@ -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
@@ -161,6 +193,31 @@ reservation_object_trylock(struct reservation_object *obj)
return ww_mutex_trylock(&obj->lock);
}
/**
* 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