[PATCH v5 2/2] serial: mxc: have putc use the TXFIFO

Pali Rohár pali at kernel.org
Tue Oct 25 23:41:20 CEST 2022


On Tuesday 25 October 2022 17:37:01 Fabio Estevam wrote:
> Hi Pali,
> 
> On 25/10/2022 17:23, Pali Rohár wrote:
> 
> > Hello! I do not have any MXC hardware but I see there one issue.
> > mxc_serial_putc() function probably should not return -EAGAIN when
> > device is busy. But instead it should wait until it is ready.
> > 
> > Could you try to change code to following?
> > 
> >     while (readl(&uart->ts) & UTS_TXFULL)
> >         ;
> > 
> >     writel(ch, &uart->txd);
> 
> Your analysis looks correct.
> 
> The kernel does like this:
> 
> static void imx_uart_console_putchar(struct uart_port *port, unsigned char
> ch)
> {
> 	struct imx_port *sport = (struct imx_port *)port;
> 
> 	while (imx_uart_readl(sport, imx_uart_uts_reg(sport)) & UTS_TXFULL)
> 		barrier();
> 
> 	imx_uart_writel(sport, ch, URTX0);
> }
> 
> Thanks

Well, "waiting for HW to be ready" vs. "returning -EAGAIN" is serial API
detail. Kernel (or other implementation) may have different API and
driver always have to implement what API expects. So aligning return
value with kernel is not the argument for fixing issue.


Anyway, I think that my change is not correct.

serial-uclass.c is already calling:

	do {
		err = ops->putc(dev, ch);
	} while (err == -EAGAIN);

Which means that function is called again.


More information about the U-Boot mailing list