Linux Serial subsystem development
 help / color / mirror / Atom feed
From: "Ionut Nechita (Wind River)" <ionut.nechita@windriver.com>
To: ilpo.jarvinen@linux.intel.com, gregkh@linuxfoundation.org
Cc: andriy.shevchenko@linux.intel.com, linux-serial@vger.kernel.org,
	Ionut Nechita <ionut.nechita@windriver.com>
Subject: [PATCH 6.12.y 2/8] serial: 8250_dw: Comment possible corner cases in serial_out() implementation
Date: Sun, 10 May 2026 16:40:05 +0300	[thread overview]
Message-ID: <20260510134011.618215-3-ionut.nechita@windriver.com> (raw)
In-Reply-To: <20260510134011.618215-1-ionut.nechita@windriver.com>

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

commit bd8cad85561b8de36f099404c332bf3e3dbe90f5 upstream.

8250 DesignWare driver uses a few custom implementations of the serial_out().
These implementations are carefully made to avoid infinite loops. But this is
not obvious from looking at the code. Comment the possible corner cases in
the respective functions.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20250317094021.1201512-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ionut Nechita <ionut.nechita@windriver.com>
---
 drivers/tty/serial/8250/8250_dw.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 3225011fd772..88c55336d50f 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -107,11 +107,23 @@ static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value)
 	return value;
 }
 
+/*
+ * This function is being called as part of the uart_port::serial_out()
+ * routine. Hence, it must not call serial_port_out() or serial_out()
+ * against the modified registers here, i.e. LCR.
+ */
 static void dw8250_force_idle(struct uart_port *p)
 {
 	struct uart_8250_port *up = up_to_u8250p(p);
 	unsigned int lsr;
 
+	/*
+	 * The following call currently performs serial_out()
+	 * against the FCR register. Because it differs to LCR
+	 * there will be no infinite loop, but if it ever gets
+	 * modified, we might need a new custom version of it
+	 * that avoids infinite recursion.
+	 */
 	serial8250_clear_and_reinit_fifos(up);
 
 	/*
@@ -128,6 +140,11 @@ static void dw8250_force_idle(struct uart_port *p)
 	serial_port_in(p, UART_RX);
 }
 
+/*
+ * This function is being called as part of the uart_port::serial_out()
+ * routine. Hence, it must not call serial_port_out() or serial_out()
+ * against the modified registers here, i.e. LCR.
+ */
 static void dw8250_check_lcr(struct uart_port *p, int offset, int value)
 {
 	struct dw8250_data *d = to_dw8250_data(p->private_data);
-- 
2.54.0


  parent reply	other threads:[~2026-05-10 13:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-10 13:40 [PATCH 6.12.y 0/8] serial: 8250_dw: backport BUSY deassert series Ionut Nechita (Wind River)
2026-05-10 13:40 ` [PATCH 6.12.y 1/8] serial: 8250: use serial_port_in/out() helpers Ionut Nechita (Wind River)
2026-05-10 13:40 ` Ionut Nechita (Wind River) [this message]
2026-05-10 13:40 ` [PATCH 6.12.y 3/8] serial: 8250: Protect LCR write in shutdown Ionut Nechita (Wind River)
2026-05-10 13:40 ` [PATCH 6.12.y 4/8] serial: 8250_dw: Avoid unnecessary LCR writes Ionut Nechita (Wind River)
2026-05-10 13:40 ` [PATCH 6.12.y 5/8] serial: 8250: Add serial8250_handle_irq_locked() Ionut Nechita (Wind River)
2026-05-10 13:40 ` [PATCH 6.12.y 6/8] serial: 8250_dw: Rework dw8250_handle_irq() locking and IIR handling Ionut Nechita (Wind River)
2026-05-10 13:40 ` [PATCH 6.12.y 7/8] serial: 8250_dw: Rework IIR_NO_INT handling to stop interrupt storm Ionut Nechita (Wind River)
2026-05-10 13:40 ` [PATCH 6.12.y 8/8] serial: 8250_dw: Ensure BUSY is deasserted Ionut Nechita (Wind River)
2026-05-11 10:26 ` [PATCH 6.12.y 0/8] 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=20260510134011.618215-3-ionut.nechita@windriver.com \
    --to=ionut.nechita@windriver.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --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