]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
dma-buf: cleanup dma-resv shared fence debugging a bit v2
authorChristian König <christian.koenig@amd.com>
Thu, 6 May 2021 12:16:01 +0000 (14:16 +0200)
committerChristian König <christian.koenig@amd.com>
Fri, 4 Jun 2021 12:04:59 +0000 (14:04 +0200)
Make that a function instead of inline.

v2: improve the kerneldoc wording as suggested by Daniel

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210602111714.212426-3-christian.koenig@amd.com
drivers/dma-buf/dma-resv.c
include/linux/dma-resv.h

index 87f5d82d992ac486065356c651917de2d47d9a25..3964df43850561c49b80c1752bc6d6f8681244be 100644 (file)
@@ -208,6 +208,26 @@ int dma_resv_reserve_shared(struct dma_resv *obj, unsigned int num_fences)
 }
 EXPORT_SYMBOL(dma_resv_reserve_shared);
 
+#ifdef CONFIG_DEBUG_MUTEXES
+/**
+ * dma_resv_reset_shared_max - reset shared fences for debugging
+ * @obj: the dma_resv object to reset
+ *
+ * Reset the number of pre-reserved shared slots to test that drivers do
+ * correct slot allocation using dma_resv_reserve_shared(). See also
+ * &dma_resv_list.shared_max.
+ */
+void dma_resv_reset_shared_max(struct dma_resv *obj)
+{
+       /* Test shared fence slot reservation */
+       if (rcu_access_pointer(obj->fence)) {
+               struct dma_resv_list *fence = dma_resv_get_list(obj);
+
+               fence->shared_max = fence->shared_count;
+       }
+}
+#endif
+
 /**
  * dma_resv_add_shared_fence - Add a fence to a shared slot
  * @obj: the reservation object
index d44a77e8a7e34a3333e61a714028beee76fa297b..f32a3d176513dcbfe43bd26d9d605998097d4a12 100644 (file)
@@ -92,6 +92,12 @@ static inline struct dma_resv_list *dma_resv_get_list(struct dma_resv *obj)
                                         dma_resv_held(obj));
 }
 
+#ifdef CONFIG_DEBUG_MUTEXES
+void dma_resv_reset_shared_max(struct dma_resv *obj);
+#else
+static inline void dma_resv_reset_shared_max(struct dma_resv *obj) {}
+#endif
+
 /**
  * dma_resv_lock - lock the reservation object
  * @obj: the reservation object
@@ -215,14 +221,7 @@ static inline struct ww_acquire_ctx *dma_resv_locking_ctx(struct dma_resv *obj)
  */
 static inline void dma_resv_unlock(struct dma_resv *obj)
 {
-#ifdef CONFIG_DEBUG_MUTEXES
-       /* Test shared fence slot reservation */
-       if (rcu_access_pointer(obj->fence)) {
-               struct dma_resv_list *fence = dma_resv_get_list(obj);
-
-               fence->shared_max = fence->shared_count;
-       }
-#endif
+       dma_resv_reset_shared_max(obj);
        ww_mutex_unlock(&obj->lock);
 }