summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2019-07-31 09:41:50 +0200
committerChristian König <christian.koenig@amd.com>2019-08-05 09:28:43 +0200
commit0dbd555a011c2d096a7b7e40c83c5776a7df367c (patch)
tree4399a2204760664daad1c91896aa3f8217744d43 /include/linux
parent05103ea9a3159b9bb7004e9c0693948d4d6124f9 (diff)
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/linux')
-rw-r--r--include/linux/reservation.h57
1 files changed, 57 insertions, 0 deletions
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
*