* [PATCH v4 1/5] dmaengine: dw-axi-dmac: keep cyclic mode in the descriptor
2026-11-12 8:22 [PATCH v4 0/5] dmaengine: dw-axi-dmac: fix termination and pause acknowledgment James Hilliard
@ 2026-11-12 8:22 ` James Hilliard
2026-11-12 8:22 ` [PATCH v4 2/5] dmaengine: dw-axi-dmac: poll the correct enable bit during termination James Hilliard
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: James Hilliard @ 2026-11-12 8:22 UTC (permalink / raw)
To: Eugeniy Paltsev, Vinod Koul, Frank Li, Sergey Khimich,
Andy Shevchenko, Sia Jee Heng
Cc: dmaengine, linux-kernel, James Hilliard, stable
dw_axi_dma_chan_prep_cyclic() sets chan->cyclic before allocating all the
hardware descriptors and leaves it set when preparation fails. The flag
also survives cyclic transfer errors and channel resource release. A
subsequent noncyclic transfer then takes the cyclic completion path,
leaving its cookie incomplete and its descriptor on the issued list.
Its zero period_len can also cause a division by zero.
Resetting the flag on failure or channel allocation is not sufficient:
preparing cyclic work while an ordinary transfer is active changes how
that transfer's completion interrupt is handled.
Store the mode in each descriptor and use the completed descriptor's
mode in the interrupt handler. Cyclic preparation sets only its own
descriptor's flag, while the zero-initialized noncyclic descriptors keep
it clear. Error recovery and channel reuse then use the next descriptor's
mode without relying on channel-wide cleanup.
Fixes: 1deb96c0fa58 ("dmaegine: dw-axi-dmac: Support device_prep_dma_cyclic()")
Closes: https://lore.kernel.org/r/sashiko-outbox-208213@kernel.org/
Cc: stable@vger.kernel.org
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 35 ++++++++++++--------------
drivers/dma/dw-axi-dmac/dw-axi-dmac.h | 2 +-
2 files changed, 17 insertions(+), 20 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 7520c78f55cc..6dae63024721 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -801,7 +801,7 @@ dw_axi_dma_chan_prep_cyclic(struct dma_chan *dchan, dma_addr_t dma_addr,
chan->direction = direction;
desc->chan = chan;
- chan->cyclic = true;
+ desc->cyclic = true;
desc->length = 0;
desc->period_len = period_len;
@@ -1117,25 +1117,23 @@ static void axi_chan_block_xfer_complete(struct axi_dma_chan *chan)
goto out;
}
- if (chan->cyclic) {
- desc = vd_to_axi_desc(vd);
- if (desc) {
- llp = lo_hi_readq(chan->chan_regs + CH_LLP);
- for (i = 0; i < count; i++) {
- hw_desc = &desc->hw_desc[i];
- if (hw_desc->llp == llp) {
- axi_chan_irq_clear(chan, hw_desc->lli->status_lo);
- hw_desc->lli->ctl_hi |= cpu_to_le32(CH_CTL_H_LLI_VALID);
- desc->completed_blocks = i;
-
- if (((hw_desc->len * (i + 1)) % desc->period_len) == 0)
- vchan_cyclic_callback(vd);
- break;
- }
+ desc = vd_to_axi_desc(vd);
+ if (desc->cyclic) {
+ llp = lo_hi_readq(chan->chan_regs + CH_LLP);
+ for (i = 0; i < count; i++) {
+ hw_desc = &desc->hw_desc[i];
+ if (hw_desc->llp == llp) {
+ axi_chan_irq_clear(chan, hw_desc->lli->status_lo);
+ hw_desc->lli->ctl_hi |= cpu_to_le32(CH_CTL_H_LLI_VALID);
+ desc->completed_blocks = i;
+
+ if (((hw_desc->len * (i + 1)) % desc->period_len) == 0)
+ vchan_cyclic_callback(vd);
+ break;
}
-
- axi_chan_enable(chan);
}
+
+ axi_chan_enable(chan);
} else {
/* Remove the completed descriptor from issued list before completing */
list_del(&vd->node);
@@ -1204,7 +1202,6 @@ static int dma_chan_terminate_all(struct dma_chan *dchan)
vchan_get_all_descriptors(&chan->vc, &head);
- chan->cyclic = false;
spin_unlock_irqrestore(&chan->vc.lock, flags);
vchan_dma_desc_free_list(&chan->vc, &head);
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
index d8dd07efe60f..3c86e5d468ea 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
@@ -50,7 +50,6 @@ struct axi_dma_chan {
struct axi_dma_desc *desc;
struct dma_slave_config config;
enum dma_transfer_direction direction;
- bool cyclic;
/* these other elements are all protected by vc.lock */
bool is_paused;
};
@@ -105,6 +104,7 @@ struct axi_dma_desc {
u32 length;
u32 period_len;
u32 nr_hw_descs;
+ bool cyclic;
};
struct axi_dma_chan_config {
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v4 2/5] dmaengine: dw-axi-dmac: poll the correct enable bit during termination
2026-11-12 8:22 [PATCH v4 0/5] dmaengine: dw-axi-dmac: fix termination and pause acknowledgment James Hilliard
2026-11-12 8:22 ` [PATCH v4 1/5] dmaengine: dw-axi-dmac: keep cyclic mode in the descriptor James Hilliard
@ 2026-11-12 8:22 ` James Hilliard
2026-11-12 8:22 ` [PATCH v4 3/5] dmaengine: dw-axi-dmac: retain descriptors when termination times out James Hilliard
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: James Hilliard @ 2026-11-12 8:22 UTC (permalink / raw)
To: Eugeniy Paltsev, Vinod Koul, Frank Li, Sergey Khimich,
Andy Shevchenko, Sia Jee Heng
Cc: dmaengine, linux-kernel, James Hilliard, stable
For channels 16 through 31, the channel enable bits occupy bits 32 through
47 of the extended DMAC_CHEN register. dma_chan_terminate_all() only reads
the low word and tests BIT(chan->id), so it can conclude that an upper-bank
channel has stopped while its actual enable bit remains set. Descriptors
can then be freed while hardware still owns them.
Poll axi_chan_is_hw_enable(), which already handles both register banks
and the smaller channel layouts, instead of constructing another mask.
Fixes: 495e18b16e3d ("dmaengine: dw-axi-dmac: Add support DMAX_NUM_CHANNELS > 16")
Cc: stable@vger.kernel.org
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 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 6dae63024721..405ab9a78955 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -28,6 +28,7 @@
#include <linux/property.h>
#include <linux/reset.h>
#include <linux/slab.h>
+#include <linux/time64.h>
#include <linux/types.h>
#include "dw-axi-dmac.h"
@@ -1179,17 +1180,17 @@ 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);
- u32 chan_active = BIT(chan->id) << DMAC_CHAN_EN_SHIFT;
unsigned long flags;
- u32 val;
+ bool enabled;
int ret;
LIST_HEAD(head);
axi_chan_disable(chan);
- ret = readl_poll_timeout_atomic(chan->chip->regs + DMAC_CHEN, val,
- !(val & chan_active), 1000, 50000);
- if (ret == -ETIMEDOUT)
+ ret = readx_poll_timeout_atomic(axi_chan_is_hw_enable, chan,
+ enabled, !enabled,
+ 1 * USEC_PER_MSEC, 50 * USEC_PER_MSEC);
+ if (ret)
dev_warn(dmaengine_chan_dev(dchan),
"%s failed to stop\n", axi_chan_name(chan));
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v4 3/5] dmaengine: dw-axi-dmac: retain descriptors when termination times out
2026-11-12 8:22 [PATCH v4 0/5] dmaengine: dw-axi-dmac: fix termination and pause acknowledgment James Hilliard
2026-11-12 8:22 ` [PATCH v4 1/5] dmaengine: dw-axi-dmac: keep cyclic mode in the descriptor James Hilliard
2026-11-12 8:22 ` [PATCH v4 2/5] dmaengine: dw-axi-dmac: poll the correct enable bit during termination James Hilliard
@ 2026-11-12 8:22 ` James Hilliard
2026-11-12 8:22 ` [PATCH v4 4/5] dmaengine: dw-axi-dmac: use atomic polling for suspend acknowledgment James Hilliard
2026-11-12 8:22 ` [PATCH v4 5/5] dmaengine: dw-axi-dmac: preserve pending pause requests James Hilliard
4 siblings, 0 replies; 7+ messages in thread
From: James Hilliard @ 2026-11-12 8:22 UTC (permalink / raw)
To: Eugeniy Paltsev, Vinod Koul, Frank Li, Sergey Khimich,
Andy Shevchenko, Sia Jee Heng
Cc: dmaengine, linux-kernel, James Hilliard, stable
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>
---
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 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 405ab9a78955..040c12d07db2 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -1185,22 +1185,25 @@ static int dma_chan_terminate_all(struct dma_chan *dchan)
int ret;
LIST_HEAD(head);
+ spin_lock_irqsave(&chan->vc.lock, flags);
+
axi_chan_disable(chan);
ret = readx_poll_timeout_atomic(axi_chan_is_hw_enable, chan,
enabled, !enabled,
1 * USEC_PER_MSEC, 50 * USEC_PER_MSEC);
- if (ret)
+ if (ret) {
+ spin_unlock_irqrestore(&chan->vc.lock, flags);
dev_warn(dmaengine_chan_dev(dchan),
"%s failed to stop\n", axi_chan_name(chan));
+ return ret;
+ }
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);
- spin_lock_irqsave(&chan->vc.lock, flags);
-
vchan_get_all_descriptors(&chan->vc, &head);
spin_unlock_irqrestore(&chan->vc.lock, flags);
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v4 4/5] dmaengine: dw-axi-dmac: use atomic polling for suspend acknowledgment
2026-11-12 8:22 [PATCH v4 0/5] dmaengine: dw-axi-dmac: fix termination and pause acknowledgment James Hilliard
` (2 preceding siblings ...)
2026-11-12 8:22 ` [PATCH v4 3/5] dmaengine: dw-axi-dmac: retain descriptors when termination times out James Hilliard
@ 2026-11-12 8:22 ` James Hilliard
2026-11-12 8:22 ` [PATCH v4 5/5] dmaengine: dw-axi-dmac: preserve pending pause requests James Hilliard
4 siblings, 0 replies; 7+ messages in thread
From: James Hilliard @ 2026-11-12 8:22 UTC (permalink / raw)
To: Eugeniy Paltsev, Vinod Koul, Frank Li, Sergey Khimich,
Andy Shevchenko, Sia Jee Heng
Cc: dmaengine, linux-kernel, James Hilliard, stable
The pause loop delays after its final status read, so an acknowledgment
that arrives during that delay is cleared without being observed and
the caller receives -EAGAIN.
Use readx_poll_timeout_atomic() to check the status after the final delay.
Keep the two-microsecond polling interval, 40-microsecond timeout and
-EAGAIN return value when suspension is not acknowledged.
Fixes: 1fe20f1b8454 ("dmaengine: Introduce DW AXI DMAC driver")
Cc: stable@vger.kernel.org
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 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 040c12d07db2..1a53fbc951a9 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -1219,7 +1219,8 @@ static int dma_chan_pause(struct dma_chan *dchan)
{
struct axi_dma_chan *chan = dchan_to_axi_dma_chan(dchan);
unsigned long flags;
- unsigned int timeout = 20; /* timeout iterations */
+ u32 status;
+ int ret;
u64 val;
spin_lock_irqsave(&chan->vc.lock, flags);
@@ -1250,12 +1251,9 @@ static int dma_chan_pause(struct dma_chan *dchan)
}
}
- do {
- if (axi_chan_irq_read(chan) & DWAXIDMAC_IRQ_SUSPENDED)
- break;
-
- udelay(2);
- } while (--timeout);
+ ret = readx_poll_timeout_atomic(axi_chan_irq_read, chan,
+ status, status & DWAXIDMAC_IRQ_SUSPENDED,
+ 2, 40);
axi_chan_irq_clear(chan, DWAXIDMAC_IRQ_SUSPENDED);
@@ -1263,7 +1261,7 @@ static int dma_chan_pause(struct dma_chan *dchan)
spin_unlock_irqrestore(&chan->vc.lock, flags);
- return timeout ? 0 : -EAGAIN;
+ return ret ? -EAGAIN : 0;
}
/* Called in chan locked context */
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v4 5/5] dmaengine: dw-axi-dmac: preserve pending pause requests
2026-11-12 8:22 [PATCH v4 0/5] dmaengine: dw-axi-dmac: fix termination and pause acknowledgment James Hilliard
` (3 preceding siblings ...)
2026-11-12 8:22 ` [PATCH v4 4/5] dmaengine: dw-axi-dmac: use atomic polling for suspend acknowledgment James Hilliard
@ 2026-11-12 8:22 ` James Hilliard
2026-11-12 9:23 ` sashiko-bot
4 siblings, 1 reply; 7+ messages in thread
From: James Hilliard @ 2026-11-12 8:22 UTC (permalink / raw)
To: Eugeniy Paltsev, Vinod Koul, Frank Li, Sergey Khimich,
Andy Shevchenko, Sia Jee Heng
Cc: dmaengine, linux-kernel, James Hilliard, stable
dma_chan_pause() clears SUSPENDED even when polling times out. Hardware
can set that status after the last poll, and the unconditional clear then
discards an acknowledgment the caller never observed. Another channel's
interrupt can also consume the status because the shared IRQ handler
clears every channel's status before taking its lock.
Leave SUSPENDED to the pause and resume paths. Track the suspend request
separately from its acknowledgment so a timeout can be followed by either
a pause retry or a resume. Wait for acknowledgment before clearing the
hardware request, since hardware ignores an earlier clear. If that wait
also times out, return -EAGAIN with the request still pending.
A completed transfer is also quiescent, but its completion handler may
still need to advance a cyclic descriptor. Defer that restart while a
pause is pending, and resume it without reprogramming the first LLI.
Track the active descriptor until its completion handler runs so that
resume and issue_pending cannot restart a completed cyclic segment or
reissue a completed noncyclic descriptor while its IRQ is pending.
Start queued work after the active descriptor is retired, respecting the
pause request.
Clear stale suspension status at the start of a new descriptor rather
than at each cyclic restart. Reset the software state after successful
termination and when allocating a channel for a new client.
Store the lock-protected pause flags as bitfields in existing padding.
Fixes: 1fe20f1b8454 ("dmaengine: Introduce DW AXI DMAC driver")
Cc: stable@vger.kernel.org
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 98 ++++++++++++++++++++++----
drivers/dma/dw-axi-dmac/dw-axi-dmac.h | 7 +-
2 files changed, 89 insertions(+), 16 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 1a53fbc951a9..70ff0c500623 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -481,6 +481,8 @@ static void axi_chan_block_xfer_start(struct axi_dma_chan *chan,
irq_mask |= DWAXIDMAC_IRQ_SUSPENDED;
axi_chan_irq_set(chan, irq_mask);
+ axi_chan_irq_clear(chan, DWAXIDMAC_IRQ_SUSPENDED);
+ chan->desc = first;
axi_chan_enable(chan);
}
@@ -489,6 +491,9 @@ static void axi_chan_start_first_queued(struct axi_dma_chan *chan)
struct axi_dma_desc *desc;
struct virt_dma_desc *vd;
+ if (chan->desc || chan->pause_requested)
+ return;
+
vd = vchan_next_desc(&chan->vc);
if (!vd)
return;
@@ -543,6 +548,10 @@ static int dma_chan_alloc_chan_resources(struct dma_chan *dchan)
pm_runtime_put(chan->chip->dev);
return -ENOMEM;
}
+ chan->desc = NULL;
+ chan->pause_requested = false;
+ chan->is_paused = false;
+ chan->cyclic_restart = false;
dev_vdbg(dmaengine_chan_dev(dchan), "%s: allocating\n", axi_chan_name(chan));
return 0;
@@ -1087,6 +1096,8 @@ static noinline void axi_chan_handle_err(struct axi_dma_chan *chan, u32 status)
vchan_cookie_complete(vd);
/* Try to restart the controller */
+ chan->desc = NULL;
+ chan->cyclic_restart = false;
axi_chan_start_first_queued(chan);
out:
@@ -1134,11 +1145,18 @@ static void axi_chan_block_xfer_complete(struct axi_dma_chan *chan)
}
}
- axi_chan_enable(chan);
+ if (chan->pause_requested) {
+ chan->is_paused = true;
+ chan->cyclic_restart = true;
+ } else {
+ axi_chan_enable(chan);
+ }
} else {
/* Remove the completed descriptor from issued list before completing */
list_del(&vd->node);
vchan_cookie_complete(vd);
+ chan->desc = NULL;
+ axi_chan_start_first_queued(chan);
}
out:
@@ -1160,6 +1178,8 @@ static irqreturn_t dw_axi_dma_interrupt(int irq, void *dev_id)
for (i = 0; i < dw->hdata->nr_channels; i++) {
chan = &dw->chan[i];
status = axi_chan_irq_read(chan);
+ /* Leave suspension status for the pause and resume paths. */
+ status &= ~DWAXIDMAC_IRQ_SUSPENDED;
axi_chan_irq_clear(chan, status);
dev_vdbg(chip->dev, "%s %u IRQ status: 0x%08x\n",
@@ -1206,6 +1226,11 @@ static int dma_chan_terminate_all(struct dma_chan *dchan)
vchan_get_all_descriptors(&chan->vc, &head);
+ axi_chan_irq_clear(chan, DWAXIDMAC_IRQ_SUSPENDED);
+ chan->desc = NULL;
+ chan->pause_requested = false;
+ chan->is_paused = false;
+ chan->cyclic_restart = false;
spin_unlock_irqrestore(&chan->vc.lock, flags);
vchan_dma_desc_free_list(&chan->vc, &head);
@@ -1215,16 +1240,50 @@ static int dma_chan_terminate_all(struct dma_chan *dchan)
return 0;
}
+static bool axi_chan_is_suspended(struct axi_dma_chan *chan)
+{
+ if (!axi_chan_is_hw_enable(chan)) {
+ /* A completed transfer cannot acknowledge a new suspend request. */
+ axi_chan_disable(chan);
+ return true;
+ }
+
+ return axi_chan_irq_read(chan) & DWAXIDMAC_IRQ_SUSPENDED;
+}
+
+/* A timed-out request can still be acknowledged. */
+static int axi_chan_wait_for_suspend(struct axi_dma_chan *chan)
+ __must_hold(&chan->vc.lock)
+{
+ bool suspended;
+ int ret;
+
+ if (chan->is_paused)
+ return 0;
+
+ ret = readx_poll_timeout_atomic(axi_chan_is_suspended, chan,
+ suspended, suspended, 2, 40);
+ if (ret)
+ return -EAGAIN;
+
+ axi_chan_irq_clear(chan, DWAXIDMAC_IRQ_SUSPENDED);
+ chan->is_paused = true;
+ return 0;
+}
+
static int dma_chan_pause(struct dma_chan *dchan)
{
struct axi_dma_chan *chan = dchan_to_axi_dma_chan(dchan);
unsigned long flags;
- u32 status;
int ret;
u64 val;
spin_lock_irqsave(&chan->vc.lock, flags);
+ chan->pause_requested = true;
+ if (chan->is_paused || !axi_chan_is_hw_enable(chan))
+ goto wait;
+
if (chan->chip->dw->hdata->nr_channels >= DMAC_CHAN_16) {
val = axi_dma_ioread64(chan->chip, DMAC_CHSUSPREG);
if (chan->id >= DMAC_CHAN_16) {
@@ -1251,17 +1310,11 @@ static int dma_chan_pause(struct dma_chan *dchan)
}
}
- ret = readx_poll_timeout_atomic(axi_chan_irq_read, chan,
- status, status & DWAXIDMAC_IRQ_SUSPENDED,
- 2, 40);
-
- axi_chan_irq_clear(chan, DWAXIDMAC_IRQ_SUSPENDED);
-
- chan->is_paused = true;
-
+wait:
+ ret = axi_chan_wait_for_suspend(chan);
spin_unlock_irqrestore(&chan->vc.lock, flags);
- return ret ? -EAGAIN : 0;
+ return ret;
}
/* Called in chan locked context */
@@ -1295,6 +1348,8 @@ static inline void axi_chan_resume(struct axi_dma_chan *chan)
}
}
+ axi_chan_irq_clear(chan, DWAXIDMAC_IRQ_SUSPENDED);
+ chan->pause_requested = false;
chan->is_paused = false;
}
@@ -1302,15 +1357,30 @@ static int dma_chan_resume(struct dma_chan *dchan)
{
struct axi_dma_chan *chan = dchan_to_axi_dma_chan(dchan);
unsigned long flags;
+ int ret = 0;
spin_lock_irqsave(&chan->vc.lock, flags);
- if (chan->is_paused)
- axi_chan_resume(chan);
+ if (!chan->pause_requested)
+ goto out;
+
+ /* Hardware ignores resume until the suspend request is acknowledged. */
+ ret = axi_chan_wait_for_suspend(chan);
+ if (ret)
+ goto out;
+
+ axi_chan_resume(chan);
+ if (chan->cyclic_restart) {
+ chan->cyclic_restart = false;
+ axi_chan_enable(chan);
+ } else {
+ axi_chan_start_first_queued(chan);
+ }
+out:
spin_unlock_irqrestore(&chan->vc.lock, flags);
- return 0;
+ return ret;
}
static int axi_dma_suspend(struct axi_dma_chip *chip)
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
index 3c86e5d468ea..332f9b9b9fd3 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
@@ -42,6 +42,11 @@ struct axi_dma_chan {
void __iomem *chan_regs;
u8 id;
u8 hw_handshake_num;
+ /* Protected by vc.lock. */
+ bool pause_requested:1;
+ bool is_paused:1;
+ bool cyclic_restart:1;
+
atomic_t descs_allocated;
struct dma_pool *desc_pool;
@@ -50,8 +55,6 @@ struct axi_dma_chan {
struct axi_dma_desc *desc;
struct dma_slave_config config;
enum dma_transfer_direction direction;
- /* these other elements are all protected by vc.lock */
- bool is_paused;
};
struct dw_axi_dma {
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v4 5/5] dmaengine: dw-axi-dmac: preserve pending pause requests
2026-11-12 8:22 ` [PATCH v4 5/5] dmaengine: dw-axi-dmac: preserve pending pause requests James Hilliard
@ 2026-11-12 9:23 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-12 9:23 UTC (permalink / raw)
To: James Hilliard; +Cc: dmaengine, vkoul, Frank.Li
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] dmaengine: dw-axi-dmac: cyclic completion bypasses suspend
cleanup
--
commit 42cf728bc72837bdd6aafccd6828bd4c191d4963
Author: James Hilliard <james.hilliard1@gmail.com>
dmaengine: dw-axi-dmac: preserve pending pause requests
This commit tracks pending pause requests separately from hardware suspend
acknowledgment and defers restarting cyclic or queued descriptors while a
pause is requested.
> 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 1a53fbc951a91..70ff0c5006231 100644
> --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
[ ... ]
> @@ -1134,11 +1145,18 @@ static void axi_chan_block_xfer_complete(struct axi_dma_chan *chan)
> }
> }
>
> - axi_chan_enable(chan);
> + if (chan->pause_requested) {
> + chan->is_paused = true;
> + chan->cyclic_restart = true;
> + } else {
> + axi_chan_enable(chan);
> + }
> } else {
[Severity: Medium]
Does setting chan->is_paused here skip cleaning up an unacknowledged
hardware suspend request when a cyclic block completes after
dma_chan_pause() times out?
If dma_chan_pause() writes the channel suspend request and times out in
axi_chan_wait_for_suspend(), chan->pause_requested remains true while the
hardware suspend request stays pending. When the in-flight cyclic block
then finishes, axi_chan_block_xfer_complete() sets chan->is_paused = true
without calling axi_chan_disable() or clearing DWAXIDMAC_IRQ_SUSPENDED. A
later dma_chan_pause() retry or dma_chan_resume() call sees chan->is_paused
and returns early from axi_chan_wait_for_suspend(), bypassing the
axi_chan_disable() call in axi_chan_is_suspended() that clears an
unacknowledged suspend request on a completed transfer.
Leaving chan->is_paused false here (or calling axi_chan_disable() and
clearing DWAXIDMAC_IRQ_SUSPENDED before setting chan->is_paused) would
ensure the pending hardware suspend state is cleaned up before the channel
is re-enabled on resume.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261112-submit-dw-axi-dma-stop-pause-v1-v4-0-3ebc24b243db@gmail.com?part=5
^ permalink raw reply [flat|nested] 7+ messages in thread