[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YrwePdVzSYDygdVA@atomide.com>
Date: Wed, 29 Jun 2022 12:41:17 +0300
From: Tony Lindgren <tony@...mide.com>
To: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>,
linux-serial <linux-serial@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] serial: 8250: Fix PM usage_count for console handover
* Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com> [220629 09:26]:
> On Wed, 29 Jun 2022, Tony Lindgren wrote:
>
> > * Andy Shevchenko <andriy.shevchenko@...ux.intel.com> [220628 21:09]:
> > > On Tue, Jun 28, 2022 at 07:58:34PM +0300, Ilpo Järvinen wrote:
> > > > When console is enabled, univ8250_console_setup() calls
> > > > serial8250_console_setup() before .dev is set to uart_port. Therefore,
> > > > it will not call pm_runtime_get_sync(). Later, when the actual driver
> > > > is going to take over univ8250_console_exit() is called. As .dev is
> > > > already set, serial8250_console_exit() makes pm_runtime_put_sync() call
> > > > with usage count being zero triggering PM usage count warning
> > > > (extra debug for univ8250_console_setup(), univ8250_console_exit(), and
> > > > serial8250_register_ports()):
> >
> > Hmm so serial8250_console_setup() calls pm_runtime_get_sync() if dev
> > exists..
> >
> > > > diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> > > > index 57e86133af4f..2e83e7367441 100644
> > > > --- a/drivers/tty/serial/8250/8250_core.c
> > > > +++ b/drivers/tty/serial/8250/8250_core.c
> > > > @@ -23,6 +23,7 @@
> > > > #include <linux/sysrq.h>
> > > > #include <linux/delay.h>
> > > > #include <linux/platform_device.h>
> > > > +#include <linux/pm_runtime.h>
> > > > #include <linux/tty.h>
> > > > #include <linux/ratelimit.h>
> > > > #include <linux/tty_flip.h>
> > > > @@ -558,6 +559,9 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev)
> > > >
> > > > up->port.dev = dev;
> > > >
> > > > + if (uart_console_enabled(&up->port))
> > > > + pm_runtime_get_sync(up->port.dev);
> > > > +
> > > > serial8250_apply_quirks(up);
> > > > uart_add_one_port(drv, &up->port);
> > > > }
> >
> > ..and now we also call it here. Are there now cases where pm_runtime_get_sync()
> > gets called twice potentially or does uart_console_enabled() ensure that is
> > not the case already?
>
> The code in serial8250_register_ports() right before that context block is
> this:
>
> if (up->port.dev)
> continue;
>
> If serial8250_console_setup() already saw .dev != NULL, we take that
> continue and pm_runtime_get_sync() will not get called again here.
OK thanks. Looks good to me:
Reviewed-by: Tony Lindgren <tony@...mide.com>
Tested-by: Tony Lindgren <tony@...mide.com>
Powered by blists - more mailing lists