Skip to contentSkip to conversation

Add NVIDIA Tegra GPC-DMA driver

PATCH Superseded Akhil R 4 participants 13 messages Dec 6, 2021 – Dec 15, 2021

Subsystems (4)

v14 of 22 Superseded Latest is v22 →

lore
Share & tools
lore

Akhil R

author
#0 lore raw

v14 cover Add NVIDIA Tegra GPC-DMA driver

Add support for NVIDIA Tegra general purpose DMA driver for Tegra186 and Tegra194 platform.

Changes in patch v14:
* Fixes for warnings in dtbs_check, dt_binding_check etc.
* Removed .owner and deprecated one element array
* Update in no of channels and channel base as per hw

v13 - https://lkml.org/lkml/2021/11/22/145

Akhil R (4):
dt-bindings: dmaengine: Add doc for tegra gpcdma
dmaengine: tegra: Add tegra gpcdma driver
arm64: defconfig: tegra: Enable GPCDMA
arm64: tegra: Add GPCDMA node for tegra186 and tegra194

 .../bindings/dma/nvidia,tegra186-gpc-dma.yaml      |  110 ++
 arch/arm64/boot/dts/nvidia/tegra186.dtsi           |   42 +
 arch/arm64/boot/dts/nvidia/tegra194.dtsi           |   43 +
 arch/arm64/configs/defconfig                       |    1 +
 drivers/dma/Kconfig                                |   12 +
 drivers/dma/Makefile                               |    1 +
 drivers/dma/tegra186-gpc-dma.c                     | 1284 ++++++++++++++++++++
 7 files changed, 1493 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml
 create mode 100644 drivers/dma/tegra186-gpc-dma.c
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v14 1/4 dt-bindings: dmaengine: Add doc for tegra gpcdma

Add DT binding document for Nvidia Tegra GPCDMA controller.

---
 .../bindings/dma/nvidia,tegra186-gpc-dma.yaml      | 110 +++++++++++++++++++++
 1 file changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml
Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml new file +110 -0
new file mode 100644
index 0000000..9dd1476
@@ -0,0 +1,110 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/nvidia,tegra186-gpc-dma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra GPC DMA Controller Device Tree Bindings
+
+description: |
+  The Tegra General Purpose Central (GPC) DMA controller is used for faster
+  data transfers between memory to memory, memory to device and device to
+  memory.
+
+maintainers:
+  - Jon Hunter <[email protected]>
+  - Rajesh Gumasta <[email protected]>
+
+allOf:
+  - $ref: "dma-controller.yaml#"
+
+properties:
+  compatible:
+    oneOf:
+      - const: nvidia,tegra186-gpcdma
+      - items:
+          - const: nvidia,tegra194-gpcdma
+          - const: nvidia,tegra186-gpcdma
+
+  "#dma-cells":
+    const: 1
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    description:
+      Should contain all of the per-channel DMA interrupts in
+      ascending order with respect to the DMA channel index.
+    minItems: 1
+    maxItems: 31
+
+  resets:
+    maxItems: 1
+
+  reset-names:
+    const: gpcdma
+
+  iommus:
+    maxItems: 1
+
+  dma-coherent: true
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - resets
+  - reset-names
+  - "#dma-cells"
+  - iommus
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/memory/tegra186-mc.h>
+    #include <dt-bindings/reset/tegra186-reset.h>
+
+    dma-controller@2600000 {
+        compatible = "nvidia,tegra186-gpcdma";
+        reg = <0x2600000 0x210000>;
+        resets = <&bpmp TEGRA186_RESET_GPCDMA>;
+        reset-names = "gpcdma";
+        interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 81 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
+        #dma-cells = <1>;
+        iommus = <&smmu TEGRA186_SID_GPCDMA_0>;
+        dma-coherent;
+    };
+...
Signature · 1 line
2.7.4
maintainer Reviewed-by on v14 1/4
#2 lore raw

