Re: [PATCH] dmaengine: fsl-edma: don't call pm_runtime_allow() from terminate_all()

From: Frank Li

Date: Wed Nov 25 2026 - 15:25:23 EST


On Wed, Nov 25, 2026 at 08:55:17AM +0100, A. Sverdlin wrote:
> From: Alexander Sverdlin <alexander.sverdlin@xxxxxxxxxxx>
>
> fsl_edma_terminate_all() may be called from atomic context via
> dmaengine_terminate_async(), which the dmaengine API explicitly allows
> (Documentation/driver-api/dmaengine/client.rst). pm_runtime_allow() must
> not be called from there, because it uses unconditional
> spin_{un,}lock_irq() and therefore re-enables interrupts.

I think pm_runtime_allow() also need be fixed, which should use
spin_lock_saveirq() although should not call pm_runtime_allow() here.

>
> Calling dmaengine_terminate_async() from a UART interrupt handler on an
> i.MX8QXP triggers:
>
> DEBUG_LOCKS_WARN_ON(lockdep_hardirq_context())
> WARNING: CPU: 0 PID: 0 at kernel/locking/lockdep.c:4404 lockdep_hardirqs_on_prepare+0x1a8/0x210
> Call trace:
> lockdep_hardirqs_on_prepare+0x1a8/0x210 (P)
> trace_hardirqs_on+0x58/0xf8
> _raw_spin_unlock_irq+0x38/0x80
> pm_runtime_allow+0x34/0x140
> fsl_edma_terminate_all+0x1d0/0x1e0
> ...
>
> followed by the IRQ core warning that the handler enabled interrupts
> (kernel/irq/handle.c). Both warnings are one-shot, so this is only
> visible once per boot.
>
> In-tree, fsl_lpuart's lpuart_flush_buffer() calls
> dmaengine_terminate_async() with the port lock held and interrupts
> disabled, so the port interrupt can then deadlock on that lock.
>
> The call has no counterpart: pm_runtime_forbid() is never called in
> fsl-edma, so runtime_auto is always already true and pm_runtime_allow()
> does nothing except the illegal unlock. Just remove it.
>
> Fixes: 72f5801a4e2b ("dmaengine: fsl-edma: integrate v3 support")
> Cc: stable@xxxxxxxxxxxxxxx
> Co-developed-by: Alessandro Zini <alessandro.zini@xxxxxxxxxxx>
> Signed-off-by: Alessandro Zini <alessandro.zini@xxxxxxxxxxx>
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@xxxxxxxxxxx>
> ---

Reviewed-by: Frank Li <Frank.Li@xxxxxxx>

> drivers/dma/fsl-edma-common.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c
> index 513b0f4e5be21..1f1f5fb353cc8 100644
> --- a/drivers/dma/fsl-edma-common.c
> +++ b/drivers/dma/fsl-edma-common.c
> @@ -10,7 +10,6 @@
> #include <linux/module.h>
> #include <linux/slab.h>
> #include <linux/dma-mapping.h>
> -#include <linux/pm_runtime.h>
> #include <linux/pm_domain.h>
>
> #include "fsl-edma-common.h"
> @@ -274,9 +273,6 @@ int fsl_edma_terminate_all(struct dma_chan *chan)
> spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
> vchan_dma_desc_free_list(&fsl_chan->vchan, &head);
>
> - if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_HAS_PD)
> - pm_runtime_allow(fsl_chan->pd_dev);
> -
> return 0;
> }
>
>
> base-commit: 2e02fb103be058cf8b2fb24112a74a2715e090f0
> --
> 2.56.1
>