Skip to contentSkip to conversation

serial: tegra: read DMA status before terminating

PATCH Superseded Kartik 3 participants 8 messages Oct 18, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kartik

author
#0 lore raw

PATCH 1/1 serial: tegra: read DMA status before terminating

To get the valid data, read DMA status before terminating the DMA. As dmaengine_terminate_all() deletes the DMA desc.

Fixes e9ea096dd225 ("serial: tegra: add serial driver")
---
 drivers/tty/serial/serial-tegra.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/serial-tegra.c +2 -2
index b7170cb9a544..2779b4491f02 100644
@@ -619,8 +619,8 @@ static void tegra_uart_stop_tx(struct uart_port *u)
 	if (tup->tx_in_progress != TEGRA_UART_TX_DMA)
 		return;
 
-	dmaengine_terminate_all(tup->tx_dma_chan);
 	dmaengine_tx_status(tup->tx_dma_chan, tup->tx_cookie, &state);
+	dmaengine_terminate_all(tup->tx_dma_chan);
 	count = tup->tx_bytes_requested - state.residue;
 	async_tx_ack(tup->tx_dma_desc);
 	uart_xmit_advance(&tup->uport, count);
@@ -763,8 +763,8 @@ static void tegra_uart_terminate_rx_dma(struct tegra_uart_port *tup)
 		return;
 	}
 
-	dmaengine_terminate_all(tup->rx_dma_chan);
 	dmaengine_tx_status(tup->rx_dma_chan, tup->rx_cookie, &state);
+	dmaengine_terminate_all(tup->rx_dma_chan);
 
 	tegra_uart_rx_buffer_push(tup, state.residue);
 	tup->rx_dma_active = false;
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/1 serial: tegra: read DMA status before terminating

To get the valid data, read DMA status before terminating the DMA. As dmaengine_terminate_all() deletes the DMA desc.

Fixes e9ea096dd225 ("serial: tegra: add serial driver")
---
 drivers/tty/serial/serial-tegra.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/serial-tegra.c +2 -2
index b7170cb9a544..2779b4491f02 100644
@@ -619,8 +619,8 @@ static void tegra_uart_stop_tx(struct uart_port *u)
 	if (tup->tx_in_progress != TEGRA_UART_TX_DMA)
 		return;
 
-	dmaengine_terminate_all(tup->tx_dma_chan);
 	dmaengine_tx_status(tup->tx_dma_chan, tup->tx_cookie, &state);
+	dmaengine_terminate_all(tup->tx_dma_chan);
 	count = tup->tx_bytes_requested - state.residue;
 	async_tx_ack(tup->tx_dma_desc);
 	uart_xmit_advance(&tup->uport, count);
@@ -763,8 +763,8 @@ static void tegra_uart_terminate_rx_dma(struct tegra_uart_port *tup)
 		return;
 	}
 
-	dmaengine_terminate_all(tup->rx_dma_chan);
 	dmaengine_tx_status(tup->rx_dma_chan, tup->rx_cookie, &state);
+	dmaengine_terminate_all(tup->rx_dma_chan);
 
 	tegra_uart_rx_buffer_push(tup, state.residue);
 	tup->rx_dma_active = false;
Signature · 1 line
2.17.1
maintainer
#2 lore raw
Quoted 10 lines · Kartik

To get the valid data, read DMA status before terminating the DMA. As dmaengine_terminate_all() deletes the DMA desc.

Fixes e9ea096dd225 ("serial: tegra: add serial driver")
---
 drivers/tty/serial/serial-tegra.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Why send this twice?

confused,

greg k-h

author
#3 lore raw
Quoted 3 lines · Greg KH

Why send this twice?

confused,

Hi Greg,

I made a mistake in my "git send-email" and the patch got posted twice.

Regards,
Kartik

maintainer
#4 lore raw
Quoted 8 lines · Kartik
Quoted 3 lines · Greg KH

Why send this twice?

confused,

Hi Greg,

I made a mistake in my "git send-email" and the patch got posted twice.

So which one is correct?

author
#5 lore raw
Quoted 1 line · Greg KH

So which one is correct?

They are basically the same patch. I goofed up while sending it. Please ignore the previous patch.

Regards,
Kartik

maintainer
#6 lore raw
In reply to Kartik
Quoted 16 lines · Kartik

To get the valid data, read DMA status before terminating the DMA. As dmaengine_terminate_all() deletes the DMA desc.

Fixes e9ea096dd225 ("serial: tegra: add serial driver")
---
  drivers/tty/serial/serial-tegra.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/serial-tegra.c +0 -0
index b7170cb9a544..2779b4491f02 100644

drivers/tty/serial/serial-tegra.c static void tegra_uart_stop_tx(struct uart_port *u) · line 623

Quoted 6 lines
drivers/tty/serial/serial-tegra.c +1 -1
@@ -619,8 +619,8 @@ static void tegra_uart_stop_tx(struct uart_port *u)
  	if (tup->tx_in_progress != TEGRA_UART_TX_DMA)
  		return;
 
-	dmaengine_terminate_all(tup->tx_dma_chan);
  	dmaengine_tx_status(tup->tx_dma_chan, tup->tx_cookie, &state);
+	dmaengine_terminate_all(tup->tx_dma_chan);

The change looks fine to me, but on further review of other similar drivers I see that they pause first ...

dmaengine_pause(tup->tx_dma_chan); dmaengine_tx_status(tup->tx_dma_chan, tup->tx_cookie, &state); dmaengine_terminate_all(tup->tx_dma_chan);

This makes sense so that when we calculate the amount of the data transferred we get the exact amount. Can we add a pause while we are at it?

Thanks!
Jon

Signature · 1 line
nvpublic
author
#7 lore raw
Quoted 7 lines

The change looks fine to me, but on further review of other similar drivers I see that they pause first ...

  dmaengine_pause(tup->tx_dma_chan);
  dmaengine_tx_status(tup->tx_dma_chan, tup->tx_cookie, &state);
  dmaengine_terminate_all(tup->tx_dma_chan);
Quoted 5 lines

This makes sense so that when we calculate the amount of the data transferred we get the exact amount. Can we add a pause while we are at it?

Thanks!
Jon

I agree.. I will include this in v2.

Regards,
Kartik