Re: [PATCH v14 1/4] dt-bindings: dmaengine: Add doc for tegra gpcdma

Quoted 10 lines · Akhil R

Add DT binding document for Nvidia Tegra GPCDMA controller.

---
 .../bindings/dma/nvidia,tegra186-gpc-dma.yaml      | 110 +++++++++++++++++++++
 1 file changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml
author
#3 lore raw

PATCH v14 2/4 dmaengine: tegra: Add tegra gpcdma driver

In reply to Akhil R

Adding GPC DMA controller driver for Tegra186 and Tegra194. The driver supports dma transfers between memory to memory, IO peripheral to memory and memory to IO peripheral.

---
 drivers/dma/Kconfig            |   12 +
 drivers/dma/Makefile           |    1 +
 drivers/dma/tegra186-gpc-dma.c | 1284 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1297 insertions(+)
 create mode 100644 drivers/dma/tegra186-gpc-dma.c
drivers/dma/Kconfig +12 -0
index 80c2c03..35095ae 100644
@@ -629,6 +629,18 @@ config TXX9_DMAC
 	  Support the TXx9 SoC internal DMA controller.  This can be
 	  integrated in chips such as the Toshiba TX4927/38/39.
 
+config TEGRA186_GPC_DMA
+	tristate "NVIDIA Tegra GPC DMA support"
+	depends on ARCH_TEGRA_186_SOC || ARCH_TEGRA_194_SOC || COMPILE_TEST
+	select DMA_ENGINE
+	help
+	  Support for the NVIDIA Tegra186 and Tegra194 GPC DMA controller
+	  driver. The DMA controller has multiple DMA channels which can
+	  be configured for different peripherals like UART, SPI, etc
+	  which are on APB bus.
+	  This DMA controller transfers data from memory to peripheral FIFO
+	  or vice versa. It also supports memory to memory data transfer.
+
 config TEGRA20_APB_DMA
 	tristate "NVIDIA Tegra20 APB DMA support"
 	depends on ARCH_TEGRA || COMPILE_TEST
drivers/dma/Makefile +1 -0
index 616d926..2f1b87f 100644
@@ -72,6 +72,7 @@ obj-$(CONFIG_STM32_MDMA) += stm32-mdma.o
 obj-$(CONFIG_SPRD_DMA) += sprd-dma.o
 obj-$(CONFIG_S3C24XX_DMAC) += s3c24xx-dma.o
 obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o
+obj-$(CONFIG_TEGRA186_GPC_DMA) += tegra186-gpc-dma.o
 obj-$(CONFIG_TEGRA20_APB_DMA) += tegra20-apb-dma.o
 obj-$(CONFIG_TEGRA210_ADMA) += tegra210-adma.o
 obj-$(CONFIG_TIMB_DMA) += timb_dma.o
drivers/dma/tegra186-gpc-dma.c new file +1284 -0

1,284 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH v14 2/4] dmaengine: tegra: Add tegra gpcdma driver

Quoted 20 lines · Akhil R

Adding GPC DMA controller driver for Tegra186 and Tegra194. The driver supports dma transfers between memory to memory, IO peripheral to memory and memory to IO peripheral.

---
 drivers/dma/Kconfig            |   12 +
 drivers/dma/Makefile           |    1 +
 drivers/dma/tegra186-gpc-dma.c | 1284 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1297 insertions(+)
 create mode 100644 drivers/dma/tegra186-gpc-dma.c
drivers/dma/Kconfig +0 -0
index 80c2c03..35095ae 100644

drivers/dma/Kconfig config TXX9_DMAC · line 634

Quoted 6 lines
drivers/dma/Kconfig +3 -0
@@ -629,6 +629,18 @@ config TXX9_DMAC
 	  Support the TXx9 SoC internal DMA controller.  This can be
 	  integrated in chips such as the Toshiba TX4927/38/39.
 
