All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Johan Hovold" <johan@kernel.org>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v2 10/12] USB: serial: io_edgeport: deassert DTR/RTS on close() and B0
Date: Fri, 23 Oct 2026 12:43:07 +0000	[thread overview]
Message-ID: <sashiko-outbox-182789@kernel.org> (raw)
In-Reply-To: <20261023121530.186541-11-johan@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] USB: serial: io_edgeport: DTR/RTS dropped on reopen with HUPCL cleared
--

commit 04f867c0006b106f7227398e82b66d8d1816c7f9
Author: Johan Hovold <johan@kernel.org>

USB: serial: io_edgeport: deassert DTR/RTS on close() and B0

This commit adds a dtr_rts() callback to handle asserting and deasserting DTR
and RTS on open(), close(), and hangup, and updates edge_set_termios() to
handle B0 transitions.

> diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
> index 566f0f1a16324..ebbe8c5370cdb 100644
> --- a/drivers/usb/serial/io_edgeport.c
> +++ b/drivers/usb/serial/io_edgeport.c

[ ... ]

> @@ -2412,9 +2429,12 @@ static void edge_set_termios(struct tty_struct *tty, struct usb_serial_port *por
>  
>  	/* set up the MCR register and send it to the EdgePort */
>  	mutex_lock(&edge_port->mutex);
> -	edge_port->shadowMCR = MCR_MASTER_IE;
> -	if (cflag & CBAUD)
> -		edge_port->shadowMCR |= (MCR_DTR | MCR_RTS);
> +	if (cflag & CBAUD) {
> +		if (old_termios && (old_termios->c_cflag & CBAUD) == B0)
> +			edge_port->shadowMCR |= MCR_DTR | MCR_RTS;
> +	} else {
> +		edge_port->shadowMCR &= ~(MCR_DTR | MCR_RTS);
> +	}
>  
>  	status = send_cmd_write_uart_register(edge_port, MCR,
>  						edge_port->shadowMCR);

[Severity: Medium]
Will this cause DTR and RTS to be momentarily dropped when reopening a port
that was closed with HUPCL cleared?

When a port is closed with HUPCL cleared, tty_port_shutdown_locked() leaves
DTR and RTS asserted. On a subsequent open, serial_open() -> tty_port_open()
-> serial_port_activate() calls edge_open(), which resets edge_port->shadowMCR
and calls edge_set_termios() before tty_port_block_til_ready() calls
edge_dtr_rts(port, 1):

drivers/usb/serial/io_edgeport.c:edge_open() {
	...
	/* Must always set this bit to enable ints! */
	mutex_lock(&edge_port->mutex);
	edge_port->shadowMCR = MCR_MASTER_IE;
	mutex_unlock(&edge_port->mutex);
	...
	if (tty)
		edge_set_termios(tty, port, NULL);
	...
}

Because edge_open() clears MCR_DTR and MCR_RTS in shadowMCR and passes
old_termios as NULL to edge_set_termios(), edge_set_termios() no longer sets
MCR_DTR | MCR_RTS and writes shadowMCR without DTR and RTS to the device
before tty_port_block_til_ready() reasserts them.

Should edge_port->shadowMCR = MCR_MASTER_IE be initialized once in
edge_port_probe() instead of being reset on every open in edge_open() so that
DTR and RTS are preserved across a close and reopen when HUPCL is cleared?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261023121530.186541-1-johan@kernel.org?part=10

  reply	other threads:[~2026-10-23 12:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 12:15 [PATCH v2 00/12] USB: serial: io_edgeport: fixes and sync commands Johan Hovold
2026-10-23 12:15 ` [PATCH v2 01/12] USB: serial: io_edgeport: fix NULL-deref on early status Johan Hovold
2026-10-23 12:24   ` sashiko-bot
2026-10-23 12:15 ` [PATCH v2 02/12] USB: serial: io_edgeport: fix potential close() use-after-free Johan Hovold
2026-10-23 12:30   ` sashiko-bot
2026-10-23 12:15 ` [PATCH v2 03/12] USB: serial: io_edgeport: fix potential NULL-deref at open Johan Hovold
2026-10-23 12:35   ` sashiko-bot
2026-10-23 12:15 ` [PATCH v2 04/12] USB: serial: io_edgeport: move initial termios update to open() Johan Hovold
2026-10-23 12:28   ` sashiko-bot
2026-10-23 12:15 ` [PATCH v2 05/12] USB: serial: io_edgeport: fix potential fifo corruption Johan Hovold
2026-10-23 12:25   ` sashiko-bot
2026-10-23 12:15 ` [PATCH v2 06/12] USB: serial: io_edgeport: fix potential use-after-free on disconnect Johan Hovold
2026-10-23 12:28   ` sashiko-bot
2026-10-23 12:15 ` [PATCH v2 07/12] USB: serial: io_edgeport: serialise MCR accesses Johan Hovold
2026-10-23 12:22   ` sashiko-bot
2026-10-23 12:15 ` [PATCH v2 08/12] USB: serial: io_edgeport: drop redundant sanity checks Johan Hovold
2026-10-23 12:25   ` sashiko-bot
2026-10-23 12:15 ` [PATCH v2 09/12] USB: serial: io_edgeport: drop redundant open " Johan Hovold
2026-10-23 12:27   ` sashiko-bot
2026-10-23 12:15 ` [PATCH v2 10/12] USB: serial: io_edgeport: deassert DTR/RTS on close() and B0 Johan Hovold
2026-10-23 12:43   ` sashiko-bot [this message]
2026-10-23 14:00     ` Johan Hovold
2026-10-23 12:15 ` [PATCH v2 11/12] USB: serial: io_edgeport: replace atomic command allocations Johan Hovold
2026-10-23 12:24   ` sashiko-bot
2026-10-23 12:15 ` [PATCH v2 12/12] USB: serial: io_edgeport: switch to synchronous commands Johan Hovold
2026-10-23 12:31   ` 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=sashiko-outbox-182789@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=johan@kernel.org \
    --cc=linux-usb@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.