All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hugo Villeneuve" <hugo@hugovil.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH] serial: sc16is7xx: declare MCR and IER as volatile registers
Date: Tue, 06 Oct 2026 19:36:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-162399@kernel.org> (raw)
In-Reply-To: <20261006192540.234402-1-hugo@hugovil.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] tty: sc16is7xx: making MCR/IER volatile fails to fix bank-switch race
--

commit d56a719b3706ed6ed6267916f8234030f616e7b3
Author: Hugo Villeneuve <hvilleneuve@dimonoff.com>

serial: sc16is7xx: declare MCR and IER as volatile registers

This commit declares MCR and IER as volatile in the regmap configuration
to prevent potential access errors, as they share addresses with XON1 and
DLH.

> diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
> index 296079c16fdb9..d6b3b67d17d55 100644
> --- a/drivers/tty/serial/sc16is7xx.c
> +++ b/drivers/tty/serial/sc16is7xx.c
> @@ -501,7 +501,9 @@ static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg)
>  {
>  	switch (reg) {
>  	case SC16IS7XX_RHR_REG: /* Shared address space with THR & DLL */
> +	case SC16IS7XX_IER_REG: /* Shared address space with DLH */
>  	case SC16IS7XX_IIR_REG: /* Shared address space with FCR & EFR */
> +	case SC16IS7XX_MCR_REG: /* Shared address space with XON1 */

[Severity: High]
Does making these registers volatile actually fix the underlying bank-switch
race?

If sc16is7xx_set_termios() holds one->lock and changes LCR to 0xBF to access
enhanced registers (like XON1), and sc16is7xx_reg_proc() concurrently updates
MCR without holding one->lock:

drivers/tty/serial/sc16is7xx.c:sc16is7xx_reg_proc() {
	...
		sc16is7xx_port_update(&one->port, SC16IS7XX_MCR_REG,
				      SC16IS7XX_MCR_RTS_BIT |
				      SC16IS7XX_MCR_DTR_BIT |
				      SC16IS7XX_MCR_LOOP_BIT,
				      mcr);
	...
}

Won't the forced physical hardware read-modify-write still hit XON1 instead
of MCR since LCR is currently switched?

This same pattern appears in sc16is7xx_tx_empty() where it reads LSR without
holding one->lock, racing with LCR bank switching:

drivers/tty/serial/sc16is7xx.c:sc16is7xx_tx_empty() {
	...
	lsr = sc16is7xx_port_read(port, SC16IS7XX_LSR_REG);
	...
}

Does this approach fail to fix the underlying locking race while adding
unnecessary I2C/SPI overhead?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006192540.234402-1-hugo@hugovil.com?part=1

  reply	other threads:[~2026-10-06 19:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 19:25 [PATCH] serial: sc16is7xx: declare MCR and IER as volatile registers Hugo Villeneuve
2026-10-06 19:36 ` sashiko-bot [this message]
2026-10-13 15:33   ` Hugo Villeneuve

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-162399@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=hugo@hugovil.com \
    --cc=linux-serial@vger.kernel.org \
    --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.