dma: Add Freescale eDMA engine driver support
Subsystems (3)
v10 cover dma: Add Freescale eDMA engine driver support
This series add Freescale eDMA engine support.
Jingchang Lu (2):
ARM: dts: vf610: Add eDMA node
dma: Add Freescale eDMA engine driver support
Documentation/devicetree/bindings/dma/fsl-edma.txt | 76 ++++ arch/arm/boot/dts/vf610.dtsi | 30 ++ drivers/dma/Kconfig | 10 + drivers/dma/Makefile | 1 + drivers/dma/fsl-edma.c | 956 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1073 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/fsl-edma.txt create mode 100644 drivers/dma/fsl-edma.c
PATCH v10 1/2 ARM: dts: vf610: Add eDMA node
---
no changes in v10.
changes in v9:
remove include/dt-bindings/dma/vf610-edma.h, the request source ID is the same as SoC's reference manual.
changes in v8:
describe dmamux info in edma node to avoid confusion. change eDMA requst source macro definitions.
changes in v7:
fix dmamux2 and dmamux3 register number.
no changes in v2 ~ v6.
arch/arm/boot/dts/vf610.dtsi | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
arch/arm/boot/dts/vf610.dtsi +30 -0
@@ -88,6 +88,21 @@ arm,tag-latency = <2 2 2>; }; + edma0: dma-controller at 40018000 { + #dma-cells = <2>; + compatible = "fsl,vf610-edma"; + reg = <0x40018000 0x2000>, + <0x40024000 0x1000>, + <0x40025000 0x1000>; + interrupts = <0 8 IRQ_TYPE_LEVEL_HIGH>, + <0 9 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "edma-tx", "edma-err"; + dma-channels = <32>; + clock-names = "dmamux0", "dmamux1"; + clocks = <&clks VF610_CLK_DMAMUX0>, + <&clks VF610_CLK_DMAMUX1>; + }; + uart0: serial at 40027000 { compatible = "fsl,vf610-lpuart"; reg = <0x40027000 0x1000>;
@@ -263,6 +278,21 @@ reg = <0x40080000 0x80000>; ranges; + edma1: dma-controller at 40098000 { + #dma-cells = <2>; + compatible = "fsl,vf610-edma"; + reg = <0x40098000 0x2000>, + <0x400a1000 0x1000>, + <0x400a2000 0x1000>; + interrupts = <0 10 IRQ_TYPE_LEVEL_HIGH>, + <0 11 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "edma-tx", "edma-err"; + dma-channels = <32>; + clock-names = "dmamux0", "dmamux1"; + clocks = <&clks VF610_CLK_DMAMUX2>, + <&clks VF610_CLK_DMAMUX3>; + }; + uart4: serial at 400a9000 { compatible = "fsl,vf610-lpuart"; reg = <0x400a9000 0x1000>;
Signature · 1 line
1.8.0
PATCH v10 2/2 dma: Add Freescale eDMA engine driver support
In reply to Jingchang LuAdd Freescale enhanced direct memory(eDMA) controller support. This module can be found on Vybrid and LS-1 SoCs.
---
changes in v10:
define fsl_edma_mutex in fsl_edma_engine instead of global. minor changes of binding description.
changes in v9:
define endian's operating functions instead of macro definition. remove the filter function, using dma_get_slave_channel instead.
changes in v8:
change the edma driver according eDMA dts change. add big-endian and little-endian handling.
no changes in v4 ~ v7.
changes in v3:
add vf610 edma dt-bindings namespace with prefix VF610_*.
changes in v2:
using generic dma-channels property instead of fsl,dma-channels.
Documentation/devicetree/bindings/dma/fsl-edma.txt | 76 ++ drivers/dma/Kconfig | 10 + drivers/dma/Makefile | 1 + drivers/dma/fsl-edma.c | 956 +++++++++++++++++++++ 4 files changed, 1043 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/fsl-edma.txt create mode 100644 drivers/dma/fsl-edma.c
Documentation/devicetree/bindings/dma/fsl-edma.txt new file +76 -0
@@ -0,0 +1,76 @@ +* Freescale enhanced Direct Memory Access(eDMA) Controller + + The eDMA channels have multiplex capability by programmble memory-mapped +registers. channels are split into two groups, called DMAMUX0 and DMAMUX1, +specific DMA request source can only be multiplexed by any channel of certain +group, DMAMUX0 or DMAMUX1, but not both. + +* eDMA Controller +Required properties: +- compatible : + - "fsl,vf610-edma" for eDMA used similar to that on Vybrid vf610 SoC +- reg : Specifies base physical address(s) and size of the eDMA registers. + The 1st region is eDMA control register's address and size. + The 2nd and the 3rd regions are programmable channel multiplexing + control register's address and size. +- interrupts : A list of interrupt-specifiers, one for each entry in + interrupt-names. +- interrupt-names : Should contain: + "edma-tx" - the transmission interrupt + "edma-err" - the error interrupt +- #dma-cells : Must be <2>. + The 1st cell specifies the DMAMUX(0 for DMAMUX0 and 1 for DMAMUX1). + Specific request source can only be multiplexed by specific channels + group called DMAMUX. + The 2nd cell specifies the request source(slot) ID. + See the SoC's reference manual for all the supported request sources. +- dma-channels : Number of channels supported by the controller +- clock-names : A list of channel group clock names. Should contain: + "dmamux0" - clock name of mux0 group + "dmamux1" - clock name of mux1 group +- clocks : A list of phandle and clock-specifier pairs, one for each entry in + clock-names. + +Optional properties: +- big-endian: If present registers and hardware scatter/gather descriptors + of the eDMA are implemented in big endian mode, otherwise in little + mode. + + +Examples: + +edma0: dma-controller at 40018000 { + #dma-cells = <2>; + compatible = "fsl,vf610-edma"; + reg = <0x40018000 0x2000>, + <0x40024000 0x1000>, + <0x40025000 0x1000>; + interrupts = <0 8 IRQ_TYPE_LEVEL_HIGH>, + <0 9 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "edma-tx", "edma-err"; + dma-channels = <32>; + clock-names = "dmamux0", "dmamux1"; + clocks = <&clks VF610_CLK_DMAMUX0>, + <&clks VF610_CLK_DMAMUX1>; +}; + + +* DMA clients +DMA client drivers that uses the DMA function must use the format described +in the dma.txt file, using a two-cell specifier for each channel: the 1st +specifies the channel group(DMAMUX) in which this request can be multiplexed, +and the 2nd specifies the request source. + +Examples: + +sai2: sai at 40031000 { + compatible = "fsl,vf610-sai"; + reg = <0x40031000 0x1000>; + interrupts = <0 86 IRQ_TYPE_LEVEL_HIGH>; + clock-names = "sai"; + clocks = <&clks VF610_CLK_SAI2>; + dma-names = "tx", "rx"; + dmas = <&edma0 0 21>, + <&edma0 0 20>; + status = "disabled"; +};
drivers/dma/Kconfig +10 -0
@@ -342,6 +342,16 @@ config K3_DMA Support the DMA engine for Hisilicon K3 platform devices. +config FSL_EDMA + tristate "Freescale eDMA engine support" + depends on OF + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + Support the Freescale eDMA engine with programmable channel + multiplexing capability for DMA request sources(slot). + This module can be found on Freescale Vybrid and LS-1 SoCs. + config DMA_ENGINE bool
drivers/dma/Makefile +1 -0
@@ -43,3 +43,4 @@ obj-$(CONFIG_MMP_PDMA) += mmp_pdma.o obj-$(CONFIG_DMA_JZ4740) += dma-jz4740.o obj-$(CONFIG_TI_CPPI41) += cppi41.o obj-$(CONFIG_K3_DMA) += k3dma.o +obj-$(CONFIG_FSL_EDMA) += fsl-edma.o
drivers/dma/fsl-edma.c new file +956 -0
956 lines not on this page · raw message
Signature · 1 line
1.8.0
Quoted 8 lines · Jingchang Lu
Add Freescale enhanced direct memory(eDMA) controller support. This module can be found on Vybrid and LS-1 SoCs.
Signed-off-by Alison Wang <[email protected]>Signed-off-by Jingchang Lu <[email protected]>Acked-by Arnd Bergmann <[email protected]>---
drivers/dma/fsl-edma.c line 137
Quoted 9 lines
drivers/dma/fsl-edma.c new file +9
-0+struct fsl_edma_sw_tcd { +dma_addr_t ptcd; +struct fsl_edma_hw_tcd *vtcd; +}; + +struct fsl_edma_slave_config { +enum dma_transfer_direction dir; +enum dma_slave_buswidth addr_width; +u32 dev_addr;
u32 for device address doesnt look right, we should be using dma_addr_t?
drivers/dma/fsl-edma.c line 139
Quoted 2 lines
drivers/dma/fsl-edma.c new file +2
-0+u32 burst; +u32 attr;
Looking at this, all fields expect attr are in dma_slave_config! So why do we need these here and what does the attr mean?
Quoted 7 lines
drivers/dma/fsl-edma.c new file +7
-0+static int fsl_edma_control (struct dma_chan *chan,enum dma_ctrl_cmd cmd, +unsigned long arg) +{ +struct fsl_edma_chan *fsl_chan =to_fsl_edma_chan (chan); +struct dma_slave_config *cfg = (void *)arg; +unsigned long flags; +LIST_HEAD (head);
drivers/dma/fsl-edma.c line 305
Quoted 10 lines
drivers/dma/fsl-edma.c new file +10
-0+ +switch (cmd) { +case DMA_TERMINATE_ALL : +spin_lock_irqsave (&fsl_chan->vchan.lock, flags); +fsl_edma_disable_request (fsl_chan); + fsl_chan->edesc =NULL ; +vchan_get_all_descriptors (&fsl_chan->vchan, &head); +spin_unlock_irqrestore (&fsl_chan->vchan.lock, flags); +vchan_dma_desc_free_list (&fsl_chan->vchan, &head); +return 0 ;
well what happens to the current ongoing transactions, i don't see those getting terminated?
drivers/dma/fsl-edma.c line 318
Quoted 13 lines
drivers/dma/fsl-edma.c new file +13
-0+ +case DMA_SLAVE_CONFIG : + fsl_chan->fsc.dir = cfg->direction; +if (cfg->direction ==DMA_DEV_TO_MEM ) { + fsl_chan->fsc.dev_addr = cfg->src_addr; + fsl_chan->fsc.addr_width = cfg->src_addr_width; + fsl_chan->fsc.burst = cfg->src_maxburst; + fsl_chan->fsc.attr =fsl_edma_get_tcd_attr (cfg->src_addr_width); + }else if (cfg->direction ==DMA_MEM_TO_DEV ) { + fsl_chan->fsc.dev_addr = cfg->dst_addr; + fsl_chan->fsc.addr_width = cfg->dst_addr_width; + fsl_chan->fsc.burst = cfg->dst_maxburst; + fsl_chan->fsc.attr =fsl_edma_get_tcd_attr (cfg->dst_addr_width);
okay atrr is address width, why not save this standard struct instead?
Quoted 53 lines
drivers/dma/fsl-edma.c new file +52
-0+ }else { +return -EINVAL ; + } +return 0 ; + +case DMA_PAUSE : +spin_lock_irqsave (&fsl_chan->vchan.lock, flags); +if (fsl_chan->edesc) { +fsl_edma_disable_request (fsl_chan); + fsl_chan->status =DMA_PAUSED ; + } +spin_unlock_irqrestore (&fsl_chan->vchan.lock, flags); +return 0 ; + +case DMA_RESUME : +spin_lock_irqsave (&fsl_chan->vchan.lock, flags); +if (fsl_chan->edesc) { +fsl_edma_enable_request (fsl_chan); + fsl_chan->status =DMA_IN_PROGRESS ; + } +spin_unlock_irqrestore (&fsl_chan->vchan.lock, flags); +return 0 ; + +default : +return -ENXIO ; + } +} + +static struct fsl_edma_desc *fsl_edma_alloc_desc (struct fsl_edma_chan *fsl_chan, +int sg_len) +{ +struct fsl_edma_desc *fsl_desc; +int i; + + fsl_desc =kzalloc (sizeof (*fsl_desc) +sizeof (struct fsl_edma_sw_tcd ) * sg_len, +GFP_NOWAIT ); +if (!fsl_desc) +return NULL ; + + fsl_desc->echan = fsl_chan; + fsl_desc->n_tcds = sg_len; +for (i =0 ; i < sg_len; i++) { + fsl_desc->tcd[i].vtcd =dma_pool_alloc (fsl_chan->tcd_pool, +GFP_NOWAIT , &fsl_desc->tcd[i].ptcd); +if (!fsl_desc->tcd[i].vtcd) + goto err; + } +return fsl_desc; + +err: +while (--i >=0 ) + dma_pool_free(fsl_chan->tcd_pool, fsl_desc->tcd[i].vtcd,
drivers/dma/fsl-edma.c line 394
Quoted 10 lines
drivers/dma/fsl-edma.c new file +10
-0+ fsl_desc->tcd[i].ptcd); +kfree (fsl_desc); +return NULL ; +} + +static struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic ( +struct dma_chan *chan,dma_addr_t dma_addr,size_t buf_len, +size_t period_len,enum dma_transfer_direction direction, +unsigned long flags,void *context) +{
you may want to implement the capablities api subsequently for audio usage.
Quoted 9 lines
drivers/dma/fsl-edma.c new file +9
-0+struct fsl_edma_chan *fsl_chan =to_fsl_edma_chan (chan); +struct fsl_edma_desc *fsl_desc; +dma_addr_t dma_buf_next; +int sg_len, i; +u32 src_addr, dst_addr, last_sg, nbytes; +u16 soff, doff, iter; + +if (!is_slave_direction (fsl_chan->fsc.dir)) +return NULL ;
drivers/dma/fsl-edma.c line 534
Quoted 10 lines
drivers/dma/fsl-edma.c new file +10
-0+ + sg_len = buf_len / period_len; + fsl_desc =fsl_edma_alloc_desc (fsl_chan, sg_len); +if (!fsl_desc) +return NULL ; + fsl_desc->iscyclic = true; + + dma_buf_next = dma_addr; + nbytes = fsl_chan->fsc.addr_width * fsl_chan->fsc.burst; + iter = period_len / nbytes;
empty line here pls
Quoted 27 lines
drivers/dma/fsl-edma.c new file +27
-0+for (i =0 ; i < sg_len; i++) { +if (dma_buf_next >= dma_addr + buf_len) + dma_buf_next = dma_addr; + +/* get next sg's physical address */ + last_sg = fsl_desc->tcd[(i +1 ) % sg_len].ptcd; + +if (fsl_chan->fsc.dir ==DMA_MEM_TO_DEV ) { + src_addr = dma_buf_next; + dst_addr = fsl_chan->fsc.dev_addr; + soff = fsl_chan->fsc.addr_width; + doff =0 ; + }else { + src_addr = fsl_chan->fsc.dev_addr; + dst_addr = dma_buf_next; + soff =0 ; + doff = fsl_chan->fsc.addr_width; + } + +fill_tcd_params (fsl_chan->edma, fsl_desc->tcd[i].vtcd, src_addr, + dst_addr, fsl_chan->fsc.attr, soff, nbytes,0 , + iter, iter, doff, last_sg, true, false, true); + dma_buf_next += period_len; + } + +return vchan_tx_prep (&fsl_chan->vchan, &fsl_desc->vdesc, flags); +}
Signature · 1 line
~Vinod
Quoted 34 lines
-----Original Message-----
From: Vinod Koul [mailto:vinod.koul at intel.com]
Sent: Monday, January 20, 2014 3:40 PM
To: Lu Jingchang-B35083
Cc: dan.j.williams at intel.com; arnd at arndb.de; shawn.guo at linaro.org; pawel.moll at arm.com; mark.rutland at arm.com; swarren at wwwdotorg.org; linux- kernel at vger.kernel.org; linux-arm-kernel at lists.infradead.org; devicetree at vger.kernel.org; Wang Huan-B18965
Subject: Re: [PATCHv10 2/2] dma: Add Freescale eDMA engine driver supportQuoted 9 lines · Jingchang Lu
Add Freescale enhanced direct memory(eDMA) controller support. This module can be found on Vybrid and LS-1 SoCs.
Signed-off-by Alison Wang <[email protected]>Signed-off-by Jingchang Lu <[email protected]>Acked-by Arnd Bergmann <[email protected]>---
+static int fsl_edma_control(struct
dma_chan*chan, enumdma_ctrl_cmdcmd,
Quoted 11 lines
drivers/dma/fsl-edma.c new file +11
-0+ unsigned long arg) +{ +struct fsl_edma_chan *fsl_chan =to_fsl_edma_chan (chan); +struct dma_slave_config *cfg = (void *)arg; +unsigned long flags; +LIST_HEAD (head); + +switch (cmd) { +case DMA_TERMINATE_ALL : +spin_lock_irqsave (&fsl_chan->vchan.lock, flags); +fsl_edma_disable_request (fsl_chan);
Quoted 8 lines
drivers/dma/fsl-edma.c line 305
Quoted 5 lines
drivers/dma/fsl-edma.c new file +5
-0+ fsl_chan->edesc =NULL ; +vchan_get_all_descriptors (&fsl_chan->vchan, &head); +spin_unlock_irqrestore (&fsl_chan->vchan.lock, flags); +vchan_dma_desc_free_list (&fsl_chan->vchan, &head); +return 0 ;well what happens to the current ongoing transactions, i don't see those getting
terminated?
The fsl_edma_disable_request(fsl_chan) would end the channel's ongoing transaction, then the eDMA would not response to device dma request, and the vchan_dma_desc_free_list() will release all associate memory. Thanks.
Quoted 17 lines
Quoted 15 lines
drivers/dma/fsl-edma.c new file +8
-0+ +case DMA_SLAVE_CONFIG : + fsl_chan->fsc.dir = cfg->direction; +if (cfg->direction ==DMA_DEV_TO_MEM ) { + fsl_chan->fsc.dev_addr = cfg->src_addr; + fsl_chan->fsc.addr_width = cfg->src_addr_width; + fsl_chan->fsc.burst = cfg->src_maxburst; + fsl_chan->fsc.attr = fsl_edma_get_tcd_attr(cfg-
src_addr_width);drivers/dma/fsl-edma.c new file +5
-0+ }else if (cfg->direction ==DMA_MEM_TO_DEV ) { + fsl_chan->fsc.dev_addr = cfg->dst_addr; + fsl_chan->fsc.addr_width = cfg->dst_addr_width; + fsl_chan->fsc.burst = cfg->dst_maxburst; + fsl_chan->fsc.attr = fsl_edma_get_tcd_attr(cfg-Quoted 1 line
dst_addr_width);okay atrr is address width, why not save this standard struct instead?
The value saved in fsc.attr is transferred by fsl_edma_get_tcd_attr(), it can be set into the channel control register later directly. the edma driver doesn't need to save all dma_slave_config parameters, so it only gets the necessaries. Thanks.
Quoted 60 lines
Quoted 21 lines
drivers/dma/fsl-edma.c new file +20
-0+ }else { +return -EINVAL ; + } +return 0 ; + +case DMA_PAUSE : +spin_lock_irqsave (&fsl_chan->vchan.lock, flags); +if (fsl_chan->edesc) { +fsl_edma_disable_request (fsl_chan); + fsl_chan->status =DMA_PAUSED ; + } +spin_unlock_irqrestore (&fsl_chan->vchan.lock, flags); +return 0 ; + +case DMA_RESUME : +spin_lock_irqsave (&fsl_chan->vchan.lock, flags); +if (fsl_chan->edesc) { +fsl_edma_enable_request (fsl_chan); + fsl_chan->status =DMA_IN_PROGRESS ; + }drivers/dma/fsl-edma.c
Quoted 10 lines
drivers/dma/fsl-edma.c new file +9
-0+spin_unlock_irqrestore (&fsl_chan->vchan.lock, flags); +return 0 ; + +default : +return -ENXIO ; + } +} + +static struct fsl_edma_desc *fsl_edma_alloc_desc(struct fsl_edma_chan
*fsl_chan,drivers/dma/fsl-edma.c
Quoted 6 lines
drivers/dma/fsl-edma.c new file +6
-0+ int sg_len) +{ +struct fsl_edma_desc *fsl_desc; +int i; + + fsl_desc = kzalloc(sizeof(*fsl_desc) + sizeof(struct
fsl_edma_sw_tcd) *sg_len,Quoted 21 lines
drivers/dma/fsl-edma.c new file +21
-0+ GFP_NOWAIT); +if (!fsl_desc) +return NULL ; + + fsl_desc->echan = fsl_chan; + fsl_desc->n_tcds = sg_len; +for (i =0 ; i < sg_len; i++) { + fsl_desc->tcd[i].vtcd =dma_pool_alloc (fsl_chan->tcd_pool, +GFP_NOWAIT , &fsl_desc->tcd[i].ptcd); +if (!fsl_desc->tcd[i].vtcd) + goto err; + } +return fsl_desc; + +err: +while (--i >=0 ) +dma_pool_free (fsl_chan->tcd_pool, fsl_desc->tcd[i].vtcd, + fsl_desc->tcd[i].ptcd); +kfree (fsl_desc); +return NULL ; +}
Quoted 8 lines
drivers/dma/fsl-edma.c line 515
Quoted 6 lines
drivers/dma/fsl-edma.c new file +6
-0+ +static struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic ( +struct dma_chan *chan,dma_addr_t dma_addr,size_t buf_len, +size_t period_len,enum dma_transfer_direction direction, +unsigned long flags,void *context) +{you may want to implement the capablities api subsequently for audio usage.
Do you mean the device_slave_caps function? If it is, I will add it. Thanks.
Quoted 13 lines
Quoted 13 lines
drivers/dma/fsl-edma.c new file +12
-0+struct fsl_edma_chan *fsl_chan =to_fsl_edma_chan (chan); +struct fsl_edma_desc *fsl_desc; +dma_addr_t dma_buf_next; +int sg_len, i; +u32 src_addr, dst_addr, last_sg, nbytes; +u16 soff, doff, iter; + +if (!is_slave_direction (fsl_chan->fsc.dir)) +return NULL ; + + sg_len = buf_len / period_len; + fsl_desc =fsl_edma_alloc_desc (fsl_chan, sg_len);
Quoted 8 lines
drivers/dma/fsl-edma.c line 534
Quoted 7 lines
drivers/dma/fsl-edma.c new file +7
-0+if (!fsl_desc) +return NULL ; + fsl_desc->iscyclic = true; + + dma_buf_next = dma_addr; + nbytes = fsl_chan->fsc.addr_width * fsl_chan->fsc.burst; + iter = period_len / nbytes;empty line here pls
Ok, thanks.
Best Regards,
Jingchang
Quoted 42 lines · Jingchang Lu
Quoted 34 lines
-----Original Message-----
From: Vinod Koul [mailto:vinod.koul at intel.com]
Sent: Monday, January 20, 2014 3:40 PM
To: Lu Jingchang-B35083
Cc: dan.j.williams at intel.com; arnd at arndb.de; shawn.guo at linaro.org; pawel.moll at arm.com; mark.rutland at arm.com; swarren at wwwdotorg.org; linux- kernel at vger.kernel.org; linux-arm-kernel at lists.infradead.org; devicetree at vger.kernel.org; Wang Huan-B18965
Subject: Re: [PATCHv10 2/2] dma: Add Freescale eDMA engine driver supportQuoted 9 lines · Jingchang Lu
Add Freescale enhanced direct memory(eDMA) controller support. This module can be found on Vybrid and LS-1 SoCs.
Signed-off-by Alison Wang <[email protected]>Signed-off-by Jingchang Lu <[email protected]>Acked-by Arnd Bergmann <[email protected]>---
+static int fsl_edma_control(struct
dma_chan*chan, enumdma_ctrl_cmdcmd,
Quoted 11 lines
drivers/dma/fsl-edma.c new file +11
-0+ unsigned long arg) +{ +struct fsl_edma_chan *fsl_chan =to_fsl_edma_chan (chan); +struct dma_slave_config *cfg = (void *)arg; +unsigned long flags; +LIST_HEAD (head); + +switch (cmd) { +case DMA_TERMINATE_ALL : +spin_lock_irqsave (&fsl_chan->vchan.lock, flags); +fsl_edma_disable_request (fsl_chan);Quoted 8 lines
drivers/dma/fsl-edma.c line 305
Quoted 5 lines
drivers/dma/fsl-edma.c new file +5
-0+ fsl_chan->edesc =NULL ; +vchan_get_all_descriptors (&fsl_chan->vchan, &head); +spin_unlock_irqrestore (&fsl_chan->vchan.lock, flags); +vchan_dma_desc_free_list (&fsl_chan->vchan, &head); +return 0 ;well what happens to the current ongoing transactions, i don't see those getting
terminated?
Quoted 3 lines
The
fsl_edma_disable_request(fsl_chan)would end the channel's ongoing transaction, then the eDMA would not response to device dma request, and thevchan_dma_desc_free_list()will release all associate memory. Thanks.
Can you explain a bit more how terminate will happen, given taht you are using same thing for pause?
Quoted 17 lines
Quoted 17 lines
Quoted 15 lines
drivers/dma/fsl-edma.c new file +8
-0+ +case DMA_SLAVE_CONFIG : + fsl_chan->fsc.dir = cfg->direction; +if (cfg->direction ==DMA_DEV_TO_MEM ) { + fsl_chan->fsc.dev_addr = cfg->src_addr; + fsl_chan->fsc.addr_width = cfg->src_addr_width; + fsl_chan->fsc.burst = cfg->src_maxburst; + fsl_chan->fsc.attr = fsl_edma_get_tcd_attr(cfg-
src_addr_width);drivers/dma/fsl-edma.c new file +5
-0+ }else if (cfg->direction ==DMA_MEM_TO_DEV ) { + fsl_chan->fsc.dev_addr = cfg->dst_addr; + fsl_chan->fsc.addr_width = cfg->dst_addr_width; + fsl_chan->fsc.burst = cfg->dst_maxburst; + fsl_chan->fsc.attr = fsl_edma_get_tcd_attr(cfg-Quoted 1 line
dst_addr_width);okay atrr is address width, why not save this standard struct instead?
Quoted 3 lines
The value saved in fsc.attr is transferred by
fsl_edma_get_tcd_attr(), it can be set into the channel control register later directly. the edma driver doesn't need to save alldma_slave_configparameters, so it only gets the necessaries.
Okay then this apprach looks okay
Quoted 67 lines
Quoted 59 lines
Quoted 20 lines
drivers/dma/fsl-edma.c new file +20
-0+ }else { +return -EINVAL ; + } +return 0 ; + +case DMA_PAUSE : +spin_lock_irqsave (&fsl_chan->vchan.lock, flags); +if (fsl_chan->edesc) { +fsl_edma_disable_request (fsl_chan); + fsl_chan->status =DMA_PAUSED ; + } +spin_unlock_irqrestore (&fsl_chan->vchan.lock, flags); +return 0 ; + +case DMA_RESUME : +spin_lock_irqsave (&fsl_chan->vchan.lock, flags); +if (fsl_chan->edesc) { +fsl_edma_enable_request (fsl_chan); + fsl_chan->status =DMA_IN_PROGRESS ; + }drivers/dma/fsl-edma.c
Quoted 10 lines
drivers/dma/fsl-edma.c new file +9
-0+spin_unlock_irqrestore (&fsl_chan->vchan.lock, flags); +return 0 ; + +default : +return -ENXIO ; + } +} + +static struct fsl_edma_desc *fsl_edma_alloc_desc(struct fsl_edma_chan
*fsl_chan,drivers/dma/fsl-edma.c
Quoted 6 lines
drivers/dma/fsl-edma.c new file +6
-0+ int sg_len) +{ +struct fsl_edma_desc *fsl_desc; +int i; + + fsl_desc = kzalloc(sizeof(*fsl_desc) + sizeof(struct
fsl_edma_sw_tcd) *sg_len,Quoted 21 lines
drivers/dma/fsl-edma.c new file +21
-0+ GFP_NOWAIT); +if (!fsl_desc) +return NULL ; + + fsl_desc->echan = fsl_chan; + fsl_desc->n_tcds = sg_len; +for (i =0 ; i < sg_len; i++) { + fsl_desc->tcd[i].vtcd =dma_pool_alloc (fsl_chan->tcd_pool, +GFP_NOWAIT , &fsl_desc->tcd[i].ptcd); +if (!fsl_desc->tcd[i].vtcd) + goto err; + } +return fsl_desc; + +err: +while (--i >=0 ) +dma_pool_free (fsl_chan->tcd_pool, fsl_desc->tcd[i].vtcd, + fsl_desc->tcd[i].ptcd); +kfree (fsl_desc); +return NULL ; +}Quoted 8 lines
drivers/dma/fsl-edma.c line 515
Quoted 6 lines
drivers/dma/fsl-edma.c new file +6
-0+ +static struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic ( +struct dma_chan *chan,dma_addr_t dma_addr,size_t buf_len, +size_t period_len,enum dma_transfer_direction direction, +unsigned long flags,void *context) +{you may want to implement the capablities api subsequently for audio usage.
Quoted 1 line
Do you mean the
device_slave_capsfunction? If it is, I will add it.
Yes, that can be incrementally added..
Quoted 59 lines
-----Original Message-----
From: Vinod Koul [mailto:vinod.koul at intel.com]
Sent: Monday, January 20, 2014 5:36 PM
To: Lu Jingchang-B35083
Cc: dan.j.williams at intel.com; arnd at arndb.de; shawn.guo at linaro.org; pawel.moll at arm.com; mark.rutland at arm.com; swarren at wwwdotorg.org; linux- kernel at vger.kernel.org; linux-arm-kernel at lists.infradead.org; devicetree at vger.kernel.org; Wang Huan-B18965
Subject: Re: [PATCHv10 2/2] dma: Add Freescale eDMA engine driver supportQuoted 8 lines · Jingchang Lu
Quoted 8 lines
-----Original Message-----
From: Vinod Koul [mailto:vinod.koul at intel.com]
Sent: Monday, January 20, 2014 3:40 PM
To: Lu Jingchang-B35083
Cc: dan.j.williams at intel.com; arnd at arndb.de; shawn.guo at linaro.org; pawel.moll at arm.com; mark.rutland at arm.com; swarren at wwwdotorg.org;linux-
Quoted 3 lines
Quoted 3 lines
kernel at vger.kernel.org; linux-arm-kernel at lists.infradead.org; devicetree at vger.kernel.org; Wang Huan-B18965
Subject: Re: [PATCHv10 2/2] dma: Add Freescale eDMA engine driversupport
Quoted 11 lines
Quoted 11 lines · Jingchang Lu
Quoted 9 lines
Add Freescale enhanced direct memory(eDMA) controller support. This module can be found on Vybrid and LS-1 SoCs.
Signed-off-by Alison Wang <[email protected]>Signed-off-by Jingchang Lu <[email protected]>Acked-by Arnd Bergmann <[email protected]>---
+static int fsl_edma_control(struct
dma_chan*chan, enum
dma_ctrl_cmdQuoted 10 lines
Quoted 10 lines
cmd,
Quoted 9 lines
drivers/dma/fsl-edma.c new file +9
-0+ unsigned long arg) +{ +struct fsl_edma_chan *fsl_chan =to_fsl_edma_chan (chan); +struct dma_slave_config *cfg = (void *)arg; +unsigned long flags; +LIST_HEAD (head); + +switch (cmd) { +case DMA_TERMINATE_ALL :Quoted 8 lines
Quoted 8 lines
drivers/dma/fsl-edma.c line 305
Quoted 7 lines
drivers/dma/fsl-edma.c new file +7
-0+spin_lock_irqsave (&fsl_chan->vchan.lock, flags); +fsl_edma_disable_request (fsl_chan); + fsl_chan->edesc =NULL ; +vchan_get_all_descriptors (&fsl_chan->vchan, &head); +spin_unlock_irqrestore (&fsl_chan->vchan.lock, flags); +vchan_dma_desc_free_list (&fsl_chan->vchan, &head); +return 0 ;well what happens to the current ongoing transactions, i don't see
those
Quoted 2 lines
Quoted 2 lines
getting
terminated?
Quoted 8 lines
Quoted 1 line
The
fsl_edma_disable_request(fsl_chan)would end the channel's ongoingtransaction, then
Quoted 1 line
the eDMA would not response to device dma request, and the
vchan_dma_desc_free_list()Quoted 1 line
will release all associate memory. Thanks.
Can you explain a bit more how terminate will happen, given taht you are using
same thing for pause?
It works just like an interrupt controller on irq enable and disable. It has a register called set/clear enable request register(SERQ/CERQ) to enable or disable the DMA request for a given channel. It won't transfer data any more with the enable request register cleared. So for the pause and terminate the pause is the same. And there is no other way to stop the channels. Thanks.
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic( + struct dma_chan *chan, dma_addr_t dma_addr, size_t
buf_len,Quoted 1 line
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ size_t period_len, enum dma_transfer_directiondirection,
Quoted 5 lines
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ unsigned long flags, void *context) +{you may want to implement the capablities api subsequently for audio usage.
Do you mean the
device_slave_capsfunction? If it is, I will add it.Yes, that can be incrementally added..
I have send the v11 patch out with a basic device_slave_caps definition. I notice that there is some new update of the dma capabilities, so if possible and others ok, could you please merge this patch first and leave me improving the driver in subsequent patches. Thanks.
Best Regards,
Jingchang
Quoted 22 lines · Jingchang Lu
Quoted 22 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/dma/fsl-edma.c new file +7
-0+struct fsl_edma_chan *fsl_chan =to_fsl_edma_chan (chan); +struct dma_slave_config *cfg = (void *)arg; +unsigned long flags; +LIST_HEAD (head); + +switch (cmd) { +case DMA_TERMINATE_ALL :Quoted 8 lines
Quoted 8 lines
drivers/dma/fsl-edma.c line 305
Quoted 7 lines
drivers/dma/fsl-edma.c new file +7
-0+spin_lock_irqsave (&fsl_chan->vchan.lock, flags); +fsl_edma_disable_request (fsl_chan); + fsl_chan->edesc =NULL ; +vchan_get_all_descriptors (&fsl_chan->vchan, &head); +spin_unlock_irqrestore (&fsl_chan->vchan.lock, flags); +vchan_dma_desc_free_list (&fsl_chan->vchan, &head); +return 0 ;well what happens to the current ongoing transactions, i don't see
those
Quoted 3 lines
Quoted 2 lines
getting
terminated?The
fsl_edma_disable_request(fsl_chan)would end the channel's ongoingtransaction, then
Quoted 1 line
the eDMA would not response to device dma request, and the
vchan_dma_desc_free_list()
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
will release all associate memory. Thanks.
Can you explain a bit more how terminate will happen, given taht you are using
same thing for pause?It works just like an interrupt controller on irq enable and disable. It has a register called set/clear enable request register(SERQ/CERQ) to enable or disable the DMA request for a given channel. It won't transfer data any more with the enable request register cleared. So for the pause and terminate the pause is the same. And there is no other way to stop the channels.
well then it is not pause! If you jave no way to stop the channel, you cant claim to support pause and resume!
Also, for terminate this will be problematic. Assuming you are doing transfers and terminate is invoked. Then you will disable irq. The transfers may get stuck and periphral clock may go away after transfer so current transaction never gets completed, how do we recovery from this?
Alstly, have you looked at edma driver already existing, any similarties in teh controller with that?
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic( + struct dma_chan *chan, dma_addr_t dma_addr, size_t
buf_len,Quoted 1 line
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +1
-0+ size_t period_len, enum dma_transfer_directiondirection,
Quoted 4 lines
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ unsigned long flags, void *context) +{you may want to implement the capablities api subsequently for audio usage.
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Do you mean the
device_slave_capsfunction? If it is, I will add it.Yes, that can be incrementally added..
I have send the v11 patch out with a basic
device_slave_capsdefinition. I notice that there is some new update of the dma capabilities, so if possible and others ok, could you please merge this patch first and leave me improving the driver in subsequent patches. Thanks.
Sure, as I said this can be incremental but atm am worried about pause and terminate behaviour.
--
~Vinod
________________________________________
From: Vinod Koul <[email protected]>
Sent: Monday, January 20, 2014 6:20 PM
To: Lu Jingchang-B35083
Cc: dan.j.williams at intel.com; arnd at arndb.de; shawn.guo at linaro.org; pawel.moll at arm.com; mark.rutland at arm.com; swarren at wwwdotorg.org; linux-kernel at vger.kernel.org; linux-arm-kernel at lists.infradead.org; devicetree at vger.kernel.org; Wang Huan-B18965
Subject: Re: [PATCHv10 2/2] dma: Add Freescale eDMA engine driver support
Quoted 30 lines · Jingchang Lu
Quoted 22 lines
Quoted 22 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/dma/fsl-edma.c new file +14
-0+struct fsl_edma_chan *fsl_chan =to_fsl_edma_chan (chan); +struct dma_slave_config *cfg = (void *)arg; +unsigned long flags; +LIST_HEAD (head); + +switch (cmd) { +case DMA_TERMINATE_ALL : +spin_lock_irqsave (&fsl_chan->vchan.lock, flags); +fsl_edma_disable_request (fsl_chan); + fsl_chan->edesc =NULL ; +vchan_get_all_descriptors (&fsl_chan->vchan, &head); +spin_unlock_irqrestore (&fsl_chan->vchan.lock, flags); +vchan_dma_desc_free_list (&fsl_chan->vchan, &head); +return 0 ;Quoted 1 line
Quoted 1 line
well what happens to the current ongoing transactions, i don't see
those
Quoted 3 lines
Quoted 2 lines
getting
terminated?The
fsl_edma_disable_request(fsl_chan)would end the channel's ongoingtransaction, then
Quoted 1 line
the eDMA would not response to device dma request, and the
vchan_dma_desc_free_list()Quoted 8 lines
Quoted 4 lines
Quoted 1 line
will release all associate memory. Thanks.
Can you explain a bit more how terminate will happen, given taht you are using
same thing for pause?It works just like an interrupt controller on irq enable and disable. It has a register called set/clear enable request register(SERQ/CERQ) to enable or disable the DMA request for a given channel. It won't transfer data any more with the enable request register cleared. So for the pause and terminate the pause is the same. And there is no other way to stop the channels.
Quoted 7 lines
well then it is not pause! If you jave no way to stop the channel, you cant claim to support pause and resume!
Quoted 1 line
Also, for terminate this will be problematic. Assuming you are doing transfers
and terminate is invoked. Then you will disable irq. The transfers may get stuck and periphral clock may go away after transfer so current transaction never gets completed, how do we recovery from this?
The clear enable request would isolate the dma request from the eDMA engine,
and the eDMA engine could not receive any dma request from the device any more, so the transmission is stopped, all the channel parameters will not be changed any more, and the eDMA engine will not do any transmission for that channel until the request is enabled by set enable request. And the channel parameters could be changed when the enable request cleared.
We have tested the eDMA drive with the SAI audio driver which uses the cyclic dma tranfer, and it work well.
Thanks.
Quoted 2 lines
Alstly, have you looked at edma driver already existing, any similarties in teh controller with that?
Yes, I have notice the TI's edma driver, but they are not the same. So we implement this driver.
Best Regards,
Jingchang