+config TEGRA186_GPC_DMA
+	tristate "NVIDIA Tegra GPC DMA support"
+	depends on ARCH_TEGRA_186_SOC || ARCH_TEGRA_194_SOC || COMPILE_TEST

I wonder if we want to maybe make this depend on ARCH_TEGRA instead to avoid having to add dependencies on newer SoCs (presumably Tegra234 will feature this GPC DMA as well).

Not worth a respin, but perhaps something to consider when adding Tegra234 support.

Thierry

#5 lore raw

Re: [PATCH v14 2/4] dmaengine: tegra: Add tegra gpcdma driver

In reply to Akhil R

06.12.2021 16:00, Akhil R пишет:

Quoted 1 line

+struct tegra_dma_channel;

This prototype is unuseful.

Quoted 4 lines
drivers/dma/tegra186-gpc-dma.c new file +4 -0
+/*
+ * tegra_dma_channel: Channel specific information
+ */
+struct tegra_dma_channel {
#6 lore raw

Re: [PATCH v14 2/4] dmaengine: tegra: Add tegra gpcdma driver

In reply to Akhil R

06.12.2021 16:00, Akhil R пишет:

drivers/dma/tegra186-gpc-dma.c line 1266

Quoted 3 lines
drivers/dma/tegra186-gpc-dma.c new file +3 -0
+static const struct __maybe_unused dev_pm_ops tegra_dma_dev_pm_ops = {
+	SET_LATE_SYSTEM_SLEEP_PM_OPS(tegra_dma_pm_suspend, tegra_dma_pm_resume)
+};

Why late?

author
#7 lore raw

RE: [PATCH v14 2/4] dmaengine: tegra: Add tegra gpcdma driver

Quoted 7 lines

06.12.2021 16:00, Akhil R пишет:

Quoted 1 line

+static const struct __maybe_unused dev_pm_ops tegra_dma_dev_pm_ops =

{

Review

Quoted 2 lines
(quoted diff) +2 -0
+     SET_LATE_SYSTEM_SLEEP_PM_OPS(tegra_dma_pm_suspend,
+tegra_dma_pm_resume) };

Why late?

To wait for the drivers using the dma to be suspended so that they don't keep the dma busy.
Agree with the other comments.

Thanks,
Akhil

#8 lore raw

Re: [PATCH v14 2/4] dmaengine: tegra: Add tegra gpcdma driver

15.12.2021 16:50, Akhil R пишет:

Quoted 10 lines
Quoted 7 lines

06.12.2021 16:00, Akhil R пишет:

Quoted 1 line

+static const struct __maybe_unused dev_pm_ops tegra_dma_dev_pm_ops =

{

Review

Quoted 2 lines
(quoted diff) +2 -0
+     SET_LATE_SYSTEM_SLEEP_PM_OPS(tegra_dma_pm_suspend,
+tegra_dma_pm_resume) };

Why late?

To wait for the drivers using the dma to be suspended so that they don't keep the dma busy.
Agree with the other comments.

Drivers are suspended in the opposite order to the probe order. DMA controller driver is always probed first. The "late" is unneeded, please see tegra20-apb-dma driver for the example.

#9 lore raw

Re: [PATCH v14 2/4] dmaengine: tegra: Add tegra gpcdma driver

In reply to Akhil R

06.12.2021 16:00, Akhil R пишет:

Quoted 1 line

+MODULE_ALIAS("platform:tegra-gpc-dma");

This is unneeded by OF and ACPI drivers.

#10 lore raw

Re: [PATCH v14 2/4] dmaengine: tegra: Add tegra gpcdma driver

In reply to Akhil R

06.12.2021 16:00, Akhil R пишет:

Quoted 34 lines
drivers/dma/tegra186-gpc-dma.c new file +34 -0
+static int tegra_dma_terminate_all(struct dma_chan *dc)
+{
+	struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
+	unsigned long wcount = 0;
+	unsigned long status;
+	unsigned long flags;
+	int err;
+
+	raw_spin_lock_irqsave(&tdc->lock, flags);
+
+	if (!tdc->dma_desc) {
+		raw_spin_unlock_irqrestore(&tdc->lock, flags);
+		return 0;
+	}
+
+	if (!tdc->busy)
+		goto skip_dma_stop;
+
+	if (tdc->tdma->chip_data->hw_support_pause)
+		err = tegra_dma_pause(tdc);
+	else
+		err = tegra_dma_stop_client(tdc);
+
+	if (err) {
+		raw_spin_unlock_irqrestore(&tdc->lock, flags);
+		return err;
+	}
+
+	status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS);
+	if (status & TEGRA_GPCDMA_STATUS_ISE_EOC) {
+		dev_dbg(tdc2dev(tdc), "%s():handling isr\n", __func__);
+		tegra_dma_xfer_complete(tdc);
+		status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS);
+	}

