mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: James Hilliard <james.hilliard1@gmail.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>,
	Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
	Sergey Khimich <serghox@gmail.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Sia Jee Heng <jee.heng.sia@intel.com>,
	Baruch Siach <baruch@tkos.co.il>,
	Mitch Barnett <mitch@accuratesound.ca>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v8 3/9] dmaengine: dw-axi-dmac: retain descriptors when termination times out
Date: Thu, 19 Nov 2026 10:18:30 -0600	[thread overview]
Message-ID: <av8hVoC1Qng9ElFt@SMW015318> (raw)
In-Reply-To: <20261119-submit-dw-axi-dma-stop-pause-v1-v8-3-f8e7fe60594c@gmail.com>

On Thu, Nov 19, 2026 at 09:00:58AM -0700, James Hilliard wrote:
> dma_chan_terminate_all() warns when the channel enable bit does not clear,
> but then frees the descriptors and returns success. Its synchronize
> callback only drains virtual-channel callbacks, so terminate_sync() can
> also report success while hardware still accesses the transfer.
>
> Return the polling error before detaching descriptors or changing the
> peripheral routing. This keeps the transfer resources available while
> the channel remains enabled and lets the caller retry termination without
> treating the timeout as a successful stop.
>
> Hold the channel lock across disabling, polling and descriptor detachment
> so an interrupt handler cannot restart the channel between the stop check
> and cleanup.
>
> Fixes: 1deb96c0fa58 ("dmaegine: dw-axi-dmac: Support device_prep_dma_cyclic()")
> Cc: stable@vger.kernel.org
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---

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

>  drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 37 ++++++++++++++------------
>  1 file changed, 20 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> index f17a71183050..def591fc75ce 100644
> --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> @@ -9,6 +9,7 @@
>
>  #include <linux/bitfield.h>
>  #include <linux/bitops.h>
> +#include <linux/cleanup.h>
>  #include <linux/delay.h>
>  #include <linux/device.h>
>  #include <linux/dmaengine.h>
> @@ -1180,30 +1181,32 @@ static irqreturn_t dw_axi_dma_interrupt(int irq, void *dev_id)
>  static int dma_chan_terminate_all(struct dma_chan *dchan)
>  {
>  	struct axi_dma_chan *chan = dchan_to_axi_dma_chan(dchan);
> -	unsigned long flags;
> -	bool enabled;
>  	int ret;
>  	LIST_HEAD(head);
>
> -	axi_chan_disable(chan);
> -
> -	ret = read_poll_timeout_atomic(axi_chan_is_hw_enable, enabled, !enabled,
> -				       1 * USEC_PER_MSEC, 50 * USEC_PER_MSEC,
> -				       false, chan);
> -	if (ret)
> -		dev_warn(dmaengine_chan_dev(dchan),
> -			 "%s failed to stop\n", axi_chan_name(chan));
> +	scoped_guard(spinlock_irqsave, &chan->vc.lock) {
> +		bool enabled;
>
> -	if (chan->direction != DMA_MEM_TO_MEM)
> -		dw_axi_dma_set_hw_channel(chan, false);
> -	if (chan->direction == DMA_MEM_TO_DEV)
> -		dw_axi_dma_set_byte_halfword(chan, false);
> +		axi_chan_disable(chan);
> +		ret = read_poll_timeout_atomic(axi_chan_is_hw_enable, enabled, !enabled,
> +					       1 * USEC_PER_MSEC, 50 * USEC_PER_MSEC,
> +					       false, chan);
> +		if (ret)
> +			break;
>
> -	spin_lock_irqsave(&chan->vc.lock, flags);
> +		if (chan->direction != DMA_MEM_TO_MEM)
> +			dw_axi_dma_set_hw_channel(chan, false);
> +		if (chan->direction == DMA_MEM_TO_DEV)
> +			dw_axi_dma_set_byte_halfword(chan, false);
>
> -	vchan_get_all_descriptors(&chan->vc, &head);
> +		vchan_get_all_descriptors(&chan->vc, &head);
> +	}
>
> -	spin_unlock_irqrestore(&chan->vc.lock, flags);
> +	if (ret) {
> +		dev_warn(dmaengine_chan_dev(dchan),
> +			 "%s failed to stop\n", axi_chan_name(chan));
> +		return ret;
> +	}
>
>  	vchan_dma_desc_free_list(&chan->vc, &head);
>
>
> --
> 2.53.0
>

  reply	other threads:[~2026-11-19 16:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 16:00 [PATCH v8 0/9] dmaengine: dw-axi-dmac: fix termination and pause acknowledgment James Hilliard
2026-11-19 16:00 ` [PATCH v8 1/9] dmaengine: dw-axi-dmac: keep cyclic mode in the descriptor James Hilliard
2026-11-19 16:00 ` [PATCH v8 2/9] dmaengine: dw-axi-dmac: poll the correct enable bit during termination James Hilliard
2026-11-19 16:17   ` Frank Li
2026-11-19 16:00 ` [PATCH v8 3/9] dmaengine: dw-axi-dmac: retain descriptors when termination times out James Hilliard
2026-11-19 16:18   ` Frank Li [this message]
2026-11-19 16:00 ` [PATCH v8 4/9] dmaengine: dw-axi-dmac: use atomic polling for suspend acknowledgment James Hilliard
2026-11-19 16:19   ` Frank Li
2026-11-19 16:01 ` [PATCH v8 5/9] dmaengine: dw-axi-dmac: preserve pending pause requests James Hilliard
2026-11-19 16:27   ` Frank Li
2026-11-19 17:07     ` James Hilliard
2026-11-19 16:01 ` [PATCH v8 6/9] dmaengine: dw-axi-dmac: retain descriptors until callbacks drain James Hilliard
2026-11-19 16:41   ` Frank Li
2026-11-19 17:07     ` James Hilliard
2026-11-19 16:01 ` [PATCH v8 7/9] dmaengine: dw-axi-dmac: serialize interrupt status with channel reuse James Hilliard
2026-11-19 16:44   ` Frank Li
2026-11-19 17:10     ` James Hilliard
2026-11-19 16:01 ` [PATCH v8 8/9] dmaengine: dw-axi-dmac: require an IRQ before registering the controller James Hilliard
2026-11-19 16:47   ` Frank Li
2026-11-19 16:01 ` [PATCH v8 9/9] dmaengine: dw-axi-dmac: guard shared IRQs across the controller lifetime James Hilliard
2026-11-19 16:50   ` Frank Li
2026-11-19 17:11     ` James Hilliard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=av8hVoC1Qng9ElFt@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Eugeniy.Paltsev@synopsys.com \
    --cc=Frank.Li@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=baruch@tkos.co.il \
    --cc=dmaengine@vger.kernel.org \
    --cc=james.hilliard1@gmail.com \
    --cc=jee.heng.sia@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mitch@accuratesound.ca \
    --cc=serghox@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®