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,
	"Bandal, Shankar" <shankar.bandal@intel.com>,
	"Murthy, Shanth" <shanth.murthy@intel.com>,
	stable <stable@kernel.org>,
	Ionut Nechita <ionut.nechita@windriver.com>
Subject: [PATCH 6.12.y 3/8] serial: 8250: Protect LCR write in shutdown
Date: Sun, 10 May 2026 16:40:06 +0300	[thread overview]
Message-ID: <20260510134011.618215-4-ionut.nechita@windriver.com> (raw)
In-Reply-To: <20260510134011.618215-1-ionut.nechita@windriver.com>

From: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

commit 59a33d83bbe6d73d2071d7ae21590b29faed0503 upstream.

The 8250_dw driver needs to potentially perform very complex operations
during LCR writes because its BUSY handling prevents updates to LCR
while UART is BUSY (which is not fully under our control without those
complex operations). Thus, LCR writes should occur under port's lock.

Move LCR write under port's lock in serial8250_do_shutdown(). Also
split the LCR RMW so that the logic is on a separate line for clarity.

Reported-by: Bandal, Shankar <shankar.bandal@intel.com>
Tested-by: Bandal, Shankar <shankar.bandal@intel.com>
Tested-by: Murthy, Shanth <shanth.murthy@intel.com>
Cc: stable <stable@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://patch.msgid.link/20260203171049.4353-2-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[Ionut: adapt to 6.12.y - keep both 'unsigned long flags' and the
 new 'u32 lcr' declaration; place the LCR RMW inside the existing
 explicit uart_port_lock_irqsave/unlock_irqrestore region rather
 than the scoped_guard() block used upstream (cleanup-based
 uart_port_lock_irqsave guard class is not present in 6.12.y).]
Signed-off-by: Ionut Nechita <ionut.nechita@windriver.com>
---
 drivers/tty/serial/8250/8250_port.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index b4c8388ea6fc..d0f2e634ac30 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2462,6 +2462,7 @@ void serial8250_do_shutdown(struct uart_port *port)
 {
 	struct uart_8250_port *up = up_to_u8250p(port);
 	unsigned long flags;
+	u32 lcr;
 
 	serial8250_rpm_get(up);
 	/*
@@ -2488,13 +2489,13 @@ void serial8250_do_shutdown(struct uart_port *port)
 		port->mctrl &= ~TIOCM_OUT2;
 
 	serial8250_set_mctrl(port, port->mctrl);
+
+	/* Disable break condition */
+	lcr = serial_port_in(port, UART_LCR);
+	lcr &= ~UART_LCR_SBC;
+	serial_port_out(port, UART_LCR, lcr);
 	uart_port_unlock_irqrestore(port, flags);
 
-	/*
-	 * Disable break condition and FIFOs
-	 */
-	serial_port_out(port, UART_LCR,
-			serial_port_in(port, UART_LCR) & ~UART_LCR_SBC);
 	serial8250_clear_fifos(up);
 
 #ifdef CONFIG_SERIAL_8250_RSA
-- 
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 ` [PATCH 6.12.y 2/8] serial: 8250_dw: Comment possible corner cases in serial_out() implementation Ionut Nechita (Wind River)
2026-05-10 13:40 ` Ionut Nechita (Wind River) [this message]
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-4-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 \
    --cc=shankar.bandal@intel.com \
    --cc=shanth.murthy@intel.com \
    --cc=stable@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