RE: [PATCH] serial: core: Don't spin for nbcon ownership with the port lock held

From: Farber, Eliav

Date: Wed Dec 02 2026 - 00:24:37 EST


On 2026-12-01, John Ogness <john.ogness@xxxxxxxxxxxxx> wrote:
> Thanks for working out the details. My suggestion was a really bad
> one. We do not want to convert spinlocks into busy-wait trylocks, even
> for the nbcon case.
>
> Your original version looks good. Sorry for the noise.

No noise. Thanks for the review.

Would you like me to send a v2 that fixes the commit log per your
comments, with your Reviewed-by added? The diff is identical to v1.

uart_port_lock() and its variants take the port lock and then spin until
they own the nbcon console context, which synchronizes port->lock users
against the write_atomic() callback. During a panic on another CPU the
only acquire still allowed is a reacquire by the context that lost
ownership, see commit 571c1ea91a73 ("printk: nbcon: Allow reacquire
during panic"). The wrapper's acquire is not one, so it is always
refused and the spin never ends.

A panic on another CPU only has to land between taking the port lock and
acquiring ownership. The CPU is then left holding the port lock, and in
the _irq and _irqsave cases with interrupts disabled, so it stops
answering the stop IPI from panic(). Triggering a panic from a shell on
the serial console reproduces this: a CPU enters the wrapper while the
tty is transmitting and never leaves it. On an 8250 console the panic
output slows to tens of milliseconds per character and never reaches the
reboot.

...

Eliav