All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Glembotzki <m.glembo@gmail.com>
To: linux-serial@vger.kernel.org
Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org,
	s.hauer@pengutronix.de, stable@vger.kernel.org,
	Michael Glembotzki <Michael.Glembotzki@iris-sensing.com>
Subject: [PATCH v2] serial: imx: disable TX interrupts when already stopped
Date: Wed,  2 Dec 2026 17:34:25 +0100	[thread overview]
Message-ID: <20261202163424.698658-2-Michael.Glembotzki@iris-sensing.com> (raw)
In-Reply-To: <20261202111526.664966-2-Michael.Glembotzki@iris-sensing.com>

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 or UCR4_TCEN. A still-enabled TX interrupt can starve the CPU
and prevent the watchdog from being serviced.

Clear both TX interrupt enable bits before returning from the OFF branch
of imx_uart_stop_tx(). This also handles stopped transmission with data
still queued, a buffer drained by the transmit handler, and platforms
using a separate TX interrupt handler. Keep the existing DMA and RS485
handling for other TX states unchanged.

UART and RX remain enabled. Subsequent transmission can enable TX
interrupts again through the normal start path.

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

Fixes: cb1a60923609 ("serial: imx: implement rts delaying for rs485")
Cc: stable@vger.kernel.org
Signed-off-by: Michael Glembotzki <Michael.Glembotzki@iris-sensing.com>
---

Runtime-tested on i.MX8MP hardware with an NXP-based Linux 6.6.161
kernel. Mainline has not been runtime-tested.

Changes in v2:
- Disable TRDYEN and TCEN in the OFF branch of imx_uart_stop_tx()
  instead of handling only an empty buffer in the combined IRQ handler.
- Add the Fixes tag for the commit introducing the early return.

v1: https://lore.kernel.org/linux-serial/20261202111526.664966-2-Michael.Glembotzki@iris-sensing.com/

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

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -415,8 +415,15 @@ static void imx_uart_stop_tx(struct uart_port *port)
 	struct imx_port *sport = to_imx_port(port);
 	u32 ucr1, ucr4, usr2;
 
-	if (sport->tx_state == OFF)
+	if (sport->tx_state == OFF) {
+		/* Disable stale TX interrupts even when already stopped. */
+		ucr1 = imx_uart_readl(sport, UCR1);
+		imx_uart_writel(sport, ucr1 & ~UCR1_TRDYEN, UCR1);
+
+		ucr4 = imx_uart_readl(sport, UCR4);
+		imx_uart_writel(sport, ucr4 & ~UCR4_TCEN, UCR4);
 		return;
+	}
 
 	/*
 	 * We are maybe in the SMP context, so if the DMA TX thread is running
-- 
2.56.1

  parent reply	other threads:[~2026-12-02 16:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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
2026-12-02 16:34 ` Michael Glembotzki [this message]
2026-12-02 16:44   ` [PATCH v2] serial: imx: disable TX interrupts when already stopped sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202163424.698658-2-Michael.Glembotzki@iris-sensing.com \
    --to=m.glembo@gmail.com \
    --cc=Michael.Glembotzki@iris-sensing.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.