Skip to contentSkip to conversation

serial: tegra: Read DMA status before terminating

PATCH In review Kartik 4 participants 4 messages Oct 18, 2022 – Oct 19, 2022

Subsystems (3)
lore
Share & tools
lore

Kartik

author
#0 lore raw

PATCH v2 1/1 serial: tegra: Read DMA status before terminating

Read the DMA status before terminating the DMA, as doing so deletes the DMA desc.

Also, to get the correct transfer status information, pause the DMA using dmaengine_pause() before reading the DMA status.

Fixes e9ea096dd225 ("serial: tegra: add serial driver")

---
v1->v2:
* Pause the DMA before reading the DMA status.
* Updated commit message.

 drivers/tty/serial/serial-tegra.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/serial-tegra.c +4 -2
index b7170cb9a544..cda9cd4fa92c 100644
@@ -619,8 +619,9 @@ 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_pause(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 +764,9 @@ static void tegra_uart_terminate_rx_dma(struct tegra_uart_port *tup)
 		return;
 	}
 
-	dmaengine_terminate_all(tup->rx_dma_chan);
+	dmaengine_pause(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
Acked-by on v2 1/1
#1 lore raw
Quoted 10 lines · Kartik

Read the DMA status before terminating the DMA, as doing so deletes the DMA desc.

Also, to get the correct transfer status information, pause the DMA using dmaengine_pause() before reading the DMA status.

Fixes e9ea096dd225 ("serial: tegra: add serial driver")
Quoted 7 lines

---
v1->v2:
* Pause the DMA before reading the DMA status.
* Updated commit message.

 drivers/tty/serial/serial-tegra.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Seems fine:

Reviewed-by on v2 1/1
#2 lore raw
In reply to Kartik
Quoted 34 lines · Kartik

Read the DMA status before terminating the DMA, as doing so deletes the DMA desc.

Also, to get the correct transfer status information, pause the DMA using dmaengine_pause() before reading the DMA status.

Fixes e9ea096dd225 ("serial: tegra: add serial driver")

---
v1->v2:
* Pause the DMA before reading the DMA status.
* Updated commit message.

 drivers/tty/serial/serial-tegra.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/serial-tegra.c +2 -1
index b7170cb9a544..cda9cd4fa92c 100644
@@ -619,8 +619,9 @@ 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_pause(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);

drivers/tty/serial/serial-tegra.c static void tegra_uart_terminate_rx_dma(struct tegra_uart_port *tup) · line 772

Quoted 10 lines
drivers/tty/serial/serial-tegra.c +2 -1
@@ -763,8 +764,9 @@ static void tegra_uart_terminate_rx_dma(struct tegra_uart_port *tup)
 		return;
 	}
 
-	dmaengine_terminate_all(tup->rx_dma_chan);
+	dmaengine_pause(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
 i.
maintainer Reviewed-by on v2 1/1
#3 lore raw
In reply to Kartik
Quoted 34 lines · Kartik

Read the DMA status before terminating the DMA, as doing so deletes the DMA desc.

Also, to get the correct transfer status information, pause the DMA using dmaengine_pause() before reading the DMA status.

Fixes e9ea096dd225 ("serial: tegra: add serial driver")

---
v1->v2:
* Pause the DMA before reading the DMA status.
* Updated commit message.

  drivers/tty/serial/serial-tegra.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/serial-tegra.c +2 -1
index b7170cb9a544..cda9cd4fa92c 100644
@@ -619,8 +619,9 @@ 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_pause(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);

drivers/tty/serial/serial-tegra.c static void tegra_uart_terminate_rx_dma(struct tegra_uart_port *tup) · line 772

Quoted 10 lines
drivers/tty/serial/serial-tegra.c +2 -1
@@ -763,8 +764,9 @@ static void tegra_uart_terminate_rx_dma(struct tegra_uart_port *tup)
  		return;
  	}
 
-	dmaengine_terminate_all(tup->rx_dma_chan);
+	dmaengine_pause(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;

Thanks!

Jon

Signature · 1 line
nvpublic