mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Ming Lei <tom.leiming@gmail.com>,
	Chen Peter-B29397 <B29397@freescale.com>,
	"Rafael J. Wysocki" <rjw@sisk.pl>, Greg KH <greg@kroah.com>,
	"gregkh@suse.de" <gregkh@suse.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"hzpeterchen@gmail.com" <hzpeterchen@gmail.com>,
	Igor Grinberg <grinberg@compulab.co.il>
Subject: Re: [PATCH 1/1] driver core: disable device's runtime pm during shutdown
Date: Tue, 6 Dec 2011 05:35:58 +1100	[thread overview]
Message-ID: <20111206053558.5430d7f1@notabene.brown> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1112051100150.5138-100000@iolanthe.rowland.org>

[-- Attachment #1: Type: text/plain, Size: 2540 bytes --]

On Mon, 5 Dec 2011 11:02:38 -0500 (EST) Alan Stern
<stern@rowland.harvard.edu> wrote:

> On Mon, 5 Dec 2011, Ming Lei wrote:
> 
> > Sorry, the above is line wrapped badly, see the below:
> > 
> > diff --git a/drivers/base/core.c b/drivers/base/core.c
> > index d8b3d89..96b266c 100644
> > --- a/drivers/base/core.c
> > +++ b/drivers/base/core.c
> > @@ -1743,8 +1743,9 @@ void device_shutdown(void)
> >  		 */
> >  		list_del_init(&dev->kobj.entry);
> >  		spin_unlock(&devices_kset->list_lock);
> > -		/* Disable all device's runtime power management */
> > -		pm_runtime_disable(dev);
> > +
> > +		/* put device into active state and forbit runtime pm */
> > +		pm_runtime_forbid(dev);
> > 
> >  		if (dev->bus && dev->bus->shutdown) {
> >  			dev_dbg(dev, "shutdown\n");
> 
> We don't want to put devices into the active state when it's not 
> necessary.  A better approach would be:
> 
> 		/* Don't allow any more runtime suspends */
> 		pm_runtime_get_noresume(dev);
> 		pm_runtime_barrier(dev);
> 
> Alan Stern

That sounds like a reasonable approach if we really need to do something at
this level.  But is this the only place that ->shutdown methods are called
from?  If they are called from elsewhere, would those places need the
same pm_runtime protection?

BTW I was wrong when I said that only calling pm_runtime_disable if there was
a ->shutdown function would not work for me. i.e. the following patch does
solve my particular issue (though I'm not sure it is "right").
I was getting confused by the two different devices: the i2c device and the
platform device.
The i2c device has a ->shutdown which does nothing, but doesn't need to wake
up.
The platform device is the one which needs to wake up, but it doesn't have a
->shutdown function is this patch causes it not have pm_runtime disabled.

Thanks,
NeilBrown

diff --git a/drivers/base/core.c b/drivers/base/core.c
index d8b3d89..b9aa5d2 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1743,13 +1743,13 @@ void device_shutdown(void)
 		 */
 		list_del_init(&dev->kobj.entry);
 		spin_unlock(&devices_kset->list_lock);
-		/* Disable all device's runtime power management */
-		pm_runtime_disable(dev);
 
 		if (dev->bus && dev->bus->shutdown) {
+			pm_runtime_disable(dev);
 			dev_dbg(dev, "shutdown\n");
 			dev->bus->shutdown(dev);
 		} else if (dev->driver && dev->driver->shutdown) {
+			pm_runtime_disable(dev);
 			dev_dbg(dev, "shutdown\n");
 			dev->driver->shutdown(dev);
 		}

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

  reply	other threads:[~2011-12-05 18:36 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-14  0:43 Peter Chen
2011-11-14  9:54 ` Ming Lei
2011-11-14 22:28   ` Rafael J. Wysocki
2011-11-14 22:27 ` Rafael J. Wysocki
2011-11-15  0:59   ` Greg KH
2011-11-15 23:16     ` Rafael J. Wysocki
2011-12-04 21:56       ` NeilBrown
2011-12-05  2:42         ` Alan Stern
2011-12-05  3:37           ` NeilBrown
2011-12-05  3:26         ` Ming Lei
2011-12-05  4:42           ` Chen Peter-B29397
2011-12-05  5:12             ` Ming Lei
2011-12-05  9:01               ` Ming Lei
2011-12-05  9:05                 ` Ming Lei
2011-12-05 16:02                   ` Alan Stern
2011-12-05 18:35                     ` NeilBrown [this message]
2011-12-05 20:55                       ` Alan Stern
2011-12-05 22:32                         ` Rafael J. Wysocki
2011-12-06 15:26                           ` [PATCH] Driver core: leave runtime PM enabled during system shutdown Alan Stern
2011-12-06 21:34                             ` NeilBrown
2011-12-06 21:48                             ` Greg KH
2011-12-06 22:05                               ` Rafael J. Wysocki
2011-12-06 22:03                             ` Rafael J. Wysocki
2011-12-05  4:53           ` [PATCH 1/1] driver core: disable device's runtime pm during shutdown NeilBrown
2011-12-05  5:53             ` Chen Peter-B29397
2011-12-05  8:08               ` NeilBrown
2011-12-05  8:32                 ` Chen Peter-B29397
2011-12-05  8:52                   ` NeilBrown
2011-12-05  3:29         ` Chen Peter-B29397
2011-12-05  5:09           ` NeilBrown

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=20111206053558.5430d7f1@notabene.brown \
    --to=neilb@suse.de \
    --cc=B29397@freescale.com \
    --cc=greg@kroah.com \
    --cc=gregkh@suse.de \
    --cc=grinberg@compulab.co.il \
    --cc=hzpeterchen@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=stern@rowland.harvard.edu \
    --cc=tom.leiming@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome