[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AS8PR04MB84047F39CD10C00CEE29213F92219@AS8PR04MB8404.eurprd04.prod.outlook.com>
Date: Sun, 9 Oct 2022 10:23:13 +0000
From: Sherry Sun <sherry.sun@....com>
To: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
CC: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>,
Lukas Wunner <lukas@...ner.de>,
linux-serial <linux-serial@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
dl-linux-imx <linux-imx@....com>
Subject: RE: [PATCH] Revert "serial: fsl_lpuart: Reset prior to registration"
> -----Original Message-----
> From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
> Sent: 2022年9月30日 20:59
> To: Sherry Sun <sherry.sun@....com>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>; Jiri Slaby
> <jirislaby@...nel.org>; Lukas Wunner <lukas@...ner.de>; linux-serial
> <linux-serial@...r.kernel.org>; LKML <linux-kernel@...r.kernel.org>; dl-
> linux-imx <linux-imx@....com>
> Subject: RE: [PATCH] Revert "serial: fsl_lpuart: Reset prior to registration"
>
> On Fri, 30 Sep 2022, Sherry Sun wrote:
> > > On Thu, 29 Sep 2022, Sherry Sun wrote:
> > >
> > > > > > This reverts commit 60f361722ad2ae5ee667d0b0545d40c42f754daf.
> > > > > >
> > > > > > commit 60f361722ad2 ("serial: fsl_lpuart: Reset prior to
> > > > > > registration") causes the lpuart console cannot work any more.
> > > > > > Since the console is registered in the uart_add_one_port(),
> > > > > > the driver cannot identify the console port before call
> > > > > > uart_add_one_port(), which causes all the uart ports including
> > > > > > the console port will be global
> > > > > reset.
> > > > > > So need to revert this patch to avoid breaking the lpuart console.
> > > > > >
> > > > > > Signed-off-by: Sherry Sun <sherry.sun@....com>
> > > > > > ---
> > > > > > drivers/tty/serial/fsl_lpuart.c | 10 +++++-----
> > > > > > 1 file changed, 5 insertions(+), 5 deletions(-)
> > > > > >
> > > > > > diff --git a/drivers/tty/serial/fsl_lpuart.c
> > > > > > b/drivers/tty/serial/fsl_lpuart.c index
> > > > > > 67fa113f77d4..7da46557fcb3
> > > > > > 100644
> > > > > > --- a/drivers/tty/serial/fsl_lpuart.c
> > > > > > +++ b/drivers/tty/serial/fsl_lpuart.c
> > > > > > @@ -2722,10 +2722,6 @@ static int lpuart_probe(struct
> > > > > > platform_device
> > > > > *pdev)
> > > > > > handler = lpuart_int;
> > > > > > }
> > > > > >
> > > > > > - ret = lpuart_global_reset(sport);
> > > > > > - if (ret)
> > > > > > - goto failed_reset;
> > > > > > -
> > > > >
> > > > > So the problem with this being so early is uart_console() in
> > > > > lpuart_global_reset() that doesn't detect a console because
> > > > > sport->cons is not yet assigned? Couldn't that be worked around
> > > differently?
> > > > >
> > > > > Or is there something else in addition to that I'm missing?
> > > > >
> > > > Hi Ilpo,
> > > >
> > > > Yes, the root cause of the console cannot work after apply the
> > > > commit
> > > > 60f361722ad2 ("serial: fsl_lpuart: Reset prior to registration")
> > > > is
> > > > lpuart_global_reset() cannot identify the console port, so reset
> > > > all uart ports.
> > >
> > > This didn't answer my question. Is the main cause just lacking the
> > > ->cons from sport at this point which, I guess, could be just
> > > assigned from lpuart_reg similar to what uart_add_one_port() does
> before calling to reset?
> > >
> >
> > Hi Ilpo,
> >
> > Actually not only the (port)->cons need to be assigned, but also to get the
> right (port)->cons->index.
> > 23 #define uart_console(port) \
> > 24 ((port)->cons && (port)->cons->index == (port)->line)
> >
> > The (port)->cons is assigned in uart_add_one_port(), quite simple.
> > 3076 uport->cons = drv->cons;
> >
> > But the (port)->cons->index is not that easy to get in lpuart driver,
> > now the value is assigned by calling register_console() from
> > uart_configure_port().
>
> I've some skepticism to this claim. I now played with 8250 myself and
> confirmed it does have non-NULL ->cons for the console ports before to calls
> to uart_add_one_port() and index is setup up correctly for cons too!
>
> The reason for the cons being setup is this being done in
> univ8250_console_setup():
>
> /* link port to console */
> port->cons = co;
>
> (which I think could be easily be done in lpuart_console_setup() too).
Hi Ilpo,
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.
I also tried the same way of 8250, it doesn't work, lpuart console still cannot work, as the lpuart_console_setup() is only called through uart_add_one_port() after the console index is initialized, to setup the "real" consoles.
> /* link port to console */
> port->cons = co;
Best Regards
Sherry
Powered by blists - more mailing lists