dmaengine: dw-edma: Add simple mode support
Subsystems (2)
PATCH 1/1 dmaengine: dw-edma: Add simple mode support
Added the simple or non-linked list DMA mode of transfer.
--- drivers/dma/dw-edma/dw-edma-core.c | 38 +++++++++++++++++ drivers/dma/dw-edma/dw-edma-core.h | 1 + drivers/dma/dw-edma/dw-hdma-v0-core.c | 59 ++++++++++++++++++++++++++- 3 files changed, 97 insertions(+), 1 deletion(-)
drivers/dma/dw-edma/dw-edma-core.c +38 -0
@@ -595,6 +595,43 @@ dw_edma_device_prep_interleaved_dma(struct dma_chan *dchan,return dw_edma_device_transfer (&xfer); } +static struct dma_async_tx_descriptor * +dw_edma_device_prep_dma_memcpy (struct dma_chan *dchan, +dma_addr_t dst, +dma_addr_t src,size_t len, +unsigned long flags) +{ +struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan); +struct dw_edma_chunk *chunk; +struct dw_edma_burst *burst; +struct dw_edma_desc *desc; + + desc =dw_edma_alloc_desc (chan); +if (unlikely (!desc)) +return NULL ; + + chunk =dw_edma_alloc_chunk (desc); +if (unlikely (!chunk)) + goto err_alloc; + + burst =dw_edma_alloc_burst (chunk); +if (unlikely (!burst)) + goto err_alloc; + + burst->sar = src; + burst->dar = dst; + burst->sz = len; + chunk->non_ll_en = true; + + desc->alloc_sz += burst->sz; + +return vchan_tx_prep (&chan->vc, &desc->vd, flags); + +err_alloc: +dw_edma_free_desc (desc); +return NULL ; +} +static void dw_edma_done_interrupt (struct dw_edma_chan *chan) {struct dw_edma_desc *desc;
@@ -806,6 +843,7 @@ static int dw_edma_channel_setup(struct dw_edma *dw, u32 wr_alloc, u32 rd_alloc) dma->device_prep_slave_sg = dw_edma_device_prep_slave_sg; dma->device_prep_dma_cyclic = dw_edma_device_prep_dma_cyclic; dma->device_prep_interleaved_dma = dw_edma_device_prep_interleaved_dma; + dma->device_prep_dma_memcpy = dw_edma_device_prep_dma_memcpy;dma_set_max_seg_size (dma->dev,U32_MAX );
drivers/dma/dw-edma/dw-edma-core.h +1 -0
@@ -58,6 +58,7 @@ struct dw_edma_chunk {u8 cb;struct dw_edma_region ll_region;/* Linked list */ +bool non_ll_en; };struct dw_edma_desc {
drivers/dma/dw-edma/dw-hdma-v0-core.c +58 -1
71 lines not on this page · raw message
Signature · 1 line
2.43.0
On Wed, Feb 19, 2025 at 04:38:47PM +0530, Devendra K Verma wrote:
+ Niklas (who also looked into the MEMCPY for eDMA)
Quoted 2 lines
Added the simple or non-linked list DMA mode of transfer.
Patch subject and description are also simple :) You completely forgot to mention that you are adding the DMA_MEMCPY support to this driver. That too only for HDMA.
Quoted 30 lines
Signed-off-by Devendra K Verma <[email protected]>--- drivers/dma/dw-edma/dw-edma-core.c | 38 +++++++++++++++++ drivers/dma/dw-edma/dw-edma-core.h | 1 + drivers/dma/dw-edma/dw-hdma-v0-core.c | 59 ++++++++++++++++++++++++++- 3 files changed, 97 insertions(+), 1 deletion(-)drivers/dma/dw-edma/dw-edma-core.c +15
-0@@ -595,6 +595,43 @@ dw_edma_device_prep_interleaved_dma(struct dma_chan *dchan,return dw_edma_device_transfer (&xfer); } +static struct dma_async_tx_descriptor * +dw_edma_device_prep_dma_memcpy (struct dma_chan *dchan, +dma_addr_t dst, +dma_addr_t src,size_t len, +unsigned long flags) +{ +struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan); +struct dw_edma_chunk *chunk; +struct dw_edma_burst *burst; +struct dw_edma_desc *desc; + + desc =dw_edma_alloc_desc (chan); +if (unlikely (!desc)) +return NULL ; +
drivers/dma/dw-edma/dw-edma-core.c dw_edma_device_prep_interleaved_dma(struct dma_chan *dchan, · line 622
Quoted 10 lines
drivers/dma/dw-edma/dw-edma-core.c +10
-0+ chunk =dw_edma_alloc_chunk (desc); +if (unlikely (!chunk)) + goto err_alloc; + + burst =dw_edma_alloc_burst (chunk); +if (unlikely (!burst)) + goto err_alloc; + + burst->sar = src; + burst->dar = dst;
Niklas looked into adding MEMCPY support but blocked by the fact that the device_prep_dma_memcpy() assumes that the direction is always MEM_TO_MEM. But the eDMA driver (HDMA also?) only support transfers between remote and local DDR. So only MEM_TO_DEV and DEV_TO_MEM are valid directions (assuming that we call the remote DDR as DEV).
One can also argue that since both are DDR addresses anyway, we could use the MEM_TO_MEM direction. But that will not help in identifying the unsupported local to local and remote to remote transfers.
I haven't referred the HDMA spec yet, but does HDMA support the above case also?
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 49 lines · Manivannan Sadhasivam
On Wed, Feb 19, 2025 at 04:38:47PM +0530, Devendra K Verma wrote:
+ Niklas (who also looked into the MEMCPY for eDMA)
Quoted 2 lines
Added the simple or non-linked list DMA mode of transfer.
Patch subject and description are also simple :) You completely forgot to mention that you are adding the
DMA_MEMCPYsupport to this driver. That too only for HDMA.Quoted 38 lines
Signed-off-by Devendra K Verma <[email protected]>--- drivers/dma/dw-edma/dw-edma-core.c | 38 +++++++++++++++++ drivers/dma/dw-edma/dw-edma-core.h | 1 + drivers/dma/dw-edma/dw-hdma-v0-core.c | 59 ++++++++++++++++++++++++++- 3 files changed, 97 insertions(+), 1 deletion(-)drivers/dma/dw-edma/dw-edma-core.c +23
-0@@ -595,6 +595,43 @@ dw_edma_device_prep_interleaved_dma(struct dma_chan *dchan,return dw_edma_device_transfer (&xfer); } +static struct dma_async_tx_descriptor * +dw_edma_device_prep_dma_memcpy (struct dma_chan *dchan, +dma_addr_t dst, +dma_addr_t src,size_t len, +unsigned long flags) +{ +struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan); +struct dw_edma_chunk *chunk; +struct dw_edma_burst *burst; +struct dw_edma_desc *desc; + + desc =dw_edma_alloc_desc (chan); +if (unlikely (!desc)) +return NULL ; + + chunk =dw_edma_alloc_chunk (desc); +if (unlikely (!chunk)) + goto err_alloc; + + burst =dw_edma_alloc_burst (chunk); +if (unlikely (!burst)) + goto err_alloc; +
Quoted 8 lines
drivers/dma/dw-edma/dw-edma-core.c dw_edma_device_prep_interleaved_dma(struct dma_chan *dchan, · line 622
Quoted 2 lines
drivers/dma/dw-edma/dw-edma-core.c +2
-0+ burst->sar = src; + burst->dar = dst;Niklas looked into adding MEMCPY support but blocked by the fact that the
device_prep_dma_memcpy()assumes that the direction is alwaysMEM_TO_MEM. But the eDMA driver (HDMA also?) only support transfers between remote and local DDR. So onlyMEM_TO_DEVandDEV_TO_MEMare valid directions (assuming that we call the remote DDR as DEV).
In rk3588 TRM:
MAP_FORMAT0x0 (EDMA_LEGACY_PL): Legacy DMA register map accessed by the port-logic
registers0x1 (EDMA_LEGACY_UNROLL): Legacy DMA register map, mapped to a PF/BAR 0x5 (HDMA_COMPATIBILITY_MODE): HDMA compatibility mode (CC_LEGACY_DMA_MAP =1)
register map, mapped to a PF/BAR0x7 (HDMA_NATIVE): HDMA native (CC_LEGACY_DMA_MAP =0) register map, mapped to
a PF/BAR
Read-only register. Value After Reset: 0x1.
So eDMA in rk3588 is EDMA_LEGACY_UNROLL.
I don't know if this limitation that you correctly described applies to all the other formats as well.
Kind regards,
Niklas