]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
dma-buf: add reservation_object_lock_interruptible()
authorChristian König <ckoenig.leichtzumerken@gmail.com>
Thu, 9 Nov 2017 08:59:05 +0000 (09:59 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 13 Nov 2017 19:50:49 +0000 (14:50 -0500)
That's the only wrapper function missing and necessary to cleanup TTM.

Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171109085909.1653-3-christian.koenig@amd.com
include/linux/reservation.h

index 21fc84d82d41572db2216c4baf07b32c45044ff8..02166e815afb904c0396159c8c9d556c370f1e9d 100644 (file)
@@ -166,6 +166,29 @@ reservation_object_lock(struct reservation_object *obj,
        return ww_mutex_lock(&obj->lock, ctx);
 }
 
+/**
+ * reservation_object_lock_interruptible - lock the reservation object
+ * @obj: the reservation object
+ * @ctx: the locking context
+ *
+ * Locks the reservation object interruptible 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.
+ *
+ * As the reservation object may be locked by multiple parties in an
+ * undefined order, a #ww_acquire_ctx is passed to unwind if a cycle
+ * is detected. See ww_mutex_lock() and ww_acquire_init(). A reservation
+ * object may be locked by itself by passing NULL as @ctx.
+ */
+static inline int
+reservation_object_lock_interruptible(struct reservation_object *obj,
+                                     struct ww_acquire_ctx *ctx)
+{
+       return ww_mutex_lock_interruptible(&obj->lock, ctx);
+}
+
+
 /**
  * reservation_object_trylock - trylock the reservation object
  * @obj: the reservation object