Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH] serial: imx: stop TX-ready interrupt storm on idle port
@ 2026-12-02 11:15 Michael Glembotzki
  2026-12-02 11:34 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Glembotzki @ 2026-12-02 11:15 UTC (permalink / raw)
  To: linux-serial; +Cc: gregkh, jirislaby, s.hauer, Michael Glembotzki, stable

On i.MX8MP, watchdog diagnostics captured repeated UART TX-ready
interrupts with tx_state OFF, an empty transmit buffer and no pending
x_char. The normal transmit handler calls imx_uart_stop_tx(), but that
function returns early when the state is OFF without clearing
UCR1_TRDYEN. The still-asserted interrupt can starve the CPU and prevent
the watchdog from being serviced.

When this precise idle condition is observed in the interrupt handler,
clear TRDYEN and continue the normal handler. Keep UART and RX enabled;
subsequent transmission can enable TX-ready interrupts through the
regular TX path. Do not change behavior when characters are pending.

The origin of the inconsistent state is not yet known. This change
addresses the observed interrupt loop, not the initial state mismatch.

Cc: stable@vger.kernel.org
Signed-off-by: Michael Glembotzki <Michael.Glembotzki@iris-sensing.com>
---

Tested on i.MX8MP hardware with an NXP-based Linux 6.6.161 kernel.
The mainline adaptation was compile-tested for ARM64, including
console support, but has not been runtime-tested.
 
For a 6.6 backport, the transmit-buffer check needs to use
uart_circ_empty(&sport->port.state->xmit) instead of
kfifo_is_empty(&sport->port.state->port.xmit_fifo).

 drivers/tty/serial/imx.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 0831bd5..258e03b 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1038,6 +1038,14 @@ static irqreturn_t imx_uart_int(int irq, void *dev_id)
 	}
 
 	if ((usr1 & USR1_TRDY) || (usr2 & USR2_TXDC)) {
+		/* An idle transmitter must not keep firing a ready interrupt. */
+		if ((usr1 & USR1_TRDY) && sport->tx_state == OFF &&
+		    !sport->port.x_char &&
+		    kfifo_is_empty(&sport->port.state->port.xmit_fifo)) {
+			u32 current_ucr1 = imx_uart_readl(sport, UCR1);
+
+			imx_uart_writel(sport, current_ucr1 & ~UCR1_TRDYEN, UCR1);
+		}
 		imx_uart_transmit_buffer(sport);
 		ret = IRQ_HANDLED;
 	}
-- 
2.56.1

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

end of thread, other threads:[~2026-12-02 11:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 11:15 [PATCH] serial: imx: stop TX-ready interrupt storm on idle port Michael Glembotzki
2026-12-02 11:34 ` sashiko-bot

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