Skip to contentSkip to conversation

dma-buf: To check DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT status on debug

RFC PATCH In review Arvind Yadav 2 participants 2 messages Aug 4, 2022 – Aug 8, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 dma-buf: To check DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT status on debug

If core DMA-buf framework forgets to call dma_fence_enable_signaling() before calling the dma_fence_is_signaled(). To handle this scenario on debug kernel the DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT needs to be checked before checking the actual signaling status.

---
 include/linux/dma-fence.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/dma-fence.h +4 -0
index 775cdc0b4f24..7c95c8d5e5f5 100644
@@ -428,6 +428,10 @@ dma_fence_is_signaled_locked(struct dma_fence *fence)
 static inline bool
 dma_fence_is_signaled(struct dma_fence *fence)
 {
+#ifdef CONFIG_DEBUG_FS
+	if (test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &fence->flags))
+		return true;
+#endif
 	if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
 		return true;
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Am 04.08.22 um 14:19 schrieb Arvind Yadav:

Quoted 15 lines

If core DMA-buf framework forgets to call dma_fence_enable_signaling() before calling the dma_fence_is_signaled(). To handle this scenario on debug kernel the DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT needs to be checked before checking the actual signaling status.

---
  include/linux/dma-fence.h | 4 ++++
  1 file changed, 4 insertions(+)
include/linux/dma-fence.h +0 -0
index 775cdc0b4f24..7c95c8d5e5f5 100644

include/linux/dma-fence.h dma_fence_is_signaled_locked(struct dma_fence *fence) · line 433

Quoted 6 lines
include/linux/dma-fence.h +3 -0
@@ -428,6 +428,10 @@ dma_fence_is_signaled_locked(struct dma_fence *fence)
  static inline bool
  dma_fence_is_signaled(struct dma_fence *fence)
  {
+#ifdef CONFIG_DEBUG_FS
+	if (test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &fence->flags))
+		return true;

The logic is just inverted. The test should be !test_bit(...) return false;

And please give that some testing as well.

Regards,
Christian.

Quoted 4 lines
include/linux/dma-fence.h +1 -0
+#endif
  	if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
  		return true;