From: Huang Ying <ying.huang@intel.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden
Date: Fri, 09 Nov 2012 10:36:44 +0800 [thread overview]
Message-ID: <1352428604.7176.103.camel@yhuang-dev> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1211081125470.1280-100000@iolanthe.rowland.org>
On Thu, 2012-11-08 at 12:07 -0500, Alan Stern wrote:
> On Thu, 8 Nov 2012, Rafael J. Wysocki wrote:
>
> > > > > is it a good idea to allow to set device state to SUSPENDED if the device
> > > > > is disabled?
> > > >
> > > > No, it is not. The status should always be ACTIVE as long as usage_count > 0.
>
> That isn't strictly true, because pm_runtime_get_noresume violates this
> rule. What the PM core actually does is prevent a transition from the
> ACTIVE state to the SUSPENDING/SUSPENDED state if usage_count > 0,
> _provided_ runtime PM is enabled. There's no such restriction when it
> is disabled.
Usage count may be not a issue for the end user. But "on" in "control"
sysfs file + SUSPENDED can be confusing for the end user. Maybe we need
to check dev->power.runtime_auto in pm_runtime_set_suspended().
> BTW, do we need to think about what happens in the case where the
> device _does_ have a driver and for some reason the driver has disabled
> the device for runtime PM? I would just as soon ignore the issue.
>
> > > > However, in some cases we actually would like to change the status to
> > > > SUSPENDED when usage_count becomes equal to 0, because that means we can
> > > > suspend (I mean really suspend) the parents of the devices in question
> > > > (and we want to notify the parents in those cases).
> > >
> > > So do you think Alan Stern's suggestion about forbidden and disabled is
> > > the right way to go?
> >
> > I'm not really sure about that.
> >
> > My original idea was that the runtime PM status and usage counter would
> > only matter when runtime PM of a device was enabled. That leads to
> > problems, though, when we enable runtime PM of a device whose usage
> > counter is greater from zero and status is SUSPENDED.
>
> That doesn't seem to be a problem. It can arise without disabling
> runtime PM at all -- just call pm_runtime_get_noresume.
I think pm_runtime_get_noresume can not fix the issue.
pm_runtiem_set_active() should be invoked before pm_runtime_enable() if
necessary. That is, the invoker should be responsible for the
consistence between usage_count and SUSPENDED/ACTIVE status. And the
API may be a little low level and error-prone to the invoker (mainly bus
code).
Best Regards,
Huang Ying
> > Also when the
> > device's status is ACTIVE, but its parent's child count is 0.
>
> __pm_runtime_set_status prevents this situation from arising. When the
> device's status is set to ACTIVE, the parent's child count is
> incremented. So this isn't a problem either.
>
> > It's not very easy to fix this at the core level, though, because we
> > depend on the current behavior in some places. I'm thinking that
> > perhaps pm_runtime_enable() should just WARN() if things are obviously
> > inconsistent (although there still may be problems, for example, if the
> > parent's child count is 2 when we enable runtime PM for its child, but that
> > child is the only one it actually has).
>
> I think we should continue the original strategy of ignoring the status
> and usage counter when runtime PM is disabled. This is definitely the
> easiest and most straightforward approach. Fixing the problem at hand
> (VGA controllers) by changing the PCI subsystem seems like the simplest
> solution.
>
> Your revised patch does do the job, except for a few problems.
> Namely, while local_pci_probe() and pci_device_remove() are running,
> the device _does_ have a driver. This means that local_pci_probe()
> should not call pm_runtime_get_sync(), for example. Doing so would
> invoke the driver's runtime_resume routine before calling the driver's
> probe routine!
>
> The USB subsystem solves this problem by carefully keeping track of the
> state of the device-driver binding:
>
> Originally the device is UNBOUND.
>
> At the start of the subsystem's probe routine, the state
> changes to BINDING.
>
> If the probe succeeds then it changes to BOUND; otherwise
> it goes back to UNBOUND.
>
> At the start of the subsystem's remove routine, the state
> changes to UNBINDING. At the end it goes to UNBOUND.
>
> When the state is anything other than BOUND, the subsystem's runtime PM
> routines act as though there is no driver. This works because the
> subsystem makes sure that the device is ACTIVE with a nonzero usage
> count before calling the driver's probe or remove routine, so no
> runtime PM callbacks can occur at these awkward times.
>
> If PCI adopted this strategy then your new patch would work okay. I
> think -- I haven't checked it thoroughly.
>
> Alan Stern
>
next prev parent reply other threads:[~2012-11-09 2:36 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 [this message]
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
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=1352428604.7176.103.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).