From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Jacques Nilo <jnilo@free.fr>
Cc: 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>,
stable@vger.kernel.org
Subject: Re: [PATCH 2/3] serial: 8250: dispatch SysRq character in serial8250_handle_irq()
Date: Wed, 13 May 2026 14:49:53 +0300 (EEST) [thread overview]
Message-ID: <8e222497-313e-6322-609b-547a3c87c165@linux.intel.com> (raw)
In-Reply-To: <5d6d693aa9e92f05412d0f9395872d41e1b8e444.1778592805.git.jnilo@free.fr>
[-- Attachment #1: Type: text/plain, Size: 2858 bytes --]
On Tue, 12 May 2026, Jacques Nilo wrote:
> serial8250_handle_irq() captures a SysRq character into port->sysrq_ch
> inside serial8250_handle_irq_locked() via uart_prepare_sysrq_char()
> (reached from serial8250_read_char()). Dispatch of that captured
> character to handle_sysrq() is expected to happen at port-unlock time,
> through uart_unlock_and_check_sysrq[_irqrestore]().
>
> After commit 8324a54f604d ("serial: 8250: Add
> serial8250_handle_irq_locked()") the function was reduced to a wrapper
> that takes the port lock via guard(uart_port_lock_irqsave) whose
> destructor is plain uart_port_unlock_irqrestore(). The sysrq-aware
> unlock helper is no longer called, so port->sysrq_ch is captured but
> never dispatched: BREAK + SysRq key is consumed silently.
>
> This was the very condition Johan Hovold's 853a9ae29e978 ("serial:
> 8250: fix handle_irq locking", 2021) introduced
> uart_unlock_and_check_sysrq_irqrestore() to address.
>
> Switch to the new guard(uart_port_lock_sysrq_irqsave), whose destructor
> is the sysrq-aware unlock helper, restoring the pre-split behaviour.
> Update the Context: comment on serial8250_handle_irq_locked() so future
> HW-specific 8250 wrappers know to use the same guard or the explicit
> sysrq-aware unlock.
>
> Verified on RTL8196E with CONFIG_MAGIC_SYSRQ_SERIAL=y: BREAK + 'h' on
> the console UART produces the SysRq help dump in dmesg and the brk
> counter in /proc/tty/driver/serial increments correctly.
>
> Fixes: 8324a54f604d ("serial: 8250: Add serial8250_handle_irq_locked()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jacques Nilo <jnilo@free.fr>
> ---
> drivers/tty/serial/8250/8250_port.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
> index e4e6a53eb..64f3487e8 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -1786,7 +1786,10 @@ static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir)
> }
>
> /*
> - * Context: port's lock must be held by the caller.
> + * Context: port's lock must be held by the caller. The caller must
> + * release it via guard(uart_port_lock_sysrq_irqsave) or
> + * uart_unlock_and_check_sysrq_irqrestore(), which captures SysRq
> + * character on unlock.
> */
> void serial8250_handle_irq_locked(struct uart_port *port, unsigned int iir)
> {
> @@ -1839,7 +1842,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
> if (iir & UART_IIR_NO_INT)
> return 0;
>
> - guard(uart_port_lock_irqsave)(port);
> + guard(uart_port_lock_sysrq_irqsave)(port);
> serial8250_handle_irq_locked(port, iir);
>
> return 1;
>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
next prev parent reply other threads:[~2026-05-13 11:49 UTC|newest]
Thread overview: 18+ 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
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-13 12:01 ` Ilpo Järvinen
2026-05-13 12:10 ` Jacques Nilo
2026-05-13 12:21 ` Ilpo Järvinen
2026-05-12 13:46 ` [PATCH 2/3] serial: 8250: dispatch SysRq character in serial8250_handle_irq() Jacques Nilo
2026-05-13 11:49 ` Ilpo Järvinen [this message]
2026-05-12 13:46 ` [PATCH 3/3] serial: 8250_dw: dispatch SysRq character in dw8250_handle_irq() Jacques Nilo
2026-05-13 11:50 ` Ilpo Järvinen
2026-05-13 13:30 ` [PATCH v2 0/3] serial: 8250: fix BREAK+SysRq dispatch on guard()-locked IRQ handlers Jacques Nilo
2026-05-13 13:30 ` [PATCH v2 1/3] serial: core: introduce guard(uart_port_lock_check_sysrq_irqsave) Jacques Nilo
2026-05-13 13:35 ` Ilpo Järvinen
2026-05-13 13:30 ` [PATCH v2 2/3] serial: 8250: dispatch SysRq character in serial8250_handle_irq() Jacques Nilo
2026-05-13 13:30 ` [PATCH v2 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=8e222497-313e-6322-609b-547a3c87c165@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 \
--cc=stable@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