linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] serial: core: introduce uart_port_tx_limited_flags()
@ 2024-02-25 15:14 Jonas Gorski
  2024-02-25 15:14 ` [PATCH 2/2] serial: bcm63xx-uart: fix tx after conversion to uart_port_tx_limited() Jonas Gorski
  0 siblings, 1 reply; 3+ messages in thread
From: Jonas Gorski @ 2024-02-25 15:14 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: Greg Kroah-Hartman, Jiri Slaby, Ilpo Järvinen, Florian Fainelli

Analogue to uart_port_tx_flags() introduced in commit 3ee07964d407
("serial: core: introduce uart_port_tx_flags()"), add a _flags variant
for uart_port_tx_limited().

Fixes: d11cc8c3c4b6 ("tty: serial: use uart_port_tx_limited()")
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 include/linux/serial_core.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 55b1f3ba48ac..e25e20034a19 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -825,6 +825,24 @@ enum UART_TX_FLAGS {
 			__count--);					      \
 })
 
+/**
+ * uart_port_tx_limited_flags -- transmit helper for uart_port with count limiting with flags
+ * @port: uart port
+ * @ch: variable to store a character to be written to the HW
+ * @flags: %UART_TX_NOSTOP or similar
+ * @count: a limit of characters to send
+ * @tx_ready: can HW accept more data function
+ * @put_char: function to write a character
+ * @tx_done: function to call after the loop is done
+ *
+ * See uart_port_tx_limited() for more details.
+ */
+#define uart_port_tx_limited_flags(port, ch, flags, count, tx_ready, put_char, tx_done) ({ \
+	unsigned int __count = (count);							   \
+	__uart_port_tx(port, ch, flags, tx_ready, put_char, tx_done, __count,		   \
+			__count--);							   \
+})
+
 /**
  * uart_port_tx -- transmit helper for uart_port
  * @port: uart port
-- 
2.34.1


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

* [PATCH 2/2] serial: bcm63xx-uart: fix tx after conversion to uart_port_tx_limited()
  2024-02-25 15:14 [PATCH 1/2] serial: core: introduce uart_port_tx_limited_flags() Jonas Gorski
@ 2024-02-25 15:14 ` Jonas Gorski
  2024-02-25 16:14   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Jonas Gorski @ 2024-02-25 15:14 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: Greg Kroah-Hartman, Jiri Slaby, Ilpo Järvinen, Florian Fainelli

When bcm63xx-uart was converted to uart_port_tx_limited(), it implicitly
added a call to stop_tx(). This causes garbage to be put out on the
serial console. To fix this, pass UART_TX_NOSTOP in flags, and manually
call stop_tx() ourselves analogue to how a similar issue was fixed in
commit 7be50f2e8f20 ("serial: mxs-auart: fix tx").

Fixes: d11cc8c3c4b6 ("tty: serial: use uart_port_tx_limited()")
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 drivers/tty/serial/bcm63xx_uart.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index a3cefa153456..259fe5895032 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -309,8 +309,8 @@ static void bcm_uart_do_tx(struct uart_port *port)
 
 	val = bcm_uart_readl(port, UART_MCTL_REG);
 	val = (val & UART_MCTL_TXFIFOFILL_MASK) >> UART_MCTL_TXFIFOFILL_SHIFT;
-
-	pending = uart_port_tx_limited(port, ch, port->fifosize - val,
+	pending = uart_port_tx_limited_flags(port, ch, UART_TX_NOSTOP,
+		port->fifosize - val,
 		true,
 		bcm_uart_writel(port, ch, UART_FIFO_REG),
 		({}));
@@ -321,6 +321,9 @@ static void bcm_uart_do_tx(struct uart_port *port)
 	val = bcm_uart_readl(port, UART_IR_REG);
 	val &= ~UART_TX_INT_MASK;
 	bcm_uart_writel(port, val, UART_IR_REG);
+
+	if (uart_tx_stopped(port))
+		bcm_uart_stop_tx(port);
 }
 
 /*
-- 
2.34.1


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

* Re: [PATCH 2/2] serial: bcm63xx-uart: fix tx after conversion to uart_port_tx_limited()
  2024-02-25 15:14 ` [PATCH 2/2] serial: bcm63xx-uart: fix tx after conversion to uart_port_tx_limited() Jonas Gorski
@ 2024-02-25 16:14   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2024-02-25 16:14 UTC (permalink / raw)
  To: Jonas Gorski
  Cc: linux-kernel, linux-serial, Jiri Slaby, Ilpo Järvinen,
	Florian Fainelli

On Sun, Feb 25, 2024 at 04:14:26PM +0100, Jonas Gorski wrote:
> When bcm63xx-uart was converted to uart_port_tx_limited(), it implicitly
> added a call to stop_tx(). This causes garbage to be put out on the
> serial console. To fix this, pass UART_TX_NOSTOP in flags, and manually
> call stop_tx() ourselves analogue to how a similar issue was fixed in
> commit 7be50f2e8f20 ("serial: mxs-auart: fix tx").
> 
> Fixes: d11cc8c3c4b6 ("tty: serial: use uart_port_tx_limited()")
> Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
> ---
>  drivers/tty/serial/bcm63xx_uart.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
> index a3cefa153456..259fe5895032 100644
> --- a/drivers/tty/serial/bcm63xx_uart.c
> +++ b/drivers/tty/serial/bcm63xx_uart.c
> @@ -309,8 +309,8 @@ static void bcm_uart_do_tx(struct uart_port *port)
>  
>  	val = bcm_uart_readl(port, UART_MCTL_REG);
>  	val = (val & UART_MCTL_TXFIFOFILL_MASK) >> UART_MCTL_TXFIFOFILL_SHIFT;
> -
> -	pending = uart_port_tx_limited(port, ch, port->fifosize - val,
> +	pending = uart_port_tx_limited_flags(port, ch, UART_TX_NOSTOP,
> +		port->fifosize - val,
>  		true,
>  		bcm_uart_writel(port, ch, UART_FIFO_REG),
>  		({}));
> @@ -321,6 +321,9 @@ static void bcm_uart_do_tx(struct uart_port *port)
>  	val = bcm_uart_readl(port, UART_IR_REG);
>  	val &= ~UART_TX_INT_MASK;
>  	bcm_uart_writel(port, val, UART_IR_REG);
> +
> +	if (uart_tx_stopped(port))
> +		bcm_uart_stop_tx(port);
>  }
>  
>  /*
> -- 
> 2.34.1
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:


- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

end of thread, other threads:[~2024-02-25 16:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-25 15:14 [PATCH 1/2] serial: core: introduce uart_port_tx_limited_flags() Jonas Gorski
2024-02-25 15:14 ` [PATCH 2/2] serial: bcm63xx-uart: fix tx after conversion to uart_port_tx_limited() Jonas Gorski
2024-02-25 16:14   ` Greg Kroah-Hartman

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