[v2,2/2] serial: mxs-auart: fix tx

Message ID 20240201105557.28043-2-jirislaby@kernel.org
State New
Headers
Series [v2,1/2] serial: core: introduce uart_port_tx_flags() |

Commit Message

Jiri Slaby Feb. 1, 2024, 10:55 a.m. UTC
  Emil reports:
  After updating Linux on an i.MX28 board, serial communication over
  AUART broke. When I TX from the board and measure on the TX pin, it
  seems like the HW fifo is not emptied before the transmission is
  stopped.

MXS performs weird things with stop_tx(). The driver makes it
conditional on uart_tx_stopped().

So the driver needs special handling. Pass the brand new UART_TX_NOSTOP
to uart_port_tx_flags() and handle the stop on its own.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Reported-by: Emil Kronborg <emil.kronborg@protonmail.com>
Fixes: 2d141e683e9a ("tty: serial: use uart_port_tx() helper")
Closes: https://lore.kernel.org/all/miwgbnvy3hjpnricubg76ytpn7xoceehwahupy25bubbduu23s@om2lptpa26xw/
---
 drivers/tty/serial/mxs-auart.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Jiri Slaby Feb. 1, 2024, 12:05 p.m. UTC | #1
On 01. 02. 24, 11:55, Jiri Slaby (SUSE) wrote:
> Emil reports:
>    After updating Linux on an i.MX28 board, serial communication over
>    AUART broke. When I TX from the board and measure on the TX pin, it
>    seems like the HW fifo is not emptied before the transmission is
>    stopped.
> 
> MXS performs weird things with stop_tx(). The driver makes it
> conditional on uart_tx_stopped().
> 
> So the driver needs special handling. Pass the brand new UART_TX_NOSTOP
> to uart_port_tx_flags() and handle the stop on its own.
> 
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Reported-by: Emil Kronborg <emil.kronborg@protonmail.com>
> Fixes: 2d141e683e9a ("tty: serial: use uart_port_tx() helper")
> Closes: https://lore.kernel.org/all/miwgbnvy3hjpnricubg76ytpn7xoceehwahupy25bubbduu23s@om2lptpa26xw/

Am I unable to send a proper patch anymore?

I forgot to add mxs+arm maintainers:
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: linux-arm-kernel@lists.infradead.org

I can resend with those fixed, if you prefer...

> ---
>   drivers/tty/serial/mxs-auart.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
> index 3ec725555bcc..4749331fe618 100644
> --- a/drivers/tty/serial/mxs-auart.c
> +++ b/drivers/tty/serial/mxs-auart.c
> @@ -605,13 +605,16 @@ static void mxs_auart_tx_chars(struct mxs_auart_port *s)
>   		return;
>   	}
>   
> -	pending = uart_port_tx(&s->port, ch,
> +	pending = uart_port_tx_flags(&s->port, ch, UART_TX_NOSTOP,
>   		!(mxs_read(s, REG_STAT) & AUART_STAT_TXFF),
>   		mxs_write(ch, s, REG_DATA));
>   	if (pending)
>   		mxs_set(AUART_INTR_TXIEN, s, REG_INTR);
>   	else
>   		mxs_clr(AUART_INTR_TXIEN, s, REG_INTR);
> +
> +	if (uart_tx_stopped(&s->port))
> +               mxs_auart_stop_tx(&s->port);
>   }
>   
>   static void mxs_auart_rx_char(struct mxs_auart_port *s)
  
Greg KH Feb. 1, 2024, 2:57 p.m. UTC | #2
On Thu, Feb 01, 2024 at 01:05:42PM +0100, Jiri Slaby wrote:
> On 01. 02. 24, 11:55, Jiri Slaby (SUSE) wrote:
> > Emil reports:
> >    After updating Linux on an i.MX28 board, serial communication over
> >    AUART broke. When I TX from the board and measure on the TX pin, it
> >    seems like the HW fifo is not emptied before the transmission is
> >    stopped.
> > 
> > MXS performs weird things with stop_tx(). The driver makes it
> > conditional on uart_tx_stopped().
> > 
> > So the driver needs special handling. Pass the brand new UART_TX_NOSTOP
> > to uart_port_tx_flags() and handle the stop on its own.
> > 
> > Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> > Reported-by: Emil Kronborg <emil.kronborg@protonmail.com>
> > Fixes: 2d141e683e9a ("tty: serial: use uart_port_tx() helper")
> > Closes: https://lore.kernel.org/all/miwgbnvy3hjpnricubg76ytpn7xoceehwahupy25bubbduu23s@om2lptpa26xw/
> 
> Am I unable to send a proper patch anymore?
> 
> I forgot to add mxs+arm maintainers:
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: NXP Linux Team <linux-imx@nxp.com>
> Cc: linux-arm-kernel@lists.infradead.org
> 
> I can resend with those fixed, if you prefer...

