From: John Ogness <john.ogness@linutronix.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>
Cc: "Andy Shevchenko" <andy.shevchenko@gmail.com>,
"Petr Mladek" <pmladek@suse.com>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
linux-kernel@vger.kernel.org,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Hugo Villeneuve" <hvilleneuve@dimonoff.com>,
"Kees Cook" <kees@kernel.org>,
"Stepan Ionichev" <sozdayvek@gmail.com>,
"Xin Zhao" <jackzxcui1989@163.com>,
"Osama Abdelkader" <osama.abdelkader@gmail.com>,
"Fushuai Wang" <wangfushuai@baidu.com>,
"Marco Felsch" <m.felsch@pengutronix.de>,
linux-serial@vger.kernel.org
Subject: Re: [PATCH tty v11 1/2] serial: 8250: Switch to nbcon console, take 2
Date: Wed, 29 Jul 2026 14:50:17 +0206 [thread overview]
Message-ID: <87y0eurmn2.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <20260729120439.281252-2-john.ogness@linutronix.de>
Hi,
Sashiko did not find anything legitimate with this version. The two
issues are incorrect (I explain why below).
If anyone has been waiting for Sashiko to "finish", this is the version
that is ready for human review.
John
On 2026-07-29, Sashiko wrote:
> > diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> > index 8c241ec7f4f29..b9ea4f898474e 100644
> > --- a/drivers/tty/serial/8250/8250_port.c
> > +++ b/drivers/tty/serial/8250/8250_port.c
> > @@ -3286,39 +3339,92 @@ static void serial8250_console_fifo_write(struct uart_8250_port *up,
> [ ... ]
> > /*
> > - * Print a string to the serial port trying not to disturb
> > - * any possible real use of the port...
> > - *
> > - * The console_lock must be held when we get here.
> > - *
> > - * Doing runtime PM is really a bad idea for the kernel console.
> > - * Thus, we assume the function is called when device is powered up.
> > + * Print a string to the serial port trying not to disturb
> > + * any possible real use of the port...
> > */
> > -void serial8250_console_write(struct uart_8250_port *up, const char *s,
> > - unsigned int count)
> > +void serial8250_console_write(struct uart_8250_port *up,
> > + struct nbcon_write_context *wctxt,
> > + bool is_atomic)
> > {
> > struct uart_8250_em485 *em485 = up->em485;
> > struct uart_port *port = &up->port;
> > - unsigned long flags;
> > - unsigned int ier, use_fifo;
> > - int locked = 1;
> > -
> > - touch_nmi_watchdog();
> > + unsigned int ier;
> > + bool use_fifo;
> >
> > - if (oops_in_progress)
> > - locked = uart_port_trylock_irqsave(port, &flags);
> > - else
> > - uart_port_lock_irqsave(port, &flags);
> > + if (!nbcon_enter_unsafe(wctxt))
> > + return;
> >
> > /*
> > - * First save the IER then disable the interrupts
> > + * First, save the IER, then disable the interrupts. The special
> > + * variant to clear the IER is used because emergency and panic
> > + * printing is synchronized only by nbcon ownership without
> > + * holding the port lock.
> > */
> > ier = serial_port_in(port, UART_IER);
> > - serial8250_clear_IER(up);
> > + __serial8250_clear_IER(up);
>
> Will this race with normal driver paths since the port lock is no longer
> acquired for atomic printing?
No. This is synchronized by nbcon ownership, which normal driver paths
also acquire via the port->lock locking wrappers. It is even within an
unsafe section.
> > @@ -3378,11 +3502,25 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s,
> > * call it if we have saved something in the saved flags
> > * while processing with interrupts off.
> > */
> > - if (up->msr_saved_flags)
> > - serial8250_modem_status(up);
> > + if (up->msr_saved_flags) {
> > + if (is_atomic) {
> > + /*
> > + * For atomic, MSR handling must be deferred to
> > + * irq_work because this may be a context that does
> > + * not permit waking up tasks.
> > + *
> > + * But no irq_work may be queued when suspending.
> > + * In that case, the MSR handling will occur during
> > + * resume in serial8250_resume_port().
> > + */
> > + if (up->console_msr_work_allow)
> > + irq_work_queue(&up->console_msr_work);
>
> Is there a race condition here between checking the flag and queuing the
> work?
Ditto.
John
next prev parent reply other threads:[~2026-07-29 12:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 12:04 [PATCH tty v11 0/2] Convert 8250 to NBCON, take 2 John Ogness
2026-07-29 12:04 ` [PATCH tty v11 1/2] serial: 8250: Switch to nbcon console, " John Ogness
2026-07-29 12:44 ` John Ogness [this message]
2026-07-30 14:24 ` Petr Mladek
2026-07-29 12:04 ` [PATCH tty v11 2/2] Revert "serial: 8250: drop lockdep annotation from serial8250_clear_IER()" John Ogness
2026-07-30 14:48 ` [PATCH tty v11 0/2] Convert 8250 to NBCON, take 2 Greg Kroah-Hartman
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=87y0eurmn2.fsf@jogness.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy.shevchenko@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=gregkh@linuxfoundation.org \
--cc=hvilleneuve@dimonoff.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jackzxcui1989@163.com \
--cc=jirislaby@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=m.felsch@pengutronix.de \
--cc=osama.abdelkader@gmail.com \
--cc=pmladek@suse.com \
--cc=sozdayvek@gmail.com \
--cc=wangfushuai@baidu.com \
/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