Skip to contentSkip to conversation

dmaengine: tegra: Fix burst size calculation

PATCH RESEND Applied Kartik Rajput 3 participants 4 messages Apr 22 – Jun 8

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 dmaengine: tegra: Fix burst size calculation

Currently, the Tegra GPC DMA hardware requires the transfer length to be a multiple of the max burst size configured for the channel. When a client requests a transfer where the length is not evenly divisible by the configured max burst size, the DMA hangs with partial burst at the end.

Fix this by reducing the burst size to the largest power-of-2 value that evenly divides the transfer length. For example, a 40-byte transfer with a 16-byte max burst will now use an 8-byte burst (40 / 8 = 5 complete bursts) instead of causing a hang.

This issue was observed with the PL011 UART driver where TX DMA transfers of arbitrary lengths were stuck.

Fixes ee17028009d4 ("dmaengine: tegra: Add tegra gpcdma driver")
---
 drivers/dma/tegra186-gpc-dma.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/dma/tegra186-gpc-dma.c +7 -0
index 5948fbf32c21..0aa3a02b2277 100644
@@ -825,6 +825,13 @@ static unsigned int get_burst_size(struct tegra_dma_channel *tdc,
 	 * len to calculate the optimum burst size
 	 */
 	burst_byte = burst_size ? burst_size * slave_bw : len;
+
+	/*
+	 * Find the largest burst size that evenly divides the transfer length.
+	 * The hardware requires the transfer length to be a multiple of the
+	 * burst size - partial bursts are not supported.
+	 */
+	burst_byte = min(burst_byte, 1U << __ffs(len));
 	burst_mmio_width = burst_byte / 4;
 
 	if (burst_mmio_width < TEGRA_GPCDMA_MMIOSEQ_BURST_MIN)
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · Kartik Rajput

Currently, the Tegra GPC DMA hardware requires the transfer length to be a multiple of the max burst size configured for the channel. When a client requests a transfer where the length is not evenly divisible by the configured max burst size, the DMA hangs with partial burst at the end.

Fix this by reducing the burst size to the largest power-of-2 value that evenly divides the transfer length. For example, a 40-byte transfer with a 16-byte max burst will now use an 8-byte burst (40 / 8 = 5 complete bursts) instead of causing a hang.

This issue was observed with the PL011 UART driver where TX DMA transfers of arbitrary lengths were stuck.

Fixes ee17028009d4 ("dmaengine: tegra: Add tegra gpcdma driver")
---
  drivers/dma/tegra186-gpc-dma.c | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/dma/tegra186-gpc-dma.c +0 -0
index 5948fbf32c21..0aa3a02b2277 100644
@@ -825,6 +825,13 @@ static unsigned int get_burst_size(struct tegra_dma_channel *tdc,
  	 * len to calculate the optimum burst size
  	 */
  	burst_byte = burst_size ? burst_size * slave_bw : len;

drivers/dma/tegra186-gpc-dma.c static unsigned int get_burst_size(struct tegra_dma_channel *tdc, · line 837

Quoted 10 lines
drivers/dma/tegra186-gpc-dma.c +7 -0
+
+	/*
+	 * Find the largest burst size that evenly divides the transfer length.
+	 * The hardware requires the transfer length to be a multiple of the
+	 * burst size - partial bursts are not supported.
+	 */
+	burst_byte = min(burst_byte, 1U << __ffs(len));
  	burst_mmio_width = burst_byte / 4;
 
  	if (burst_mmio_width < TEGRA_GPCDMA_MMIOSEQ_BURST_MIN)

Thanks
Jon

Signature · 1 line
nvpublic
#2 lore raw

Hi Vinod,

Quoted 45 lines · Jon Hunter
Quoted 29 lines · Kartik Rajput

Currently, the Tegra GPC DMA hardware requires the transfer length to be a multiple of the max burst size configured for the channel. When a client requests a transfer where the length is not evenly divisible by the configured max burst size, the DMA hangs with partial burst at the end.

Fix this by reducing the burst size to the largest power-of-2 value that evenly divides the transfer length. For example, a 40-byte transfer with a 16-byte max burst will now use an 8-byte burst (40 / 8 = 5 complete bursts) instead of causing a hang.

This issue was observed with the PL011 UART driver where TX DMA transfers of arbitrary lengths were stuck.

Fixes ee17028009d4 ("dmaengine: tegra: Add tegra gpcdma driver")

---
  drivers/dma/tegra186-gpc-dma.c | 7 +++++++

  1 file changed, 7 insertions(+)
drivers/dma/tegra186-gpc-dma.c +0 -0
index 5948fbf32c21..0aa3a02b2277 100644
@@ -825,6 +825,13 @@ static unsigned int get_burst_size(struct tegra_dma_channel *tdc,
        * len to calculate the optimum burst size
        */

drivers/dma/tegra186-gpc-dma.c static unsigned int get_burst_size(struct tegra_dma_channel *tdc, · line 836

Quoted 10 lines
drivers/dma/tegra186-gpc-dma.c +7 -0
       burst_byte = burst_size ? burst_size * slave_bw : len;
+
+    /*
+     * Find the largest burst size that evenly divides the transfer length.
+     * The hardware requires the transfer length to be a multiple of the
+     * burst size - partial bursts are not supported.
+     */
+    burst_byte = min(burst_byte, 1U << __ffs(len));
       burst_mmio_width = burst_byte / 4;
       if (burst_mmio_width < TEGRA_GPCDMA_MMIOSEQ_BURST_MIN)
Quoted 3 lines

Thanks
Jon

This applies cleanly on top of Akhil's Tegra264 series:
https://lore.kernel.org/linux-tegra/[email protected]/T/#t

Could you please pick this up if there are no objections?

Thanks,
Kartik

maintainer Applied
#3 lore raw
In reply to Kartik Rajput
Quoted 6 lines · Kartik Rajput

Currently, the Tegra GPC DMA hardware requires the transfer length to be a multiple of the max burst size configured for the channel. When a client requests a transfer where the length is not evenly divisible by the configured max burst size, the DMA hangs with partial burst at the end.

Quoted 6 lines

Fix this by reducing the burst size to the largest power-of-2 value that evenly divides the transfer length. For example, a 40-byte transfer with a 16-byte max burst will now use an 8-byte burst (40 / 8 = 5 complete bursts) instead of causing a hang.

[...]

Applied, thanks!

[1/1] dmaengine: tegra: Fix burst size calculation

      commit: 4651df83b6c796daead3447e8fd874322918ee4f

Best regards,

Signature · 1 line
~Vinod