All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nicolai Buchwitz" <nb@tipi-net.de>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH] serial: amba-pl011: keep transmitter enabled when disabling RS485
Date: Sun, 11 Oct 2026 19:59:33 +0000	[thread overview]
Message-ID: <sashiko-outbox-167434@kernel.org> (raw)
In-Reply-To: <20261011-fix-pl011-rs485-txe-v1-1-302b6c034b7f@tipi-net.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] tty: serial: amba-pl011: stalled transmission when disabling RS485 during deferred start
--

commit fd97eed6e0ab8bd63d1bb5300339347d34c58cdc
Author: Nicolai Buchwitz <nb@tipi-net.de>

serial: amba-pl011: keep transmitter enabled when disabling RS485

This commit addresses an issue where disabling RS485 mode on an open port
turns off the transmitter, causing pending output and active DMA transfers
to stall. It updates pl011_rs485_config() to leave the transmitter enabled
and cancel pending timers when transitioning out of RS485 mode.

> diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
> --- a/drivers/tty/serial/amba-pl011.c
> +++ b/drivers/tty/serial/amba-pl011.c
> @@ -2397,8 +2397,24 @@ static int pl011_rs485_config(struct uart_port *port, struct ktermios *termios,
>  	struct uart_amba_port *uap =
>  		container_of(port, struct uart_amba_port, port);
>  
> -	if (port->rs485.flags & SER_RS485_ENABLED)
> +	if ((port->rs485.flags & SER_RS485_ENABLED) &&
> +	    !(rs485->flags & SER_RS485_ENABLED)) {
> +		u32 cr = pl011_read(uap, REG_CR);
> +
> +		/*
> +		 * Leaving RS485 mode, which only enables the transmitter while
> +		 * sending. Don't stop it, as that stalls a DMA transfer still
> +		 * in flight. Drop a pending deferred stop and keep it enabled.
> +		 */
> +		hrtimer_try_to_cancel(&uap->trigger_start_tx);

[Severity: Medium]
Does canceling trigger_start_tx here without manually starting the
transmission risk permanently stranding queued characters?

If a userspace application writes data with a non-zero delay_rts_before_send
in RS485 mode, transmission is deferred via this timer.

If the application then immediately disables RS485 mode via ioctl(TIOCSRS485)
before the timer fires, this code cancels the start timer.

Since there is no fallback to manually kick the stalled transmission (such as
calling pl011_dma_tx_start() or pl011_start_tx_pio()), the TX interrupt
remains masked and the DMA is never started. This could cause subsequent
calls to tcdrain() or close() to hang indefinitely.

> +		hrtimer_try_to_cancel(&uap->trigger_stop_tx);
> +		uap->rs485_tx_state = OFF;
> +
> +		cr |= UART011_CR_TXE | UART011_CR_RXE;
> +		pl011_write(cr, uap, REG_CR);
> +	} else if (port->rs485.flags & SER_RS485_ENABLED) {
>  		pl011_rs485_tx_stop(uap);
> +	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261011-fix-pl011-rs485-txe-v1-1-302b6c034b7f@tipi-net.de?part=1

      reply	other threads:[~2026-10-11 19:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 19:48 [PATCH] serial: amba-pl011: keep transmitter enabled when disabling RS485 Nicolai Buchwitz
2026-10-11 19:59 ` 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-167434@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=nb@tipi-net.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 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.