tty: serial: fsl_lpuart: flush RX and TX FIFO when lpuart shutdown
Subsystems (2)
PATCH 1/1 tty: serial: fsl_lpuart: flush RX and TX FIFO when lpuart shutdown
Need to flush UART RX and TX FIFO when lpuart is shutting down to make sure restore a clean data transfer environment.
--- drivers/tty/serial/fsl_lpuart.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/tty/serial/fsl_lpuart.c +5 -0
@@ -1965,6 +1965,11 @@ static void lpuart32_shutdown(struct uart_port *port) UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE | UARTCTRL_SBK);lpuart32_write (port, temp,UARTCTRL ); +/* flush Rx/Tx FIFO */ + temp =lpuart32_read (port,UARTFIFO ); + temp |=UARTFIFO_TXFLUSH |UARTFIFO_RXFLUSH ; +lpuart32_write (port, temp,UARTFIFO ); +uart_port_unlock_irqrestore (port, flags);lpuart_dma_shutdown (sport);
Signature · 1 line
2.34.1
Frank Li
maintainerQuoted 2 lines · Sherry Sun
Need to flush UART RX and TX FIFO when lpuart is shutting down to make sure restore a clean data transfer environment.
why not flush it at open()?
Frank
Quoted 25 lines
Signed-off-by Sherry Sun <[email protected]>--- drivers/tty/serial/fsl_lpuart.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/tty/serial/fsl_lpuart.c +5
-1@@ -1965,6 +1965,11 @@ static void lpuart32_shutdown(struct uart_port *port) UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE | UARTCTRL_SBK);lpuart32_write (port, temp,UARTCTRL ); +/* flush Rx/Tx FIFO */ + temp =lpuart32_read (port,UARTFIFO ); + temp |=UARTFIFO_TXFLUSH |UARTFIFO_RXFLUSH ; +lpuart32_write (port, temp,UARTFIFO ); +uart_port_unlock_irqrestore (port, flags);lpuart_dma_shutdown (sport); --2.34.1
Quoted 11 lines
-----Original Message-----
From: Frank Li <[email protected]>
Sent: Tuesday, January 7, 2025 11:46 PM
To: Sherry Sun <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] tty: serial:fsl_lpuart: flush RX and TX FIFO when lpuart shutdown
Quoted 5 lines
Quoted 2 lines · Sherry Sun
Need to flush UART RX and TX FIFO when lpuart is shutting down to make sure restore a clean data transfer environment.
why not flush it at
open()?
Hi Frank,
Some background: We observed an issue during imx952 zebu simulation, imx952 edma IP has a bug that if an edma error occurs, it will directly return an error without marking the current request completed, so the current uart transfer will pending, the data will stuck in the FIFO even if we close the uart port and reopen it, which will impact the next data transfer. Actually when we configure and enable the FIFO during uart startup, we also flush the RX/TX FIFO, but it is done after the rx/tx dma are started, so the dma request is still triggered by mistake.
And I think it is reasonable to flush the RX/TX FIFO when closing the uart port, so add this behavior in shutdown() to avoid changing the workflow of startup().
Best Regards
Sherry
Quoted 29 lines
drivers/tty/serial/fsl_lpuart.c static void lpuart32_shutdown(struct uart_port
Quoted 13 lines
Signed-off-by Sherry Sun <[email protected]>--- drivers/tty/serial/fsl_lpuart.c | 5 +++++ 1 file changed, 5 insertions(+)(quoted diff) +0
-0
b/drivers/tty/serial/fsl_lpuart.cindex7cb1e36fdaab..c91b9d9818cd100644drivers/tty/serial/fsl_lpuart.c +0
-0@@ -1965,6 +1965,11 @@ static void lpuart32_shutdown(struct uart_port*port)
drivers/tty/serial/fsl_lpuart.c static void lpuart32_shutdown(struct uart_port · line 1965
Quoted 1 line
drivers/tty/serial/fsl_lpuart.c +0
-0UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE |
UARTCTRL_SBK);Quoted 13 lines
drivers/tty/serial/fsl_lpuart.c +5
-1lpuart32_write (port, temp,UARTCTRL ); +/* flush Rx/Tx FIFO */ + temp =lpuart32_read (port,UARTFIFO ); + temp |=UARTFIFO_TXFLUSH |UARTFIFO_RXFLUSH ; +lpuart32_write (port, temp,UARTFIFO ); +uart_port_unlock_irqrestore (port, flags);lpuart_dma_shutdown (sport); --2.34.1
Frank Li
maintainerQuoted 15 lines · Sherry Sun
Quoted 15 lines
-----Original Message-----
From: Frank Li <[email protected]>
Sent: Tuesday, January 7, 2025 11:46 PM
To: Sherry Sun <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] tty: serial:fsl_lpuart: flush RX and TX FIFO when lpuart shutdownQuoted 2 lines · Sherry Sun
Need to flush UART RX and TX FIFO when lpuart is shutting down to make sure restore a clean data transfer environment.
Quoted 6 lines
Quoted 1 line
why not flush it at
open()?Hi Frank,
Some background: We observed an issue during imx952 zebu simulation, imx952 edma IP has a bug that if an edma error occurs, it will directly return an error without marking the current request completed, so the current uart transfer will pending, the data will stuck in the FIFO even if we close the uart port and reopen it, which will impact the next data transfer. Actually when we configure and enable the FIFO during uart startup, we also flush the RX/TX FIFO, but it is done after the rx/tx dma are started,
Please wrap at 75 char to read easily.
It looks like make sense to move flash before start dma.
Quoted 2 lines
so the dma request is still triggered by mistake.
And I think it is reasonable to flush the RX/TX FIFO when closing the uart port, so add this behavior inshutdown()to avoid changing the workflow ofstartup().
the target is make driver logic reasonable, not avoid changing ... if external devices continue send data, even you flash fifo in closing, it may still have data in FIFO if uart have not disabled yet.
Frank
Quoted 33 lines
Best Regards
SherryQuoted 29 lines
drivers/tty/serial/fsl_lpuart.c static void lpuart32_shutdown(struct uart_port
Quoted 13 lines
Signed-off-by Sherry Sun <[email protected]>--- drivers/tty/serial/fsl_lpuart.c | 5 +++++ 1 file changed, 5 insertions(+)(quoted diff) +0
-0
b/drivers/tty/serial/fsl_lpuart.cindex7cb1e36fdaab..c91b9d9818cd100644drivers/tty/serial/fsl_lpuart.c +0
-0@@ -1965,6 +1965,11 @@ static void lpuart32_shutdown(struct uart_port*port)
drivers/tty/serial/fsl_lpuart.c static void lpuart32_shutdown(struct uart_port · line 1965
Quoted 1 line
drivers/tty/serial/fsl_lpuart.c +0
-0UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE |
UARTCTRL_SBK);Quoted 13 lines
drivers/tty/serial/fsl_lpuart.c +5
-1lpuart32_write (port, temp,UARTCTRL ); +/* flush Rx/Tx FIFO */ + temp =lpuart32_read (port,UARTFIFO ); + temp |=UARTFIFO_TXFLUSH |UARTFIFO_RXFLUSH ; +lpuart32_write (port, temp,UARTFIFO ); +uart_port_unlock_irqrestore (port, flags);lpuart_dma_shutdown (sport); --2.34.1
Quoted 37 lines
-----Original Message-----
From: Frank Li <[email protected]>
Sent: Thursday, January 9, 2025 12:41 AM
To: Sherry Sun <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] tty: serial:fsl_lpuart: flush RX and TX FIFO when lpuart shutdownQuoted 13 lines · Sherry Sun
Quoted 13 lines
-----Original Message-----
From: Frank Li <[email protected]>
Sent: Tuesday, January 7, 2025 11:46 PM
To: Sherry Sun <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] tty: serial:fsl_lpuart: flush RX and TX FIFO when lpuart shutdownOn Tue, Jan 07, 2025 at 03:48:34PM +0800, Sherry Sun wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Need to flush UART RX and TX FIFO when lpuart is shutting down to make sure restore a clean data transfer environment.
why not flush it at
open()?Hi Frank,
Some background: We observed an issue during imx952 zebu simulation,
imx952 edma IP has a bug that if an edma error occurs, it will directly return an error without marking the current request completed, so the current uart transfer will pending, the data will stuck in the FIFO even if we close the uart port and reopen it, which will impact the next data transfer.
Quoted 5 lines
Quoted 3 lines
Actually when we configure and enable the FIFO during uart startup, we also flush the RX/TX FIFO, but it is done after the rx/tx dma are started,
Please wrap at 75 char to read easily.
Hi Frank, sorry for that, will pay attention next time. :)
Quoted 2 lines
It looks like make sense to move flash before start dma.
Yes, as we discussed internally, this is an improvement needs to be done. Thanks for the suggestions.
Quoted 10 lines
Quoted 3 lines
so the dma request is still triggered by mistake.
And I think it is reasonable to flush the RX/TX FIFO when closing the uartport, so add this behavior in
shutdown()to avoid changing the workflow ofstartup().the target is make driver logic reasonable, not avoid changing ... if external devices continue send data, even you flash fifo in closing, it may still have data in FIFO if uart have not disabled yet.
Since we flush the FIFO after disabling the receiver and transmitter, so this won't happen.
Best Regards
Sherry
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 13 lines
Signed-off-by Sherry Sun <[email protected]>--- drivers/tty/serial/fsl_lpuart.c | 5 +++++ 1 file changed, 5 insertions(+)(quoted diff) +0
-0
b/drivers/tty/serial/fsl_lpuart.cindex7cb1e36fdaab..c91b9d9818cd100644drivers/tty/serial/fsl_lpuart.c +0
-0@@ -1965,6 +1965,11 @@ static void lpuart32_shutdown(structQuoted 1 line
uart_port*port)
Quoted 1 line
UARTCTRL_TIE|UARTCTRL_TCIE|UARTCTRL_RIE|
UARTCTRL_SBK);Quoted 13 lines
drivers/tty/serial/fsl_lpuart.c +5
-1lpuart32_write (port, temp,UARTCTRL ); +/* flush Rx/Tx FIFO */ + temp =lpuart32_read (port,UARTFIFO ); + temp |=UARTFIFO_TXFLUSH |UARTFIFO_RXFLUSH ; +lpuart32_write (port, temp,UARTFIFO ); +uart_port_unlock_irqrestore (port, flags);lpuart_dma_shutdown (sport); --2.34.1