Re: [PATCH v2] serial: core: Shut down a running console port before removing it
From: Greg Kroah-Hartman
Date: Wed Oct 14 2026 - 11:59:03 EST
On Tue, Oct 13, 2026 at 04:42:47PM +0000, Phil Rosenthal wrote:
> On Tue, Oct 13, 2026 at 06:12:52PM +0200, Greg Kroah-Hartman wrote:
> > Is this the same as:
> > https://patch.msgid.link/20261003163337.45577-1-igorpetindev@xxxxxxxxx
> > ?
>
> Yes, it's the same bug and the same fix. I hadn't seen Igor's patch when I
> sent mine, sorry for the noise. His is in tty-testing already, so
> please drop mine.
>
> > Why does that commit set a field and this change does not? Which is
> > correct?
>
> Both work. Clearing port->console isn't needed for the fix, and it does
> no harm. uart_shutdown() doesn't look at that flag. It is only read in
> tty_port_shutdown_locked() and tty_port_close(), on the last close of a
> tty, and by this point any open tty has been hung up, so
> tty_port_close_start() returns before either is reached.
> serial_core_add_one_port() sets the flag again when the line is reused.
>
> The other difference is that Igor's patch calls uart_shutdown() only if
> tty_port_initialized(), as my v1 did. Sashiko's review of my v1 pointed
> out that a console port removed while suspended is not initialized but
> still has its suspended flag set and its transmit buffer allocated, and
> uart_shutdown() would clear both. That needs the device to go away
> between system suspend and resume, and I haven't found a way to test
> it. If you want it covered I can send a patch on top of Igor's commit
> that drops the tty_port_initialized() check.
That would be nice, thank you.
greg k-h