summaryrefslogtreecommitdiffstats
path: root/include/linux/reservation.h
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-11-15 15:46:42 +0000
committerDaniel Vetter <daniel.vetter@ffwll.ch>2016-12-12 07:54:43 +0100
commit122020af856181c24fe45903e43e3cc987c175f7 (patch)
tree1051070c15768f36ca3c45442f40e0bbfceceb91 /include/linux/reservation.h
parent7da0e124af76c79927f0d7abcc58d58d0fd7072f (diff)
downloadlinux-stable-122020af856181c24fe45903e43e3cc987c175f7.tar.gz
linux-stable-122020af856181c24fe45903e43e3cc987c175f7.tar.bz2
linux-stable-122020af856181c24fe45903e43e3cc987c175f7.zip
dma-buf: Provide wrappers for reservation's lock
Joonas complained that writing ww_mutex_lock(&resv->lock, ctx) was too intrusive compared to reservation_object_lock(resv, ctx); 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> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20161115154642.31850-1-chris@chris-wilson.co.uk
Diffstat (limited to 'include/linux/reservation.h')
-rw-r--r--include/linux/reservation.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/linux/reservation.h b/include/linux/reservation.h
index d9706a6f5ae2..2b5a4679daea 100644
--- a/include/linux/reservation.h
+++ b/include/linux/reservation.h
@@ -145,6 +145,40 @@ reservation_object_get_list(struct reservation_object *obj)
}
/**
+ * reservation_object_lock - lock the reservation object
+ * @obj: the reservation object
+ * @ctx: the locking context
+ *
+ * Locks the reservation object 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(struct reservation_object *obj,
+ struct ww_acquire_ctx *ctx)
+{
+ return ww_mutex_lock(&obj->lock, ctx);
+}
+
+/**
+ * reservation_object_unlock - unlock the reservation object
+ * @obj: the reservation object
+ *
+ * Unlocks the reservation object following exclusive access.
+ */
+static inline void
+reservation_object_unlock(struct reservation_object *obj)
+{
+ ww_mutex_unlock(&obj->lock);
+}
+
+/**
* reservation_object_get_excl - get the reservation object's
* exclusive fence, with update-side lock held
* @obj: the reservation object