Re: [PATCH 1/1] tty: serial: owl: Initialize lock before registering port

From: Andy Shevchenko
Date: Fri May 29 2020 - 08:04:06 EST


On Fri, May 29, 2020 at 2:56 PM Andreas FÃrber <afaerber@xxxxxxx> wrote:
>
> Am 29.05.20 um 13:34 schrieb Greg Kroah-Hartman:
> > On Fri, May 29, 2020 at 02:06:47PM +0300, Cristian Ciocaltea wrote:
> >> Running a lockdep-enabled kernel leads to the following splat when
> >> probing the owl-uart driver:

...

> >> Fixes: a3cb39d258ef ("serial: core: Allow detach and attach serial device for console")
> >> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@xxxxxxxxx>

> >> + spin_lock_init(&owl_port->port.lock);
> >> +
> >> ret = uart_add_one_port(&owl_uart_driver, &owl_port->port);
> >> if (ret)
> >> owl_uart_ports[pdev->id] = NULL;
> >
> > Ugh, another one :(
> >
> > Thanks for this, will queue this up now.
>
> Thanks. If this is the expected pattern now, I'll also have to update
> in-flight patches, such as Sunplus.

Expected is to register properly console via register_console() call.
If you do so, you also need to initialize spin lock before coming to
uart_add_one_port().
It seems drivers (ab)used that feature.

$ git grep -n -w register_console -- drivers/tty/serial/ | cut -f1 -d:
| sort -u | wc -l
37
$ git grep -n _CONSOLE -- drivers/tty/serial/ | cut -f1 -d: | sort -u | wc -l
77

But as a quick fix this initialization is okay.

--
With Best Regards,
Andy Shevchenko