From: John Ogness <john.ogness@linutronix.de>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: [PATCH tty v3 1/6] serial: core: Add dedicated uart_port field for console flow
Date: Fri, 17 Apr 2026 12:30:14 +0206 [thread overview]
Message-ID: <20260417102423.40984-2-john.ogness@linutronix.de> (raw)
In-Reply-To: <20260417102423.40984-1-john.ogness@linutronix.de>
Currently the UPF_CONS_FLOW bit in the uart_port.flags field is used
by serial console drivers to identify if a user has configured flow
control on the console. This policy is most commonly setup during
early boot, but can be changed at runtime.
The bits in uart_port.flags are either hardware and driver properties
that are initialized before usage or are properties that can be
changed via the tty layer.
The UPF_CONS_FLOW is an exception because it is a console-only policy
that can change at runtime and its setting and usage have nothing to
do with the tty layer. This actually causes a problem for its usage
because uart_port.flags is synchronized by a related tty_port.mutex,
but a console has no relation to a tty (other than sharing the port).
This is probably why console flow control is not properly available
for most serial drivers. And it is hindering being able to provide a
proper implementation. Commit d01f4d181c92 ("serial: core: Privatize
tty->hw_stopped") addressed a similar issue to deal with software
assisted CTS flow state tracking.
Add a new uart_port boolean field "cons_flow" to store the user
configuration for console flow control. Add get/set wrappers to allow
for adding more policies later and/or locking constraint validation.
Mark UPF_CONS_FLOW as deprecated.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
include/linux/serial_core.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 666430b478997..2327a364ded16 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -533,6 +533,7 @@ struct uart_port {
#define UPF_HARD_FLOW ((__force upf_t) (UPF_AUTO_CTS | UPF_AUTO_RTS))
/* Port has hardware-assisted s/w flow control */
#define UPF_SOFT_FLOW ((__force upf_t) BIT_ULL(22))
+/* Deprecated: use uart_get_cons_flow()/uart_set_cons_flow() instead. */
#define UPF_CONS_FLOW ((__force upf_t) BIT_ULL(23))
#define UPF_SHARE_IRQ ((__force upf_t) BIT_ULL(24))
#define UPF_EXAR_EFR ((__force upf_t) BIT_ULL(25))
@@ -567,6 +568,7 @@ struct uart_port {
#define UPSTAT_SYNC_FIFO ((__force upstat_t) (1 << 5))
bool hw_stopped; /* sw-assisted CTS flow state */
+ bool cons_flow; /* user specified console flow control */
unsigned int mctrl; /* current modem ctrl settings */
unsigned int frame_time; /* frame timing in ns */
unsigned int type; /* port type */
@@ -1163,6 +1165,16 @@ static inline bool uart_softcts_mode(struct uart_port *uport)
return ((uport->status & mask) == UPSTAT_CTS_ENABLE);
}
+static inline void uart_set_cons_flow(struct uart_port *uport, bool on)
+{
+ uport->cons_flow = on;
+}
+
+static inline bool uart_get_cons_flow(const struct uart_port *uport)
+{
+ return uport->cons_flow;
+}
+
/*
* The following are helper functions for the low level drivers.
*/
--
2.47.3
next prev parent reply other threads:[~2026-04-17 10:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 10:24 [PATCH tty v3 0/6] 8250: Add console flow control John Ogness
2026-04-17 10:24 ` John Ogness [this message]
2026-04-17 13:15 ` [PATCH tty v3 1/6] serial: core: Add dedicated uart_port field for console flow John Ogness
2026-04-17 10:24 ` [PATCH tty v3 2/6] serial: Replace driver usage of UPF_CONS_FLOW John Ogness
2026-04-17 10:24 ` [PATCH tty v3 3/6] serial: sh-sci: Avoid deprecated UPF_CONS_FLOW John Ogness
2026-04-17 10:24 ` [PATCH tty v3 4/6] serial: 8250: Set cons_flow on port registration John Ogness
2026-04-17 10:24 ` [PATCH tty v3 5/6] serial: 8250: Check LSR timeout on console flow control John Ogness
2026-04-17 10:24 ` [PATCH tty v3 6/6] serial: 8250: Add support for " John Ogness
2026-04-20 9:12 ` Andy Shevchenko
2026-04-20 9:57 ` John Ogness
2026-04-20 10:16 ` Andy Shevchenko
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=20260417102423.40984-2-john.ogness@linutronix.de \
--to=john.ogness@linutronix.de \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@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