drivers/dma/tegra186-gpc-dma.c line 622

Quoted 10 lines
drivers/dma/tegra186-gpc-dma.c new file +10 -0
+
+	wcount = tdc_read(tdc, TEGRA_GPCDMA_CHAN_XFER_COUNT);
+	tegra_dma_stop(tdc);
+
+	tdc->dma_desc->bytes_transferred +=
+			tdc->dma_desc->bytes_requested - (wcount * 4);
+
+skip_dma_stop:
+	tegra_dma_sid_free(tdc);
+	kfree(tdc->dma_desc);

This kfree looks very suspicious. It should be on the tdc->vc list AFAICS, secondly I don't think that driver can be considered the owner of the descriptor.

Quoted 1 line
drivers/dma/tegra186-gpc-dma.c new file +1 -0
+	vchan_free_chan_resources(&tdc->vc);
author
#11 lore raw

PATCH v14 3/4 arm64: defconfig: tegra: Enable GPCDMA

In reply to Akhil R

Enable TEGRA_GPC_DMA in defconfig for Tegra186 and Tegra196 gpc dma controller driver

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index 156d96a..6616148 100644
@@ -928,6 +928,7 @@ CONFIG_MV_XOR=y
 CONFIG_MV_XOR_V2=y
 CONFIG_OWL_DMA=y
 CONFIG_PL330_DMA=y
+CONFIG_TEGRA186_GPC_DMA=m
 CONFIG_TEGRA20_APB_DMA=y
 CONFIG_TEGRA210_ADMA=m
 CONFIG_QCOM_BAM_DMA=y
Signature · 1 line
2.7.4
author
#12 lore raw

PATCH v14 4/4 arm64: tegra: Add GPCDMA node for tegra186 and tegra194

In reply to Akhil R

Add device tree node for GPCDMA controller on Tegra186 target and Tegra194 target.

---
 arch/arm64/boot/dts/nvidia/tegra186.dtsi | 42 +++++++++++++++++++++++++++++++
 arch/arm64/boot/dts/nvidia/tegra194.dtsi | 43 ++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+)
arch/arm64/boot/dts/nvidia/tegra186.dtsi +42 -0
index e94f8ad..9e4225f 100644
@@ -73,6 +73,48 @@
 		snps,rxpbl = <8>;
 	};
 
+	dma-controller@2600000 {
+		compatible = "nvidia,tegra186-gpcdma";
+		reg = <0x0 0x2600000 0x0 0x210000>;
+		resets = <&bpmp TEGRA186_RESET_GPCDMA>;
+		reset-names = "gpcdma";
+		interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 81 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
+		#dma-cells = <1>;
+		iommus = <&smmu TEGRA186_SID_GPCDMA_0>;
+		dma-coherent;
+		status = "okay";
+	};
+
 	aconnect@2900000 {
 		compatible = "nvidia,tegra186-aconnect",
 			     "nvidia,tegra210-aconnect";
arch/arm64/boot/dts/nvidia/tegra194.dtsi +43 -0

49 lines not on this page · raw message

Signature · 1 line
2.7.4