diff mbox series

[08/15] dma-buf: add support for polling on user fences

Message ID 20220502163722.3957-9-christian.koenig@amd.com
State New
Headers show
Series [01/15] dma-buf: rename DMA_FENCE_FLAG_USER_BITS to _DEVICE | expand

Commit Message

Christian König May 2, 2022, 4:37 p.m. UTC
Just also wait for user fences to signal when we wait for write fences.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/dma-buf/dma-buf.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 79795857be3e..5558f4e555f8 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -225,6 +225,16 @@  static bool dma_buf_poll_add_cb(struct dma_resv *resv, bool write,
 		dma_fence_put(fence);
 	}
 
+	if (!write)
+		return false;
+
+	dma_resv_for_each_fence(&cursor, resv, DMA_RESV_USAGE_USER, fence) {
+		dma_fence_get(fence);
+		r = dma_fence_add_callback(fence, &dcb->cb, dma_buf_poll_cb);
+		if (!r)
+			return true;
+		dma_fence_put(fence);
+	}
 	return false;
 }