linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] serial: tegra: Read DMA status before terminating
@ 2022-10-18 14:58 Kartik
  2022-10-18 15:19 ` Thierry Reding
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kartik @ 2022-10-18 14:58 UTC (permalink / raw)
  To: ldewangan, gregkh, jirislaby, thierry.reding, jonathanh, alan,
	swarren, akhilrajeev, linux-serial, linux-tegra, linux-kernel

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")

Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Signed-off-by: Kartik <kkartik@nvidia.com>
---
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(-)

diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
index b7170cb9a544..cda9cd4fa92c 100644
--- a/drivers/tty/serial/serial-tegra.c
+++ b/drivers/tty/serial/serial-tegra.c
@@ -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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] serial: tegra: Read DMA status before terminating
  2022-10-18 14:58 [PATCH v2] serial: tegra: Read DMA status before terminating Kartik
@ 2022-10-18 15:19 ` Thierry Reding
  2022-10-19  9:12 ` Ilpo Järvinen
  2022-10-19  9:48 ` Jon Hunter
  2 siblings, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2022-10-18 15:19 UTC (permalink / raw)
  To: Kartik
  Cc: ldewangan, gregkh, jirislaby, jonathanh, alan, swarren,
	akhilrajeev, linux-serial, linux-tegra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 711 bytes --]

On Tue, Oct 18, 2022 at 08:28:06PM +0530, Kartik wrote:
> 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")
> 
> Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
> Signed-off-by: Kartik <kkartik@nvidia.com>
> ---
> 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:

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] serial: tegra: Read DMA status before terminating
  2022-10-18 14:58 [PATCH v2] serial: tegra: Read DMA status before terminating Kartik
  2022-10-18 15:19 ` Thierry Reding
@ 2022-10-19  9:12 ` Ilpo Järvinen
  2022-10-19  9:48 ` Jon Hunter
  2 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2022-10-19  9:12 UTC (permalink / raw)
  To: Kartik
  Cc: ldewangan, gregkh, jirislaby, thierry.reding, jonathanh, alan,
	swarren, akhilrajeev, linux-serial, linux-tegra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1767 bytes --]

On Tue, 18 Oct 2022, Kartik wrote:

> 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")
> 
> Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
> Signed-off-by: Kartik <kkartik@nvidia.com>
> ---
> 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(-)
> 
> diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
> index b7170cb9a544..cda9cd4fa92c 100644
> --- a/drivers/tty/serial/serial-tegra.c
> +++ b/drivers/tty/serial/serial-tegra.c
> @@ -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;

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>


-- 
 i.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] serial: tegra: Read DMA status before terminating
  2022-10-18 14:58 [PATCH v2] serial: tegra: Read DMA status before terminating Kartik
  2022-10-18 15:19 ` Thierry Reding
  2022-10-19  9:12 ` Ilpo Järvinen
@ 2022-10-19  9:48 ` Jon Hunter
  2 siblings, 0 replies; 4+ messages in thread
From: Jon Hunter @ 2022-10-19  9:48 UTC (permalink / raw)
  To: Kartik, ldewangan, gregkh, jirislaby, thierry.reding, alan,
	swarren, akhilrajeev, linux-serial, linux-tegra, linux-kernel


On 18/10/2022 15:58, Kartik wrote:
> 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")
> 
> Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
> Signed-off-by: Kartik <kkartik@nvidia.com>
> ---
> 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(-)
> 
> diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
> index b7170cb9a544..cda9cd4fa92c 100644
> --- a/drivers/tty/serial/serial-tegra.c
> +++ b/drivers/tty/serial/serial-tegra.c
> @@ -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;

Thanks!

Reviewed-by: Jon Hunter <jonathanh@nvidia.com>

Jon

-- 
nvpublic

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-19 10:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-18 14:58 [PATCH v2] serial: tegra: Read DMA status before terminating Kartik
2022-10-18 15:19 ` Thierry Reding
2022-10-19  9:12 ` Ilpo Järvinen
2022-10-19  9:48 ` Jon Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).