Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH V2] tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete
@ 2022-08-04  7:04 Sherry Sun
  2022-08-15  8:04 ` Sherry Sun
  2022-08-21  8:38 ` Greg KH
  0 siblings, 2 replies; 5+ messages in thread
From: Sherry Sun @ 2022-08-04  7:04 UTC (permalink / raw)
  To: gregkh, jirislaby; +Cc: linux-serial, linux-kernel, linux-imx

When the user initializes the uart port, and waits for the transmit
engine to complete in lpuart32_set_termios(), if the UART TX fifo has
dirty data and the UARTMODIR enable the flow control, the TX fifo may
never be empty. So here we should disable the flow control first to make
sure the transmit engin can complete.

Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
Changes in V2:
1. Rephrase the commit log as suggested by Jiri.
---
 drivers/tty/serial/fsl_lpuart.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index fc7d235a1e27..f0fccd2ff7ac 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -2172,6 +2172,7 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
 	uart_update_timeout(port, termios->c_cflag, baud);
 
 	/* wait transmit engin complete */
+	lpuart32_write(&sport->port, 0, UARTMODIR);
 	lpuart32_wait_bit_set(&sport->port, UARTSTAT, UARTSTAT_TC);
 
 	/* disable transmit and receive */
-- 
2.17.1


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

* RE: [PATCH V2] tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete
  2022-08-04  7:04 [PATCH V2] tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete Sherry Sun
@ 2022-08-15  8:04 ` Sherry Sun
  2022-08-21  8:38 ` Greg KH
  1 sibling, 0 replies; 5+ messages in thread
From: Sherry Sun @ 2022-08-15  8:04 UTC (permalink / raw)
  To: gregkh@linuxfoundation.org, jirislaby@kernel.org
  Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	dl-linux-imx

Gentle ping...

Best regards
Sherry

