mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Amita Mishra <amitamishra@google.com>
Cc: Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
	Dan Williams <djbw@kernel.org>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] dmaengine: dmatest: terminate channel on timeout or error
Date: Wed, 18 Nov 2026 11:04:44 -0600	[thread overview]
Message-ID: <av3arNfXL8zWJv3P@SMW015318> (raw)
In-Reply-To: <20261118100839.3090172-1-amitamishra@google.com>

On Wed, Nov 18, 2026 at 10:08:39AM +0000, Amita Mishra wrote:
> [You don't often get email from amitamishra@google.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> In interrupt mode (!params->polled), when wait_event_freezable_timeout()
> times out (!done->done) or dma_async_is_tx_complete() reports a
> non-DMA_COMPLETE status, dmatest_func() jumps to error_unmap_continue and
> calls dmaengine_unmap_put() without terminating the DMA channel first.
> Channel termination via dmaengine_terminate_sync() only happens later
> when the test thread exits, unlike the polled path which terminates the
> channel immediately after dma_sync_wait().
>
> If the DMA controller is still actively transferring when the source and
> destination buffers are unmapped, an IOMMU-backed DMA engine will trigger
> use-after-unmap translation faults, or overwrite the buffers while the
> next iteration reinitializes them. In addition, if the timed-out transfer
> completes during a subsequent iteration, its callback sets the shared
> per-thread done flag and wakes done_wait prematurely, causing the next
> iteration to fail with "completion busy status".
>
> Terminate the channel with dmaengine_terminate_sync() on both the timeout
> and non-DMA_COMPLETE error paths before unmapping the buffers, skipping
> the redundant call on timeout when params->polled has already terminated
> the channel.
>
> Fixes: 4076e755dbec ("dmatest: convert to dmaengine_unmap_data")
> Cc: stable@vger.kernel.org
> Signed-off-by: Amita Mishra <amitamishra@google.com>
> ---

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

>  drivers/dma/dmatest.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
> index 2ae3469397f3..950b7a9e7769 100644
> --- a/drivers/dma/dmatest.c
> +++ b/drivers/dma/dmatest.c
> @@ -852,6 +852,8 @@ static int dmatest_func(void *data)
>                 }
>
>                 if (!done->done) {
> +                       if (!params->polled)
> +                               dmaengine_terminate_sync(chan);
>                         result("test timed out", total_tests, src->off, dst->off,
>                                len, 0);
>                         goto error_unmap_continue;
> @@ -859,6 +861,7 @@ static int dmatest_func(void *data)
>                            !(dma_has_cap(DMA_COMPLETION_NO_ORDER,
>                                          dev->cap_mask) &&
>                              status == DMA_OUT_OF_ORDER)) {
> +                       dmaengine_terminate_sync(chan);
>                         result(status == DMA_ERROR ?
>                                "completion error status" :
>                                "completion busy status", total_tests, src->off,
>
> base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
> --
> 2.56.1.703.gf848ed807c-goog
>

      reply	other threads:[~2026-11-18 17:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 10:08 Amita Mishra
2026-11-18 17:04 ` Frank Li [this message]

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=av3arNfXL8zWJv3P@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=amitamishra@google.com \
    --cc=djbw@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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®