Linux Serial subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Michael Glembotzki" <m.glembo@gmail.com>, linux-serial@vger.kernel.org
Subject: Re: [PATCH] serial: imx: stop TX-ready interrupt storm on idle port
Date: Wed, 02 Dec 2026 11:34:21 +0000	[thread overview]
Message-ID: <sashiko-outbox-245608@kernel.org> (raw)
In-Reply-To: <20261202111526.664966-2-Michael.Glembotzki@iris-sensing.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] serial: imx: incomplete TX interrupt storm fix in
  imx_uart_int()
- [Low] serial: imx: missing Fixes trailer for commit cb1a60923609
--

commit 11d7b6ef67792384c5672f5466f0d1655bebf34b
Author: Michael Glembotzki <m.glembo@gmail.com>

> serial: imx: stop TX-ready interrupt storm on idle port
>
> 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>

[Severity: Low]
Since this fixes the early return before clearing UCR1_TRDYEN in
imx_uart_stop_tx() and is tagged for stable, should it include:

  Fixes: cb1a60923609 ("serial: imx: implement rts delaying for rs485")

> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 0831bd5ee3dc2..258e03b744c06 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;
>  	}

[Severity: Medium]
Can this still leave UCR1_TRDYEN enabled in an interrupt storm when
uart_tx_stopped(&sport->port) is true and xmit_fifo is non-empty?

When flow control stops transmission while unsent bytes remain in
xmit_fifo, kfifo_is_empty() is false, so this new check is skipped.
imx_uart_transmit_buffer() then sees uart_tx_stopped() and calls
imx_uart_stop_tx() without draining xmit_fifo:

drivers/tty/serial/imx.c:imx_uart_transmit_buffer() {
	...
	if (kfifo_is_empty(&tport->xmit_fifo) ||
			uart_tx_stopped(&sport->port)) {
		imx_uart_stop_tx(&sport->port);
		return;
	}
	...
}

Because sport->tx_state is OFF, imx_uart_stop_tx() returns early without
clearing UCR1_TRDYEN, repeating the interrupt loop and starving the CPU.

Handling this in imx_uart_int() also misses a few other paths where
imx_uart_stop_tx() returns early while sport->tx_state == OFF: draining
pending characters in imx_uart_transmit_buffer() fails to clear
UCR1_TRDYEN at the end of the transfer, USR2_TXDC with UCR4_TCEN set is
not cleared, and platforms with a separate TX IRQ use imx_uart_txint()
instead of imx_uart_int().

Would clearing UCR1_TRDYEN (and UCR4_TCEN) in imx_uart_stop_tx() before
the sport->tx_state == OFF early return cover all of these paths in one
place?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202111526.664966-2-Michael.Glembotzki@iris-sensing.com?part=1

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

Thread overview: 2+ 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 [this message]

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=sashiko-outbox-245608@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=m.glembo@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox