Re: [PATCH] Revert "serial: fsl_lpuart: Reset prior to registration"

From: Lukas Wunner
Date: Mon Oct 10 2022 - 05:09:43 EST


On Sun, Oct 09, 2022 at 10:23:13AM +0000, Sherry Sun wrote:
> I am not familiar with 8250 serial, but at least for imx uart driver
> and lpuart driver, the following behavior is same.
> For the "real" consoles (everything which is not a bootconsole),
> the (port)->cons and (port)->cons->index are initialized through
> uart_add_one_port()->uart_configure_port()->register_console()->
> try_enable_new_console(), here the console index is assigned by
> the console cmdline parameters.

Hm, uart_add_one_port() does the following *before* calling
uart_configure_port():

/*
* If this port is in use as a console then the spinlock is already
* initialised.
*/
if (!uart_console_enabled(uport))
uart_port_spin_lock_init(uport);

It sounds like in the case of fsl_lpuart.c, the spin lock is *always*
initialized, even though a concurrent lpuart_console_write() may be
holding it. That's not solved by moving lpuart_global_reset() around.

The problem with performing lpuart_global_reset() after UART registration
is that as soon as uart_add_one_port() returns, the port is available
for user space to use. So resetting it is a no-go.

Thanks,

Lukas