Nah, this is fine, I'll take this as-is, thanks!

greg k-h
  
Emil Kronborg Feb. 1, 2024, 3:49 p.m. UTC | #3
On Thu, Feb 01, 2024 at 11:55 +0100, Jiri Slaby (SUSE) wrote:
> Emil reports:
>   After updating Linux on an i.MX28 board, serial communication over
>   AUART broke. When I TX from the board and measure on the TX pin, it
>   seems like the HW fifo is not emptied before the transmission is
>   stopped.
> 
> MXS performs weird things with stop_tx(). The driver makes it
> conditional on uart_tx_stopped().
> 
> So the driver needs special handling. Pass the brand new UART_TX_NOSTOP
> to uart_port_tx_flags() and handle the stop on its own.
> 
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Reported-by: Emil Kronborg <emil.kronborg@protonmail.com>
> Fixes: 2d141e683e9a ("tty: serial: use uart_port_tx() helper")
> Closes: https://lore.kernel.org/all/miwgbnvy3hjpnricubg76ytpn7xoceehwahupy25bubbduu23s@om2lptpa26xw/
> ---
>  drivers/tty/serial/mxs-auart.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
> index 3ec725555bcc..4749331fe618 100644
> --- a/drivers/tty/serial/mxs-auart.c
> +++ b/drivers/tty/serial/mxs-auart.c
> @@ -605,13 +605,16 @@ static void mxs_auart_tx_chars(struct mxs_auart_port *s)
>  		return;
>  	}
> 
> -	pending = uart_port_tx(&s->port, ch,
> +	pending = uart_port_tx_flags(&s->port, ch, UART_TX_NOSTOP,
>  		!(mxs_read(s, REG_STAT) & AUART_STAT_TXFF),
>  		mxs_write(ch, s, REG_DATA));
>  	if (pending)
>  		mxs_set(AUART_INTR_TXIEN, s, REG_INTR);
>  	else
>  		mxs_clr(AUART_INTR_TXIEN, s, REG_INTR);
> +
> +	if (uart_tx_stopped(&s->port))
> +               mxs_auart_stop_tx(&s->port);
>  }
> 
>  static void mxs_auart_rx_char(struct mxs_auart_port *s)
> --
> 2.43.0
> 

Tested on i.MX28.

Tested-by: Emil Kronborg <emil.kronborg@protonmail.com>
  
Stefan Wahren Feb. 1, 2024, 5:59 p.m. UTC | #4
Am 01.02.24 um 13:05 schrieb Jiri Slaby:
> On 01. 02. 24, 11:55, Jiri Slaby (SUSE) wrote:
>> Emil reports:
>>    After updating Linux on an i.MX28 board, serial communication over
>>    AUART broke. When I TX from the board and measure on the TX pin, it
>>    seems like the HW fifo is not emptied before the transmission is
>>    stopped.
>>
>> MXS performs weird things with stop_tx(). The driver makes it
>> conditional on uart_tx_stopped().
>>
>> So the driver needs special handling. Pass the brand new UART_TX_NOSTOP
>> to uart_port_tx_flags() and handle the stop on its own.
>>
>> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
>> Reported-by: Emil Kronborg <emil.kronborg@protonmail.com>
>> Fixes: 2d141e683e9a ("tty: serial: use uart_port_tx() helper")
>> Closes:
>> https://lore.kernel.org/all/miwgbnvy3hjpnricubg76ytpn7xoceehwahupy25bubbduu23s@om2lptpa26xw/
>
Tested-by: Stefan Wahren <wahrenst@gmx.net>

Thanks
  

Patch

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 3ec725555bcc..4749331fe618 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -605,13 +605,16 @@  static void mxs_auart_tx_chars(struct mxs_auart_port *s)
 		return;
 	}
 
-	pending = uart_port_tx(&s->port, ch,
+	pending = uart_port_tx_flags(&s->port, ch, UART_TX_NOSTOP,
 		!(mxs_read(s, REG_STAT) & AUART_STAT_TXFF),
 		mxs_write(ch, s, REG_DATA));
 	if (pending)
 		mxs_set(AUART_INTR_TXIEN, s, REG_INTR);
 	else
 		mxs_clr(AUART_INTR_TXIEN, s, REG_INTR);
+
+	if (uart_tx_stopped(&s->port))
+               mxs_auart_stop_tx(&s->port);
 }
 
 static void mxs_auart_rx_char(struct mxs_auart_port *s)