* [PATCH v7 00/10] dmaengine: arm-dma350: Add slave support and Sky1 integration
@ 2026-11-17 9:43 Jelly Jia
2026-11-17 9:43 ` [PATCH v7 01/10] dmaengine: arm-dma350: Fix source trigger bit Jelly Jia
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Jelly Jia @ 2026-11-17 9:43 UTC (permalink / raw)
To: vkoul, Frank.Li, robh, krzk+dt, conor+dt, robin.murphy
Cc: devicetree, cix-kernel-upstream, dmaengine, linux-arm-kernel,
linux-kernel, Jelly.Jia
Hello,
This series adds scatter-gather and cyclic peripheral transfers to the
Arm DMA-350 driver and describes the CIX Sky1 clock/reset integration.
The companion AUDSS interrupt-path series builds on these changes.
The first five patches fix existing trigger, DMA mask, coherency,
IRQ/termination and queued-status handling. Patches 6 and 7 prepare
managed registration and command bookkeeping before patch 8 adds slave
and cyclic transfers. The final two patches describe and handle the
integration clock and optional reset. DTS enablement is kept separate.
Linked commands use a coherent DMA pool and descriptor-owned peripheral
resource mappings. Sky1 has no IOMMU on this path, but its RCSU windows
still require CPU-to-DMA address translation through the DMA API.
Changes since v6:
- Split existing fixes and memcpy/memset preparation out of the new
slave/cyclic support. (Frank.)
- Use named little-endian hardware command fields and fill the coherent
pool directly. Keep CPU-endian memcpy/memset command storage and MMIO
handling; decode peripheral fields only when loading their registers.
Derive SG lengths from saved command sizes without cmd_len[]. (Frank.)
- Remove the prep-time DMA write barrier; retain the final non-relaxed
channel-enable writel and normal descriptor publication locking.
Keep descriptor-owned peripheral address mappings and the distinction
between read-only interrupt flags and W1C status bits. (Frank.)
- Use scoped guards consistently without extending critical sections,
consistent device_config/device_caps names and managed DMA/OF
registration. (Frank.)
- Put the submitter's Signed-off-by after the retained Reviewed-by tags.
(Frank.)
Previous version:
https://lore.kernel.org/r/20261106013453.1134239-1-Jelly.Jia@cixtech.com
Jelly Jia (10):
dmaengine: arm-dma350: Fix source trigger bit
dmaengine: arm-dma350: Check DMA mask setup errors
dmaengine: arm-dma350: Initialize channel coherency
dmaengine: arm-dma350: Serialize IRQ and termination state
dmaengine: arm-dma350: Report submitted descriptor status
dmaengine: arm-dma350: Use managed device registration
dmaengine: arm-dma350: Track descriptor byte lengths explicitly
dmaengine: arm-dma350: Add slave and cyclic transfer support
dt-bindings: dma: arm,dma-350: Describe the CIX Sky1 integration
dmaengine: arm-dma350: Support integration clocks and resets
.../devicetree/bindings/dma/arm,dma-350.yaml | 30 +-
drivers/dma/arm-dma350.c | 946 ++++++++++++++++--
2 files changed, 886 insertions(+), 90 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.54.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 01/10] dmaengine: arm-dma350: Fix source trigger bit
2026-11-17 9:43 [PATCH v7 00/10] dmaengine: arm-dma350: Add slave support and Sky1 integration Jelly Jia
@ 2026-11-17 9:43 ` Jelly Jia
2026-11-17 9:43 ` [PATCH v7 02/10] dmaengine: arm-dma350: Check DMA mask setup errors Jelly Jia
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jelly Jia @ 2026-11-17 9:43 UTC (permalink / raw)
To: vkoul, Frank.Li, robh, krzk+dt, conor+dt, robin.murphy
Cc: devicetree, cix-kernel-upstream, dmaengine, linux-arm-kernel,
linux-kernel, Jelly.Jia, Frank Li
CH_CTRL_USESRCTRIGIN is the source trigger enable bit in CH_CTRL and must
use bit 25, not bit 26 which is the destination trigger enable bit
(CH_CTRL_USEDESTRIGIN).
The constant has no users yet, but enabling the source trigger input
would silently enable the destination trigger input instead, breaking
any transfer that waits for a peripheral request. Fix it before the
first user arrives.
Fixes: 5d099706449d ("dmaengine: Add Arm DMA-350 driver")
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Jelly Jia <Jelly.Jia@cixtech.com>
---
drivers/dma/arm-dma350.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c
index 52f5242ea332..fdc4cd224579 100644
--- a/drivers/dma/arm-dma350.c
+++ b/drivers/dma/arm-dma350.c
@@ -63,7 +63,7 @@
#define CH_CTRL 0x0c
#define CH_CTRL_USEDESTRIGIN BIT(26)
-#define CH_CTRL_USESRCTRIGIN BIT(26)
+#define CH_CTRL_USESRCTRIGIN BIT(25)
#define CH_CTRL_DONETYPE GENMASK(23, 21)
#define CH_CTRL_REGRELOADTYPE GENMASK(20, 18)
#define CH_CTRL_XTYPE GENMASK(11, 9)
--
2.54.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 02/10] dmaengine: arm-dma350: Check DMA mask setup errors
2026-11-17 9:43 [PATCH v7 00/10] dmaengine: arm-dma350: Add slave support and Sky1 integration Jelly Jia
2026-11-17 9:43 ` [PATCH v7 01/10] dmaengine: arm-dma350: Fix source trigger bit Jelly Jia
@ 2026-11-17 9:43 ` Jelly Jia
2026-11-17 9:43 ` [PATCH v7 03/10] dmaengine: arm-dma350: Initialize channel coherency Jelly Jia
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jelly Jia @ 2026-11-17 9:43 UTC (permalink / raw)
To: vkoul, Frank.Li, robh, krzk+dt, conor+dt, robin.murphy
Cc: devicetree, cix-kernel-upstream, dmaengine, linux-arm-kernel,
linux-kernel, Jelly.Jia
The controller's address width is used to configure its DMA mask. If
dma_set_mask_and_coherent() fails, continuing probe leaves the device
registered with an unsupported DMA address configuration.
Check the return value and fail probe before allocating DMA resources.
Fixes: 5d099706449d ("dmaengine: Add Arm DMA-350 driver")
Signed-off-by: Jelly Jia <Jelly.Jia@cixtech.com>
---
drivers/dma/arm-dma350.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c
index fdc4cd224579..d9f1d2976034 100644
--- a/drivers/dma/arm-dma350.c
+++ b/drivers/dma/arm-dma350.c
@@ -553,7 +553,9 @@ static int d350_probe(struct platform_device *pdev)
dw = 1 << FIELD_GET(DMA_CFG_DATA_WIDTH, reg);
aw = FIELD_GET(DMA_CFG_ADDR_WIDTH, reg) + 1;
- dma_set_mask_and_coherent(dev, DMA_BIT_MASK(aw));
+ ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(aw));
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to set DMA mask\n");
coherent = device_get_dma_attr(dev) == DEV_DMA_COHERENT;
dmac = devm_kzalloc(dev, struct_size(dmac, channels, nchan), GFP_KERNEL);
--
2.54.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 03/10] dmaengine: arm-dma350: Initialize channel coherency
2026-11-17 9:43 [PATCH v7 00/10] dmaengine: arm-dma350: Add slave support and Sky1 integration Jelly Jia
2026-11-17 9:43 ` [PATCH v7 01/10] dmaengine: arm-dma350: Fix source trigger bit Jelly Jia
2026-11-17 9:43 ` [PATCH v7 02/10] dmaengine: arm-dma350: Check DMA mask setup errors Jelly Jia
@ 2026-11-17 9:43 ` Jelly Jia
2026-11-17 9:43 ` [PATCH v7 04/10] dmaengine: arm-dma350: Serialize IRQ and termination state Jelly Jia
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jelly Jia @ 2026-11-17 9:43 UTC (permalink / raw)
To: vkoul, Frank.Li, robh, krzk+dt, conor+dt, robin.murphy
Cc: devicetree, cix-kernel-upstream, dmaengine, linux-arm-kernel,
linux-kernel, Jelly.Jia
Command preparation chooses memory attributes from dch->coherent, but probe
only uses the device's coherency for the command-link attributes. The zero-
initialized channel field therefore selects noncoherent memory attributes
even for a coherent controller.
Initialize each usable channel's coherency from the DMA device attribute.
Fixes: 5d099706449d ("dmaengine: Add Arm DMA-350 driver")
Signed-off-by: Jelly Jia <Jelly.Jia@cixtech.com>
---
drivers/dma/arm-dma350.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c
index d9f1d2976034..266df7923d7f 100644
--- a/drivers/dma/arm-dma350.c
+++ b/drivers/dma/arm-dma350.c
@@ -625,6 +625,7 @@ static int d350_probe(struct platform_device *pdev)
reg |= FIELD_PREP(CH_LINK_MEMATTR, coherent ? MEMATTR_WB : MEMATTR_NC);
writel_relaxed(reg, dch->base + CH_LINKATTR);
+ dch->coherent = coherent;
dch->vc.desc_free = d350_desc_free;
vchan_init(&dch->vc, &dmac->dma);
}
--
2.54.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 04/10] dmaengine: arm-dma350: Serialize IRQ and termination state
2026-11-17 9:43 [PATCH v7 00/10] dmaengine: arm-dma350: Add slave support and Sky1 integration Jelly Jia
` (2 preceding siblings ...)
2026-11-17 9:43 ` [PATCH v7 03/10] dmaengine: arm-dma350: Initialize channel coherency Jelly Jia
@ 2026-11-17 9:43 ` Jelly Jia
2026-11-17 9:43 ` [PATCH v7 05/10] dmaengine: arm-dma350: Report submitted descriptor status Jelly Jia
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jelly Jia @ 2026-11-17 9:43 UTC (permalink / raw)
To: vkoul, Frank.Li, robh, krzk+dt, conor+dt, robin.murphy
Cc: devicetree, cix-kernel-upstream, dmaengine, linux-arm-kernel,
linux-kernel, Jelly.Jia
The interrupt handler samples status before locking and assumes an active
descriptor, while termination can detach that descriptor concurrently.
Completion can also leave a stale active pointer or overwrite the status of
a failed cookie with another transfer.
Pair status sampling and descriptor handling under the channel lock,
acknowledge only the W1C completion/error status, and detach completed
descriptors. Preserve errors until termination resets the channel state.
Wait for STOPCMD and synchronize the IRQ before releasing terminated
descriptors, including when channel resources are freed.
The existing DMAengine terminate/synchronize contract remains unchanged.
STOP timeout handling remains bounded and best-effort, as previously
agreed; no hardware-stop guarantee or new recovery policy is claimed.
Use scoped guards consistently for channel state locking, retaining the
original critical-section boundaries and keeping stop waits and resource
cleanup outside the channel lock.
Fixes: 5d099706449d ("dmaengine: Add Arm DMA-350 driver")
Signed-off-by: Jelly Jia <Jelly.Jia@cixtech.com>
---
drivers/dma/arm-dma350.c | 133 +++++++++++++++++++++++++--------------
1 file changed, 87 insertions(+), 46 deletions(-)
diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c
index 266df7923d7f..af1b030b955f 100644
--- a/drivers/dma/arm-dma350.c
+++ b/drivers/dma/arm-dma350.c
@@ -3,9 +3,11 @@
// Arm DMA-350 driver
#include <linux/bitfield.h>
+#include <linux/cleanup.h>
#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/of.h>
#include <linux/module.h>
#include <linux/platform_device.h>
@@ -47,6 +49,8 @@
#define CH_CMD_CLEAR BIT(1)
#define CH_CMD_ENABLE BIT(0)
+#define D350_STOP_TIMEOUT_US 10000
+
#define CH_STATUS 0x04
#define CH_STAT_RESUMEWAIT BIT(21)
#define CH_STAT_PAUSED BIT(20)
@@ -127,7 +131,6 @@
#define CH_CFG_HAS_TRIGIN BIT(5)
#define CH_CFG_HAS_WRAP BIT(1)
-
#define LINK_REGCLEAR BIT(0)
#define LINK_INTREN BIT(2)
#define LINK_CTRL BIT(3)
@@ -147,7 +150,6 @@
#define LINK_LINKADDR BIT(30)
#define LINK_LINKADDRHI BIT(31)
-
enum ch_ctrl_donetype {
CH_CTRL_DONETYPE_NONE = 0,
CH_CTRL_DONETYPE_CMD = 1,
@@ -294,14 +296,13 @@ static struct dma_async_tx_descriptor *d350_prep_memset(struct dma_chan *chan,
static int d350_pause(struct dma_chan *chan)
{
struct d350_chan *dch = to_d350_chan(chan);
- unsigned long flags;
- spin_lock_irqsave(&dch->vc.lock, flags);
+ guard(spinlock_irqsave)(&dch->vc.lock);
+
if (dch->status == DMA_IN_PROGRESS) {
writel_relaxed(CH_CMD_PAUSE, dch->base + CH_CMD);
dch->status = DMA_PAUSED;
}
- spin_unlock_irqrestore(&dch->vc.lock, flags);
return 0;
}
@@ -309,14 +310,13 @@ static int d350_pause(struct dma_chan *chan)
static int d350_resume(struct dma_chan *chan)
{
struct d350_chan *dch = to_d350_chan(chan);
- unsigned long flags;
- spin_lock_irqsave(&dch->vc.lock, flags);
+ guard(spinlock_irqsave)(&dch->vc.lock);
+
if (dch->status == DMA_PAUSED) {
writel_relaxed(CH_CMD_RESUME, dch->base + CH_CMD);
dch->status = DMA_IN_PROGRESS;
}
- spin_unlock_irqrestore(&dch->vc.lock, flags);
return 0;
}
@@ -342,28 +342,46 @@ static u32 d350_get_residue(struct d350_chan *dch)
static int d350_terminate_all(struct dma_chan *chan)
{
struct d350_chan *dch = to_d350_chan(chan);
- unsigned long flags;
LIST_HEAD(list);
- spin_lock_irqsave(&dch->vc.lock, flags);
+ guard(spinlock_irqsave)(&dch->vc.lock);
+
writel_relaxed(CH_CMD_STOP, dch->base + CH_CMD);
if (dch->desc) {
if (dch->status != DMA_ERROR)
vchan_terminate_vdesc(&dch->desc->vd);
dch->desc = NULL;
- dch->status = DMA_COMPLETE;
}
+ dch->status = DMA_COMPLETE;
vchan_get_all_descriptors(&dch->vc, &list);
list_splice_tail(&list, &dch->vc.desc_terminated);
- spin_unlock_irqrestore(&dch->vc.lock, flags);
return 0;
}
+static int d350_wait_for_stop(struct d350_chan *dch)
+{
+ u32 cmd;
+ int ret;
+
+ /* STOPCMD clears only after the channel has stopped using commands. */
+ ret = readl_poll_timeout(dch->base + CH_CMD, cmd,
+ !(cmd & CH_CMD_STOP), 10,
+ D350_STOP_TIMEOUT_US);
+ if (ret)
+ dev_warn(dch->vc.chan.device->dev,
+ "channel %d failed to stop\n", dch->vc.chan.chan_id);
+
+ return ret;
+}
+
static void d350_synchronize(struct dma_chan *chan)
{
struct d350_chan *dch = to_d350_chan(chan);
+ /* A stop timeout must not skip IRQ or callback synchronization. */
+ d350_wait_for_stop(dch);
+ synchronize_irq(dch->irq);
vchan_synchronize(&dch->vc);
}
@@ -378,24 +396,26 @@ static enum dma_status d350_tx_status(struct dma_chan *chan, dma_cookie_t cookie
struct d350_chan *dch = to_d350_chan(chan);
struct virt_dma_desc *vd;
enum dma_status status;
- unsigned long flags;
u32 residue = 0;
status = dma_cookie_status(chan, cookie, state);
- spin_lock_irqsave(&dch->vc.lock, flags);
- if (cookie == dch->cookie) {
- status = dch->status;
- if (status == DMA_IN_PROGRESS || status == DMA_PAUSED)
- dch->residue = d350_get_residue(dch);
- residue = dch->residue;
- } else if ((vd = vchan_find_desc(&dch->vc, cookie))) {
- residue = d350_desc_bytes(to_d350_desc(vd));
- } else if (status == DMA_IN_PROGRESS) {
- /* Somebody else terminated it? */
- status = DMA_ERROR;
+ scoped_guard(spinlock_irqsave, &dch->vc.lock) {
+ if (cookie == dch->cookie) {
+ status = dch->status;
+ if (status == DMA_IN_PROGRESS || status == DMA_PAUSED)
+ dch->residue = d350_get_residue(dch);
+ residue = dch->residue;
+ } else {
+ vd = vchan_find_desc(&dch->vc, cookie);
+ if (vd) {
+ residue = d350_desc_bytes(to_d350_desc(vd));
+ } else if (status == DMA_IN_PROGRESS) {
+ /* Somebody else terminated it? */
+ status = DMA_ERROR;
+ }
+ }
}
- spin_unlock_irqrestore(&dch->vc.lock, flags);
dma_set_residue(state, residue);
return status;
@@ -405,6 +425,10 @@ static void d350_start_next(struct d350_chan *dch)
{
u32 hdr, *reg;
+ /* Preserve the failed cookie's status until the channel is terminated. */
+ if (dch->status == DMA_ERROR)
+ return;
+
dch->desc = to_d350_desc(vchan_next_desc(&dch->vc));
if (!dch->desc)
return;
@@ -458,28 +482,44 @@ static void d350_start_next(struct d350_chan *dch)
static void d350_issue_pending(struct dma_chan *chan)
{
struct d350_chan *dch = to_d350_chan(chan);
- unsigned long flags;
- spin_lock_irqsave(&dch->vc.lock, flags);
+ guard(spinlock_irqsave)(&dch->vc.lock);
+
if (vchan_issue_pending(&dch->vc) && !dch->desc)
d350_start_next(dch);
- spin_unlock_irqrestore(&dch->vc.lock, flags);
}
static irqreturn_t d350_irq(int irq, void *data)
{
struct d350_chan *dch = data;
- struct device *dev = dch->vc.chan.device->dev;
- struct virt_dma_desc *vd = &dch->desc->vd;
+ struct virt_dma_desc *vd;
+ struct d350_desc *desc;
+ u32 residue;
u32 ch_status;
+ u32 irq_status;
+ u32 errinfo = 0;
+
+ /* Keep the sampled status paired with the active descriptor. */
+ guard(spinlock)(&dch->vc.lock);
ch_status = readl(dch->base + CH_STATUS);
- if (!ch_status)
+ irq_status = ch_status & (CH_STAT_INTR_DONE | CH_STAT_INTR_ERR);
+ if (!irq_status)
return IRQ_NONE;
- if (ch_status & CH_STAT_INTR_ERR) {
- u32 errinfo = readl_relaxed(dch->base + CH_ERRINFO);
+ /* INTR bits are read-only; clearing W1C STAT_ERR also clears ERRINFO. */
+ if (irq_status & CH_STAT_INTR_ERR)
+ errinfo = readl_relaxed(dch->base + CH_ERRINFO);
+
+ writel_relaxed(ch_status & (CH_STAT_DONE | CH_STAT_ERR),
+ dch->base + CH_STATUS);
+ desc = dch->desc;
+ if (!desc)
+ return IRQ_HANDLED;
+
+ vd = &desc->vd;
+ if (irq_status & CH_STAT_INTR_ERR) {
if (errinfo & (CH_ERRINFO_AXIRDPOISERR | CH_ERRINFO_AXIRDRESPERR))
vd->tx_result.result = DMA_TRANS_READ_FAILED;
else if (errinfo & CH_ERRINFO_AXIWRRESPERR)
@@ -487,23 +527,19 @@ static irqreturn_t d350_irq(int irq, void *data)
else
vd->tx_result.result = DMA_TRANS_ABORTED;
- vd->tx_result.residue = d350_get_residue(dch);
- } else if (!(ch_status & CH_STAT_INTR_DONE)) {
- dev_warn(dev, "Unexpected IRQ source? 0x%08x\n", ch_status);
- }
- writel_relaxed(ch_status, dch->base + CH_STATUS);
-
- spin_lock(&dch->vc.lock);
- vchan_cookie_complete(vd);
- if (ch_status & CH_STAT_INTR_DONE) {
+ residue = d350_get_residue(dch);
+ vd->tx_result.residue = residue;
+ dch->status = DMA_ERROR;
+ dch->residue = residue;
+ dch->desc = NULL;
+ vchan_cookie_complete(vd);
+ } else {
dch->status = DMA_COMPLETE;
dch->residue = 0;
+ dch->desc = NULL;
+ vchan_cookie_complete(vd);
d350_start_next(dch);
- } else {
- dch->status = DMA_ERROR;
- dch->residue = vd->tx_result.residue;
}
- spin_unlock(&dch->vc.lock);
return IRQ_HANDLED;
}
@@ -513,6 +549,7 @@ static int d350_alloc_chan_resources(struct dma_chan *chan)
struct d350_chan *dch = to_d350_chan(chan);
int ret = request_irq(dch->irq, d350_irq, IRQF_SHARED,
vchan_chan_name(&dch->vc), dch);
+
if (!ret)
writel_relaxed(CH_INTREN_DONE | CH_INTREN_ERR, dch->base + CH_INTREN);
@@ -524,7 +561,11 @@ static void d350_free_chan_resources(struct dma_chan *chan)
struct d350_chan *dch = to_d350_chan(chan);
writel_relaxed(0, dch->base + CH_INTREN);
+ d350_terminate_all(chan);
+ d350_wait_for_stop(dch);
+
free_irq(dch->irq, dch);
+ vchan_synchronize(&dch->vc);
vchan_free_chan_resources(&dch->vc);
}
--
2.54.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 05/10] dmaengine: arm-dma350: Report submitted descriptor status
2026-11-17 9:43 [PATCH v7 00/10] dmaengine: arm-dma350: Add slave support and Sky1 integration Jelly Jia
` (3 preceding siblings ...)
2026-11-17 9:43 ` [PATCH v7 04/10] dmaengine: arm-dma350: Serialize IRQ and termination state Jelly Jia
@ 2026-11-17 9:43 ` Jelly Jia
2026-11-17 9:43 ` [PATCH v7 06/10] dmaengine: arm-dma350: Use managed device registration Jelly Jia
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jelly Jia @ 2026-11-17 9:43 UTC (permalink / raw)
To: vkoul, Frank.Li, robh, krzk+dt, conor+dt, robin.murphy
Cc: devicetree, cix-kernel-upstream, dmaengine, linux-arm-kernel,
linux-kernel, Jelly.Jia
A submitted descriptor can still be on desc_submitted before issue_pending
moves it to desc_issued. Searching only the issued list misreports such a
cookie as failed.
Search both submitted and issued descriptors when reporting queued work.
Fixes: 5d099706449d ("dmaengine: Add Arm DMA-350 driver")
Signed-off-by: Jelly Jia <Jelly.Jia@cixtech.com>
---
drivers/dma/arm-dma350.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c
index af1b030b955f..f785251935f4 100644
--- a/drivers/dma/arm-dma350.c
+++ b/drivers/dma/arm-dma350.c
@@ -390,6 +390,18 @@ static u32 d350_desc_bytes(struct d350_desc *desc)
return ((u32)desc->xsizehi << 16 | desc->xsize) << desc->tsz;
}
+static struct virt_dma_desc *d350_find_queued_desc(struct d350_chan *dch,
+ dma_cookie_t cookie)
+{
+ struct virt_dma_desc *vd;
+
+ list_for_each_entry(vd, &dch->vc.desc_submitted, node)
+ if (vd->tx.cookie == cookie)
+ return vd;
+
+ return vchan_find_desc(&dch->vc, cookie);
+}
+
static enum dma_status d350_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
struct dma_tx_state *state)
{
@@ -407,7 +419,7 @@ static enum dma_status d350_tx_status(struct dma_chan *chan, dma_cookie_t cookie
dch->residue = d350_get_residue(dch);
residue = dch->residue;
} else {
- vd = vchan_find_desc(&dch->vc, cookie);
+ vd = d350_find_queued_desc(dch, cookie);
if (vd) {
residue = d350_desc_bytes(to_d350_desc(vd));
} else if (status == DMA_IN_PROGRESS) {
--
2.54.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 06/10] dmaengine: arm-dma350: Use managed device registration
2026-11-17 9:43 [PATCH v7 00/10] dmaengine: arm-dma350: Add slave support and Sky1 integration Jelly Jia
` (4 preceding siblings ...)
2026-11-17 9:43 ` [PATCH v7 05/10] dmaengine: arm-dma350: Report submitted descriptor status Jelly Jia
@ 2026-11-17 9:43 ` Jelly Jia
2026-11-17 9:43 ` [PATCH v7 07/10] dmaengine: arm-dma350: Track descriptor byte lengths explicitly Jelly Jia
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jelly Jia @ 2026-11-17 9:43 UTC (permalink / raw)
To: vkoul, Frank.Li, robh, krzk+dt, conor+dt, robin.murphy
Cc: devicetree, cix-kernel-upstream, dmaengine, linux-arm-kernel,
linux-kernel, Jelly.Jia
Use managed DMA device registration so probe unwind and device removal
unregister the DMA device before its managed resources are released. Drop
the explicit remove callback.
Signed-off-by: Jelly Jia <Jelly.Jia@cixtech.com>
---
drivers/dma/arm-dma350.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c
index f785251935f4..bf87460c1c20 100644
--- a/drivers/dma/arm-dma350.c
+++ b/drivers/dma/arm-dma350.c
@@ -690,20 +690,13 @@ static int d350_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dmac);
- ret = dma_async_device_register(&dmac->dma);
+ ret = dmaenginem_async_device_register(&dmac->dma);
if (ret)
return dev_err_probe(dev, ret, "Failed to register DMA device\n");
return 0;
}
-static void d350_remove(struct platform_device *pdev)
-{
- struct d350 *dmac = platform_get_drvdata(pdev);
-
- dma_async_device_unregister(&dmac->dma);
-}
-
static const struct of_device_id d350_of_match[] __maybe_unused = {
{ .compatible = "arm,dma-350" },
{}
@@ -716,7 +709,6 @@ static struct platform_driver d350_driver = {
.of_match_table = of_match_ptr(d350_of_match),
},
.probe = d350_probe,
- .remove = d350_remove,
};
module_platform_driver(d350_driver);
--
2.54.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 07/10] dmaengine: arm-dma350: Track descriptor byte lengths explicitly
2026-11-17 9:43 [PATCH v7 00/10] dmaengine: arm-dma350: Add slave support and Sky1 integration Jelly Jia
` (5 preceding siblings ...)
2026-11-17 9:43 ` [PATCH v7 06/10] dmaengine: arm-dma350: Use managed device registration Jelly Jia
@ 2026-11-17 9:43 ` Jelly Jia
2026-11-17 9:43 ` [PATCH v7 08/10] dmaengine: arm-dma350: Add slave and cyclic transfer support Jelly Jia
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jelly Jia @ 2026-11-17 9:43 UTC (permalink / raw)
To: vkoul, Frank.Li, robh, krzk+dt, conor+dt, robin.murphy
Cc: devicetree, cix-kernel-upstream, dmaengine, linux-arm-kernel,
linux-kernel, Jelly.Jia
Keep the total transfer length in the descriptor instead of deriving it
from memcpy/memset-specific size fields. This allows the queued-status and
start paths to report the total length for linked peripheral work.
Use local size fields when constructing existing memcpy/memset commands.
Keep these CPU-consumed command words and their MMIO loader in CPU byte
order; little-endian pool storage is introduced with peripheral support.
Signed-off-by: Jelly Jia <Jelly.Jia@cixtech.com>
---
drivers/dma/arm-dma350.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c
index bf87460c1c20..465a8b9b722a 100644
--- a/drivers/dma/arm-dma350.c
+++ b/drivers/dma/arm-dma350.c
@@ -178,8 +178,7 @@ enum ch_cfg_memattr {
struct d350_desc {
struct virt_dma_desc vd;
u32 command[16];
- u16 xsize;
- u16 xsizehi;
+ size_t bytes;
u8 tsz;
};
@@ -224,15 +223,18 @@ static struct dma_async_tx_descriptor *d350_prep_memcpy(struct dma_chan *chan,
{
struct d350_chan *dch = to_d350_chan(chan);
struct d350_desc *desc;
+ u16 xsize;
+ u16 xsizehi;
u32 *cmd;
desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
+ desc->bytes = len;
desc->tsz = __ffs(len | dest | src | (1 << dch->tsz));
- desc->xsize = lower_16_bits(len >> desc->tsz);
- desc->xsizehi = upper_16_bits(len >> desc->tsz);
+ xsize = lower_16_bits(len >> desc->tsz);
+ xsizehi = upper_16_bits(len >> desc->tsz);
cmd = desc->command;
cmd[0] = LINK_CTRL | LINK_SRCADDR | LINK_SRCADDRHI | LINK_DESADDR |
@@ -247,8 +249,8 @@ static struct dma_async_tx_descriptor *d350_prep_memcpy(struct dma_chan *chan,
cmd[3] = upper_32_bits(src);
cmd[4] = lower_32_bits(dest);
cmd[5] = upper_32_bits(dest);
- cmd[6] = FIELD_PREP(CH_XY_SRC, desc->xsize) | FIELD_PREP(CH_XY_DES, desc->xsize);
- cmd[7] = FIELD_PREP(CH_XY_SRC, desc->xsizehi) | FIELD_PREP(CH_XY_DES, desc->xsizehi);
+ cmd[6] = FIELD_PREP(CH_XY_SRC, xsize) | FIELD_PREP(CH_XY_DES, xsize);
+ cmd[7] = FIELD_PREP(CH_XY_SRC, xsizehi) | FIELD_PREP(CH_XY_DES, xsizehi);
cmd[8] = dch->coherent ? TRANSCFG_WB : TRANSCFG_NC;
cmd[9] = dch->coherent ? TRANSCFG_WB : TRANSCFG_NC;
cmd[10] = FIELD_PREP(CH_XY_SRC, 1) | FIELD_PREP(CH_XY_DES, 1);
@@ -262,15 +264,18 @@ static struct dma_async_tx_descriptor *d350_prep_memset(struct dma_chan *chan,
{
struct d350_chan *dch = to_d350_chan(chan);
struct d350_desc *desc;
+ u16 xsize;
+ u16 xsizehi;
u32 *cmd;
desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
+ desc->bytes = len;
desc->tsz = __ffs(len | dest | (1 << dch->tsz));
- desc->xsize = lower_16_bits(len >> desc->tsz);
- desc->xsizehi = upper_16_bits(len >> desc->tsz);
+ xsize = lower_16_bits(len >> desc->tsz);
+ xsizehi = upper_16_bits(len >> desc->tsz);
cmd = desc->command;
cmd[0] = LINK_CTRL | LINK_DESADDR | LINK_DESADDRHI |
@@ -283,8 +288,8 @@ static struct dma_async_tx_descriptor *d350_prep_memset(struct dma_chan *chan,
cmd[2] = lower_32_bits(dest);
cmd[3] = upper_32_bits(dest);
- cmd[4] = FIELD_PREP(CH_XY_DES, desc->xsize);
- cmd[5] = FIELD_PREP(CH_XY_DES, desc->xsizehi);
+ cmd[4] = FIELD_PREP(CH_XY_DES, xsize);
+ cmd[5] = FIELD_PREP(CH_XY_DES, xsizehi);
cmd[6] = dch->coherent ? TRANSCFG_WB : TRANSCFG_NC;
cmd[7] = FIELD_PREP(CH_XY_DES, 1);
cmd[8] = (u8)value * 0x01010101;
@@ -387,7 +392,7 @@ static void d350_synchronize(struct dma_chan *chan)
static u32 d350_desc_bytes(struct d350_desc *desc)
{
- return ((u32)desc->xsizehi << 16 | desc->xsize) << desc->tsz;
+ return desc->bytes;
}
static struct virt_dma_desc *d350_find_queued_desc(struct d350_chan *dch,
--
2.54.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 08/10] dmaengine: arm-dma350: Add slave and cyclic transfer support
2026-11-17 9:43 [PATCH v7 00/10] dmaengine: arm-dma350: Add slave support and Sky1 integration Jelly Jia
` (6 preceding siblings ...)
2026-11-17 9:43 ` [PATCH v7 07/10] dmaengine: arm-dma350: Track descriptor byte lengths explicitly Jelly Jia
@ 2026-11-17 9:43 ` Jelly Jia
2026-11-17 9:43 ` [PATCH v7 09/10] dt-bindings: dma: arm,dma-350: Describe the CIX Sky1 integration Jelly Jia
2026-11-17 9:43 ` [PATCH v7 10/10] dmaengine: arm-dma350: Support integration clocks and resets Jelly Jia
9 siblings, 0 replies; 11+ messages in thread
From: Jelly Jia @ 2026-11-17 9:43 UTC (permalink / raw)
To: vkoul, Frank.Li, robh, krzk+dt, conor+dt, robin.murphy
Cc: devicetree, cix-kernel-upstream, dmaengine, linux-arm-kernel,
linux-kernel, Jelly.Jia
Add peripheral scatter-gather and cyclic transfers with descriptor-owned
resource mappings, coherent linked commands and hardware-based residue.
Snapshot channel configuration under the lock, validate per-channel
capabilities, and reject slave preparation without a valid request line.
Describe peripheral hardware commands with named little-endian fields
and fill them directly in the coherent pool. Decode only when loading
the first peripheral command into MMIO or reading saved command sizes.
Keep CPU-endian memcpy/memset commands unchanged. Single-entry slave SG
uses embedded command storage without an extra pool allocation.
Derive SG lengths from the command sizes rather than a separate array.
Rely on the final non-relaxed channel-enable writel for publication
ordering rather than a prep-time DMA write barrier.
Use scoped locking and consistent device_config/device_caps names. Use
managed OF DMA controller registration and clear request/configuration
when channel resources are freed, retaining them across termination.
Signed-off-by: Jelly Jia <Jelly.Jia@cixtech.com>
---
drivers/dma/arm-dma350.c | 765 +++++++++++++++++++++++++++++++++++++--
1 file changed, 736 insertions(+), 29 deletions(-)
diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c
index 465a8b9b722a..7b46b4fdcf9c 100644
--- a/drivers/dma/arm-dma350.c
+++ b/drivers/dma/arm-dma350.c
@@ -3,14 +3,23 @@
// Arm DMA-350 driver
#include <linux/bitfield.h>
+#include <linux/bitops.h>
+#include <linux/byteorder/generic.h>
#include <linux/cleanup.h>
-#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>
+#include <linux/dmaengine.h>
+#include <linux/dmapool.h>
#include <linux/io.h>
#include <linux/iopoll.h>
-#include <linux/of.h>
+#include <linux/limits.h>
#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_dma.h>
+#include <linux/overflow.h>
#include <linux/platform_device.h>
+#include <linux/scatterlist.h>
+#include <linux/slab.h>
+#include <linux/string.h>
#include "dmaengine.h"
#include "virt-dma.h"
@@ -106,6 +115,10 @@
#define CH_FILLVAL 0x38
#define CH_SRCTRIGINCFG 0x4c
#define CH_DESTRIGINCFG 0x50
+#define CH_TRIGINCFG_BLKSIZE GENMASK(23, 16)
+#define CH_TRIGINCFG_MODE GENMASK(11, 10)
+#define CH_TRIGINCFG_TYPE GENMASK(9, 8)
+#define CH_TRIGINCFG_SEL GENMASK(7, 0)
#define CH_LINKATTR 0x70
#define CH_LINK_SHAREATTR GENMASK(9, 8)
#define CH_LINK_MEMATTR GENMASK(7, 0)
@@ -163,6 +176,18 @@ enum ch_ctrl_xtype {
CH_CTRL_XTYPE_FILL = 3
};
+enum ch_trigincfg_mode {
+ CH_TRIGINCFG_MODE_COMMAND = 0,
+ CH_TRIGINCFG_MODE_DMA_FC = 2,
+ CH_TRIGINCFG_MODE_PERIPH_FC = 3
+};
+
+enum ch_trigincfg_type {
+ CH_TRIGINCFG_TYPE_SW = 0,
+ CH_TRIGINCFG_TYPE_HW = 2,
+ CH_TRIGINCFG_TYPE_INTERNAL = 3
+};
+
enum ch_cfg_shareattr {
SHAREATTR_NSH = 0,
SHAREATTR_OSH = 2,
@@ -175,11 +200,44 @@ enum ch_cfg_memattr {
MEMATTR_WB = 0xff
};
+/* Register-update words in the order selected by the slave header. */
+struct d350_slave_cmd {
+ __le32 header;
+ __le32 ctrl;
+ __le64 src_addr;
+ __le64 dst_addr;
+ __le32 xsize;
+ __le32 xsizehi;
+ __le32 src_transcfg;
+ __le32 dst_transcfg;
+ __le32 xaddrinc;
+ __le32 trigincfg;
+ __le64 link_addr;
+} __packed;
+
+struct d350_hw_cmd {
+ struct d350_slave_cmd *cmd;
+ dma_addr_t dma;
+};
+
struct d350_desc {
struct virt_dma_desc vd;
- u32 command[16];
+ union {
+ u32 command[16];
+ struct d350_slave_cmd slave;
+ };
+ enum dma_transfer_direction direction;
+ dma_addr_t resource_dma;
+ size_t resource_size;
+ enum dma_data_direction resource_dir;
+ bool resource_mapped;
+ struct d350_hw_cmd *cmds;
+ size_t ncmds;
size_t bytes;
+ size_t period_len;
+ size_t periods;
u8 tsz;
+ bool cyclic;
};
struct d350_chan {
@@ -190,14 +248,17 @@ struct d350_chan {
enum dma_status status;
dma_cookie_t cookie;
u32 residue;
+ u32 req;
u8 tsz;
bool has_trig;
bool has_wrap;
bool coherent;
+ struct dma_slave_config sconfig;
};
struct d350 {
struct dma_device dma;
+ struct dma_pool *cmd_pool;
int nchan;
int nreq;
struct d350_chan channels[] __counted_by(nchan);
@@ -208,14 +269,447 @@ static inline struct d350_chan *to_d350_chan(struct dma_chan *chan)
return container_of(chan, struct d350_chan, vc.chan);
}
+static inline struct d350 *d350_chan_to_dmac(struct d350_chan *dch)
+{
+ return container_of(dch->vc.chan.device, struct d350, dma);
+}
+
static inline struct d350_desc *to_d350_desc(struct virt_dma_desc *vd)
{
return container_of(vd, struct d350_desc, vd);
}
+static void d350_unmap_resource(struct device *dev, struct d350_desc *desc)
+{
+ if (!desc->resource_mapped)
+ return;
+
+ dma_unmap_resource(dev, desc->resource_dma, desc->resource_size,
+ desc->resource_dir, 0);
+ desc->resource_mapped = false;
+}
+
+static void d350_free_cmds(struct d350 *dmac, struct d350_desc *desc)
+{
+ size_t i;
+
+ for (i = 0; i < desc->ncmds; i++) {
+ if (desc->cmds[i].cmd)
+ dma_pool_free(dmac->cmd_pool, desc->cmds[i].cmd,
+ desc->cmds[i].dma);
+ }
+
+ kfree(desc->cmds);
+}
+
static void d350_desc_free(struct virt_dma_desc *vd)
{
- kfree(to_d350_desc(vd));
+ struct d350_desc *desc = to_d350_desc(vd);
+ struct device *dev = vd->tx.chan->device->dev;
+ struct d350 *dmac = d350_chan_to_dmac(to_d350_chan(vd->tx.chan));
+
+ d350_unmap_resource(dev, desc);
+ d350_free_cmds(dmac, desc);
+ kfree(desc);
+}
+
+static int d350_alloc_cmds(struct dma_chan *dchan, struct d350_desc *desc,
+ size_t ncmds)
+{
+ struct d350 *dmac = d350_chan_to_dmac(to_d350_chan(dchan));
+ size_t i;
+
+ desc->cmds = kcalloc(ncmds, sizeof(*desc->cmds), GFP_NOWAIT);
+ if (!desc->cmds)
+ return -ENOMEM;
+
+ desc->ncmds = ncmds;
+ for (i = 0; i < ncmds; i++) {
+ desc->cmds[i].cmd = dma_pool_alloc(dmac->cmd_pool, GFP_NOWAIT,
+ &desc->cmds[i].dma);
+ if (!desc->cmds[i].cmd) {
+ d350_free_cmds(dmac, desc);
+ desc->cmds = NULL;
+ desc->ncmds = 0;
+ return -ENOMEM;
+ }
+ }
+
+ return 0;
+}
+
+static dma_addr_t d350_map_resource(struct dma_chan *dchan,
+ struct d350_desc *desc,
+ phys_addr_t cpu_addr, size_t size,
+ enum dma_data_direction dir)
+{
+ struct device *dev = dchan->device->dev;
+ dma_addr_t dma_addr;
+
+ dma_addr = dma_map_resource(dev, cpu_addr, size, dir, 0);
+ if (dma_mapping_error(dev, dma_addr)) {
+ dev_err(dev, "map slave failed ch%u phys=%pa size=%zu dir=%d\n",
+ dchan->chan_id, &cpu_addr, size, dir);
+ return DMA_MAPPING_ERROR;
+ }
+
+ desc->resource_dma = dma_addr;
+ desc->resource_size = size;
+ desc->resource_dir = dir;
+ desc->resource_mapped = true;
+
+ return dma_addr;
+}
+
+static bool d350_buswidth_supported(u32 widths, enum dma_slave_buswidth width)
+{
+ return width < BITS_PER_TYPE(widths) && (widths & BIT(width));
+}
+
+static bool d350_slave_supported(struct d350_chan *dch)
+{
+ return dch->has_trig && d350_chan_to_dmac(dch)->nreq > 0;
+}
+
+static u32 d350_chan_widths(struct d350_chan *dch)
+{
+ struct dma_device *dma = dch->vc.chan.device;
+ u32 widths = dma->src_addr_widths | dma->dst_addr_widths;
+
+ return widths & GENMASK(min_t(unsigned int, BIT(dch->tsz),
+ BITS_PER_TYPE(widths) - 1), 1);
+}
+
+static void d350_device_caps(struct dma_chan *chan, struct dma_slave_caps *caps)
+{
+ struct d350_chan *dch = to_d350_chan(chan);
+ u32 widths = d350_chan_widths(dch);
+
+ caps->src_addr_widths &= widths;
+ caps->dst_addr_widths &= widths;
+ if (!d350_slave_supported(dch))
+ caps->directions &= ~(BIT(DMA_MEM_TO_DEV) | BIT(DMA_DEV_TO_MEM));
+}
+
+static int d350_check_slave_config(struct d350_chan *dch,
+ struct dma_slave_config *config)
+{
+ u32 maxburst = FIELD_MAX(CH_CFG_MAXBURSTLEN) + 1;
+ u32 widths = d350_chan_widths(dch);
+
+ if (!d350_slave_supported(dch))
+ return -EOPNOTSUPP;
+
+ /* The unused direction may leave its bus width unspecified. */
+ if ((config->src_addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED &&
+ !d350_buswidth_supported(widths, config->src_addr_width)) ||
+ (config->dst_addr_width != DMA_SLAVE_BUSWIDTH_UNDEFINED &&
+ !d350_buswidth_supported(widths, config->dst_addr_width)))
+ return -EINVAL;
+
+ if (config->src_maxburst > maxburst ||
+ config->dst_maxburst > maxburst)
+ return -EINVAL;
+
+ return 0;
+}
+
+static int d350_device_config(struct dma_chan *chan,
+ struct dma_slave_config *config)
+{
+ struct d350_chan *dch = to_d350_chan(chan);
+ struct dma_device *dma = chan->device;
+ int ret;
+
+ ret = d350_check_slave_config(dch, config);
+ if (ret) {
+ dev_err(dma->dev, "invalid slave configuration\n");
+ return ret;
+ }
+
+ guard(spinlock_irqsave)(&dch->vc.lock);
+
+ dch->sconfig = *config;
+
+ return 0;
+}
+
+static struct dma_chan *d350_of_xlate(struct of_phandle_args *dma_spec,
+ struct of_dma *ofdma)
+{
+ struct d350 *dmac = ofdma->of_dma_data;
+ struct d350_chan *dch;
+ struct dma_chan *chan;
+ u32 req;
+ int i;
+
+ if (dma_spec->args_count != 1) {
+ dev_err(dmac->dma.dev, "dma phandle must have one argument\n");
+ return NULL;
+ }
+
+ req = dma_spec->args[0];
+ if (req >= dmac->nreq) {
+ dev_err(dmac->dma.dev, "invalid DMA request %u, have %d\n",
+ req, dmac->nreq);
+ return NULL;
+ }
+
+ for (i = 0; i < dmac->nchan; i++) {
+ dch = &dmac->channels[i];
+ if (!dch->has_trig)
+ continue;
+
+ chan = dma_get_slave_channel(&dch->vc.chan);
+ if (chan) {
+ dch->req = req;
+ return chan;
+ }
+ }
+
+ dev_err(dmac->dma.dev, "no free channel with trigger support\n");
+
+ return NULL;
+}
+
+static u32 d350_device_transcfg(u32 maxburst)
+{
+ return FIELD_PREP(CH_CFG_MAXBURSTLEN, maxburst - 1) |
+ FIELD_PREP(CH_CFG_SHAREATTR, SHAREATTR_OSH) |
+ FIELD_PREP(CH_CFG_MEMATTR, MEMATTR_DEVICE);
+}
+
+static int d350_slave_params(struct d350_chan *dch,
+ enum dma_transfer_direction direction,
+ phys_addr_t *dev_cpu_addr,
+ enum dma_data_direction *dev_dir,
+ enum dma_slave_buswidth *width, u32 *maxburst)
+{
+ struct dma_slave_config config;
+ int ret;
+
+ scoped_guard(spinlock_irqsave, &dch->vc.lock)
+ config = dch->sconfig;
+
+ ret = d350_check_slave_config(dch, &config);
+ if (ret)
+ return ret;
+ if (dch->req >= d350_chan_to_dmac(dch)->nreq)
+ return -EINVAL;
+
+ if (direction == DMA_MEM_TO_DEV) {
+ *dev_cpu_addr = config.dst_addr;
+ *dev_dir = DMA_FROM_DEVICE;
+ *width = config.dst_addr_width;
+ *maxburst = config.dst_maxburst;
+ } else if (direction == DMA_DEV_TO_MEM) {
+ *dev_cpu_addr = config.src_addr;
+ *dev_dir = DMA_TO_DEVICE;
+ *width = config.src_addr_width;
+ *maxburst = config.src_maxburst;
+ } else {
+ return -EINVAL;
+ }
+
+ return *width && *maxburst ? 0 : -EINVAL;
+}
+
+static void d350_fill_slave_cmd(struct d350_chan *dch, struct d350_desc *desc,
+ struct d350_slave_cmd *cmd,
+ dma_addr_t mem, dma_addr_t dev_dma_addr,
+ size_t len, bool link, dma_addr_t link_addr,
+ enum dma_transfer_direction direction,
+ enum dma_slave_buswidth width, u32 maxburst,
+ enum ch_ctrl_donetype donetype)
+{
+ bool mem_to_dev = direction == DMA_MEM_TO_DEV;
+ dma_addr_t src_addr = mem_to_dev ? mem : dev_dma_addr;
+ dma_addr_t dst_addr = mem_to_dev ? dev_dma_addr : mem;
+ u16 xsize;
+ u16 xsizehi;
+ u32 devcfg;
+ u32 memcfg;
+ u32 trigcfg;
+ u32 header;
+ u32 ctrl;
+
+ desc->tsz = __ffs(width);
+ xsize = lower_16_bits(len >> desc->tsz);
+ xsizehi = upper_16_bits(len >> desc->tsz);
+ devcfg = d350_device_transcfg(maxburst);
+ memcfg = dch->coherent ? TRANSCFG_WB : TRANSCFG_NC;
+
+ trigcfg = FIELD_PREP(CH_TRIGINCFG_BLKSIZE, maxburst - 1) |
+ FIELD_PREP(CH_TRIGINCFG_MODE, CH_TRIGINCFG_MODE_PERIPH_FC) |
+ FIELD_PREP(CH_TRIGINCFG_TYPE, CH_TRIGINCFG_TYPE_HW) |
+ FIELD_PREP(CH_TRIGINCFG_SEL, dch->req);
+
+ header = LINK_CTRL | LINK_SRCADDR | LINK_SRCADDRHI | LINK_DESADDR |
+ LINK_DESADDRHI | LINK_XSIZE | LINK_XSIZEHI | LINK_SRCTRANSCFG |
+ LINK_DESTRANSCFG | LINK_XADDRINC | LINK_LINKADDR |
+ LINK_LINKADDRHI |
+ (mem_to_dev ? LINK_DESTRIGINCFG : LINK_SRCTRIGINCFG);
+ ctrl = (mem_to_dev ? CH_CTRL_USEDESTRIGIN : CH_CTRL_USESRCTRIGIN) |
+ FIELD_PREP(CH_CTRL_TRANSIZE, desc->tsz) |
+ FIELD_PREP(CH_CTRL_XTYPE, CH_CTRL_XTYPE_CONTINUE) |
+ FIELD_PREP(CH_CTRL_DONETYPE, donetype);
+
+ cmd->header = cpu_to_le32(header);
+ cmd->ctrl = cpu_to_le32(ctrl);
+ cmd->src_addr = cpu_to_le64(src_addr);
+ cmd->dst_addr = cpu_to_le64(dst_addr);
+ cmd->xsize = cpu_to_le32(FIELD_PREP(CH_XY_SRC, xsize) |
+ FIELD_PREP(CH_XY_DES, xsize));
+ cmd->xsizehi = cpu_to_le32(FIELD_PREP(CH_XY_SRC, xsizehi) |
+ FIELD_PREP(CH_XY_DES, xsizehi));
+ cmd->src_transcfg = cpu_to_le32(mem_to_dev ? memcfg : devcfg);
+ cmd->dst_transcfg = cpu_to_le32(mem_to_dev ? devcfg : memcfg);
+ cmd->xaddrinc = cpu_to_le32(mem_to_dev ?
+ FIELD_PREP(CH_XY_SRC, 1) : FIELD_PREP(CH_XY_DES, 1));
+ cmd->trigincfg = cpu_to_le32(trigcfg);
+ cmd->link_addr = cpu_to_le64(link_addr | (link ? CH_LINKADDR_EN : 0));
+}
+
+static struct dma_async_tx_descriptor *
+d350_prep_slave_sg(struct dma_chan *dchan, struct scatterlist *sgl,
+ unsigned int sg_len,
+ enum dma_transfer_direction direction,
+ unsigned long flags, void *context)
+{
+ struct d350_chan *dch = to_d350_chan(dchan);
+ enum dma_data_direction dev_dir;
+ enum dma_slave_buswidth width;
+ struct d350_desc *desc;
+ phys_addr_t dev_cpu_addr;
+ dma_addr_t dev_dma_addr;
+ dma_addr_t mem;
+ struct scatterlist *sg;
+ u32 maxburst;
+ size_t len;
+ int i;
+
+ if (unlikely(!is_slave_direction(direction) || !sg_len))
+ return NULL;
+
+ if (d350_slave_params(dch, direction, &dev_cpu_addr, &dev_dir, &width,
+ &maxburst))
+ return NULL;
+
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
+ if (!desc)
+ return NULL;
+
+ desc->direction = direction;
+ dev_dma_addr = d350_map_resource(dchan, desc, dev_cpu_addr, width,
+ dev_dir);
+ if (dma_mapping_error(dchan->device->dev, dev_dma_addr))
+ goto err_free_desc;
+
+ if (sg_len > 1 && d350_alloc_cmds(dchan, desc, sg_len))
+ goto err_free_desc;
+
+ for_each_sg(sgl, sg, sg_len, i) {
+ enum ch_ctrl_donetype donetype = CH_CTRL_DONETYPE_CMD;
+ dma_addr_t link_addr = 0;
+ bool link = false;
+ struct d350_slave_cmd *cmd = &desc->slave;
+
+ mem = sg_dma_address(sg);
+ len = sg_dma_len(sg);
+ if (!len || (len >> __ffs(width)) > U32_MAX ||
+ !IS_ALIGNED(len | mem | dev_dma_addr, width))
+ goto err_free_cmds;
+
+ if (sg_len > 1) {
+ cmd = desc->cmds[i].cmd;
+ if (i < sg_len - 1) {
+ link = true;
+ link_addr = desc->cmds[i + 1].dma;
+ donetype = CH_CTRL_DONETYPE_NONE;
+ }
+ }
+
+ if (check_add_overflow(desc->bytes, len, &desc->bytes) ||
+ desc->bytes > U32_MAX)
+ goto err_free_cmds;
+
+ d350_fill_slave_cmd(dch, desc, cmd, mem, dev_dma_addr, len,
+ link, link_addr, direction, width, maxburst,
+ donetype);
+ }
+
+ return vchan_tx_prep(&dch->vc, &desc->vd, flags);
+
+err_free_cmds:
+ d350_free_cmds(d350_chan_to_dmac(dch), desc);
+err_free_desc:
+ d350_unmap_resource(dchan->device->dev, desc);
+ kfree(desc);
+
+ return NULL;
+}
+
+static struct dma_async_tx_descriptor *
+d350_prep_dma_cyclic(struct dma_chan *dchan, dma_addr_t buf_addr,
+ size_t buf_len, size_t period_len,
+ enum dma_transfer_direction direction, unsigned long flags)
+{
+ struct d350_chan *dch = to_d350_chan(dchan);
+ struct d350_desc *desc;
+ phys_addr_t dev_cpu_addr;
+ dma_addr_t dev_dma_addr;
+ enum dma_data_direction dev_dir;
+ enum dma_slave_buswidth width;
+ size_t period;
+ u32 maxburst;
+ int ret;
+
+ if (!buf_len || !period_len || buf_len % period_len ||
+ buf_len > U32_MAX || !is_slave_direction(direction))
+ return NULL;
+
+ ret = d350_slave_params(dch, direction, &dev_cpu_addr, &dev_dir, &width,
+ &maxburst);
+ if (ret)
+ return NULL;
+
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
+ if (!desc)
+ return NULL;
+
+ desc->direction = direction;
+ dev_dma_addr = d350_map_resource(dchan, desc, dev_cpu_addr, width,
+ dev_dir);
+ if (dma_mapping_error(dchan->device->dev, dev_dma_addr))
+ goto err_free_desc;
+
+ if (!IS_ALIGNED(buf_addr | dev_dma_addr | period_len, width))
+ goto err_free_desc;
+
+ desc->bytes = buf_len;
+ desc->period_len = period_len;
+ desc->periods = buf_len / period_len;
+ desc->cyclic = true;
+
+ if (d350_alloc_cmds(dchan, desc, desc->periods))
+ goto err_free_desc;
+
+ for (period = 0; period < desc->periods; period++) {
+ dma_addr_t mem = buf_addr + period * period_len;
+ dma_addr_t next = desc->cmds[(period + 1) % desc->periods].dma;
+
+ d350_fill_slave_cmd(dch, desc, desc->cmds[period].cmd, mem,
+ dev_dma_addr, period_len, true, next,
+ direction, width, maxburst, CH_CTRL_DONETYPE_CMD);
+ }
+
+ return vchan_tx_prep(&dch->vc, &desc->vd, flags);
+
+err_free_desc:
+ d350_unmap_resource(dchan->device->dev, desc);
+ kfree(desc);
+
+ return NULL;
}
static struct dma_async_tx_descriptor *d350_prep_memcpy(struct dma_chan *chan,
@@ -344,6 +838,75 @@ static u32 d350_get_residue(struct d350_chan *dch)
return res << dch->desc->tsz;
}
+static u32 d350_get_sg_residue(struct d350_chan *dch)
+{
+ struct d350_desc *desc = dch->desc;
+ size_t cmd = 0;
+ size_t i;
+ u32 linkaddr;
+ u32 linkaddrhi;
+ u32 hi_new;
+ u32 lo_new;
+ u32 residue;
+ u64 next_cmd;
+ int retries = 3;
+
+ if (!desc->cmds)
+ return d350_get_residue(dch);
+
+ /*
+ * CH_LINKADDR points at the next command. Match it against the command
+ * array to find the command currently executing, then add every later
+ * command which has not started yet.
+ */
+ /* The channel may step the link pointer between the two reads */
+ hi_new = readl_relaxed(dch->base + CH_LINKADDRHI);
+ do {
+ linkaddrhi = hi_new;
+ linkaddr = readl_relaxed(dch->base + CH_LINKADDR);
+ hi_new = readl_relaxed(dch->base + CH_LINKADDRHI);
+ } while (linkaddrhi != hi_new && --retries);
+
+ next_cmd = (linkaddr & ~CH_LINKADDR_EN) | ((u64)linkaddrhi << 32);
+
+ if (!next_cmd) {
+ cmd = desc->ncmds - 1;
+ } else {
+ for (i = 1; i < desc->ncmds; i++) {
+ if (next_cmd == desc->cmds[i].dma) {
+ cmd = i - 1;
+ break;
+ }
+ }
+ if (i == desc->ncmds)
+ return dch->residue;
+ }
+
+ residue = d350_get_residue(dch);
+
+ /*
+ * If the channel stepped to the next command while CH_XSIZE was read,
+ * the size belongs to the command which just finished and the sum below
+ * would count the bytes left in it twice. Keep the residue from the last
+ * completion in that case.
+ */
+ hi_new = readl_relaxed(dch->base + CH_LINKADDRHI);
+ lo_new = readl_relaxed(dch->base + CH_LINKADDR);
+ if (hi_new != linkaddrhi || lo_new != linkaddr)
+ return dch->residue;
+
+ for (i = cmd + 1; i < desc->ncmds; i++) {
+ const struct d350_slave_cmd *cmd = desc->cmds[i].cmd;
+ u32 count;
+
+ count = FIELD_GET(CH_XY_DES, le32_to_cpu(cmd->xsize));
+ count |= FIELD_GET(CH_XY_DES, le32_to_cpu(cmd->xsizehi)) << 16;
+ residue += (u64)count << desc->tsz;
+ }
+
+ return residue;
+}
+
static int d350_terminate_all(struct dma_chan *chan)
{
struct d350_chan *dch = to_d350_chan(chan);
@@ -395,6 +958,74 @@ static u32 d350_desc_bytes(struct d350_desc *desc)
return desc->bytes;
}
+static u32 d350_get_cyclic_residue(struct d350_chan *dch)
+{
+ struct d350_desc *desc = dch->desc;
+ size_t period;
+ size_t next;
+ u32 linkaddr;
+ u32 linkaddrhi;
+ u32 xsize;
+ u32 xsizehi;
+ u32 hi_new;
+ u32 lo_new;
+ u64 next_cmd;
+ u64 remaining;
+ int retries = 3;
+
+ /*
+ * Locate the current period from the next command's address rather than
+ * counting interrupts, since multiple period completions may share a
+ * pending DONE interrupt.
+ */
+ do {
+ linkaddrhi = readl_relaxed(dch->base + CH_LINKADDRHI);
+ linkaddr = readl_relaxed(dch->base + CH_LINKADDR);
+ hi_new = readl_relaxed(dch->base + CH_LINKADDRHI);
+ if (linkaddrhi != hi_new)
+ continue;
+
+ xsizehi = readl_relaxed(dch->base + CH_XSIZEHI);
+ xsize = readl_relaxed(dch->base + CH_XSIZE);
+ hi_new = readl_relaxed(dch->base + CH_XSIZEHI);
+ if (xsizehi != hi_new)
+ continue;
+
+ /* Retry if the link changed while reading the remaining size. */
+ lo_new = readl_relaxed(dch->base + CH_LINKADDR);
+ hi_new = readl_relaxed(dch->base + CH_LINKADDRHI);
+ if (linkaddrhi != hi_new || linkaddr != lo_new)
+ continue;
+
+ next_cmd = (linkaddr & ~CH_LINKADDR_EN) |
+ ((u64)linkaddrhi << 32);
+ for (next = 0; next < desc->periods; next++)
+ if (next_cmd == desc->cmds[next].dma)
+ break;
+ if (next == desc->periods)
+ continue;
+
+ remaining = FIELD_GET(CH_XY_DES, xsize) |
+ ((u64)FIELD_GET(CH_XY_DES, xsizehi) << 16);
+ remaining <<= desc->tsz;
+ if (remaining > desc->period_len)
+ continue;
+
+ period = next ? next - 1 : desc->periods - 1;
+ return desc->bytes - (period + 1) * desc->period_len + remaining;
+ } while (--retries);
+
+ return dch->residue;
+}
+
+static u32 d350_get_active_residue(struct d350_chan *dch)
+{
+ if (dch->desc->cyclic)
+ return d350_get_cyclic_residue(dch);
+
+ return d350_get_sg_residue(dch);
+}
+
static struct virt_dma_desc *d350_find_queued_desc(struct d350_chan *dch,
dma_cookie_t cookie)
{
@@ -421,7 +1052,7 @@ static enum dma_status d350_tx_status(struct dma_chan *chan, dma_cookie_t cookie
if (cookie == dch->cookie) {
status = dch->status;
if (status == DMA_IN_PROGRESS || status == DMA_PAUSED)
- dch->residue = d350_get_residue(dch);
+ dch->residue = d350_get_active_residue(dch);
residue = dch->residue;
} else {
vd = d350_find_queued_desc(dch, cookie);
@@ -438,22 +1069,10 @@ static enum dma_status d350_tx_status(struct dma_chan *chan, dma_cookie_t cookie
return status;
}
-static void d350_start_next(struct d350_chan *dch)
+static void d350_load_mem_cmd(struct d350_chan *dch)
{
- u32 hdr, *reg;
-
- /* Preserve the failed cookie's status until the channel is terminated. */
- if (dch->status == DMA_ERROR)
- return;
-
- dch->desc = to_d350_desc(vchan_next_desc(&dch->vc));
- if (!dch->desc)
- return;
-
- list_del(&dch->desc->vd.node);
- dch->status = DMA_IN_PROGRESS;
- dch->cookie = dch->desc->vd.tx.cookie;
- dch->residue = d350_desc_bytes(dch->desc);
+ u32 *reg;
+ u32 hdr;
hdr = dch->desc->command[0];
reg = &dch->desc->command[1];
@@ -492,6 +1111,55 @@ static void d350_start_next(struct d350_chan *dch)
writel_relaxed(*reg++, dch->base + CH_LINKADDR);
if (hdr & LINK_LINKADDRHI)
writel_relaxed(*reg++, dch->base + CH_LINKADDRHI);
+}
+
+static void d350_write_addr(struct d350_chan *dch, u32 reg, u64 addr)
+{
+ writel_relaxed(lower_32_bits(addr), dch->base + reg);
+ writel_relaxed(upper_32_bits(addr), dch->base + reg + sizeof(u32));
+}
+
+static void d350_load_slave_cmd(struct d350_chan *dch)
+{
+ struct d350_desc *desc = dch->desc;
+ const struct d350_slave_cmd *cmd;
+ u32 trig_reg;
+
+ cmd = desc->cmds ? desc->cmds[0].cmd : &desc->slave;
+ trig_reg = desc->direction == DMA_MEM_TO_DEV ?
+ CH_DESTRIGINCFG : CH_SRCTRIGINCFG;
+
+ writel_relaxed(le32_to_cpu(cmd->ctrl), dch->base + CH_CTRL);
+ d350_write_addr(dch, CH_SRCADDR, le64_to_cpu(cmd->src_addr));
+ d350_write_addr(dch, CH_DESADDR, le64_to_cpu(cmd->dst_addr));
+ writel_relaxed(le32_to_cpu(cmd->xsize), dch->base + CH_XSIZE);
+ writel_relaxed(le32_to_cpu(cmd->xsizehi), dch->base + CH_XSIZEHI);
+ writel_relaxed(le32_to_cpu(cmd->src_transcfg), dch->base + CH_SRCTRANSCFG);
+ writel_relaxed(le32_to_cpu(cmd->dst_transcfg), dch->base + CH_DESTRANSCFG);
+ writel_relaxed(le32_to_cpu(cmd->xaddrinc), dch->base + CH_XADDRINC);
+ writel_relaxed(le32_to_cpu(cmd->trigincfg), dch->base + trig_reg);
+ d350_write_addr(dch, CH_LINKADDR, le64_to_cpu(cmd->link_addr));
+}
+
+static void d350_start_next(struct d350_chan *dch)
+{
+ /* Preserve the failed cookie's status until the channel is terminated. */
+ if (dch->status == DMA_ERROR)
+ return;
+
+ dch->desc = to_d350_desc(vchan_next_desc(&dch->vc));
+ if (!dch->desc)
+ return;
+
+ list_del(&dch->desc->vd.node);
+ dch->status = DMA_IN_PROGRESS;
+ dch->cookie = dch->desc->vd.tx.cookie;
+ dch->residue = d350_desc_bytes(dch->desc);
+
+ if (is_slave_direction(dch->desc->direction))
+ d350_load_slave_cmd(dch);
+ else
+ d350_load_mem_cmd(dch);
writel(CH_CMD_ENABLE, dch->base + CH_CMD);
}
@@ -511,7 +1179,7 @@ static irqreturn_t d350_irq(int irq, void *data)
struct d350_chan *dch = data;
struct virt_dma_desc *vd;
struct d350_desc *desc;
- u32 residue;
+ u32 residue = 0;
u32 ch_status;
u32 irq_status;
u32 errinfo = 0;
@@ -544,18 +1212,26 @@ static irqreturn_t d350_irq(int irq, void *data)
else
vd->tx_result.result = DMA_TRANS_ABORTED;
- residue = d350_get_residue(dch);
+ residue = d350_get_active_residue(dch);
vd->tx_result.residue = residue;
dch->status = DMA_ERROR;
dch->residue = residue;
dch->desc = NULL;
- vchan_cookie_complete(vd);
+ if (desc->cyclic)
+ vchan_terminate_vdesc(vd);
+ else
+ vchan_cookie_complete(vd);
} else {
- dch->status = DMA_COMPLETE;
- dch->residue = 0;
- dch->desc = NULL;
- vchan_cookie_complete(vd);
- d350_start_next(dch);
+ if (desc->cyclic) {
+ dch->residue = d350_get_cyclic_residue(dch);
+ vchan_cyclic_callback(vd);
+ } else {
+ dch->status = DMA_COMPLETE;
+ dch->residue = 0;
+ dch->desc = NULL;
+ vchan_cookie_complete(vd);
+ d350_start_next(dch);
+ }
}
return IRQ_HANDLED;
@@ -584,6 +1260,11 @@ static void d350_free_chan_resources(struct dma_chan *chan)
free_irq(dch->irq, dch);
vchan_synchronize(&dch->vc);
vchan_free_chan_resources(&dch->vc);
+
+ guard(spinlock_irqsave)(&dch->vc.lock);
+
+ dch->req = U32_MAX;
+ memset(&dch->sconfig, 0, sizeof(dch->sconfig));
}
static int d350_probe(struct platform_device *pdev)
@@ -621,6 +1302,11 @@ static int d350_probe(struct platform_device *pdev)
return -ENOMEM;
dmac->nchan = nchan;
+ dmac->cmd_pool = dmam_pool_create("dma350-cmd", dev,
+ sizeof(struct d350_slave_cmd),
+ sizeof(u64), 0);
+ if (!dmac->cmd_pool)
+ return -ENOMEM;
reg = readl_relaxed(base + DMAINFO + DMA_BUILDCFG1);
dmac->nreq = FIELD_GET(DMA_CFG_NUM_TRIGGER_IN, reg);
@@ -639,19 +1325,23 @@ static int d350_probe(struct platform_device *pdev)
dmac->dma.device_free_chan_resources = d350_free_chan_resources;
dma_cap_set(DMA_MEMCPY, dmac->dma.cap_mask);
dmac->dma.device_prep_dma_memcpy = d350_prep_memcpy;
+ dmac->dma.device_prep_slave_sg = d350_prep_slave_sg;
+ dmac->dma.device_prep_dma_cyclic = d350_prep_dma_cyclic;
dmac->dma.device_pause = d350_pause;
dmac->dma.device_resume = d350_resume;
dmac->dma.device_terminate_all = d350_terminate_all;
dmac->dma.device_synchronize = d350_synchronize;
dmac->dma.device_tx_status = d350_tx_status;
dmac->dma.device_issue_pending = d350_issue_pending;
+ dmac->dma.device_config = d350_device_config;
+ dmac->dma.device_caps = d350_device_caps;
INIT_LIST_HEAD(&dmac->dma.channels);
reg = readl_relaxed(base + DMANSECCTRL + NSEC_CTRL);
writel_relaxed(reg | INTREN_ANYCHINTR_EN,
base + DMANSECCTRL + NSEC_CTRL);
- /* Would be nice to have per-channel caps for this... */
+ /* Advertise memset only if every usable channel supports wrap. */
memset = true;
for (int i = 0; i < nchan; i++) {
struct d350_chan *dch = &dmac->channels[i];
@@ -684,8 +1374,17 @@ static int d350_probe(struct platform_device *pdev)
writel_relaxed(reg, dch->base + CH_LINKATTR);
dch->coherent = coherent;
+ /* Request line 0 is valid, so it cannot mean unconfigured. */
+ dch->req = U32_MAX;
dch->vc.desc_free = d350_desc_free;
vchan_init(&dch->vc, &dmac->dma);
+
+ if (d350_slave_supported(dch)) {
+ dma_cap_set(DMA_SLAVE, dmac->dma.cap_mask);
+ dma_cap_set(DMA_CYCLIC, dmac->dma.cap_mask);
+ dmac->dma.directions |= BIT(DMA_MEM_TO_DEV) |
+ BIT(DMA_DEV_TO_MEM);
+ }
}
if (memset) {
@@ -699,6 +1398,14 @@ static int d350_probe(struct platform_device *pdev)
if (ret)
return dev_err_probe(dev, ret, "Failed to register DMA device\n");
+ if (dev->of_node) {
+ ret = devm_of_dma_controller_register(dev, dev->of_node,
+ d350_of_xlate, dmac);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to register OF DMA controller\n");
+ }
+
return 0;
}
--
2.54.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 09/10] dt-bindings: dma: arm,dma-350: Describe the CIX Sky1 integration
2026-11-17 9:43 [PATCH v7 00/10] dmaengine: arm-dma350: Add slave support and Sky1 integration Jelly Jia
` (7 preceding siblings ...)
2026-11-17 9:43 ` [PATCH v7 08/10] dmaengine: arm-dma350: Add slave and cyclic transfer support Jelly Jia
@ 2026-11-17 9:43 ` Jelly Jia
2026-11-17 9:43 ` [PATCH v7 10/10] dmaengine: arm-dma350: Support integration clocks and resets Jelly Jia
9 siblings, 0 replies; 11+ messages in thread
From: Jelly Jia @ 2026-11-17 9:43 UTC (permalink / raw)
To: vkoul, Frank.Li, robh, krzk+dt, conor+dt, robin.murphy
Cc: devicetree, cix-kernel-upstream, dmaengine, linux-arm-kernel,
linux-kernel, Jelly.Jia, Krzysztof Kozlowski, Frank Li
DMA-350 integrations may gate the controller with a bus clock or hold it
in reset. Describe these standard resources on the DMA controller node.
Add the CIX Sky1 compatible with an arm,dma-350 fallback. Sky1 requires
a bus clock for both its FCH and AUDSS instances, while only the AUDSS
instance provides a reset. Require clocks for the Sky1 compatible and
keep resets optional.
Both resources remain optional for the generic compatible alone, so
existing device trees remain valid.
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Jelly Jia <Jelly.Jia@cixtech.com>
---
.../devicetree/bindings/dma/arm,dma-350.yaml | 30 ++++++++++++++++---
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/dma/arm,dma-350.yaml b/Documentation/devicetree/bindings/dma/arm,dma-350.yaml
index 429f682f15d8..eab3b31aeba7 100644
--- a/Documentation/devicetree/bindings/dma/arm,dma-350.yaml
+++ b/Documentation/devicetree/bindings/dma/arm,dma-350.yaml
@@ -9,12 +9,13 @@ title: Arm CoreLink DMA-350 Controller
maintainers:
- Robin Murphy <robin.murphy@arm.com>
-allOf:
- - $ref: dma-controller.yaml#
-
properties:
compatible:
- const: arm,dma-350
+ oneOf:
+ - const: arm,dma-350
+ - items:
+ - const: cix,sky1-dma350
+ - const: arm,dma-350
reg:
items:
@@ -36,9 +37,30 @@ properties:
const: 1
description: The cell is the trigger input number
+ clocks:
+ maxItems: 1
+ description:
+ Bus clock, where the integration gates the controller clock.
+
+ resets:
+ maxItems: 1
+ description:
+ Optional reset line, where the integration exposes one.
+
required:
- compatible
- reg
- interrupts
+allOf:
+ - $ref: dma-controller.yaml#
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: cix,sky1-dma350
+ then:
+ required:
+ - clocks
+
unevaluatedProperties: false
--
2.54.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v7 10/10] dmaengine: arm-dma350: Support integration clocks and resets
2026-11-17 9:43 [PATCH v7 00/10] dmaengine: arm-dma350: Add slave support and Sky1 integration Jelly Jia
` (8 preceding siblings ...)
2026-11-17 9:43 ` [PATCH v7 09/10] dt-bindings: dma: arm,dma-350: Describe the CIX Sky1 integration Jelly Jia
@ 2026-11-17 9:43 ` Jelly Jia
9 siblings, 0 replies; 11+ messages in thread
From: Jelly Jia @ 2026-11-17 9:43 UTC (permalink / raw)
To: vkoul, Frank.Li, robh, krzk+dt, conor+dt, robin.murphy
Cc: devicetree, cix-kernel-upstream, dmaengine, linux-arm-kernel,
linux-kernel, Jelly.Jia, Frank Li
DMA-350 integrations may gate the controller with a clock or hold it in
reset. Enable an optional clock and deassert an optional reset before
accessing the controller registers.
Use the deasserted reset helper rather than requesting a reset pulse.
This also supports reset controllers that only implement assert and
deassert operations.
Both resources remain optional, so existing integrations without them
are unchanged.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Jelly Jia <Jelly.Jia@cixtech.com>
---
drivers/dma/arm-dma350.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c
index 7b46b4fdcf9c..ab68213d0bbb 100644
--- a/drivers/dma/arm-dma350.c
+++ b/drivers/dma/arm-dma350.c
@@ -6,6 +6,7 @@
#include <linux/bitops.h>
#include <linux/byteorder/generic.h>
#include <linux/cleanup.h>
+#include <linux/clk.h>
#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
#include <linux/dmapool.h>
@@ -17,6 +18,7 @@
#include <linux/of_dma.h>
#include <linux/overflow.h>
#include <linux/platform_device.h>
+#include <linux/reset.h>
#include <linux/scatterlist.h>
#include <linux/slab.h>
#include <linux/string.h>
@@ -1270,12 +1272,24 @@ static void d350_free_chan_resources(struct dma_chan *chan)
static int d350_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
+ struct reset_control *reset;
+ struct clk *clk;
struct d350 *dmac;
void __iomem *base;
u32 reg;
int ret, nchan, dw, aw, r, p;
bool coherent, memset;
+ clk = devm_clk_get_optional_enabled(dev, NULL);
+ if (IS_ERR(clk))
+ return dev_err_probe(dev, PTR_ERR(clk),
+ "failed to enable clock\n");
+
+ reset = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
+ if (IS_ERR(reset))
+ return dev_err_probe(dev, PTR_ERR(reset),
+ "failed to deassert reset\n");
+
base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base))
return PTR_ERR(base);
--
2.54.0
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-17 9:43 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 9:43 [PATCH v7 00/10] dmaengine: arm-dma350: Add slave support and Sky1 integration Jelly Jia
2026-11-17 9:43 ` [PATCH v7 01/10] dmaengine: arm-dma350: Fix source trigger bit Jelly Jia
2026-11-17 9:43 ` [PATCH v7 02/10] dmaengine: arm-dma350: Check DMA mask setup errors Jelly Jia
2026-11-17 9:43 ` [PATCH v7 03/10] dmaengine: arm-dma350: Initialize channel coherency Jelly Jia
2026-11-17 9:43 ` [PATCH v7 04/10] dmaengine: arm-dma350: Serialize IRQ and termination state Jelly Jia
2026-11-17 9:43 ` [PATCH v7 05/10] dmaengine: arm-dma350: Report submitted descriptor status Jelly Jia
2026-11-17 9:43 ` [PATCH v7 06/10] dmaengine: arm-dma350: Use managed device registration Jelly Jia
2026-11-17 9:43 ` [PATCH v7 07/10] dmaengine: arm-dma350: Track descriptor byte lengths explicitly Jelly Jia
2026-11-17 9:43 ` [PATCH v7 08/10] dmaengine: arm-dma350: Add slave and cyclic transfer support Jelly Jia
2026-11-17 9:43 ` [PATCH v7 09/10] dt-bindings: dma: arm,dma-350: Describe the CIX Sky1 integration Jelly Jia
2026-11-17 9:43 ` [PATCH v7 10/10] dmaengine: arm-dma350: Support integration clocks and resets Jelly Jia
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®