Skip to contentSkip to conversation

serial: Fix regression in omap-serial and pxa

PATCH In review Doug Brown 2 participants 6 messages Jun 6, 2024 – Jun 7, 2024

Subsystems (2)
lore
Share & tools
lore

Doug Brown

author
#0 lore raw

v2 cover serial: Fix regression in omap-serial and pxa

This series fixes a problem observed starting with v6.9 on the PXA168 Chumby 8 and the OMAP3530 BeagleBoard. The UART would hang and stop transmitting further data.

The root cause ended up being the change in commit 7bfb915a597a ("serial: core: only stop transmit when HW fifo is empty") that restricted when tx_stop() could be called. It broke omap-serial and pxa.

The change was intended to fix an issue with bcm63xx-uart after commit d11cc8c3c4b6 ("tty: serial: use uart_port_tx_limited()"). Instead, go back to Jonas' original patch series that fixes the issue directly in the bcm63xx-uart driver [1].

Changes since V1 [2]:

- Revert the broken commit and apply Jonas' patches for bcm63xx-uart instead of directly fixing the issue in the pxa driver (at the time, I didn't realize omap-serial was also affected).

[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/linux-serial/[email protected]/

Doug Brown (1):
Revert "serial: core: only stop transmit when HW fifo is empty"

Jonas Gorski (2):
serial: core: introduce uart_port_tx_limited_flags()
serial: bcm63xx-uart: fix tx after conversion to
uart_port_tx_limited()

 drivers/tty/serial/bcm63xx_uart.c |  7 +++++--
 include/linux/serial_core.h       | 21 +++++++++++++++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 1/3 Revert "serial: core: only stop transmit when HW fifo is empty"

This reverts commit 7bfb915a597a301abb892f620fe5c283a9fdbd77.

This commit broke pxa and omap-serial, because it inhibited them from calling stop_tx() if their TX FIFOs weren't completely empty. This resulted in these two drivers hanging during transmits because the TX interrupt would stay enabled, and a new TX interrupt would never fire.

---
 include/linux/serial_core.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
include/linux/serial_core.h +1 -2
index 8cb65f50e830..3fb9a29e025f 100644
@@ -811,8 +811,7 @@ enum UART_TX_FLAGS {
 	if (pending < WAKEUP_CHARS) {					      \
 		uart_write_wakeup(__port);				      \
 									      \
-		if (!((flags) & UART_TX_NOSTOP) && pending == 0 &&	      \
-		    __port->ops->tx_empty(__port))			      \
+		if (!((flags) & UART_TX_NOSTOP) && pending == 0)	      \
 			__port->ops->stop_tx(__port);			      \
 	}								      \
 									      \
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v2 2/3 serial: core: introduce uart_port_tx_limited_flags()

In reply to Doug Brown

From: Jonas Gorski <[email protected]>

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()")
---
 include/linux/serial_core.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/linux/serial_core.h +18 -0
index 3fb9a29e025f..aea25eef9a1a 100644
@@ -850,6 +850,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
Signature · 1 line
2.34.1
author
#3 lore raw

PATCH v2 3/3 serial: bcm63xx-uart: fix tx after conversion to uart_port_tx_limited()

In reply to Doug Brown

From: Jonas Gorski <[email protected]>

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()")
---
 drivers/tty/serial/bcm63xx_uart.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/tty/serial/bcm63xx_uart.c +5 -2
index 34801a6f300b..b88cc28c94e3 100644
@@ -308,8 +308,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),
 		({}));
@@ -320,6 +320,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);
 }
 
 /*
Signature · 1 line
2.34.1
#4 lore raw
In reply to Doug Brown

Hi Doug,

Quoted 5 lines · Doug Brown

This series fixes a problem observed starting with v6.9 on the PXA168 Chumby 8 and the OMAP3530 BeagleBoard. The UART would hang and stop transmitting further data.

Quoted 8 lines

The root cause ended up being the change in commit 7bfb915a597a ("serial: core: only stop transmit when HW fifo is empty") that restricted when tx_stop() could be called. It broke omap-serial and pxa.

The change was intended to fix an issue with bcm63xx-uart after commit d11cc8c3c4b6 ("tty: serial: use uart_port_tx_limited()"). Instead, go back to Jonas' original patch series that fixes the issue directly in the bcm63xx-uart driver [1].

Thanks for taking care of this.

Changes since V1 [2]:

Quoted 4 lines

- Revert the broken commit and apply Jonas' patches for bcm63xx-uart instead of directly fixing the issue in the pxa driver (at the time, I didn't realize omap-serial was also affected).

Note that this is technically a new V1 (or V3, depending on how you count), since the V2 of the original patchset was what became d11cc8c3c4b6 ("tty: serial: use uart_port_tx_limited()") and you are reverting in 1/3.

Not that this should be cause for a resend, just wanted to mention it.

Best Regards,
Jonas

author
#5 lore raw

Hi Jonas,

Quoted 6 lines · Jonas Gorski

Note that this is technically a new V1 (or V3, depending on how you count), since the V2 of the original patchset was what became d11cc8c3c4b6 ("tty: serial: use uart_port_tx_limited()") and you are reverting in 1/3.

Not that this should be cause for a resend, just wanted to mention it.

I'm still pretty new at this, so I honestly wasn't quite sure what to do in this case, but the reason I called it V2 is because I am considering V1 to be my original attempt at fixing the pxa driver that had all of the related discussion. I tried to point that out here with the link 2:

Quoted 1 line
Quoted 1 line

Changes since V1 [2]:

I probably should have made that more clear. You may be right that I should have just treated it as a brand new V1 series instead.

Thanks for your help on this!
Doug