From: "Ionut Nechita (Wind River)" <ionut.nechita@windriver.com>
To: ilpo.jarvinen@linux.intel.com, gregkh@linuxfoundation.org
Cc: stable@kernel.org, andriy.shevchenko@linux.intel.com,
wander@redhat.com, chris.friesen@windriver.com,
linux-serial@vger.kernel.org,
"Jiri Slaby (SUSE)" <jirislaby@kernel.org>,
Ionut Nechita <ionut.nechita@windriver.com>
Subject: [PATCH v2 6.12.y 03/10] serial: introduce uart_port_lock() guard()s
Date: Wed, 13 May 2026 09:50:21 +0300 [thread overview]
Message-ID: <20260513065028.112468-4-ionut.nechita@windriver.com> (raw)
In-Reply-To: <20260513065028.112468-1-ionut.nechita@windriver.com>
From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
commit 0fd60b689b0dacce659253ec15cb3d3bf660e30b upstream.
Having this, guards like these work:
guard(uart_port_lock_irq)(&up->port);
or
scoped_guard(uart_port_lock_irqsave, port) {
...
}
See e.g. "serial: 8250: use guard()s" later in this series.
Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20250814072456.182853-4-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ionut Nechita <ionut.nechita@windriver.com>
---
include/linux/serial_core.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 4ab65874a850..191154b8ada2 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -782,6 +782,19 @@ static inline void uart_port_unlock_irqrestore(struct uart_port *up, unsigned lo
spin_unlock_irqrestore(&up->lock, flags);
}
+DEFINE_GUARD(uart_port_lock, struct uart_port *, uart_port_lock(_T), uart_port_unlock(_T));
+DEFINE_GUARD_COND(uart_port_lock, _try, uart_port_trylock(_T));
+
+DEFINE_GUARD(uart_port_lock_irq, struct uart_port *, uart_port_lock_irq(_T),
+ uart_port_unlock_irq(_T));
+
+DEFINE_LOCK_GUARD_1(uart_port_lock_irqsave, struct uart_port,
+ uart_port_lock_irqsave(_T->lock, &_T->flags),
+ uart_port_unlock_irqrestore(_T->lock, _T->flags),
+ unsigned long flags);
+DEFINE_LOCK_GUARD_1_COND(uart_port_lock_irqsave, _try,
+ uart_port_trylock_irqsave(_T->lock, &_T->flags));
+
static inline int serial_port_in(struct uart_port *up, int offset)
{
return up->serial_in(up, offset);
--
2.54.0
next prev parent reply other threads:[~2026-05-13 6:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 6:50 [PATCH v2 6.12.y 00/10] serial: 8250_dw: backport BUSY deassert series Ionut Nechita (Wind River)
2026-05-13 6:50 ` [PATCH v2 6.12.y 01/10] serial: 8250: use serial_port_in/out() helpers Ionut Nechita (Wind River)
2026-05-13 6:50 ` [PATCH v2 6.12.y 02/10] serial: 8250_dw: Comment possible corner cases in serial_out() implementation Ionut Nechita (Wind River)
2026-05-13 6:50 ` Ionut Nechita (Wind River) [this message]
2026-05-13 6:50 ` [PATCH v2 6.12.y 04/10] serial: 8250: convert serial8250_do_shutdown() to scoped_guard() Ionut Nechita (Wind River)
2026-05-13 6:50 ` [PATCH v2 6.12.y 05/10] serial: 8250: Protect LCR write in shutdown Ionut Nechita (Wind River)
2026-05-13 6:50 ` [PATCH v2 6.12.y 06/10] serial: 8250_dw: Avoid unnecessary LCR writes Ionut Nechita (Wind River)
2026-05-13 6:50 ` [PATCH v2 6.12.y 07/10] serial: 8250: Add serial8250_handle_irq_locked() Ionut Nechita (Wind River)
2026-05-13 6:50 ` [PATCH v2 6.12.y 08/10] serial: 8250_dw: Rework dw8250_handle_irq() locking and IIR handling Ionut Nechita (Wind River)
2026-05-13 6:50 ` [PATCH v2 6.12.y 09/10] serial: 8250_dw: Rework IIR_NO_INT handling to stop interrupt storm Ionut Nechita (Wind River)
2026-05-13 6:50 ` [PATCH v2 6.12.y 10/10] serial: 8250_dw: Ensure BUSY is deasserted Ionut Nechita (Wind River)
2026-05-13 10:16 ` [PATCH v2 6.12.y 00/10] serial: 8250_dw: backport BUSY deassert series Ilpo Järvinen
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=20260513065028.112468-4-ionut.nechita@windriver.com \
--to=ionut.nechita@windriver.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=chris.friesen@windriver.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=stable@kernel.org \
--cc=wander@redhat.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