dmaengine: sf-pdma: Add platform dma driver
Subsystems (5)
v5 cover dmaengine: sf-pdma: Add platform dma driver
Add PDMA driver support for SiFive HiFive Unleashed RevA00 board. Mainly follows DMAengine controller doc[1] to implement and take other DMA drivers as reference. Such as
- drivers/dma/fsl-edma.c
- drivers/dma/dw-edma/
- drivers/dma/pxa-dma.c
Using DMA test client[2] to test. Detailed datasheet is doc[3]. Driver supports:
- 4 physical DMA channels, share same DONE and error interrupt handler.
- Support MEM_TO_MEM
- Tested by DMA test client
- patches include DT Bindgins document and dts for fu450-c000 SoC. Separate dts patch for easier review and apply to different branch or SoC platform.
- retry 1 time if DMA error occurs.
[Reference Doc]
[1] ./Documentation/driver-api/dmaengine/provider.rst
[2] ./Documentation/driver-api/dmaengine/dmatest.rst
[3] https://static.dev.sifive.com/FU540-C000-v1.0.pdf
[Simple steps to test of DMA Test client]
$ echo 1 > /sys/module/dmatest/parameters/iterations $ echo dma0chan0 > /sys/module/dmatest/parameters/channel $ echo dma0chan1 > /sys/module/dmatest/parameters/channel $ echo dma0chan2 > /sys/module/dmatest/parameters/channel $ echo dma0chan3 > /sys/module/dmatest/parameters/channel $ echo 1 > /sys/module/dmatest/parameters/run
[Expected test result]
[ 267.563323] dmatest: dma0chan0-copy0: summary 45629 tests, 0 failures 38769.01 iops 309661 KB/s (0) [ 267.572427] dmatest: dma0chan1-copy0: summary 45863 tests, 0 failures 40286.85 iops 321643 KB/s (0) [ 267.581392] dmatest: dma0chan2-copy0: summary 45975 tests, 0 failures 41178.48 iops 328740 KB/s (0) [ 267.590542] dmatest: dma0chan3-copy0: summary 44768 tests, 0 failures 38560.29 iops 307726 KB/s (0)
Green Wan (4):
dt-bindings: dmaengine: sf-pdma: add bindins for SiFive PDMA
riscv: dts: add support for PDMA device of HiFive Unleashed Rev A00
dmaengine: sf-pdma: add platform DMA support for HiFive Unleashed A00
MAINTAINERS: Add Green as SiFive PDMA driver maintainer
.../bindings/dma/sifive,fu540-c000-pdma.yaml | 55 ++ MAINTAINERS | 6 + arch/riscv/boot/dts/sifive/fu540-c000.dtsi | 7 + drivers/dma/Kconfig | 2 + drivers/dma/Makefile | 1 + drivers/dma/sf-pdma/Kconfig | 6 + drivers/dma/sf-pdma/Makefile | 1 + drivers/dma/sf-pdma/sf-pdma.c | 602 ++++++++++++++++++ drivers/dma/sf-pdma/sf-pdma.h | 123 ++++ 9 files changed, 803 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/sifive,fu540-c000-pdma.yaml create mode 100644 drivers/dma/sf-pdma/Kconfig create mode 100644 drivers/dma/sf-pdma/Makefile create mode 100644 drivers/dma/sf-pdma/sf-pdma.c create mode 100644 drivers/dma/sf-pdma/sf-pdma.h
base-commit: d6d5df1db6e9d7f8f76d2911707f7d5877251b02
Signature · 1 line
2.17.1
PATCH v5 1/4 dt-bindings: dmaengine: sf-pdma: add bindins for SiFive PDMA
Add DT bindings document for Platform DMA(PDMA) driver of board, HiFive Unleashed Rev A00.
--- .../bindings/dma/sifive,fu540-c000-pdma.yaml | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/sifive,fu540-c000-pdma.yaml
Documentation/devicetree/bindings/dma/sifive,fu540-c000-pdma.yaml new file +55 -0
@@ -0,0 +1,55 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/sifive,fu540-c000-pdma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SiFive Unleashed Rev C000 Platform DMA + +maintainers: + - Green Wan <[email protected]> + - Palmer Debbelt <[email protected]> + - Paul Walmsley <[email protected]> + +description: | + Platform DMA is a DMA engine of SiFive Unleashed. It supports 4 + channels. Each channel has 2 interrupts. One is for DMA done and + the other is for DME error. + + In different SoC, DMA could be attached to different IRQ line. + DT file need to be changed to meet the difference. For technical + doc, + + https://static.dev.sifive.com/FU540-C000-v1.0.pdf + +properties: + compatible: + items: + - const: sifive,fu540-c000-pdma + + reg: + maxItems: 1 + + interrupts: + minItems: 1 + maxItems: 8 + + '#dma-cells': + const: 1 + +required: + - compatible + - reg + - interrupts + - '#dma-cells' + +examples: + - | + dma@3000000 { + compatible = "sifive,fu540-c000-pdma"; + reg = <0x0 0x3000000 0x0 0x8000>; + interrupts = <23 24 25 26 27 28 29 30>; + #dma-cells = <1>; + }; + +...
base-commit: d6d5df1db6e9d7f8f76d2911707f7d5877251b02
Signature · 1 line
2.17.1
PATCH v5 2/4 riscv: dts: add support for PDMA device of HiFive Unleashed Rev A00
In reply to Green WanAdd PDMA support to (arch/riscv/boot/dts/sifive/fu540-c000.dtsi)
--- arch/riscv/boot/dts/sifive/fu540-c000.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/riscv/boot/dts/sifive/fu540-c000.dtsi +7 -0
@@ -162,6 +162,13 @@ clocks = <&prci PRCI_CLK_TLCLK>; status = "disabled"; }; + dma: dma@3000000 { + compatible = "sifive,fu540-c000-pdma"; + reg = <0x0 0x3000000 0x0 0x8000>; + interrupt-parent = <&plic0>; + interrupts = <23 24 25 26 27 28 29 30>; + #dma-cells = <1>; + }; uart1: serial@10011000 { compatible = "sifive,fu540-c000-uart", "sifive,uart0"; reg = <0x0 0x10011000 0x0 0x1000>;
Signature · 1 line
2.17.1
PATCH v5 3/4 dmaengine: sf-pdma: add platform DMA support for HiFive Unleashed A00
In reply to Green WanAdd PDMA driver, sf-pdma, to enable DMA engine on HiFive Unleashed Rev A00 board.
- Implement dmaengine APIs, support MEM_TO_MEM async copy.
- Tested by DMA Test client
- Supports 4 channels DMA, each channel has 1 done and 1 err interrupt connected to platform-level interrupt controller (PLIC).
- Depends on DMA_ENGINE and DMA_VIRTUAL_CHANNELS
The datasheet is here:
https://static.dev.sifive.com/FU540-C000-v1.0.pdf
Follow the DMAengine controller doc, "./Documentation/driver-api/dmaengine/provider.rst" to implement DMA engine. And use the dma test client in doc, "./Documentation/driver-api/dmaengine/dmatest.rst", to test.
Each DMA channel has separate HW regs and support done and error ISRs. 4 channels share 1 done and 1 err ISRs. There's no expander/arbitrator in DMA HW.
------ ------ | |--< done 23 >--|ch 0| | |--< err 24 >--| | (dma0chan0) | | ------ | | ------ | |--< done 25 >--|ch 1| | |--< err 26 >--| | (dma0chan1) |PLIC| ------ | | ------ | |--< done 27 >--|ch 2| | |--< err 28 >--| | (dma0chan2) | | ------ | | ------ | |--< done 29 >--|ch 3| | |--< err 30 >--| | (dma0chan3) ------ ------
--- drivers/dma/Kconfig | 2 + drivers/dma/Makefile | 1 + drivers/dma/sf-pdma/Kconfig | 6 + drivers/dma/sf-pdma/Makefile | 1 + drivers/dma/sf-pdma/sf-pdma.c | 602 ++++++++++++++++++++++++++++++++++ drivers/dma/sf-pdma/sf-pdma.h | 123 +++++++ 6 files changed, 735 insertions(+) create mode 100644 drivers/dma/sf-pdma/Kconfig create mode 100644 drivers/dma/sf-pdma/Makefile create mode 100644 drivers/dma/sf-pdma/sf-pdma.c create mode 100644 drivers/dma/sf-pdma/sf-pdma.h
drivers/dma/Kconfig +2 -0
@@ -665,6 +665,8 @@ source "drivers/dma/dw-edma/Kconfig" source "drivers/dma/hsu/Kconfig" +source "drivers/dma/sf-pdma/Kconfig" + source "drivers/dma/sh/Kconfig" source "drivers/dma/ti/Kconfig"
drivers/dma/Makefile +1 -0
@@ -60,6 +60,7 @@ obj-$(CONFIG_PL330_DMA) += pl330.o obj-$(CONFIG_PPC_BESTCOMM) += bestcomm/ obj-$(CONFIG_PXA_DMA) += pxa_dma.o obj-$(CONFIG_RENESAS_DMA) += sh/ +obj-$(CONFIG_SF_PDMA) += sf-pdma/ obj-$(CONFIG_SIRF_DMA) += sirf-dma.o obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o obj-$(CONFIG_STM32_DMA) += stm32-dma.o
drivers/dma/sf-pdma/Kconfig new file +6 -0
@@ -0,0 +1,6 @@ +config SF_PDMA + tristate "Sifive PDMA controller driver" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + Support the SiFive PDMA controller.
drivers/dma/sf-pdma/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_SF_PDMA) += sf-pdma.o
drivers/dma/sf-pdma/sf-pdma.c new file +602 -0
602 lines not on this page · raw message
drivers/dma/sf-pdma/sf-pdma.h new file +123 -0
123 lines not on this page · raw message
Signature · 1 line
2.17.1
Vinod Koul
maintainerRe: [PATCH v5 3/4] dmaengine: sf-pdma: add platform DMA support for HiFive Unleashed A00
Quoted 39 lines · Green Wan
Add PDMA driver, sf-pdma, to enable DMA engine on HiFive Unleashed Rev A00 board.
- Implement dmaengine APIs, support
MEM_TO_MEMasync copy.
- Tested by DMA Test client
- Supports 4 channels DMA, each channel has 1 done and 1 err interrupt connected to platform-level interrupt controller (PLIC).
- Depends onDMA_ENGINEandDMA_VIRTUAL_CHANNELSThe datasheet is here:
https://static.dev.sifive.com/FU540-C000-v1.0.pdf
Follow the DMAengine controller doc, "
./Documentation/driver-api/dmaengine/provider.rst" to implement DMA engine. And use the dma test client in doc, "./Documentation/driver-api/dmaengine/dmatest.rst", to test.Each DMA channel has separate HW regs and support done and error ISRs. 4 channels share 1 done and 1 err ISRs. There's no expander/arbitrator in DMA HW.
------ ------ | |--< done 23 >--|ch 0| | |--< err 24 >--| | (dma0chan0) | | ------ | | ------ | |--< done 25 >--|ch 1| | |--< err 26 >--| | (dma0chan1) |PLIC| ------ | | ------ | |--< done 27 >--|ch 2| | |--< err 28 >--| | (dma0chan2) | | ------ | | ------ | |--< done 29 >--|ch 3| | |--< err 30 >--| | (dma0chan3) ------ ------
Quoted 1 line
Reviewed-by Vinod Koul <[email protected]>
when did i provide this?
Quoted 3 lines
Signed-off-by Green Wan <[email protected]>Reported-by kbuild test robot <[email protected]>Fixes 31c3b98b5a01 ("dmaengine: sf-pdma: add platform DMA support for HiFive Unleashed A00")
Fixes what... this is not a upstream commit?
Quoted 2 lines
Signed-off-by kbuild test robot <[email protected]>---
Please list the changes done from prev version, here or in cover letter
Quoted 6 lines
drivers/dma/sf-pdma/sf-pdma.c new file +6
-0+static struct sf_pdma_desc *sf_pdma_alloc_desc (struct sf_pdma_chan *chan) +{ +struct sf_pdma_desc *desc; +unsigned long flags; + +spin_lock_irqsave (&chan->lock, flags);
drivers/dma/sf-pdma/sf-pdma.c line 66
Quoted 10 lines
drivers/dma/sf-pdma/sf-pdma.c new file +10
-0+ +if (chan->desc && !chan->desc->in_use) { +spin_unlock_irqrestore (&chan->lock, flags); +return chan->desc; + } + +spin_unlock_irqrestore (&chan->lock, flags); + + desc =kzalloc (sizeof (*desc),GFP_NOWAIT ); +
this empty line in not required
drivers/dma/sf-pdma/sf-pdma.c line 93
Quoted 3 lines
drivers/dma/sf-pdma/sf-pdma.c new file +3
-0+static struct dma_async_tx_descriptor * + sf_pdma_prep_dma_memcpy(struct dma_chan *dchan, + dma_addr_t dest,
please make it left justified
drivers/dma/sf-pdma/sf-pdma.c line 129
Quoted 7 lines
drivers/dma/sf-pdma/sf-pdma.c new file +7
-0+static int sf_pdma_slave_config (struct dma_chan *dchan, +struct dma_slave_config *cfg) +{ +struct sf_pdma_chan *chan =to_sf_pdma_chan (dchan); + +memcpy (&chan->cfg, cfg,sizeof (*cfg)); + chan->dma_dir =DMA_MEM_TO_MEM ;
?? looking at changelog we have only memcpy support, so this should not be here, pls remove this.
drivers/dma/sf-pdma/sf-pdma.c line 189
Quoted 12 lines
drivers/dma/sf-pdma/sf-pdma.c new file +12
-0+static enum dma_status +sf_pdma_tx_status (struct dma_chan *dchan, +dma_cookie_t cookie, +struct dma_tx_state *txstate) +{ +struct sf_pdma_chan *chan =to_sf_pdma_chan (dchan); +enum dma_status status; + + status =dma_cookie_status (dchan, cookie, txstate); + +if (txstate && status !=DMA_ERROR ) +dma_set_residue (txstate,sf_pdma_desc_residue (chan));
which residue? the query can be for a cookie which is still in pending list! you need to check the cookie and only read register for cookie if submitted
drivers/dma/sf-pdma/sf-pdma.c line 563
Quoted 13 lines
drivers/dma/sf-pdma/sf-pdma.c new file +13
-0+static int sf_pdma_remove (struct platform_device *pdev) +{ +struct sf_pdma *pdma =platform_get_drvdata (pdev); +struct sf_pdma_chan *ch; +int i; + +for (i =0 ; i <PDMA_NR_CH ; i++) { + ch = &pdma->chans[i]; + +list_del (&ch->vchan.chan.device_node); +tasklet_kill (&ch->vchan.task); +tasklet_kill (&ch->done_tasklet); +tasklet_kill (&ch->err_tasklet);
you have an isr registered which can fire and schedule tasklets..
Signature · 1 line
~Vinod
Re: [PATCH v5 3/4] dmaengine: sf-pdma: add platform DMA support for HiFive Unleashed A00
Quoted 43 lines · Vinod Koul
Quoted 39 lines · Green Wan
Add PDMA driver, sf-pdma, to enable DMA engine on HiFive Unleashed Rev A00 board.
- Implement dmaengine APIs, support
MEM_TO_MEMasync copy.
- Tested by DMA Test client
- Supports 4 channels DMA, each channel has 1 done and 1 err interrupt connected to platform-level interrupt controller (PLIC).
- Depends onDMA_ENGINEandDMA_VIRTUAL_CHANNELSThe datasheet is here:
https://static.dev.sifive.com/FU540-C000-v1.0.pdf
Follow the DMAengine controller doc, "
./Documentation/driver-api/dmaengine/provider.rst" to implement DMA engine. And use the dma test client in doc, "./Documentation/driver-api/dmaengine/dmatest.rst", to test.Each DMA channel has separate HW regs and support done and error ISRs. 4 channels share 1 done and 1 err ISRs. There's no expander/arbitrator in DMA HW.
------ ------ | |--< done 23 >--|ch 0| | |--< err 24 >--| | (dma0chan0) | | ------ | | ------ | |--< done 25 >--|ch 1| | |--< err 26 >--| | (dma0chan1) |PLIC| ------ | | ------ | |--< done 27 >--|ch 2| | |--< err 28 >--| | (dma0chan2) | | ------ | | ------ | |--< done 29 >--|ch 3| | |--< err 30 >--| | (dma0chan3) ------ ------Quoted 1 line
Reviewed-by Vinod Koul <[email protected]>
Quoted 8 lines
when did i provide this?
Quoted 3 lines
Signed-off-by Green Wan <[email protected]>Reported-by kbuild test robot <[email protected]>Fixes 31c3b98b5a01 ("dmaengine: sf-pdma: add platform DMA support for HiFive Unleashed A00")Fixes what... this is not a upstream commit?
Since I received a RFC patch from kbuild with the fix commit number I thought it was about merged. RFC requested to add the "Reported-by" and "Fixes" but looks miss the contributor so I added them as well. I'll remove them in next submit. Sorry for causing confusion.
Quoted 5 lines
Quoted 2 lines
Signed-off-by kbuild test robot <[email protected]>---
Please list the changes done from prev version, here or in cover letter
will add change log.
Quoted 19 lines
Quoted 6 lines
drivers/dma/sf-pdma/sf-pdma.c new file +6
-0+static struct sf_pdma_desc *sf_pdma_alloc_desc (struct sf_pdma_chan *chan) +{ +struct sf_pdma_desc *desc; +unsigned long flags; + +spin_lock_irqsave (&chan->lock, flags);drivers/dma/sf-pdma/sf-pdma.c line 66
Quoted 10 lines
drivers/dma/sf-pdma/sf-pdma.c new file +10
-0+ +if (chan->desc && !chan->desc->in_use) { +spin_unlock_irqrestore (&chan->lock, flags); +return chan->desc; + } + +spin_unlock_irqrestore (&chan->lock, flags); + + desc =kzalloc (sizeof (*desc),GFP_NOWAIT ); +this empty line in not required
Quoted 5 lines
drivers/dma/sf-pdma/sf-pdma.c line 93
Quoted 3 lines
drivers/dma/sf-pdma/sf-pdma.c new file +3
-0+static struct dma_async_tx_descriptor * + sf_pdma_prep_dma_memcpy(struct dma_chan *dchan, + dma_addr_t dest,please make it left justified
will fix.
Quoted 12 lines
drivers/dma/sf-pdma/sf-pdma.c line 129
Quoted 8 lines
drivers/dma/sf-pdma/sf-pdma.c new file +7
-0+static int sf_pdma_slave_config (struct dma_chan *dchan, +struct dma_slave_config *cfg) +{ +struct sf_pdma_chan *chan =to_sf_pdma_chan (dchan); + +memcpy (&chan->cfg, cfg,sizeof (*cfg)); + chan->dma_dir =DMA_MEM_TO_MEM ;?? looking at changelog we have only memcpy support, so this should not be here, pls remove this.
Quoted 17 lines
drivers/dma/sf-pdma/sf-pdma.c line 189
Quoted 12 lines
drivers/dma/sf-pdma/sf-pdma.c new file +12
-0+static enum dma_status +sf_pdma_tx_status (struct dma_chan *dchan, +dma_cookie_t cookie, +struct dma_tx_state *txstate) +{ +struct sf_pdma_chan *chan =to_sf_pdma_chan (dchan); +enum dma_status status; + + status =dma_cookie_status (dchan, cookie, txstate); + +if (txstate && status !=DMA_ERROR ) +dma_set_residue (txstate,sf_pdma_desc_residue (chan));which residue? the query can be for a cookie which is still in pending list! you need to check the cookie and only read register for cookie if submitted
WIll fix this.
Quoted 7 lines
Quoted 7 lines
drivers/dma/sf-pdma/sf-pdma.c new file +7
-0+static int sf_pdma_remove (struct platform_device *pdev) +{ +struct sf_pdma *pdma =platform_get_drvdata (pdev); +struct sf_pdma_chan *ch; +int i; + +for (i =0 ; i <PDMA_NR_CH ; i++) {
Quoted 8 lines
drivers/dma/sf-pdma/sf-pdma.c line 563
Quoted 6 lines
drivers/dma/sf-pdma/sf-pdma.c new file +6
-0+ ch = &pdma->chans[i]; + +list_del (&ch->vchan.chan.device_node); +tasklet_kill (&ch->vchan.task); +tasklet_kill (&ch->done_tasklet); +tasklet_kill (&ch->err_tasklet);you have an isr registered which can fire and schedule tasklets..
will fix it by free irq first. Thanks for reviewing.
Quoted 2 lines
--
~Vinod
PATCH v5 4/4 MAINTAINERS: Add Green as SiFive PDMA driver maintainer
In reply to Green WanUpdate MAINTAINERS for SiFive PDMA driver.
--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -14782,6 +14782,12 @@ F: drivers/media/usb/siano/ F: drivers/media/usb/siano/ F: drivers/media/mmc/siano/ +SIFIVE PDMA DRIVER +M: Green Wan <[email protected]> +S: Maintained +F: drivers/dma/sf-pdma/ +F: Documentation/devicetree/bindings/dma/sifive,fu540-c000-pdma.yaml + SIFIVE DRIVERS M: Palmer Dabbelt <[email protected]> M: Paul Walmsley <[email protected]>
Signature · 1 line
2.17.1