[PATCH 2/2] dma-resv: Fix dma_resv_held

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Fri Feb 25 17:41:18 UTC 2022


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Avoid false positives if lock state is unknown.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 include/linux/dma-resv.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
index afdfdfac729f..f475814c0d7a 100644
--- a/include/linux/dma-resv.h
+++ b/include/linux/dma-resv.h
@@ -278,7 +278,8 @@ static inline bool dma_resv_iter_is_restarted(struct dma_resv_iter *cursor)
 	     fence = dma_resv_iter_first(cursor); fence;	\
 	     fence = dma_resv_iter_next(cursor))
 
-#define dma_resv_held(obj) lockdep_is_held(&(obj)->lock.base)
+#define dma_resv_held(obj) \
+	(lockdep_is_held(&(obj)->lock.base) == LOCK_STATE_HELD)
 #define dma_resv_assert_held(obj) lockdep_assert_held(&(obj)->lock.base)
 
 #ifdef CONFIG_DEBUG_MUTEXES
-- 
2.32.0



More information about the dri-devel mailing list