[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] drivers/char: imx-lpuart: use interrupt-driven transmit



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@xxxxxxxxxxxxxx>
> > ---
> > 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



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.