> -----Original Message-----
> From: Sherry Sun
> Sent: 2022年8月4日 15:06
> To: gregkh@linuxfoundation.org; jirislaby@kernel.org
> Cc: linux-serial@vger.kernel.org; linux-kernel@vger.kernel.org; dl-linux-imx
> <linux-imx@nxp.com>
> Subject: [PATCH V2] tty: serial: lpuart: disable flow control while waiting for
> the transmit engine to complete
> 
> When the user initializes the uart port, and waits for the transmit engine to
> complete in lpuart32_set_termios(), if the UART TX fifo has dirty data and the
> UARTMODIR enable the flow control, the TX fifo may never be empty. So
> here we should disable the flow control first to make sure the transmit engin
> can complete.
> 
> Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> ---
> Changes in V2:
> 1. Rephrase the commit log as suggested by Jiri.
> ---
>  drivers/tty/serial/fsl_lpuart.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
> index fc7d235a1e27..f0fccd2ff7ac 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
> @@ -2172,6 +2172,7 @@ lpuart32_set_termios(struct uart_port *port,
> struct ktermios *termios,
>  	uart_update_timeout(port, termios->c_cflag, baud);
> 
>  	/* wait transmit engin complete */
> +	lpuart32_write(&sport->port, 0, UARTMODIR);
>  	lpuart32_wait_bit_set(&sport->port, UARTSTAT, UARTSTAT_TC);
> 
>  	/* disable transmit and receive */
> --
> 2.17.1


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

* Re: [PATCH V2] tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete
  2022-08-04  7:04 [PATCH V2] tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete Sherry Sun
  2022-08-15  8:04 ` Sherry Sun
@ 2022-08-21  8:38 ` Greg KH
  2022-08-21 10:01   ` Sherry Sun
  1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2022-08-21  8:38 UTC (permalink / raw)
  To: Sherry Sun; +Cc: jirislaby, linux-serial, linux-kernel, linux-imx

On Thu, Aug 04, 2022 at 03:04:20PM +0800, Sherry Sun wrote:
> When the user initializes the uart port, and waits for the transmit
> engine to complete in lpuart32_set_termios(), if the UART TX fifo has
> dirty data and the UARTMODIR enable the flow control, the TX fifo may
> never be empty. So here we should disable the flow control first to make
> sure the transmit engin can complete.
> 
> Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> ---
> Changes in V2:
> 1. Rephrase the commit log as suggested by Jiri.
> ---
>  drivers/tty/serial/fsl_lpuart.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
> index fc7d235a1e27..f0fccd2ff7ac 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
> @@ -2172,6 +2172,7 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
>  	uart_update_timeout(port, termios->c_cflag, baud);
>  
>  	/* wait transmit engin complete */
> +	lpuart32_write(&sport->port, 0, UARTMODIR);
>  	lpuart32_wait_bit_set(&sport->port, UARTSTAT, UARTSTAT_TC);
>  
>  	/* disable transmit and receive */
> -- 
> 2.17.1

What commit id does this fix?  Should it be backported to older stable
kernels?

thanks,

greg k-h

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

* RE: [PATCH V2] tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete
  2022-08-21  8:38 ` Greg KH
@ 2022-08-21 10:01   ` Sherry Sun
  2022-08-21 10:07     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Sherry Sun @ 2022-08-21 10:01 UTC (permalink / raw)
  To: Greg KH
  Cc: jirislaby@kernel.org, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, dl-linux-imx

> On Thu, Aug 04, 2022 at 03:04:20PM +0800, Sherry Sun wrote:
> > When the user initializes the uart port, and waits for the transmit
> > engine to complete in lpuart32_set_termios(), if the UART TX fifo has
> > dirty data and the UARTMODIR enable the flow control, the TX fifo may
> > never be empty. So here we should disable the flow control first to
> > make sure the transmit engin can complete.
> >
> > Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> > ---
> > Changes in V2:
> > 1. Rephrase the commit log as suggested by Jiri.
> > ---
> >  drivers/tty/serial/fsl_lpuart.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/tty/serial/fsl_lpuart.c
> > b/drivers/tty/serial/fsl_lpuart.c index fc7d235a1e27..f0fccd2ff7ac
> > 100644
> > --- a/drivers/tty/serial/fsl_lpuart.c
> > +++ b/drivers/tty/serial/fsl_lpuart.c
> > @@ -2172,6 +2172,7 @@ lpuart32_set_termios(struct uart_port *port,
> struct ktermios *termios,
> >  	uart_update_timeout(port, termios->c_cflag, baud);
> >
> >  	/* wait transmit engin complete */
> > +	lpuart32_write(&sport->port, 0, UARTMODIR);
> >  	lpuart32_wait_bit_set(&sport->port, UARTSTAT, UARTSTAT_TC);
> >
> >  	/* disable transmit and receive */
> > --
> > 2.17.1
> 
> What commit id does this fix?  Should it be backported to older stable kernels?

This issue existed when the lpuart32_set_termios() was introduced. So the Fixes tag should be:
Fixes: 380c966c093e ("tty: serial: fsl_lpuart: add 32-bit register interface support"), and I believe it can be backported to the older stable kernels.

Should I send a V2 patch to add the Fixes tag?

Best regards
Sherry

> 
> thanks,
> 
> greg k-h

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

* Re: [PATCH V2] tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete
  2022-08-21 10:01   ` Sherry Sun
@ 2022-08-21 10:07     ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2022-08-21 10:07 UTC (permalink / raw)
  To: Sherry Sun
  Cc: jirislaby@kernel.org, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, dl-linux-imx

On Sun, Aug 21, 2022 at 10:01:45AM +0000, Sherry Sun wrote:
> > On Thu, Aug 04, 2022 at 03:04:20PM +0800, Sherry Sun wrote:
> > > When the user initializes the uart port, and waits for the transmit
> > > engine to complete in lpuart32_set_termios(), if the UART TX fifo has
> > > dirty data and the UARTMODIR enable the flow control, the TX fifo may
> > > never be empty. So here we should disable the flow control first to
> > > make sure the transmit engin can complete.
> > >
> > > Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> > > ---
> > > Changes in V2:
> > > 1. Rephrase the commit log as suggested by Jiri.
> > > ---
> > >  drivers/tty/serial/fsl_lpuart.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/tty/serial/fsl_lpuart.c
> > > b/drivers/tty/serial/fsl_lpuart.c index fc7d235a1e27..f0fccd2ff7ac
> > > 100644
> > > --- a/drivers/tty/serial/fsl_lpuart.c
> > > +++ b/drivers/tty/serial/fsl_lpuart.c
> > > @@ -2172,6 +2172,7 @@ lpuart32_set_termios(struct uart_port *port,
> > struct ktermios *termios,
> > >  	uart_update_timeout(port, termios->c_cflag, baud);
> > >
> > >  	/* wait transmit engin complete */
> > > +	lpuart32_write(&sport->port, 0, UARTMODIR);
> > >  	lpuart32_wait_bit_set(&sport->port, UARTSTAT, UARTSTAT_TC);
> > >
> > >  	/* disable transmit and receive */
> > > --
> > > 2.17.1
> > 
> > What commit id does this fix?  Should it be backported to older stable kernels?
> 
> This issue existed when the lpuart32_set_termios() was introduced. So the Fixes tag should be:
> Fixes: 380c966c093e ("tty: serial: fsl_lpuart: add 32-bit register interface support"), and I believe it can be backported to the older stable kernels.
> 
> Should I send a V2 patch to add the Fixes tag?

Yes please.

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

end of thread, other threads:[~2022-08-21 10:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-04  7:04 [PATCH V2] tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete Sherry Sun
2022-08-15  8:04 ` Sherry Sun
2022-08-21  8:38 ` Greg KH
2022-08-21 10:01   ` Sherry Sun
2022-08-21 10:07     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox