From: Huang Ying <ying.huang@intel.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Alan Stern <stern@rowland.harvard.edu>,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden
Date: Thu, 15 Nov 2012 09:03:44 +0800 [thread overview]
Message-ID: <1352941424.7176.261.camel@yhuang-dev> (raw)
In-Reply-To: <37583314.JAxoSZqTsM@vostro.rjw.lan>
On Thu, 2012-11-15 at 00:10 +0100, Rafael J. Wysocki wrote:
> On Wednesday, November 14, 2012 04:45:01 PM Alan Stern wrote:
> > On Wed, 14 Nov 2012, Rafael J. Wysocki wrote:
> >
> > > > This has the side effect that when a driver unbinds, it can't leave the
> > > > device in a special low-power state. The device will always end up in
> > > > the generic low-power state supported by the PCI core.
> > >
> > > Well, I'm not sure I'd like that.
> > >
> > > Let's just go back even one step more and think what we'd like to have in
> > > general terms and then how to implement it. :-)
> > >
> > > Suppose that pci_pm_init() calls pm_runtime_enable() for all devices (in
> > > addition to what it does currently). The runtime PM status of each device is
> > > RPM_SUSPENDED at this point. Then:
> >
> > Wait a moment. When the device is detected and initialized, it is in
> > D0, right? Currently we don't care much because the device starts out
> > disabled for runtime PM. But now you are going to enable it. While
> > the device is enabled, its runtime status should match the physical
> > power level.
>
> OK
If my memory were correct, RPM_SUSPENDED just means device stop working,
but need not be put into low-power state. So for RPM_ACTIVE, PCI
devices should be in D0, but for RPM_SUSPENDED, PCI devices can in any
power state.
Best Regards,
Huang Ying
> > This means the initialization routine would have to call
> > pm_runtime_set_active() before pm_runtime_enable(). If you then wanted
> > to change the status to RPM_SUSPENDED, you would actually have to put
> > the device into D3 by calling pm_runtime_suspend() (or maybe
> > pm_runtime_schedule_suspend() to give drivers some time to get loaded
> > and bind).
>
> No, I don't want that. It may be RPM_ACTIVE all the time as long as the
> device doesn't have a driver. Which probably would even make things
> simpler. :-)
>
> > > (1) We want to keep the current semantics during probe, i.e. the device should
> > > (a) be RPM_ACTIVE and (b) have usage_count == (user space usage_count + 1)
> > > right before ddi->drv->probe() is executed.
> >
> > In theory the usage_count could be higher and then adjusted back after
> > the probe is finished, if that would make anything easier.
>
> No, it wouldn't, because of (5). Suppose that the driver wants to suspend
> the device directly from .probe() and the user space doesn't mind. We can't
> prevent that from being doable.
>
> > > (2) We don't want the driver's PM callbacks to be run before ddi->drv->probe().
> > > There's a question if we want the bus type's PM callbacks to be run at
> > > that point, but they are not run currently and IMO we shouldn't change
> > > that.
> >
> > The device is supposed to be in D0 when it is probed. Since we are
> > assuming that initialization is now going to leave it in D3, there's no
> > choice -- you _have_ to invoke pci_pm_runtime_resume(), which would
> > invoke the driver's callback, which we don't want.
>
> Let's say the device will stay in D0 after the initialization and then
> we'll require that it be in D0 if .probe() fails or after .remove().
>
> The only thing we'll need to do before .probe() in that case is to
> bump up the usage counter and then to bump it down if .probe() fails
> (and after .remove()).
>
> The only problem we have in that case are buggy drivers that leave
> devices in, say, D3cold after a failing .probe(). That doesn't
> seem to be avoidable, though.
>
> Thanks,
> Rafael
>
>
next prev parent reply other threads:[~2012-11-15 1:03 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-05 1:17 [BUGFIX] PM: Fix active child counting when disabled and forbidden Huang Ying
2012-11-05 1:56 ` Alan Stern
2012-11-06 0:43 ` Huang Ying
2012-11-06 15:17 ` Alan Stern
2012-11-07 0:26 ` Huang Ying
2012-11-07 15:49 ` Alan Stern
2012-11-07 16:09 ` Rafael J. Wysocki
2012-11-07 17:17 ` Alan Stern
2012-11-07 20:21 ` Rafael J. Wysocki
2012-11-07 20:47 ` Alan Stern
2012-11-07 21:44 ` Rafael J. Wysocki
2012-11-07 21:56 ` Alan Stern
2012-11-07 22:51 ` Rafael J. Wysocki
2012-11-07 23:09 ` Rafael J. Wysocki
2012-11-08 1:15 ` Huang Ying
2012-11-08 1:35 ` Rafael J. Wysocki
2012-11-08 2:04 ` Huang Ying
2012-11-08 9:56 ` Rafael J. Wysocki
2012-11-08 17:07 ` Alan Stern
2012-11-09 2:36 ` Huang Ying
2012-11-09 16:41 ` Alan Stern
2012-11-12 0:37 ` Huang Ying
2012-11-12 2:36 ` Alan Stern
2012-11-12 5:55 ` Huang Ying
2012-11-12 16:32 ` Alan Stern
2012-11-13 1:19 ` Huang Ying
2012-11-13 2:32 ` Alan Stern
2012-11-13 5:12 ` Huang Ying
2012-11-13 16:10 ` Alan Stern
2012-11-14 1:08 ` Huang Ying
2012-11-14 9:52 ` Rafael J. Wysocki
2012-11-14 13:35 ` Huang Ying
2012-11-14 16:06 ` Alan Stern
2012-11-13 23:43 ` Rafael J. Wysocki
2012-11-14 10:05 ` Rafael J. Wysocki
2012-11-14 16:42 ` Alan Stern
2012-11-14 19:42 ` Rafael J. Wysocki
2012-11-14 21:45 ` Alan Stern
2012-11-14 23:10 ` Rafael J. Wysocki
2012-11-15 1:03 ` Huang Ying [this message]
2012-11-15 9:51 ` Rafael J. Wysocki
2012-11-15 10:09 ` Rafael J. Wysocki
2012-11-15 15:27 ` Alan Stern
2012-11-16 0:36 ` Huang Ying
2012-11-16 0:44 ` Rafael J. Wysocki
2012-11-16 0:48 ` Huang Ying
2012-11-16 0:55 ` Rafael J. Wysocki
2012-11-16 0:54 ` Huang Ying
2012-11-16 1:29 ` Rafael J. Wysocki
2012-11-16 1:27 ` Huang Ying
2012-11-16 10:10 ` Rafael J. Wysocki
2012-11-16 3:11 ` Huang Ying
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=1352941424.7176.261.camel@yhuang-dev \
--to=ying.huang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=stern@rowland.harvard.edu \
/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;
as well as URLs for NNTP newsgroup(s).