[03/28] dma-buf: make fence mandatory for dma_resv_add_excl_fence v2

Message ID 20211129120659.1815-4-christian.koenig@amd.com (mailing list archive)
State Not Applicable, archived
Headers
Series [01/28] drm/i915: Remove dma_resv_prune |

Commit Message

Christian König Nov. 29, 2021, 12:06 p.m. UTC
  Calling dma_resv_add_excl_fence() with the fence as NULL and expecting
that that this frees up the fences is simply abuse of the internals of
the dma_resv object.

v2: drop the fence pruning completely.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/dma-buf/dma-resv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Daniel Vetter Nov. 30, 2021, 9:03 a.m. UTC | #1
On Mon, Nov 29, 2021 at 01:06:34PM +0100, Christian König wrote:
> Calling dma_resv_add_excl_fence() with the fence as NULL and expecting
> that that this frees up the fences is simply abuse of the internals of
> the dma_resv object.
> 
> v2: drop the fence pruning completely.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>

Cursory look says you got them all, and it's definitely the right thing to
do.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/dma-buf/dma-resv.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
> index ff3c0558b3b8..4deea75c0b9c 100644
> --- a/drivers/dma-buf/dma-resv.c
> +++ b/drivers/dma-buf/dma-resv.c
> @@ -305,8 +305,7 @@ void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence)
>  	if (old)
>  		i = old->shared_count;
>  
> -	if (fence)
> -		dma_fence_get(fence);
> +	dma_fence_get(fence);
>  
>  	write_seqcount_begin(&obj->seq);
>  	/* write_seqcount_begin provides the necessary memory barrier */
> -- 
> 2.25.1
>
  

Patch

diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
index ff3c0558b3b8..4deea75c0b9c 100644
--- a/drivers/dma-buf/dma-resv.c
+++ b/drivers/dma-buf/dma-resv.c
@@ -305,8 +305,7 @@  void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence)
 	if (old)
 		i = old->shared_count;
 
-	if (fence)
-		dma_fence_get(fence);
+	dma_fence_get(fence);
 
 	write_seqcount_begin(&obj->seq);
 	/* write_seqcount_begin provides the necessary memory barrier */