* [PATCH] drivers/char: imx-lpuart: use interrupt-driven transmit
@ 2026-12-03 6:45 Edwin Thankachan
2026-12-03 8:00 ` Mykyta Poturai
2026-12-03 8:21 ` John Ernberg
0 siblings, 2 replies; 4+ messages in thread
From: Edwin Thankachan @ 2026-12-03 6:45 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini, Julien Grall, Bertrand Marquis, Michal Orzel,
Volodymyr_Babchuk@epam.com, John Ernberg
The driver handles the TX interrupt but never calls
serial_async_transmit(), so every console character is written
synchronously. serial_puts() holds the port's tx_lock with interrupts
disabled meanwhile. Each console line therefore keeps a CPU spinning
with interrupts off until it has been transmitted, which takes about
5 ms for a 60-character line at 115200 baud.
Call serial_async_transmit() once the interrupt is set up, as ns16550
does, so printk() only queues characters and the TX interrupt drains
the buffer.
This requires ->tx_ready() to return the number of characters the port
can accept, as the serial core expects. It returns the raw UARTSTAT_TC
bit instead, which serial_tx_interrupt() would take as a count of
4194304 characters. Return 1 when TDRE is set, which is also what
->putc() waits for.
Fixes: 44e17aa60d47 ("xen/arm: Add i.MX lpuart driver")
Signed-off-by: Edwin Thankachan <edwin.thankachan@electrifex.com>
---
Tested on an i.MX95 board (Xen 4.21 based tree, which adds an i.MX95
compatible entry): Xen, dom0 and three domUs boot.
Build-tested on staging for arm64.
Example of the stall: with guest_loglvl=all, each
XEN_DOMCTL_memory_mapping call logs one line. Timing the dom0 privcmd
ioctl over 16 s, the call took 5.66 ms (median) before this patch and
0.071 ms after.
One interrupt per character is enough for a console; using the TX FIFO
depth in ->tx_ready() could follow separately. When the transmit buffer
overflows, characters are dropped instead of stalling the CPU, as with
the other interrupt-driven UART drivers; "sync_console" keeps the old
behaviour.
xen/drivers/char/imx-lpuart.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/xen/drivers/char/imx-lpuart.c b/xen/drivers/char/imx-lpuart.c
index cf034d7ed062..469d791894bd 100644
--- a/xen/drivers/char/imx-lpuart.c
+++ b/xen/drivers/char/imx-lpuart.c
@@ -98,13 +98,15 @@
temp |= (UARTCTRL_RIE | UARTCTRL_TIE);
temp |= UARTCTRL_ILIE;
imx_lpuart_write(uart, UARTCTRL, temp);
+
+ serial_async_transmit(port);
}
static int imx_lpuart_tx_ready(struct serial_port *port)
{
struct imx_lpuart *uart = port->uart;
- return imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TC;
+ return !!(imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TDRE);
}
static void imx_lpuart_putc(struct serial_port *port, char c)
base-commit: 0f5037b465b647428b66ba2d413f44315d5b97d0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] drivers/char: imx-lpuart: use interrupt-driven transmit
2026-12-03 6:45 [PATCH] drivers/char: imx-lpuart: use interrupt-driven transmit Edwin Thankachan
@ 2026-12-03 8:00 ` Mykyta Poturai
2026-12-03 8:21 ` John Ernberg
1 sibling, 0 replies; 4+ messages in thread
From: Mykyta Poturai @ 2026-12-03 8:00 UTC (permalink / raw)
To: Edwin Thankachan, xen-devel@lists.xenproject.org
Cc: Stefano Stabellini, Julien Grall, Bertrand Marquis, Michal Orzel,
Volodymyr Babchuk, John Ernberg, Xen-devel
On Thu Dec 3, 2026 at 8:45 AM EET, Edwin Thankachan wrote:
> The driver handles the TX interrupt but never calls
> serial_async_transmit(), so every console character is written
> synchronously. serial_puts() holds the port's tx_lock with interrupts
> disabled meanwhile. Each console line therefore keeps a CPU spinning
> with interrupts off until it has been transmitted, which takes about
> 5 ms for a 60-character line at 115200 baud.
>
> Call serial_async_transmit() once the interrupt is set up, as ns16550
> does, so printk() only queues characters and the TX interrupt drains
> the buffer.
>
> This requires ->tx_ready() to return the number of characters the port
> can accept, as the serial core expects. It returns the raw UARTSTAT_TC
> bit instead, which serial_tx_interrupt() would take as a count of
> 4194304 characters. Return 1 when TDRE is set, which is also what
> ->putc() waits for.
>
> Fixes: 44e17aa60d47 ("xen/arm: Add i.MX lpuart driver")
> Signed-off-by: Edwin Thankachan <edwin.thankachan@electrifex.com>
> ---
> Tested on an i.MX95 board (Xen 4.21 based tree, which adds an i.MX95
> compatible entry): Xen, dom0 and three domUs boot.
> Build-tested on staging for arm64.
>
> Example of the stall: with guest_loglvl=all, each
> XEN_DOMCTL_memory_mapping call logs one line. Timing the dom0 privcmd
> ioctl over 16 s, the call took 5.66 ms (median) before this patch and
> 0.071 ms after.
>
> One interrupt per character is enough for a console; using the TX FIFO
> depth in ->tx_ready() could follow separately. When the transmit buffer
> overflows, characters are dropped instead of stalling the CPU, as with
> the other interrupt-driven UART drivers; "sync_console" keeps the old
> behaviour.
>
> xen/drivers/char/imx-lpuart.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/xen/drivers/char/imx-lpuart.c b/xen/drivers/char/imx-lpuart.c
> index cf034d7ed062..469d791894bd 100644
> --- a/xen/drivers/char/imx-lpuart.c
> +++ b/xen/drivers/char/imx-lpuart.c
> @@ -98,13 +98,15 @@
> temp |= (UARTCTRL_RIE | UARTCTRL_TIE);
> temp |= UARTCTRL_ILIE;
> imx_lpuart_write(uart, UARTCTRL, temp);
> +
> + serial_async_transmit(port);
> }
>
> static int imx_lpuart_tx_ready(struct serial_port *port)
> {
> struct imx_lpuart *uart = port->uart;
>
> - return imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TC;
> + return !!(imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TDRE);
> }
>
> static void imx_lpuart_putc(struct serial_port *port, char c)
>
> base-commit: 0f5037b465b647428b66ba2d413f44315d5b97d0
LGTM
Reviewed-by: Mykyta Poturai <mykyta_poturai@epam.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] drivers/char: imx-lpuart: use interrupt-driven transmit
2026-12-03 6:45 [PATCH] drivers/char: imx-lpuart: use interrupt-driven transmit Edwin Thankachan
2026-12-03 8:00 ` Mykyta Poturai
@ 2026-12-03 8:21 ` John Ernberg
2026-12-04 1:17 ` Stefano Stabellini
1 sibling, 1 reply; 4+ messages in thread
From: John Ernberg @ 2026-12-03 8:21 UTC (permalink / raw)
To: Edwin Thankachan, xen-devel@lists.xenproject.org
Cc: Stefano Stabellini, Julien Grall, Bertrand Marquis, Michal Orzel,
Volodymyr_Babchuk@epam.com
Hi Edwin,
On 03/12/2026 07:45, Edwin Thankachan wrote:
> The driver handles the TX interrupt but never calls
> serial_async_transmit(), so every console character is written
> synchronously. serial_puts() holds the port's tx_lock with interrupts
> disabled meanwhile. Each console line therefore keeps a CPU spinning
> with interrupts off until it has been transmitted, which takes about
> 5 ms for a 60-character line at 115200 baud.
>
> Call serial_async_transmit() once the interrupt is set up, as ns16550
> does, so printk() only queues characters and the TX interrupt drains
> the buffer.
>
> This requires ->tx_ready() to return the number of characters the port
> can accept, as the serial core expects. It returns the raw UARTSTAT_TC
> bit instead, which serial_tx_interrupt() would take as a count of
> 4194304 characters. Return 1 when TDRE is set, which is also what
> ->putc() waits for.
>
> Fixes: 44e17aa60d47 ("xen/arm: Add i.MX lpuart driver")
> Signed-off-by: Edwin Thankachan <edwin.thankachan@electrifex.com>
> ---
> Tested on an i.MX95 board (Xen 4.21 based tree, which adds an i.MX95
> compatible entry): Xen, dom0 and three domUs boot.
> Build-tested on staging for arm64.
>
> Example of the stall: with guest_loglvl=all, each
> XEN_DOMCTL_memory_mapping call logs one line. Timing the dom0 privcmd
> ioctl over 16 s, the call took 5.66 ms (median) before this patch and
> 0.071 ms after.
>
> One interrupt per character is enough for a console; using the TX FIFO
> depth in ->tx_ready() could follow separately. When the transmit buffer
> overflows, characters are dropped instead of stalling the CPU, as with
> the other interrupt-driven UART drivers; "sync_console" keeps the old
> behaviour.
>
> xen/drivers/char/imx-lpuart.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/xen/drivers/char/imx-lpuart.c b/xen/drivers/char/imx-lpuart.c
> index cf034d7ed062..469d791894bd 100644
> --- a/xen/drivers/char/imx-lpuart.c
> +++ b/xen/drivers/char/imx-lpuart.c
> @@ -98,13 +98,15 @@
> temp |= (UARTCTRL_RIE | UARTCTRL_TIE);
> temp |= UARTCTRL_ILIE;
> imx_lpuart_write(uart, UARTCTRL, temp);
> +
> + serial_async_transmit(port);
> }
>
> static int imx_lpuart_tx_ready(struct serial_port *port)
> {
> struct imx_lpuart *uart = port->uart;
>
> - return imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TC;
> + return !!(imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TDRE);
> }
>
> static void imx_lpuart_putc(struct serial_port *port, char c)
>
> base-commit: 0f5037b465b647428b66ba2d413f44315d5b97d0
I'm a bit short on time this week, I'll have a proper look at it early
next week.
Thanks! // John Ernberg
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] drivers/char: imx-lpuart: use interrupt-driven transmit
2026-12-03 8:21 ` John Ernberg
@ 2026-12-04 1:17 ` Stefano Stabellini
0 siblings, 0 replies; 4+ messages in thread
From: Stefano Stabellini @ 2026-12-04 1:17 UTC (permalink / raw)
To: John Ernberg
Cc: Edwin Thankachan, xen-devel@lists.xenproject.org,
Stefano Stabellini, Julien Grall, Bertrand Marquis, Michal Orzel,
Volodymyr_Babchuk@epam.com
On Thu, 3 Dec 2026, John Ernberg wrote:
> Hi Edwin,
>
> On 03/12/2026 07:45, Edwin Thankachan wrote:
> > The driver handles the TX interrupt but never calls
> > serial_async_transmit(), so every console character is written
> > synchronously. serial_puts() holds the port's tx_lock with interrupts
> > disabled meanwhile. Each console line therefore keeps a CPU spinning
> > with interrupts off until it has been transmitted, which takes about
> > 5 ms for a 60-character line at 115200 baud.
> >
> > Call serial_async_transmit() once the interrupt is set up, as ns16550
> > does, so printk() only queues characters and the TX interrupt drains
> > the buffer.
> >
> > This requires ->tx_ready() to return the number of characters the port
> > can accept, as the serial core expects. It returns the raw UARTSTAT_TC
> > bit instead, which serial_tx_interrupt() would take as a count of
> > 4194304 characters. Return 1 when TDRE is set, which is also what
> > ->putc() waits for.
> >
> > Fixes: 44e17aa60d47 ("xen/arm: Add i.MX lpuart driver")
> > Signed-off-by: Edwin Thankachan <edwin.thankachan@electrifex.com>
> > ---
> > Tested on an i.MX95 board (Xen 4.21 based tree, which adds an i.MX95
> > compatible entry): Xen, dom0 and three domUs boot.
> > Build-tested on staging for arm64.
> >
> > Example of the stall: with guest_loglvl=all, each
> > XEN_DOMCTL_memory_mapping call logs one line. Timing the dom0 privcmd
> > ioctl over 16 s, the call took 5.66 ms (median) before this patch and
> > 0.071 ms after.
> >
> > One interrupt per character is enough for a console; using the TX FIFO
> > depth in ->tx_ready() could follow separately. When the transmit buffer
> > overflows, characters are dropped instead of stalling the CPU, as with
> > the other interrupt-driven UART drivers; "sync_console" keeps the old
> > behaviour.
> >
> > xen/drivers/char/imx-lpuart.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/xen/drivers/char/imx-lpuart.c b/xen/drivers/char/imx-lpuart.c
> > index cf034d7ed062..469d791894bd 100644
> > --- a/xen/drivers/char/imx-lpuart.c
> > +++ b/xen/drivers/char/imx-lpuart.c
> > @@ -98,13 +98,15 @@
> > temp |= (UARTCTRL_RIE | UARTCTRL_TIE);
> > temp |= UARTCTRL_ILIE;
> > imx_lpuart_write(uart, UARTCTRL, temp);
> > +
> > + serial_async_transmit(port);
> > }
> >
> > static int imx_lpuart_tx_ready(struct serial_port *port)
> > {
> > struct imx_lpuart *uart = port->uart;
> >
> > - return imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TC;
> > + return !!(imx_lpuart_read(uart, UARTSTAT) & UARTSTAT_TDRE);
> > }
> >
> > static void imx_lpuart_putc(struct serial_port *port, char c)
> >
> > base-commit: 0f5037b465b647428b66ba2d413f44315d5b97d0
>
> I'm a bit short on time this week, I'll have a proper look at it early next
> week.
The patch looks good to me, but I'd prefer to wait for John to have a
chance to review it
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-04 1:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 6:45 [PATCH] drivers/char: imx-lpuart: use interrupt-driven transmit Edwin Thankachan
2026-12-03 8:00 ` Mykyta Poturai
2026-12-03 8:21 ` John Ernberg
2026-12-04 1:17 ` Stefano Stabellini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.