[PATCH v2] serial: amba-pl011: touch the watchdogs in write_atomic()
From: Breno Leitao
Date: Fri Nov 06 2026 - 09:55:01 EST
In emergency context, such as WARN(), nbcon prints the pending records
through write_atomic() with preemption disabled.
On arm64, WARN() can run with IRQs masked, so the whole backlog is
printed with IRQs off as well.
Commit 9bd18e1262c0 ("printk/nbcon: Restore IRQ in atomic flush after
each emitted record") does not help here, as it only restores the
caller's IRQ state between records.
pl011_console_write_atomic() busy-waits on the UART for every
character, and at 115200 baud it prints about 11.5KB per second.
Flushing a few hundred kilobytes outlasts the hard lockup threshold
(10 seconds by default), so the printing CPU is reported, or the
machine panics with hardlockup_panic set. See [1].
The 8250 driver avoids this by calling touch_nmi_watchdog() while it
polls the transmitter. Do the same in pl011_console_write_atomic(),
once per record.
Suggested-by: John Ogness <john.ogness@xxxxxxxxxxxxx>
Link: https://lore.kernel.org/all/87wlqtxb14.fsf@xxxxxxxxxxxxxxxxxxxxx/ [1]
Reviewed-by: John Ogness <john.ogness@xxxxxxxxxxxxx>
Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
---
Changes in v2:
- Move touch_nmi_watchdog() to the end of pl011_console_write_atomic(),
per Petr Mladek.
- Link to v1: https://patch.msgid.link/20261104-pl011_touch-v1-1-e292bd834e14@xxxxxxxxxx
---
drivers/tty/serial/amba-pl011.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index e6f652905ca6f1..b6bb7effb08740 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -41,6 +41,7 @@
#include <linux/sizes.h>
#include <linux/io.h>
#include <linux/acpi.h>
+#include <linux/nmi.h>
#define UART_NR 14
@@ -2754,6 +2755,9 @@ pl011_console_write_atomic(struct console *co, struct nbcon_write_context *wctxt
pl011_write(old_cr, uap, REG_CR);
nbcon_exit_unsafe(wctxt);
+
+ /* An atomic flush may print a long backlog with IRQs disabled. */
+ touch_nmi_watchdog();
}
static void
---
base-commit: d6bcfc94eb4da6e089c5473970cd96727292fd97
change-id: 20261104-pl011_touch-d01385c0a5d7
Best regards,
--
Breno Leitao <leitao@xxxxxxxxxx>