[PATCH v5 1/7] dmaengine: fsl-edma: unregister channels before vchan cleanup

Frank Li Frank.li at oss.nxp.com
Wed Nov 11 09:27:31 PST 2026


On Wed, Nov 11, 2026 at 09:47:29PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan at nxp.com>
>
> Since commit 4035726a6b72 ("dmaengine: fsl-edma: Use managed API
> dmaenginem_async_device_register()"), dma_async_device_unregister() runs
> as a devres action after fsl_edma_remove(). However, fsl_edma_remove()
> still calls fsl_edma_cleanup_vchan() first, which removes every channel
> from dma_dev.channels.  When the devres action later runs,
> dma_async_device_unregister() sees an empty channel list and never
> unregisters the channel devices. They remain visible in /sys/class/dma.
>
> Keep the vchan cleanup, but register it as a devres action before
> dmaenginem_async_device_register(). Devres actions run in reverse
> order, so the DMA channels are unregistered first and the vchan list is
> cleaned up afterwards. Remove the premature cleanup call from
> fsl_edma_remove().
>
> Fixes: 4035726a6b72 ("dmaengine: fsl-edma: Use managed API dmaenginem_async_device_register()")
> Signed-off-by: Peng Fan <peng.fan at nxp.com>
> ---

Reviewed-by: Frank Li <Frank.Li at nxp.com>

>  drivers/dma/fsl-edma-main.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/fsl-edma-main.c b/drivers/dma/fsl-edma-main.c
> index da5139911488..7f82dcb7831d 100644
> --- a/drivers/dma/fsl-edma-main.c
> +++ b/drivers/dma/fsl-edma-main.c
> @@ -31,6 +31,11 @@ static void fsl_edma_synchronize(struct dma_chan *chan)
>  	vchan_synchronize(&fsl_chan->vchan);
>  }
>
> +static void fsl_edma_cleanup_vchan_action(void *data)
> +{
> +	fsl_edma_cleanup_vchan(data);
> +}
> +
>  static irqreturn_t fsl_edma_tx_handler(int irq, void *dev_id)
>  {
>  	struct fsl_edma_engine *fsl_edma = dev_id;
> @@ -881,6 +886,12 @@ static int fsl_edma_probe(struct platform_device *pdev)
>
>  	platform_set_drvdata(pdev, fsl_edma);
>
> +	ret = devm_add_action_or_reset(&pdev->dev,
> +				       fsl_edma_cleanup_vchan_action,
> +				       &fsl_edma->dma_dev);
> +	if (ret)
> +		return ret;
> +
>  	ret = dmaenginem_async_device_register(&fsl_edma->dma_dev);
>  	if (ret)
>  		return dev_err_probe(&pdev->dev, ret,
> @@ -905,7 +916,6 @@ static void fsl_edma_remove(struct platform_device *pdev)
>  	struct fsl_edma_engine *fsl_edma = platform_get_drvdata(pdev);
>
>  	fsl_edma_irq_exit(pdev, fsl_edma);
> -	fsl_edma_cleanup_vchan(&fsl_edma->dma_dev);
>  }
>
>  static int fsl_edma_suspend_late(struct device *dev)
>
> --
> 2.34.1
>



More information about the linux-arm-kernel mailing list