linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma-buf: cleanup dma_fence_chain_walk
@ 2022-05-18  8:54 Christian König
  2022-05-25 15:18 ` Daniel Vetter
  0 siblings, 1 reply; 2+ messages in thread
From: Christian König @ 2022-05-18  8:54 UTC (permalink / raw)
  To: sumit.semwal, linux-media, dri-devel, linaro-mm-sig; +Cc: Christian König

Use unrcu_pointer() instead of the manual cast.

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

diff --git a/drivers/dma-buf/dma-fence-chain.c b/drivers/dma-buf/dma-fence-chain.c
index 06f8ef97c6e8..a0d920576ba6 100644
--- a/drivers/dma-buf/dma-fence-chain.c
+++ b/drivers/dma-buf/dma-fence-chain.c
@@ -62,8 +62,8 @@ struct dma_fence *dma_fence_chain_walk(struct dma_fence *fence)
 			replacement = NULL;
 		}
 
-		tmp = cmpxchg((struct dma_fence __force **)&chain->prev,
-			      prev, replacement);
+		tmp = unrcu_pointer(cmpxchg(&chain->prev, RCU_INITIALIZER(prev),
+					     RCU_INITIALIZER(replacement)));
 		if (tmp == prev)
 			dma_fence_put(tmp);
 		else
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dma-buf: cleanup dma_fence_chain_walk
  2022-05-18  8:54 [PATCH] dma-buf: cleanup dma_fence_chain_walk Christian König
@ 2022-05-25 15:18 ` Daniel Vetter
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Vetter @ 2022-05-25 15:18 UTC (permalink / raw)
  To: Christian König
  Cc: sumit.semwal, linux-media, dri-devel, linaro-mm-sig,
	Christian König

On Wed, May 18, 2022 at 10:54:46AM +0200, Christian König wrote:
> Use unrcu_pointer() instead of the manual cast.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>

TIL about unrcu_pointer, and also that entire code here freaks me out. But
at least this seems more with what other users of similar xchg and cmpxchg
tricks are doing, so that's nice.

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

> ---
>  drivers/dma-buf/dma-fence-chain.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma-buf/dma-fence-chain.c b/drivers/dma-buf/dma-fence-chain.c
> index 06f8ef97c6e8..a0d920576ba6 100644
> --- a/drivers/dma-buf/dma-fence-chain.c
> +++ b/drivers/dma-buf/dma-fence-chain.c
> @@ -62,8 +62,8 @@ struct dma_fence *dma_fence_chain_walk(struct dma_fence *fence)
>  			replacement = NULL;
>  		}
>  
> -		tmp = cmpxchg((struct dma_fence __force **)&chain->prev,
> -			      prev, replacement);
> +		tmp = unrcu_pointer(cmpxchg(&chain->prev, RCU_INITIALIZER(prev),
> +					     RCU_INITIALIZER(replacement)));
>  		if (tmp == prev)
>  			dma_fence_put(tmp);
>  		else
> -- 
> 2.25.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-25 15:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18  8:54 [PATCH] dma-buf: cleanup dma_fence_chain_walk Christian König
2022-05-25 15:18 ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).