Skip to contentSkip to conversation

add support for Mediatek High-Speed DMA controller on MT7622 and MT7623 SoC

PATCH Superseded [email protected] 3 participants 7 messages Feb 1, 2018 – Feb 5, 2018

Subsystems (4)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

v3 cover add support for Mediatek High-Speed DMA controller on MT7622 and MT7623 SoC

From: Sean Wang <[email protected]>

Changes since v2:
- remove extra tasklets and refactor driver for letting descriptors being processed ASAP.
- add more comments stating the relevant logic
- remove unused macro and variables
- change to use the disclaimer with SPDX identifier
- add mt7622 support
- refine hardware initialization sequence
- add tx_status support for DMA_RESIDUE_GRANULARITY_SEGMENT
- refine remove handler with killing vc's tasklet

Changes since v1:
- fix typo in the commit message.
- delete status shown in the dt-binding example.

This patchset introduces support for MediaTek High-Speed DMA controller (MTK-HSDMA) Currently, the driver is already tested successfully with dmatest module on MT7622 and MT7623 SoC.

MTK-HSDMA on MT7622/23 SoC has a single ring which is dedicated for doing memory-to-memory transfer through ring-based descriptor management. Even though there is only a single ring available inside HSDMA, the driver is being extended to the support for multiple virtual channels processing simultaneously by means of DMA_VIRTUAL_CHANNELS.

Sean Wang (3):
dt-bindings: dmaengine: Add MediaTek High-Speed DMA controller
bindings
dmaengine: mediatek: Add MediaTek High-Speed DMA controller for MT7622

    and MT7623 SoC

dmaengine: mediatek: update MAINTAINERS entry with MediaTek DMA driver

 .../devicetree/bindings/dma/mtk-hsdma.txt          |   33 +
 MAINTAINERS                                        |    9 +
 drivers/dma/Kconfig                                |    2 +
 drivers/dma/Makefile                               |    1 +
 drivers/dma/mediatek/Kconfig                       |   13 +
 drivers/dma/mediatek/Makefile                      |    1 +
 drivers/dma/mediatek/mtk-hsdma.c                   | 1045 ++++++++++++++++++++
 7 files changed, 1104 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/mtk-hsdma.txt
 create mode 100644 drivers/dma/mediatek/Kconfig
 create mode 100644 drivers/dma/mediatek/Makefile
 create mode 100644 drivers/dma/mediatek/mtk-hsdma.c
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH v3 1/3 dt-bindings: dmaengine: Add MediaTek High-Speed DMA controller bindings

From: Sean Wang <[email protected]>

Document the devicetree bindings for MediaTek High-Speed DMA controller which could be found on MT7623 SoC or other similar Mediatek SoCs.

---
 .../devicetree/bindings/dma/mtk-hsdma.txt          | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/mtk-hsdma.txt
Documentation/devicetree/bindings/dma/mtk-hsdma.txt new file +33 -0
new file mode 100644
index 0000000..c07c03e
@@ -0,0 +1,33 @@
+MediaTek High-Speed DMA Controller
+==================================
+
+This driver follows the generic DMA bindings defined in dma/dma.txt.
+
+Required properties:
+
+- compatible:	Must be one of
+		  "mediatek,mt7622-hsdma": for MT7622 SoC
+		  "mediatek,mt7623-hsdma": for MT7623 SoC
+- reg:		Should contain the register's base address and length.
+- interrupts:	Should contain a reference to the interrupt used by this
+		device.
+- clocks:	Should be the clock specifiers corresponding to the entry in
+		clock-names property.
+- clock-names:	Should contain "hsdma" entries.
+- power-domains: Phandle to the power domain that the device is part of
+- #dma-cells: 	The length of the DMA specifier, must be <1>. This one cell
+		in dmas property of a client device represents the channel
+		number.
+Example:
+
+        hsdma: hsdma@1b007000 {
+		compatible = "mediatek,mt7623-hsdma";
+		reg = <0 0x1b007000 0 0x1000>;
+		interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&ethsys CLK_ETHSYS_HSDMA>;
+		clock-names = "hsdma";
+		power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>;
+		#dma-cells = <1>;
+	};
+
+DMA clients must use the format described in dma/dma.txt file.
maintainer
#2 lore raw

Re: [PATCH v3 1/3] dt-bindings: dmaengine: Add MediaTek High-Speed DMA controller bindings

Quoted 17 lines · On Thu, Feb 01, 2018 at 11:45:23AM +0800, [email protected] wrote:

From: Sean Wang <[email protected]>

Document the devicetree bindings for MediaTek High-Speed DMA controller which could be found on MT7623 SoC or other similar Mediatek SoCs.

---
 .../devicetree/bindings/dma/mtk-hsdma.txt          | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/mtk-hsdma.txt
Documentation/devicetree/bindings/dma/mtk-hsdma.txt new file +0 -0
new file mode 100644
index 0000000..c07c03e

