All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	linux-serial <linux-serial@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] serial: 8250: Fix PM usage_count for console handover
Date: Wed, 29 Jun 2022 12:41:17 +0300	[thread overview]
Message-ID: <YrwePdVzSYDygdVA@atomide.com> (raw)
In-Reply-To: <5548afe5-20aa-9066-37e7-a3b2b26872e1@linux.intel.com>

* Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> [220629 09:26]:
> 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.

OK thanks. Looks good to me:

Reviewed-by: Tony Lindgren <tony@atomide.com>
Tested-by: Tony Lindgren <tony@atomide.com>

      reply	other threads:[~2022-06-29  9:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28 16:58 [PATCH] serial: 8250: Fix PM usage_count for console handover Ilpo Järvinen
2022-06-28 21:14 ` Andy Shevchenko
2022-06-29  9:21   ` Tony Lindgren
2022-06-29  9:31     ` Ilpo Järvinen
2022-06-29  9:41       ` Tony Lindgren [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YrwePdVzSYDygdVA@atomide.com \
    --to=tony@atomide.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.