Linux Serial subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nicolas Thibert" <nithibert@gmail.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v2] serial: 8250_of: set UART_CAP_NOTEMT for ports with rts-gpios
Date: Wed, 02 Dec 2026 11:29:41 +0000	[thread overview]
Message-ID: <sashiko-outbox-245597@kernel.org> (raw)
In-Reply-To: <20261202111032.981532-1-nithibert@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] serial: 8250_of: setting UART_CAP_NOTEMT skips uart_config
  default flags
- [Medium] serial: 8250_of: gating UART_CAP_NOTEMT on rts-gpios misses
  native RTS em485
--

commit 3ce247ebc56619daf138861af9c248e9f1ac7b45
Author: Nicolas Thibert <nithibert@gmail.com>

serial: 8250_of: set UART_CAP_NOTEMT for ports with rts-gpios

This commit sets UART_CAP_NOTEMT on 8250_of ports when the rts-gpios
Device Tree property is present so that software-emulated RS485 direction
control releases the direction line after transmission completes.

> diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
> index b41ca604083f6..b58535f73cb88 100644
> --- a/drivers/tty/serial/8250/8250_of.c
> +++ b/drivers/tty/serial/8250/8250_of.c
> @@ -292,6 +292,9 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
>  			&port8250.overrun_backoff_time_ms) != 0)
>  		port8250.overrun_backoff_time_ms = 0;
>  
> +	if (of_property_present(ofdev->dev.of_node, "rts-gpios"))
> +		port8250.capabilities |= UART_CAP_NOTEMT;
> +
>  	info->uport = serial8250_register_8250_port(&port8250);
>  	if (IS_ERR(info->uport)) {
>  		ret = PTR_ERR(info->uport);

[Severity: High]
Does setting UART_CAP_NOTEMT here drop UART_CAP_FIFO and the rest of
uart_config[type].flags when the Device Tree node omits the optional
fifo-size property?

Earlier in of_platform_serial_probe(), UART_CAP_FIFO is only set if
port8250.port.fifosize is already non-zero.  When fifo-size is not in
Device Tree, fifosize and capabilities are still 0 here, and
serial8250_register_8250_port() -> serial8250_set_defaults() only loads
the per-type default flags when capabilities is 0:

drivers/tty/serial/8250/8250_port.c:serial8250_set_defaults() {
    ...
		if (!up->capabilities)
			up->capabilities = uart_config[type].flags;
    ...
}

Because capabilities is now UART_CAP_NOTEMT, uart_config[type].flags is
skipped.  Without UART_CAP_FIFO, serial8250_clear_fifos() becomes a no-op
(including during serial8250_em485_stop_tx()) and console writes fall back
from FIFO bursts to single-byte polling.

[Severity: Medium]
Should UART_CAP_NOTEMT also be set for RS485 ports that drive the
transceiver direction pin with the UART's native RTS signal instead of
rts-gpios?

of_platform_serial_setup() enables software-emulated RS485
(serial8250_em485_config) for all 8250_of ports, and serial8250_out_MCR()
toggles UART_MCR_RTS as well as any rts-gpios.  Gating UART_CAP_NOTEMT on
rts-gpios leaves native-RTS RS485 ports with the same bug where
__stop_tx() returns early when UART_LSR_TEMT is not yet set and never
deasserts RTS.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202111032.981532-1-nithibert@gmail.com?part=1

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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 11:10 [PATCH v2] serial: 8250_of: set UART_CAP_NOTEMT for ports with rts-gpios Nicolas Thibert
2026-12-02 11:29 ` sashiko-bot [this message]
2026-12-02 11:37   ` Nicolas Thibert

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-245597@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=nithibert@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