Documentation/devicetree/bindings/dma/mtk-hsdma.txt line 4

Quoted 4 lines
Documentation/devicetree/bindings/dma/mtk-hsdma.txt new file +4 -0
@@ -0,0 +1,33 @@
+MediaTek High-Speed DMA Controller
+==================================
+
+This driver follows the generic DMA bindings defined in dma/dma.txt.

Bindings describe h/w, not drivers.

Quoted 9 lines
Documentation/devicetree/bindings/dma/mtk-hsdma.txt new file +9 -0
+
+Required properties:
+
+- compatible:	Must be one of
+		  "mediatek,mt7622-hsdma": for MT7622 SoC
+		  "mediatek,mt7623-hsdma": for MT7623 SoC
+- reg:		Should contain the register's base address and length.
+- interrupts:	Should contain a reference to the interrupt used by this
+		device.

Documentation/devicetree/bindings/dma/mtk-hsdma.txt line 23

Quoted 10 lines
Documentation/devicetree/bindings/dma/mtk-hsdma.txt new file +10 -0
+- clocks:	Should be the clock specifiers corresponding to the entry in
+		clock-names property.
+- clock-names:	Should contain "hsdma" entries.
+- power-domains: Phandle to the power domain that the device is part of
+- #dma-cells: 	The length of the DMA specifier, must be <1>. This one cell
+		in dmas property of a client device represents the channel
+		number.
+Example:
+
+        hsdma: hsdma@1b007000 {

dma-controller@...

Quoted 13 lines
Documentation/devicetree/bindings/dma/mtk-hsdma.txt new file +10 -0
+		compatible = "mediatek,mt7623-hsdma";
+		reg = <0 0x1b007000 0 0x1000>;
+		interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&ethsys CLK_ETHSYS_HSDMA>;
+		clock-names = "hsdma";
+		power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>;
+		#dma-cells = <1>;
+	};
+
+DMA clients must use the format described in dma/dma.txt file.
Signature · 1 line
2.7.4

---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#3 lore raw

PATCH v3 2/3 dmaengine: mediatek: Add MediaTek High-Speed DMA controller for MT7622 and MT7623 SoC

In reply to [email protected]

From: Sean Wang <[email protected]>

MediaTek High-Speed DMA controller (HSDMA) on MT7622 and MT7623 SoC has a single ring is dedicated to memory-to-memory transfer through ring based descriptor management.

Even though there is only one physical ring available inside HSDMA, the driver can be easily extended to the support of multiple virtual channels processing simultaneously by means of DMA_VIRTUAL_CHANNELS effort.

---
 drivers/dma/Kconfig              |    2 +
 drivers/dma/Makefile             |    1 +
 drivers/dma/mediatek/Kconfig     |   13 +
 drivers/dma/mediatek/Makefile    |    1 +
 drivers/dma/mediatek/mtk-hsdma.c | 1045 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 1062 insertions(+)
 create mode 100644 drivers/dma/mediatek/Kconfig
 create mode 100644 drivers/dma/mediatek/Makefile
 create mode 100644 drivers/dma/mediatek/mtk-hsdma.c
drivers/dma/Kconfig +2 -0
index 27df3e2..86ace76 100644
@@ -633,6 +633,8 @@ config ZX_DMA
 # driver files
 source "drivers/dma/bestcomm/Kconfig"
 
+source "drivers/dma/mediatek/Kconfig"
+
 source "drivers/dma/qcom/Kconfig"
 
 source "drivers/dma/dw/Kconfig"
drivers/dma/Makefile +1 -0
index b9dca8a..7a57b97 100644
@@ -75,5 +75,6 @@ obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
 obj-$(CONFIG_ZX_DMA) += zx_dma.o
 obj-$(CONFIG_ST_FDMA) += st_fdma.o
 
+obj-y += mediatek/
 obj-y += qcom/
 obj-y += xilinx/
drivers/dma/mediatek/Kconfig new file +13 -0
new file mode 100644
index 0000000..27bac0b
@@ -0,0 +1,13 @@
+
+config MTK_HSDMA
+	tristate "MediaTek High-Speed DMA controller support"
+	depends on ARCH_MEDIATEK || COMPILE_TEST
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+	---help---
+	  Enable support for High-Speed DMA controller on MediaTek
+	  SoCs.
+
+	  This controller provides the channels which is dedicated to
+	  memory-to-memory transfer to offload from CPU through ring-
+	  based descriptor management.
drivers/dma/mediatek/Makefile new file +1 -0
new file mode 100644
index 0000000..6e778f8
@@ -0,0 +1 @@
+obj-$(CONFIG_MTK_HSDMA) += mtk-hsdma.o
drivers/dma/mediatek/mtk-hsdma.c new file +1045 -0

1,045 lines not on this page · raw message

#4 lore raw

Re: [PATCH v3 2/3] dmaengine: mediatek: Add MediaTek High-Speed DMA controller for MT7622 and MT7623 SoC

