Re: [PATCH v4 4/4] dmaengine: wait for RCU readers before releasing dma_device

Logan Gunthorpe <[email protected]>
Newsgroups org.kernel.vger.dmaengine,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>

On 2026-08-17 21:43, Shivank Garg wrote:
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index d075051dd187..604c9af19936 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -429,6 +429,12 @@ static void dma_device_release(struct kref *ref)
>  	list_del_rcu(&device->global_node);
>  	dma_channel_rebalance();
>  
> +	/*
> +	 * Wait for RCU readers (e.g. dma_issue_pending_all()) that may still
> +	 * be traversing dma_device_list before the device is freed.
> +	 */
> +	synchronize_rcu();
> +
>  	if (device->device_release)
>  		device->device_release(device);
>  }
> 

A couple minor points on this:

1. I think the comment, as is, isn't useful. It's pretty clear the
synchronize_rcu() call is paired with the list_del_rcu() call above it.

2. The new synchronize_rcu() call will delay for a grace period with the
dma_list_mutex lock held. Is that okay? It might be, but if so, it could
use a note in the commit message.

Besides that, these are minor points and the patch does fix a real issue so:

Reviewed-by: Logan Gunthorpe <[email protected]>

Thanks,

Logan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.