[PATCH 06/15] dma-buf: add user fence support to dma_fence_merge()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just make sure that we forward the user fence status to the output
whenever any of the inputs are an user fence.

Signed-off-by: Christian König <christian.koenig@xxxxxxx>
---
 drivers/dma-buf/dma-fence-unwrap.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/dma-buf/dma-fence-unwrap.c b/drivers/dma-buf/dma-fence-unwrap.c
index 87ee2efced10..dd3c43aba8f1 100644
--- a/drivers/dma-buf/dma-fence-unwrap.c
+++ b/drivers/dma-buf/dma-fence-unwrap.c
@@ -66,17 +66,19 @@ struct dma_fence *__dma_fence_merge(unsigned int num_fences,
 {
 	struct dma_fence_array *result;
 	struct dma_fence *tmp, **array;
+	bool user_fence = false;
 	unsigned int i, count;
 
 	count = 0;
 	for (i = 0; i < num_fences; ++i) {
+		user_fence |= test_bit(DMA_FENCE_FLAG_USER, &fences[i]->flags);
 		dma_fence_unwrap_for_each(tmp, &iter[i], fences[i])
 			if (!dma_fence_is_signaled(tmp))
 				++count;
 	}
 
 	if (count == 0)
-		return dma_fence_get_stub(false);
+		return dma_fence_get_stub(user_fence);
 
 	if (count > INT_MAX)
 		return NULL;
@@ -129,11 +131,12 @@ struct dma_fence *__dma_fence_merge(unsigned int num_fences,
 	} while (tmp);
 
 	if (count == 0) {
-		tmp = dma_fence_get_stub(false);
+		tmp = dma_fence_get_stub(user_fence);
 		goto return_tmp;
 	}
 
-	if (count == 1) {
+	if (count == 1 &&
+	    test_bit(DMA_FENCE_FLAG_USER, &array[0]->flags) == user_fence) {
 		tmp = array[0];
 		goto return_tmp;
 	}
@@ -145,6 +148,8 @@ struct dma_fence *__dma_fence_merge(unsigned int num_fences,
 		tmp = NULL;
 		goto return_tmp;
 	}
+	if (user_fence)
+		set_bit(DMA_FENCE_FLAG_USER, &result->base.flags);
 	return &result->base;
 
 return_tmp:
-- 
2.25.1




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux