From: James Hilliard <james.hilliard1@gmail.com>
To: Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Arnd Bergmann <arnd@arndb.de>,
Maxime Ripard <mripard@kernel.org>,
Jens Kuske <jenskuske@gmail.com>,
Jean-Francois Moine <moinejf@free.fr>
Cc: Hongling Zeng <zenghongling@kylinos.cn>,
Chengfeng Ye <cyeaa@connect.ust.hk>,
Nguyen Minh Tien <tien.nguyenminh@embeddedlinux.blog>,
dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
James Hilliard <james.hilliard1@gmail.com>
Subject: [PATCH v4 7/9] dmaengine: sun6i: track paused virtual channels
Date: Sun, 15 Nov 2026 02:32:55 -0700 [thread overview]
Message-ID: <20261115-submit-sun6i-dma-lifetime-next-v1-v4-7-043cd476a45f@gmail.com> (raw)
In-Reply-To: <20261115-submit-sun6i-dma-lifetime-next-v1-v4-0-043cd476a45f@gmail.com>
sun6i_dma_tx_status() only returns the cookie state, so a paused but
incomplete transfer is reported as DMA_IN_PROGRESS. The 8250 RX flush
path pauses the channel and calls its completion helper before terminating
it. That helper ignores an in-progress transfer to avoid consuming a new
RX operation. With sun6i it consequently drops the partial buffer and
leaves rx_running set, preventing another receive from being submitted.
Track pause state under the channel-assignment lock and report DMA_PAUSED
for incomplete cookies, including status queries without a residue output.
Read back the pause register before returning so a posted MMIO write
has reached the controller when the client inspects the transfer. The
readback flushes the request; it is not a separate hardware suspension
acknowledgment. Completed cookies remain DMA_COMPLETE.
Keep paused channels out of the pending queue and do not start a queued
descriptor when a paused channel's previous descriptor completes. Release
the completed physical channel so other virtual channels can use it, and
clear its hardware pause request before reassignment. The paused virtual
channel retains its queued descriptors until resume.
Resume requeues an unassigned channel only once and schedules the
allocator, so an idle controller does not require an unrelated completion
to resume it. Clear the pause state when terminating the channel.
Fixes: 555859308723 ("dmaengine: sun6i: Add driver for the Allwinner A31 DMA controller")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/dma/sun6i-dma.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
index ab4474f0a8aa..14f1f463005e 100644
--- a/drivers/dma/sun6i-dma.c
+++ b/drivers/dma/sun6i-dma.c
@@ -208,6 +208,7 @@ struct sun6i_vchan {
u8 port;
u8 irq_type;
bool cyclic;
+ bool paused;
};
struct sun6i_dma_dev {
@@ -539,13 +540,17 @@ static void sun6i_dma_tasklet(struct tasklet_struct *t)
pchan = vchan->phy;
if (pchan && !pchan->desc) {
- if (sun6i_dma_start_desc(vchan)) {
+ if (vchan->paused || sun6i_dma_start_desc(vchan)) {
/*
* No current txd associated with this channel
*/
dev_dbg(sdev->slave.dev, "pchan %u: free\n",
pchan->idx);
+ /* The next owner must not inherit the pause request. */
+ writel(DMA_CHAN_PAUSE_RESUME,
+ pchan->base + DMA_CHAN_PAUSE);
+
/* Mark this channel free */
vchan->phy = NULL;
pchan->vchan = NULL;
@@ -937,10 +942,13 @@ static int sun6i_dma_pause(struct dma_chan *chan)
dev_dbg(dmaengine_chan_dev(chan), "vchan %p: pause\n", &vchan->vc);
spin_lock_irqsave(&sdev->lock, flags);
+ vchan->paused = true;
pchan = vchan->phy;
if (pchan) {
writel(DMA_CHAN_PAUSE_PAUSE,
pchan->base + DMA_CHAN_PAUSE);
+ /* Flush the request before clients inspect the transfer. */
+ readl(pchan->base + DMA_CHAN_PAUSE);
} else {
list_del_init(&vchan->node);
}
@@ -962,12 +970,14 @@ static int sun6i_dma_resume(struct dma_chan *chan)
spin_lock(&vchan->vc.lock);
pchan = vchan->phy;
+ vchan->paused = false;
if (pchan) {
writel(DMA_CHAN_PAUSE_RESUME,
pchan->base + DMA_CHAN_PAUSE);
- } else if (!list_empty(&vchan->vc.desc_issued)) {
+ } else if (!list_empty(&vchan->vc.desc_issued) && list_empty(&vchan->node)) {
list_add_tail(&vchan->node, &sdev->pending);
}
+ tasklet_schedule(&sdev->task);
spin_unlock(&vchan->vc.lock);
spin_unlock_irqrestore(&sdev->lock, flags);
@@ -996,6 +1006,7 @@ static int sun6i_dma_terminate_all(struct dma_chan *chan)
}
vchan->cyclic = false;
+ vchan->paused = false;
vchan_get_all_descriptors(&vchan->vc, &head);
if (pchan) {
@@ -1041,6 +1052,8 @@ static enum dma_status sun6i_dma_tx_status(struct dma_chan *chan,
spin_lock_irqsave(&sdev->lock, flags);
spin_lock(&vchan->vc.lock);
ret = dma_cookie_status(chan, cookie, state);
+ if (ret == DMA_IN_PROGRESS && vchan->paused)
+ ret = DMA_PAUSED;
if (ret == DMA_COMPLETE || !state)
goto out;
pchan = vchan->phy;
@@ -1075,7 +1088,7 @@ static void sun6i_dma_issue_pending(struct dma_chan *chan)
spin_lock(&vchan->vc.lock);
if (vchan_issue_pending(&vchan->vc)) {
- if (!vchan->phy && list_empty(&vchan->node)) {
+ if (!vchan->paused && !vchan->phy && list_empty(&vchan->node)) {
list_add_tail(&vchan->node, &sdev->pending);
tasklet_schedule(&sdev->task);
dev_dbg(dmaengine_chan_dev(chan), "vchan %p: issued\n",
--
2.53.0
next prev parent reply other threads:[~2026-11-15 9:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 9:32 [PATCH v4 0/9] dmaengine: sun6i: fix interrupt routing and channel lifetime James Hilliard
2026-11-15 9:32 ` [PATCH v4 1/9] dmaengine: sun6i: fix physical channel index in interrupt handler James Hilliard
2026-11-15 9:32 ` [PATCH v4 2/9] dmaengine: sun6i: handle the last partial interrupt bank James Hilliard
2026-11-18 20:06 ` Frank Li
2026-11-15 9:32 ` [PATCH v4 3/9] dmaengine: sun6i: take the device lock before the virtual channel lock James Hilliard
2026-11-15 9:32 ` [PATCH v4 4/9] dmaengine: sun6i: serialize physical channel ownership James Hilliard
2026-11-15 9:32 ` [PATCH v4 5/9] dmaengine: sun6i: detach completed descriptors before invoking callbacks James Hilliard
2026-11-15 9:32 ` [PATCH v4 6/9] dmaengine: sun6i: retire interrupt state before reusing physical channels James Hilliard
2026-11-15 9:32 ` James Hilliard [this message]
2026-11-18 20:08 ` [PATCH v4 7/9] dmaengine: sun6i: track paused virtual channels Frank Li
2026-11-15 9:32 ` [PATCH v4 8/9] dmaengine: sun6i: synchronize callbacks before releasing channel resources James Hilliard
2026-11-15 9:32 ` [PATCH v4 9/9] dmaengine: sun6i: keep cyclic state with the prepared descriptor 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=20261115-submit-sun6i-dma-lifetime-next-v1-v4-7-043cd476a45f@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=Frank.Li@kernel.org \
--cc=arnd@arndb.de \
--cc=cyeaa@connect.ust.hk \
--cc=dmaengine@vger.kernel.org \
--cc=jenskuske@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=moinejf@free.fr \
--cc=mripard@kernel.org \
--cc=samuel@sholland.org \
--cc=tien.nguyenminh@embeddedlinux.blog \
--cc=vkoul@kernel.org \
--cc=wens@kernel.org \
--cc=zenghongling@kylinos.cn \
/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®