Re: [RFC PATCH 1/2] serial: imx: Avoid busy polling for transmitter to become empty

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

 



On 04.04.2024 13:54:22, Esben Haabendal wrote:
> >> In fsl_lpuart.c and uartlite.c a warning message is printed if/when this
> >> timeout occurs. I am fine with doing that here as well...

You mean the read_poll_timeout() in fsl_lpuart.c in
lpuart_global_reset()? This looks like a totally different codepath to
me.

https://elixir.bootlin.com/linux/v6.8/source/drivers/tty/serial/fsl_lpuart.c#L2793

In the write callback the fsl_lpuart.c does a readb(); cpu_relax();
while loop.

https://elixir.bootlin.com/linux/v6.8/source/drivers/tty/serial/fsl_lpuart.c#L629
https://elixir.bootlin.com/linux/v6.8/source/drivers/tty/serial/fsl_lpuart.c#L636

The other driver is ma35d1_serial.c and uses a timeout of 10ms and
ignored the return value :/

> >> On a related note. I am unsure if 10 ms is a good choice for timeout. I
> >> picked it because it seems like a common value used in many/most
> >> drivers. But at least some drivers use something like 1 s, which to me
> >> sounds more sane given that we cannot do any meaningful error handling
> >> on timeout.
> >
> > Not having any experience with console drivers, I think the time to
> > empty the FIFO depends on the size of the TX FIFO and the speed of the
> > UART.
> >
> > With some numbers (FIFO size and UART speed) pulled out of thin air (and
> > neglecting start/stop/parity bits):
> >
> >     32 bytes * 8 bit/byte / 9600 bit/s = 26.7ms
> 
> I assume that typical console usage will have messages much larger than
> 32 bytes. But on the other hand, most use cases will be 115200 bit/s.

I think it's about the length of the TX FIFO, not the full console
message. And yes, while 115200 bps is typical, the corner cases should
work too.

> But in general, I would be more comofortable with a 1 second timeout. It
> should be more than large enough to handle all realistic cases. But
> will avoid spinning forever if uart for some reason does never clear the
> TXD bit.

makes sense

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux