[PATCH v2] serial: mxc: Keep the original FIFO empty check

Tim Harvey tharvey at gateworks.com
Wed Oct 26 01:23:31 CEST 2022


On Tue, Oct 25, 2022 at 3:57 PM Fabio Estevam <festevam at gmail.com> wrote:
>
> From: Fabio Estevam <festevam at denx.de>
>
> Tim Harvey reported that since commit c7878a0483c5 ("serial: mxc:
> have putc use the TXFIFO"), console messages put inside board_init()
> are no longer printed correctly.
>
> This change added a check to handle the UART FIFO full condition and
> removed the UART FIFO empty check, which causes the problem.
>
> To avoid console corruption, add back the original UART FIFO empty
> check so that when the FIFO is empty, mxc_serial_putc() returns -EAGAIN
> to the core serial-uclass.c.
>
> This way the serial core can properly handle the UART empty condition
> by not doing character transmission when -EAGAIN is returned.
>
> Fixes: c7878a0483c5 ("serial: mxc: have putc use the TXFIFO")
> Reported-by: Tim Harvey <tharvey at gateworks.com>
> Signed-off-by: Fabio Estevam <festevam at denx.de>
> ---
> Changes since v1:
> - Add the check for FIFO full and FIFO empty.
>
>  drivers/serial/serial_mxc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
> index 4cf79c1ca24f..d3fbe76065ec 100644
> --- a/drivers/serial/serial_mxc.c
> +++ b/drivers/serial/serial_mxc.c
> @@ -311,7 +311,7 @@ static int mxc_serial_putc(struct udevice *dev, const char ch)
>         struct mxc_serial_plat *plat = dev_get_plat(dev);
>         struct mxc_uart *const uart = plat->reg;
>
> -       if (readl(&uart->ts) & UTS_TXFULL)
> +       if ((readl(&uart->ts) & UTS_TXFULL) || !(readl(&uart->ts) & UTS_TXEMPTY))
>                 return -EAGAIN;
>
>         writel(ch, &uart->txd);
> --
> 2.25.1
>

Fabio,

This resolves the issue. Why would the kernel not suffer from this as
well? We are essentially saying if the FIFO is not full but also not
empty we need to wait.... so do we have a FIFO size of 1 or something
here as opposed to the kernel?

Best Regards,

Tim


More information about the U-Boot mailing list