Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH v2] serial: 8250: release the transmit PM reference on shutdown
@ 2026-12-04  9:57 James Hilliard
  2026-12-04 10:23 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: James Hilliard @ 2026-12-04  9:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Raul E Rangel, Ilpo Järvinen,
	Andy Shevchenko, Heikki Krogerus, Tony Lindgren,
	Sebastian Andrzej Siewior
  Cc: linux-kernel, linux-serial, James Hilliard

Transmit holds a runtime PM reference until the transmitter-empty path
clears THRI. A hangup can shut down the port while that reference is still
held. Shutdown clears the interrupt enables and stops DMA, leaving no TX
interrupt to release rpm_tx_active. A suppressed DMA completion cannot
release it either.

Drop the transmit reference after shutting down TX in both the generic
and OMAP shutdown paths. Their separate shutdown PM references keep the
UART accessible throughout cleanup. The exchange in the helper also
handles shutdown after the normal TX path already released its reference.

Fixes: d74d5d1b7288 ("tty: serial: 8250_core: add run time pm")
Reported-by: Raul E Rangel <rrangel@chromium.org>
Closes: https://lore.kernel.org/r/20261022152019.1621716-1-rrangel@chromium.org
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
Changes in v2:
- Rebase on current tty-next for resubmission.
- Link to v1: https://patch.msgid.link/20261022-submit-serial-8250-tx-pm-shutdown-v1-v1-1-0e894afa3bb8@gmail.com
---
 drivers/tty/serial/8250/8250.h      | 1 +
 drivers/tty/serial/8250/8250_omap.c | 1 +
 drivers/tty/serial/8250/8250_port.c | 5 ++++-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index 21ed9c41b751..4a7d26e2dbf0 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -190,6 +190,7 @@ void serial8250_wait_for_xmitr(struct uart_8250_port *up, int bits);
 
 void serial8250_rpm_get(struct uart_8250_port *p);
 void serial8250_rpm_put(struct uart_8250_port *p);
+void serial8250_rpm_put_tx(struct uart_8250_port *p);
 DEFINE_GUARD(serial8250_rpm, struct uart_8250_port *,
 	     serial8250_rpm_get(_T), serial8250_rpm_put(_T));
 
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index ed0b8f125332..bdef7c4b6b20 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -795,6 +795,7 @@ static void omap_8250_shutdown(struct uart_port *port)
 	if (up->lcr & UART_LCR_SBC)
 		serial_out(up, UART_LCR, up->lcr & ~UART_LCR_SBC);
 	serial_out(up, UART_FCR, UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);
+	serial8250_rpm_put_tx(up);
 }
 
 static void omap_8250_throttle(struct uart_port *port)
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 36b2b0a2c05c..d8a5ca46d9a9 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -672,7 +672,7 @@ static void serial8250_rpm_get_tx(struct uart_8250_port *p)
 	pm_runtime_get_sync(p->port.dev);
 }
 
-static void serial8250_rpm_put_tx(struct uart_8250_port *p)
+void serial8250_rpm_put_tx(struct uart_8250_port *p)
 {
 	unsigned char rpm_active;
 
@@ -684,6 +684,7 @@ static void serial8250_rpm_put_tx(struct uart_8250_port *p)
 		return;
 	pm_runtime_put_autosuspend(p->port.dev);
 }
+EXPORT_SYMBOL_GPL(serial8250_rpm_put_tx);
 
 /*
  * IER sleep support.  UARTs which have EFRs need the "extended
@@ -2486,6 +2487,8 @@ void serial8250_do_shutdown(struct uart_port *port)
 	 */
 	synchronize_irq(port->irq);
 
+	/* TX interrupts can no longer release the transmit reference. */
+	serial8250_rpm_put_tx(up);
 	serial8250_rpm_put(up);
 
 	up->ops->release_irq(up);

---
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
base-tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-next
change-id: 20261022-submit-serial-8250-tx-pm-shutdown-v1-db9091dde8f7

Best regards,
--  
James Hilliard <james.hilliard1@gmail.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04 10:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  9:57 [PATCH v2] serial: 8250: release the transmit PM reference on shutdown James Hilliard
2026-12-04 10:23 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox