The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 0/2] serial: amba-pl011: fix console clock lifetime
@ 2026-07-24 21:33 Karl Mehltretter
  2026-07-24 21:33 ` [PATCH v2 1/2] serial: amba-pl011: unprepare console clock on unregister Karl Mehltretter
  2026-07-24 21:33 ` [PATCH v2 2/2] serial: amba-pl011: keep console clock enabled for atomic writes Karl Mehltretter
  0 siblings, 2 replies; 5+ messages in thread
From: Karl Mehltretter @ 2026-07-24 21:33 UTC (permalink / raw)
  To: Russell King, Greg Kroah-Hartman, Jiri Slaby
  Cc: Karl Mehltretter, linux-arm-kernel, linux-serial, linux-kernel,
	linux-rt-devel, Sebastian Andrzej Siewior, John Ogness,
	Petr Mladek, Steven Rostedt, Clark Williams, Toshiyuki Sato

Patch 1 fixes an independent bug: pl011_console_setup() prepares the UART
clock but nothing releases it when the console is unregistered, so the
clock's prepare count leaks one reference per unregister. It adds the
missing console .exit() and stands on its own.

Patch 2 fixes a PREEMPT_RT failure: pl011_console_write_atomic() runs in
nbcon atomic context but calls clk_enable(), which under RT can acquire a
sleeping lock. It keeps the clock enabled while the console is available
for output and releases it in .exit(); it depends on patch 1.

Changes in v2:
- Add suspend/resume management for the persistent clock reference.
- Keep the reference for no_console_suspend and RX-wakeup ports.
- Document the platform-dependent power impact.

Patch 1 is unchanged.

Tested in QEMU on raspi1ap, raspi2b, and RealView ARMv6 SMP, and on arm64
virt under PREEMPT_RT. Actual s2idle suspend/resume (RTC-wake) dropped and
restored the PL011 clock reference, balanced across repeated cycles, while
wake-capable and no_console_suspend cases kept it enabled. Strict clock
checking found no access while stopped, and RX behaved as expected.
Toggling /sys/class/tty/ttyAMA0/console showed the prepare-count leak
without patch 1 and a balanced count with it.

Full-platform-sleep and actual RX-wakeup were not exercised.

Karl Mehltretter (2):
  serial: amba-pl011: unprepare console clock on unregister
  serial: amba-pl011: keep console clock enabled for atomic writes

 drivers/tty/serial/amba-pl011.c | 53 ++++++++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 11 deletions(-)

-- 
2.53.0

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

end of thread, other threads:[~2026-07-24 22:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 21:33 [PATCH v2 0/2] serial: amba-pl011: fix console clock lifetime Karl Mehltretter
2026-07-24 21:33 ` [PATCH v2 1/2] serial: amba-pl011: unprepare console clock on unregister Karl Mehltretter
2026-07-24 21:55   ` sashiko-bot
2026-07-24 22:22     ` Karl Mehltretter
2026-07-24 21:33 ` [PATCH v2 2/2] serial: amba-pl011: keep console clock enabled for atomic writes Karl Mehltretter

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