Skip to contentSkip to conversation

Add compatible for Tegra234 GPCDMA

PATCH Superseded Akhil R 2 participants 7 messages Jul 7, 2022

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Akhil R

author
#0 lore raw

cover Add compatible for Tegra234 GPCDMA

Tegra234 supports recovery of a channel hung in pause flush mode. This could happen when the client bus gets corrupted or if the end device ceases to send/receive data.

Add a separate compatible for Tegra234 so that this scenario can be handled in the driver.

Akhil R (2):
dmaengine: tegra: Add terminate() for Tegra234
dt-bindings: dmaengine: Add compatible for Tegra234

 .../bindings/dma/nvidia,tegra186-gpc-dma.yaml |  1 +
 arch/arm64/boot/dts/nvidia/tegra234.dtsi      |  5 ++--
 drivers/dma/tegra186-gpc-dma.c                | 26 +++++++++++++++++--
 3 files changed, 28 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/2 dmaengine: tegra: Add terminate() for Tegra234

In certain cases where the DMA client bus gets corrupted or if the end device ceases to send/receive data, DMA can wait indefinitely for the data to be received/sent. Attempting to terminate the transfer will put the DMA in pause flush mode and it remains there.

The channel is irrecoverable once this pause times out in Tegra194 and earlier chips. Whereas, from Tegra234, it can be recovered by disabling the channel and reprograming it.

Hence add a new terminate() function that ignores the outcome of dma_pause() and disables the channel.

---
 arch/arm64/boot/dts/nvidia/tegra234.dtsi |  5 +++--
 drivers/dma/tegra186-gpc-dma.c           | 26 ++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/nvidia/tegra234.dtsi +3 -2
index cf611eff7f6b..83d1ad7d3c8c 100644
@@ -22,8 +22,9 @@
 		ranges = <0x0 0x0 0x0 0x40000000>;
 
 		gpcdma: dma-controller@2600000 {
-			compatible = "nvidia,tegra194-gpcdma",
-				      "nvidia,tegra186-gpcdma";
+			compatible = "nvidia,tegra234-gpcdma",
+				     "nvidia,tegra194-gpcdma",
+				     "nvidia,tegra186-gpcdma";
 			reg = <0x2600000 0x210000>;
 			resets = <&bpmp TEGRA234_RESET_GPCDMA>;
 			reset-names = "gpcdma";
drivers/dma/tegra186-gpc-dma.c +24 -2
index 05cd451f541d..fa9bda4a2bc6 100644
@@ -157,8 +157,8 @@
  * If any burst is in flight and DMA paused then this is the time to complete
  * on-flight burst and update DMA status register.
  */
-#define TEGRA_GPCDMA_BURST_COMPLETE_TIME	20
-#define TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT	100
+#define TEGRA_GPCDMA_BURST_COMPLETE_TIME	10
+#define TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT	5000 /* 5 msec */
 
 /* Channel base address offset from GPCDMA base address */
 #define TEGRA_GPCDMA_CHANNEL_BASE_ADD_OFFSET	0x20000
@@ -432,6 +432,17 @@ static int tegra_dma_device_resume(struct dma_chan *dc)
 	return 0;
 }
 
+static inline int tegra_dma_pause_noerr(struct tegra_dma_channel *tdc)
+{
+	/* Return 0 irrespective of PAUSE status.
+	 * This is useful to recover channels that can exit out of flush
+	 * state when the channel is disabled.
+	 */
+
+	tegra_dma_pause(tdc);
+	return 0;
+}
+
 static void tegra_dma_disable(struct tegra_dma_channel *tdc)
 {
 	u32 csr, status;
@@ -1292,6 +1303,14 @@ static const struct tegra_dma_chip_data tegra194_dma_chip_data = {
 	.terminate = tegra_dma_pause,
 };
 
+static const struct tegra_dma_chip_data tegra234_dma_chip_data = {
+	.nr_channels = 31,
+	.channel_reg_size = SZ_64K,
+	.max_dma_count = SZ_1G,
+	.hw_support_pause = true,
+	.terminate = tegra_dma_pause_noerr,
+};
+
 static const struct of_device_id tegra_dma_of_match[] = {
 	{
 		.compatible = "nvidia,tegra186-gpcdma",
@@ -1299,6 +1318,9 @@ static const struct of_device_id tegra_dma_of_match[] = {
 	}, {
 		.compatible = "nvidia,tegra194-gpcdma",
 		.data = &tegra194_dma_chip_data,
+	}, {
+		.compatible = "nvidia,tegra234-gpcdma",
+		.data = &tegra234_dma_chip_data,
 	}, {
 	},
 };
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH 1/2] dmaengine: tegra: Add terminate() for Tegra234

Quoted 24 lines · Akhil R

In certain cases where the DMA client bus gets corrupted or if the end device ceases to send/receive data, DMA can wait indefinitely for the data to be received/sent. Attempting to terminate the transfer will put the DMA in pause flush mode and it remains there.

The channel is irrecoverable once this pause times out in Tegra194 and earlier chips. Whereas, from Tegra234, it can be recovered by disabling the channel and reprograming it.

Hence add a new terminate() function that ignores the outcome of dma_pause() and disables the channel.

---
  arch/arm64/boot/dts/nvidia/tegra234.dtsi |  5 +++--
  drivers/dma/tegra186-gpc-dma.c           | 26 ++++++++++++++++++++++--
  2 files changed, 27 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/nvidia/tegra234.dtsi +0 -0
index cf611eff7f6b..83d1ad7d3c8c 100644
@@ -22,8 +22,9 @@
  		ranges = <0x0 0x0 0x0 0x40000000>;

arch/arm64/boot/dts/nvidia/tegra234.dtsi line 30

Quoted 10 lines
arch/arm64/boot/dts/nvidia/tegra234.dtsi +3 -2
 
  		gpcdma: dma-controller@2600000 {
-			compatible = "nvidia,tegra194-gpcdma",
-				      "nvidia,tegra186-gpcdma";
+			compatible = "nvidia,tegra234-gpcdma",
+				     "nvidia,tegra194-gpcdma",
+				     "nvidia,tegra186-gpcdma";
  			reg = <0x2600000 0x210000>;
  			resets = <&bpmp TEGRA234_RESET_GPCDMA>;
  			reset-names = "gpcdma";

I think that this should be split into two patches.

Quoted 19 lines
drivers/dma/tegra186-gpc-dma.c +2 -2
index 05cd451f541d..fa9bda4a2bc6 100644
@@ -157,8 +157,8 @@
   * If any burst is in flight and DMA paused then this is the time to complete
   * on-flight burst and update DMA status register.
   */
-#define TEGRA_GPCDMA_BURST_COMPLETE_TIME	20
-#define TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT	100
+#define TEGRA_GPCDMA_BURST_COMPLETE_TIME	10
+#define TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT	5000 /* 5 msec */
 
  /* Channel base address offset from GPCDMA base address */
  #define TEGRA_GPCDMA_CHANNEL_BASE_ADD_OFFSET	0x20000
@@ -432,6 +432,17 @@ static int tegra_dma_device_resume(struct dma_chan *dc)
  	return 0;
  }
 

drivers/dma/tegra186-gpc-dma.c static int tegra_dma_device_resume(struct dma_chan *dc) · line 444

Quoted 10 lines
drivers/dma/tegra186-gpc-dma.c +10 -0
+static inline int tegra_dma_pause_noerr(struct tegra_dma_channel *tdc)
+{
+	/* Return 0 irrespective of PAUSE status.
+	 * This is useful to recover channels that can exit out of flush
+	 * state when the channel is disabled.
+	 */
+
+	tegra_dma_pause(tdc);
+	return 0;
+}

The commit message says that "add a new terminate() function that ignores the outcome of dma_pause() and disables the channel". But I only see pause being done here.

Quoted 29 lines
drivers/dma/tegra186-gpc-dma.c +12 -0
+
  static void tegra_dma_disable(struct tegra_dma_channel *tdc)
  {
  	u32 csr, status;
@@ -1292,6 +1303,14 @@ static const struct tegra_dma_chip_data tegra194_dma_chip_data = {
  	.terminate = tegra_dma_pause,
  };
 
+static const struct tegra_dma_chip_data tegra234_dma_chip_data = {
+	.nr_channels = 31,
+	.channel_reg_size = SZ_64K,
+	.max_dma_count = SZ_1G,
+	.hw_support_pause = true,
+	.terminate = tegra_dma_pause_noerr,
+};
+
  static const struct of_device_id tegra_dma_of_match[] = {
  	{
  		.compatible = "nvidia,tegra186-gpcdma",
@@ -1299,6 +1318,9 @@ static const struct of_device_id tegra_dma_of_match[] = {
  	}, {
  		.compatible = "nvidia,tegra194-gpcdma",
  		.data = &tegra194_dma_chip_data,
+	}, {
+		.compatible = "nvidia,tegra234-gpcdma",
+		.data = &tegra234_dma_chip_data,
  	}, {
  	},
  };
Signature · 1 line
nvpublic
author
#3 lore raw

RE: [PATCH 1/2] dmaengine: tegra: Add terminate() for Tegra234

Quoted 61 lines · Akhil R
Quoted 25 lines

In certain cases where the DMA client bus gets corrupted or if the end device ceases to send/receive data, DMA can wait indefinitely for the data to be received/sent. Attempting to terminate the transfer will put the DMA in pause flush mode and it remains there.

The channel is irrecoverable once this pause times out in Tegra194 and earlier chips. Whereas, from Tegra234, it can be recovered by disabling the channel and reprograming it.

Hence add a new terminate() function that ignores the outcome of dma_pause() and disables the channel.

---
  arch/arm64/boot/dts/nvidia/tegra234.dtsi |  5 +++--
  drivers/dma/tegra186-gpc-dma.c           | 26 ++++++++++++++++++++++--
  2 files changed, 27 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/nvidia/tegra234.dtsi +0 -0
index cf611eff7f6b..83d1ad7d3c8c 100644
@@ -22,8 +22,9 @@
  		ranges = <0x0 0x0 0x0 0x40000000>;

arch/arm64/boot/dts/nvidia/tegra234.dtsi line 30

Quoted 10 lines
arch/arm64/boot/dts/nvidia/tegra234.dtsi +3 -2
 
  		gpcdma: dma-controller@2600000 {
-			compatible = "nvidia,tegra194-gpcdma",
-				      "nvidia,tegra186-gpcdma";
+			compatible = "nvidia,tegra234-gpcdma",
+				     "nvidia,tegra194-gpcdma",
+				     "nvidia,tegra186-gpcdma";
  			reg = <0x2600000 0x210000>;
  			resets = <&bpmp TEGRA234_RESET_GPCDMA>;
  			reset-names = "gpcdma";

I think that this should be split into two patches.

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

Quoted 13 lines
(quoted diff) +0 -0

b/drivers/dma/tegra186-gpc-dma.c index 05cd451f541d..fa9bda4a2bc6 100644

drivers/dma/tegra186-gpc-dma.c +2 -2
@@ -157,8 +157,8 @@
   * If any burst is in flight and DMA paused then this is the time to complete
   * on-flight burst and update DMA status register.
   */
-#define TEGRA_GPCDMA_BURST_COMPLETE_TIME	20
-#define TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT	100
+#define TEGRA_GPCDMA_BURST_COMPLETE_TIME	10
+#define TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT	5000 /* 5

msec */

drivers/dma/tegra186-gpc-dma.c static int tegra_dma_device_resume(struct

Quoted 4 lines
drivers/dma/tegra186-gpc-dma.c +0 -0
  /* Channel base address offset from GPCDMA base address */
  #define TEGRA_GPCDMA_CHANNEL_BASE_ADD_OFFSET	0x20000
@@ -432,6 +432,17 @@ static int tegra_dma_device_resume(struct

dma_chan *dc)

Quoted 3 lines
drivers/dma/tegra186-gpc-dma.c +0 -0
  	return 0;
  }
 
Quoted 14 lines

drivers/dma/tegra186-gpc-dma.c static int tegra_dma_device_resume(struct dma_chan *dc) · line 444

Quoted 10 lines
drivers/dma/tegra186-gpc-dma.c +10 -0
+static inline int tegra_dma_pause_noerr(struct tegra_dma_channel
+*tdc) {
+	/* Return 0 irrespective of PAUSE status.
+	 * This is useful to recover channels that can exit out of flush
+	 * state when the channel is disabled.
+	 */
+
+	tegra_dma_pause(tdc);
+	return 0;
+}

The commit message says that "add a new terminate() function that ignores the outcome of dma_pause() and disables the channel". But I only see pause being done here.

The function is set as .terminate() function in chip_data and is called during terminate_all(). Since this return 0, tegra_dma_terminate_all() will proceed and calls tegra_dma_disable() in the next step.

Regards,
Akhil

--
nvpublic

maintainer
#4 lore raw

Re: [PATCH 1/2] dmaengine: tegra: Add terminate() for Tegra234

Quoted 75 lines · Akhil R
Quoted 61 lines · Akhil R
Quoted 25 lines

In certain cases where the DMA client bus gets corrupted or if the end device ceases to send/receive data, DMA can wait indefinitely for the data to be received/sent. Attempting to terminate the transfer will put the DMA in pause flush mode and it remains there.

The channel is irrecoverable once this pause times out in Tegra194 and earlier chips. Whereas, from Tegra234, it can be recovered by disabling the channel and reprograming it.

Hence add a new terminate() function that ignores the outcome of dma_pause() and disables the channel.

---
   arch/arm64/boot/dts/nvidia/tegra234.dtsi |  5 +++--
   drivers/dma/tegra186-gpc-dma.c           | 26 ++++++++++++++++++++++--
   2 files changed, 27 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/nvidia/tegra234.dtsi +0 -0
index cf611eff7f6b..83d1ad7d3c8c 100644
@@ -22,8 +22,9 @@
   		ranges = <0x0 0x0 0x0 0x40000000>;

arch/arm64/boot/dts/nvidia/tegra234.dtsi line 30

Quoted 10 lines
arch/arm64/boot/dts/nvidia/tegra234.dtsi +3 -2
 
   		gpcdma: dma-controller@2600000 {
-			compatible = "nvidia,tegra194-gpcdma",
-				      "nvidia,tegra186-gpcdma";
+			compatible = "nvidia,tegra234-gpcdma",
+				     "nvidia,tegra194-gpcdma",
+				     "nvidia,tegra186-gpcdma";
   			reg = <0x2600000 0x210000>;
   			resets = <&bpmp TEGRA234_RESET_GPCDMA>;
   			reset-names = "gpcdma";

I think that this should be split into two patches.

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

Quoted 13 lines
(quoted diff) +0 -0

b/drivers/dma/tegra186-gpc-dma.c index 05cd451f541d..fa9bda4a2bc6 100644

drivers/dma/tegra186-gpc-dma.c +2 -2
@@ -157,8 +157,8 @@
    * If any burst is in flight and DMA paused then this is the time to complete
    * on-flight burst and update DMA status register.
    */
-#define TEGRA_GPCDMA_BURST_COMPLETE_TIME	20
-#define TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT	100
+#define TEGRA_GPCDMA_BURST_COMPLETE_TIME	10
+#define TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT	5000 /* 5

msec */

drivers/dma/tegra186-gpc-dma.c static int tegra_dma_device_resume(struct

Quoted 4 lines
drivers/dma/tegra186-gpc-dma.c +0 -0
   /* Channel base address offset from GPCDMA base address */
   #define TEGRA_GPCDMA_CHANNEL_BASE_ADD_OFFSET	0x20000
@@ -432,6 +432,17 @@ static int tegra_dma_device_resume(struct

dma_chan *dc)

Quoted 3 lines
drivers/dma/tegra186-gpc-dma.c +0 -0
   	return 0;
   }
 
Quoted 14 lines

drivers/dma/tegra186-gpc-dma.c static int tegra_dma_device_resume(struct dma_chan *dc) · line 444

Quoted 10 lines
drivers/dma/tegra186-gpc-dma.c +10 -0
+static inline int tegra_dma_pause_noerr(struct tegra_dma_channel
+*tdc) {
+	/* Return 0 irrespective of PAUSE status.
+	 * This is useful to recover channels that can exit out of flush
+	 * state when the channel is disabled.
+	 */
+
+	tegra_dma_pause(tdc);
+	return 0;
+}

The commit message says that "add a new terminate() function that ignores the outcome of dma_pause() and disables the channel". But I only see pause being done here.

Quoted 3 lines

The function is set as .terminate() function in chip_data and is called during terminate_all(). Since this return 0, tegra_dma_terminate_all() will proceed and calls tegra_dma_disable() in the next step.

That's fine, but it is not clear from the commit message.

Jon

Signature · 1 line
nvpublic
author
#5 lore raw

PATCH 2/2 dt-bindings: dmaengine: Add compatible for Tegra234

In reply to Akhil R

Document the compatible string used by GPCDMA controller for Tegra234.

---
 .../devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml         | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml +1 -0
index 9dd1476d1849..81f3badbc8ec 100644
@@ -23,6 +23,7 @@ properties:
     oneOf:
       - const: nvidia,tegra186-gpcdma
       - items:
+          - const: nvidia,tegra234-gpcdma
           - const: nvidia,tegra194-gpcdma
           - const: nvidia,tegra186-gpcdma
 
Signature · 1 line
2.17.1
maintainer
#6 lore raw

Re: [PATCH 2/2] dt-bindings: dmaengine: Add compatible for Tegra234

Quoted 12 lines · Akhil R

Document the compatible string used by GPCDMA controller for Tegra234.

---
  .../devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml         | 1 +
  1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml +0 -0
index 9dd1476d1849..81f3badbc8ec 100644

Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml properties: · line 29

Quoted 7 lines
Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml +1 -0
@@ -23,6 +23,7 @@ properties:
      oneOf:
        - const: nvidia,tegra186-gpcdma
        - items:
+          - const: nvidia,tegra234-gpcdma
            - const: nvidia,tegra194-gpcdma
            - const: nvidia,tegra186-gpcdma
 

Typically, we put the binding doc patches first in the series.

Jon

Signature · 1 line
nvpublic