[1/9] dma-buf: fix dma_fence_array_signaled
diff mbox series

Message ID 20190826145731.1725-2-christian.koenig@amd.com
State New
Headers show
Series
  • [1/9] dma-buf: fix dma_fence_array_signaled
Related show

Commit Message

Christian König Aug. 26, 2019, 2:57 p.m. UTC
The function is supposed to give a hint even if signaling is not enabled.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/dma-buf/dma-fence-array.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Chris Wilson Aug. 27, 2019, 11:44 a.m. UTC | #1
Quoting Christian König (2019-08-26 15:57:23)
> The function is supposed to give a hint even if signaling is not enabled.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/dma-buf/dma-fence-array.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> index d3fbd950be94..52068ee5eb35 100644
> --- a/drivers/dma-buf/dma-fence-array.c
> +++ b/drivers/dma-buf/dma-fence-array.c
> @@ -103,8 +103,18 @@ static bool dma_fence_array_enable_signaling(struct dma_fence *fence)
>  static bool dma_fence_array_signaled(struct dma_fence *fence)
>  {
>         struct dma_fence_array *array = to_dma_fence_array(fence);
> +       int i, num_pending;
>  
> -       return atomic_read(&array->num_pending) <= 0;
> +       num_pending = atomic_read(&array->num_pending);
> +       if (test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &fence->flags))
> +               return num_pending <= 0;
> +
> +       for (i = 0; i < array->num_fences; ++i)
> +               if (dma_fence_is_signaled(array->fences[i]) &&
> +                   --num_pending == 0)
> +                       return true;

num_fences may be 0 (it's not rejected in construction and works
currently as a simple always-signaled stub).

	if (!test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &fence->flags)) {
		for (i = 0; i < array->num_fences; ++i)
			if (dma_fence_is_signaled(array->fences[i]) &&
			    --num_pending == 0)
				break;
	}

	return num_pending <= 0;

Patch
diff mbox series

diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
index d3fbd950be94..52068ee5eb35 100644
--- a/drivers/dma-buf/dma-fence-array.c
+++ b/drivers/dma-buf/dma-fence-array.c
@@ -103,8 +103,18 @@  static bool dma_fence_array_enable_signaling(struct dma_fence *fence)
 static bool dma_fence_array_signaled(struct dma_fence *fence)
 {
 	struct dma_fence_array *array = to_dma_fence_array(fence);
+	int i, num_pending;
 
-	return atomic_read(&array->num_pending) <= 0;
+	num_pending = atomic_read(&array->num_pending);
+	if (test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &fence->flags))
+		return num_pending <= 0;
+
+	for (i = 0; i < array->num_fences; ++i)
+		if (dma_fence_is_signaled(array->fences[i]) &&
+		    --num_pending == 0)
+			return true;
+
+	return false;
 }
 
 static void dma_fence_array_release(struct dma_fence *fence)