lkml.org 
[lkml]   [2022]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] serial: 8250: Fix PM usage_count for console handover
On Wed, 29 Jun 2022, Tony Lindgren wrote:

> * Andy Shevchenko <andriy.shevchenko@linux.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.


--
i.
\
 
 \ /
  Last update: 2022-06-29 11:32    [W:10.359 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site