I love your patch! Yet something to improve:

Hi Sean,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.15 next-20180202]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/sean-wang-mediatek-com/dt-bindings-dmaengine-Add-MediaTek-High-Speed-DMA-controller-bindings/20180203-203814
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sh

All error/warnings (new ones prefixed by >>):

In file included from drivers/dma/mediatek/mtk-hsdma.c:19:0:

>> drivers/dma/mediatek/mtk-hsdma.c:880:25: error: 'mtk_dma_match' undeclared here (not in a function); did you mean 'mtk_hsdma_match'?
    MODULE_DEVICE_TABLE(of, mtk_dma_match);
                            ^
   include/linux/module.h:213:15: note: in definition of macro 'MODULE_DEVICE_TABLE'
    extern typeof(name) __mod_##type##__##name##_device_table  \
                  ^~~~
>> include/linux/module.h:213:21: error: '__mod_of__mtk_dma_match_device_table' aliased to undefined symbol 'mtk_dma_match'
    extern typeof(name) __mod_##type##__##name##_device_table  \
                        ^
>> drivers/dma/mediatek/mtk-hsdma.c:880:1: note: in expansion of macro 'MODULE_DEVICE_TABLE'
    MODULE_DEVICE_TABLE(of, mtk_dma_match);
    ^~~~~~~~~~~~~~~~~~~
---
   In file included from drivers/dma//mediatek/mtk-hsdma.c:19:0:
   drivers/dma//mediatek/mtk-hsdma.c:880:25: error: 'mtk_dma_match' undeclared here (not in a function); did you mean 'mtk_hsdma_match'?
    MODULE_DEVICE_TABLE(of, mtk_dma_match);
                            ^
   include/linux/module.h:213:15: note: in definition of macro 'MODULE_DEVICE_TABLE'
    extern typeof(name) __mod_##type##__##name##_device_table  \
                  ^~~~
>> include/linux/module.h:213:21: error: '__mod_of__mtk_dma_match_device_table' aliased to undefined symbol 'mtk_dma_match'
    extern typeof(name) __mod_##type##__##name##_device_table  \
                        ^
   drivers/dma//mediatek/mtk-hsdma.c:880:1: note: in expansion of macro 'MODULE_DEVICE_TABLE'
    MODULE_DEVICE_TABLE(of, mtk_dma_match);
    ^~~~~~~~~~~~~~~~~~~

vim +880 drivers/dma/mediatek/mtk-hsdma.c

874
875 static const struct of_device_id mtk_hsdma_match[] = {
876 { .compatible = "mediatek,mt7623-hsdma", .data = &mt7623_soc},
877 { .compatible = "mediatek,mt7622-hsdma", .data = &mt7622_soc},
878 { /* sentinel */ }
879 };

 > 880	MODULE_DEVICE_TABLE(of, mtk_dma_match);

881

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#5 lore raw

[RFC PATCH] dmaengine: mediatek: mtk_hsdma_find_active_desc() can be static

In reply to [email protected]
-- To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Fixes 73006a033ef0 ("dmaengine: mediatek: Add MediaTek High-Speed DMA controller for MT7622 and MT7623 SoC")
---
 mtk-hsdma.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

drivers/dma/mediatek/mtk-hsdma.c +2 -2
index cd3af5c..c1523b4 100644
@@ -643,8 +643,8 @@ static irqreturn_t mtk_hsdma_irq(int irq, void *devid)
 	return IRQ_HANDLED;
 }
 
-struct virt_dma_desc *mtk_hsdma_find_active_desc(struct dma_chan *c,
-						 dma_cookie_t cookie)
+static struct virt_dma_desc *mtk_hsdma_find_active_desc(struct dma_chan *c,
+							dma_cookie_t cookie)
 {
 	struct mtk_hsdma_vchan *hvc = to_hsdma_vchan(c);
 	struct virt_dma_desc *vd;
author maintainer
#6 lore raw

PATCH v3 3/3 dmaengine: mediatek: update MAINTAINERS entry with MediaTek DMA driver

In reply to [email protected]

From: Sean Wang <[email protected]>

I work for MediaTek and maintain SoC targeting to home gateway and also will keep extending and testing the function.

---
 MAINTAINERS | 9 +++++++++
 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
index c90687e..48f85f4 100644
@@ -8786,6 +8786,15 @@ M:	Sean Wang <[email protected]>
 S:	Maintained
 F:	drivers/media/rc/mtk-cir.c
 
+MEDIATEK DMA DRIVER
+M:	Sean Wang <[email protected]>
+L:	[email protected]
+L:	[email protected] (moderated for non-subscribers)
+L:	[email protected] (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/devicetree/bindings/dma/mtk-*
+F:	drivers/dma/mediatek/
+
 MEDIATEK PMIC LED DRIVER
 M:	Sean Wang <[email protected]>
 S:	Maintained