All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tomi Valkeinen" <tomi.valkeinen@ideasonboard.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH] dmaengine: xilinx_dma: Use readl_poll_timeout() instead of atomic variant
Date: Mon, 03 Aug 2026 13:41:28 +0000	[thread overview]
Message-ID: <20260803134129.8735E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260803-xilinx-dma-poll-fix-v1-1-892302c4847d@ideasonboard.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch replaces `readl_poll_timeout_atomic()` with `readl_poll_timeout()` in an atomic context, violating the `iopoll.h` API contract and introducing a risk of infinite loops and severe latency.
--

--- Patch [1]: [PATCH] dmaengine: xilinx_dma: Use readl_poll_timeout() instead of atomic variant ---
commit f549bf1ac3f30db8e280af9c3f9f7f1f4d4ac1b5
Author: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

dmaengine: xilinx_dma: Use readl_poll_timeout() instead of atomic variant

This commit switches xilinx_dma_poll_timeout() from the atomic to the
regular readl_poll_timeout() macro. The commit message states that this
is safe because zero delay means it never sleeps.

> Calling xilinx_dma_poll_timeout() from atomic context is still safe even
> after this change, as readl_poll_timeout() with zero delay never sleeps.

> diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
> --- a/drivers/dma/xilinx/xilinx_dma.c
> +++ b/drivers/dma/xilinx/xilinx_dma.c
> @@ -530,7 +530,7 @@ struct xilinx_dma_device {
>  #define to_dma_tx_descriptor(tx) \
>  	container_of(tx, struct xilinx_dma_tx_descriptor, async_tx)
>  #define xilinx_dma_poll_timeout(chan, reg, val, cond, delay_us, timeout_us) \
> -	readl_poll_timeout_atomic(chan->xdev->regs + chan->ctrl_offset + reg, \
> +	readl_poll_timeout(chan->xdev->regs + chan->ctrl_offset + reg, \
>  				  val, cond, delay_us, timeout_us)

[Severity: High]
Is the assertion in the commit message accurate for all hardware
configurations, or could this regression lead to a hard lockup during DMA
transfers or error resets?

While it is true that readl_poll_timeout() does not sleep with a zero delay,
it still relies on ktime_get() for timekeeping. The API documentation in
iopoll.h explicitly forbids calling readl_poll_timeout() from atomic context
if timeout_us is used.

This macro is called with interrupts disabled in multiple paths. For example,
xilinx_dma_issue_pending() calls start_transfer() under spin_lock_irqsave(),
and the irq handler also calls it under a spinlock:

drivers/dma/xilinx/xilinx_dma.c:xilinx_dma_irq_handler() {
        ...
        spin_lock(&chan->lock);
        xilinx_dma_complete_descriptor(chan);
        chan->idle = true;
        chan->start_transfer(chan);
        ...
}

If ktime_get() relies on timer interrupts to advance the clock on certain
hardware configurations, and those interrupts are disabled, would this cause
the polling loop to hang indefinitely if the hardware condition is never met?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260803-xilinx-dma-poll-fix-v1-1-892302c4847d@ideasonboard.com?part=1

  reply	other threads:[~2026-08-03 13:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <UR3xiwNn0coPyYguDWjjQi-IWPyN8Surtot50IAldzugiznKwuwlVUScNRaQ1TMK5KEQcdglATeQVSWqQrsOuw==@protonmail.internalid>
2026-08-03 13:20 ` [PATCH] dmaengine: xilinx_dma: Use readl_poll_timeout() instead of atomic variant Tomi Valkeinen
2026-08-03 13:41   ` sashiko-bot [this message]
2026-08-03 14:39   ` Tomi Valkeinen
2026-08-04  7:12   ` Alex Bereza
2026-08-04  7:28     ` Tomi Valkeinen

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=20260803134129.8735E1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tomi.valkeinen@ideasonboard.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.