From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Jacques Nilo <jnilo@free.fr>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
linux-serial <linux-serial@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"Johan Hovold" <johan@kernel.org>
Subject: Re: [REPORT] serial: 8250: BREAK + SysRq dispatch silently broken since 8324a54f604d
Date: Tue, 12 May 2026 16:21:59 +0300 (EEST) [thread overview]
Message-ID: <efc4fd93-9b0f-dee6-9725-ef7a09c4214f@linux.intel.com> (raw)
In-Reply-To: <122f6431-2241-4367-be28-bfd3b31f5333@free.fr>
[-- Attachment #1: Type: text/plain, Size: 3670 bytes --]
On Tue, 12 May 2026, Jacques Nilo wrote:
> On Tue, 12 May 2026, Ilpo Järvinen wrote:
>
> > I seem to have come blind to the (unlock function) names. I'm sorry
> > about breaking this.
>
> No problem at all -- the asymmetry between the lock and unlock helper
> names is exactly the kind of thing that's easy to miss in a refactor.
>
> > 8250_dw's handle_irq also uses guard() which was the reason for this
> > change in the first place so it should be fixed as well.
>
> Confirmed -- dw8250_handle_irq() at drivers/tty/serial/8250/8250_dw.c:421
> does the same guard(uart_port_lock_irqsave)(p) before
> serial8250_handle_irq_locked(). Same bug.
>
> > > Option B -- fix the guard destructor in serial_core.h:
> >
> > There will be many such sites so this doesn't sound a great idea.
> >
> > I wonder why we couldn't instead do another DEFINE_GUARD() for the
> > sysrq case?
>
> Agreed, that's cleaner. The lock side is identical -- only the unlock
> needs the sysrq-aware variant -- so a second lock-guard macro keyed off
> the unlock destructor fits well:
>
> DEFINE_LOCK_GUARD_1(uart_port_lock_irqsave_sysrq, struct uart_port,
> uart_port_lock_irqsave(_T->lock, &_T->flags),
> uart_unlock_and_check_sysrq_irqrestore(_T->lock,
> _T->flags),
> unsigned long flags);
>
> Callers that may capture sysrq_ch (currently serial8250_handle_irq and
> dw8250_handle_irq) opt in by using guard(uart_port_lock_irqsave_sysrq);
> the existing guard(uart_port_lock_irqsave) keeps its current plain-unlock
> semantics for everyone else.
>
> Naming-wise I'm not attached to "_sysrq" -- if you'd prefer something
> shorter (e.g. uart_port_rx_lock_irqsave) or aligned with another
> convention in the tree, happy to take direction.
I don't have strong preferences (I'm usually not good with names
anyway :-)). Somebody might object not placing _irqsave as last in the
name (and reversing the word order would be a bit inconsistent compared
with the unlock name).
> > I suppose thought the lockdep assert in serial8250_handle_irq_locked()
> > cannot discern that the correct one of them is being used by the
> > caller. But at least it's context comment should mention that the
> > correct guard/unlock variant should be used.
>
> Right -- both guards take port->lock so lockdep can't distinguish them.
> I'll update the Context: line on serial8250_handle_irq_locked() to spell
> out the requirement, e.g.:
>
> /*
> * Context: port's lock must be held by the caller, and must be released
> * via guard(uart_port_lock_irqsave_sysrq) or
> * uart_unlock_and_check_sysrq_irqrestore()
> so a SysRq character
> * captured by serial8250_read_char() is dispatched on unlock.
This would be less words to the same effect:
which captures SysRq character on unlock.
?
> */
>
> Plan, then, for a v1 patch series against tty-next:
>
> 1. include/linux/serial_core.h: add the new lock-guard macro.
> 2. drivers/tty/serial/8250/8250_port.c: switch serial8250_handle_irq()
> to guard(uart_port_lock_irqsave_sysrq); update the Context comment
> on serial8250_handle_irq_locked().
> 3. drivers/tty/serial/8250/8250_dw.c: switch dw8250_handle_irq() to
> the same guard.
>
> I'll mark it with Fixes: 8324a54f604d and Cc: stable for the kernels
> that carry the regression. Let me know if the naming or the Context
> wording wants adjusting before I send.
+
Fixes: 883c5a2bc934 ("serial: 8250_dw: Rework dw8250_handle_irq() locking and IIR handling")
--
i.
next prev parent reply other threads:[~2026-05-12 13:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 12:38 [REPORT] serial: 8250: BREAK + SysRq dispatch silently broken since 8324a54f604d Jacques Nilo
2026-05-12 12:58 ` Ilpo Järvinen
2026-05-12 13:06 ` Jacques Nilo
2026-05-12 13:21 ` Ilpo Järvinen [this message]
2026-05-12 13:46 ` [PATCH 0/3] serial: 8250: fix BREAK+SysRq dispatch on guard()-locked IRQ handlers Jacques Nilo
2026-05-12 13:46 ` [PATCH 1/3] serial: core: introduce guard(uart_port_lock_sysrq_irqsave) Jacques Nilo
2026-05-12 13:46 ` [PATCH 2/3] serial: 8250: dispatch SysRq character in serial8250_handle_irq() Jacques Nilo
2026-05-12 13:46 ` [PATCH 3/3] serial: 8250_dw: dispatch SysRq character in dw8250_handle_irq() Jacques Nilo
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=efc4fd93-9b0f-dee6-9725-ef7a09c4214f@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=jnilo@free.fr \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/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