Linux Serial subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Paul Mbewe" <paultyson.mbewe@ziehl-abegg.de>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v2 RESEND 1/2] serial: sc16is7xx: refill TX FIFO below trigger using fresh TXLVL
Date: Wed, 30 Sep 2026 15:09:43 +0000	[thread overview]
Message-ID: <20260930150943.B69331F0089D@smtp.kernel.org> (raw)
In-Reply-To: <20260930145628.566535-2-paultyson.mbewe@ziehl-abegg.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] serial: sc16is7xx: unbounded tx refill loop starves rx irqs
--

commit a658261936f3762a047ddfec6aa9737edd0babeb
Author: Paul Mbewe <paultyson.mbewe@ziehl-abegg.de>

serial: sc16is7xx: refill TX FIFO below trigger using fresh TXLVL

This commit changes the driver to continually refill the hardware TX FIFO
by polling the available space (TXLVL) until the hardware reports a level
strictly below the trigger.

Link: https://lore.kernel.org/linux-serial/20260623112225.82386-3-paultyson.mbewe@ziehl-abegg.de/

> diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
> index fa7805d2cde23..1f7e98c2b5709 100644
> --- a/drivers/tty/serial/sc16is7xx.c
> +++ b/drivers/tty/serial/sc16is7xx.c

[ ... ]

> @@ -687,7 +698,14 @@ static void sc16is7xx_handle_tx(struct uart_port *port)
>  
>  		sc16is7xx_fifo_write(port, tail, to_send);
>  		uart_xmit_advance(port, to_send);
> -		txlen -= to_send;
> +
> +		if (kfifo_is_empty(&tport->xmit_fifo))
> +			break;
> +
> +		/* Refill below the trigger to enable the next THRI crossing. */
> +		txlen = sc16is7xx_txlvl(port);
> +		if (txlen < SC16IS7XX_TX_TRIGGER_LEVEL)
> +			break;
>  	}

[Severity: High]
Could updating the loop boundary directly from the hardware without an
iteration limit cause an unbounded loop that starves RX interrupts?

If the UART baud rate exceeds the I2C or SPI bus throughput (for example,
921600 baud over 400kHz I2C), the hardware TX FIFO will drain faster than
sc16is7xx_fifo_write() can fill it over the bus.

In this scenario, the fresh txlvl reading remains high, meaning the loop exit
condition fails to trigger. This allows the loop to spin continuously until
the 4KB xmit_fifo is completely emptied.

Because sc16is7xx_handle_tx() is executed in the shared IRQ handling thread,
spinning here completely blocks the thread while it flushes the xmit_fifo. RX
interrupts cannot be serviced during this time, which could cause the 64-byte
hardware RX FIFO to rapidly overrun, resulting in data loss.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260930145628.566535-1-paultyson.mbewe@ziehl-abegg.de?part=1

  reply	other threads:[~2026-09-30 15:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 14:56 [PATCH v2 RESEND 0/2] serial: sc16is7xx: improve TX FIFO refill Paul Mbewe
2026-09-30 14:56 ` [PATCH v2 RESEND 1/2] serial: sc16is7xx: refill TX FIFO below trigger using fresh TXLVL Paul Mbewe
2026-09-30 15:09   ` sashiko-bot [this message]
2026-09-30 18:24   ` David Laight
2026-09-30 14:56 ` [PATCH v2 RESEND 2/2] serial: sc16is7xx: reduce TX refill rate with half-FIFO trigger Paul Mbewe
2026-09-30 15:06   ` 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=20260930150943.B69331F0089D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=paultyson.mbewe@ziehl-abegg.de \
    --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