linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH 0/3] PM / sleep: Avoid resuming runtime-suspended devices during system suspend
@ 2014-05-13  1:02 Rafael J. Wysocki
  2014-05-13  1:03 ` [RFC][PATCH 1/3] PM / sleep: Move runtime PM barrier invocation to device_prepare() Rafael J. Wysocki
                   ` (3 more replies)
  0 siblings, 4 replies; 52+ messages in thread
From: Rafael J. Wysocki @ 2014-05-13  1:02 UTC (permalink / raw)
  To: Alan Stern, Linux PM list
  Cc: ACPI Devel Maling List, Aaron Lu, Mika Westerberg,
	Linux Kernel Mailing List, Kevin Hilman, Ulf Hansson

Hi All,

We've discussed that at length here:

http://marc.info/?t=139950469000003&r=1&w=4

but I'm starting a new thread to refresh things a bit.

This is about adding a mechanism allowing us to avoid runtime-suspended
devices during system suspend.  The reason why it has to touch the PM core
is because that needs to be coordinated across the device hierarchy.

The idea is to add a new device PM flag and to modify the PM core as follows.

 - If ->prepare() returns a positive number for a device, that means "this
   device is runtime-suspended and you can leave it like that if you do the
   same for all of its descendants".

 - If that happens, the PM core sets the new flag for the device in
   question *if* the device is indeed runtime-suspended *and* *if*
   the transition is a suspend (and not hibernation, for example).
   Otherwise, it clears the flag for the device.  All of that happens in
   device_prepare().

 - In __device_suspend() the PM core clears the new flag for the device's
   parent if it is clear for the device to ensure that the flag will only
   be set for a device if it is also set for all of its descendants.

 - PM core skips ->suspend/late/noirq and ->resume/early/noirq for all devices
   having the flag set - so the flag can be called "direct_complete" as it
   causes the PM core to go directy for the ->complete() callback when set.

 - The ->complete() callback has to check direct_complete if ->prepare()
   returned a positive number previously and is responsible for further
   handling of the device.

That is introduced by patch [2/3].

To simplify things slightly it is helpful to move the invocation of
pm_runtime_barrier() from __device_suspend() to device_prepare(), but still
under pm_runtime_get_noresume() beforehand (patch [1/3]).

Patch [3/3] shows how this can be used by adding support for it to the ACPI
PM comain.

Thanks!

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 52+ messages in thread
* Re: [RFC][PATCH 1/3] PM / sleep: Flag to speed up suspend-resume of runtime-suspended devices
@ 2014-05-08 21:20 Alan Stern
  2014-05-08 21:50 ` Rafael J. Wysocki
  0 siblings, 1 reply; 52+ messages in thread
From: Alan Stern @ 2014-05-08 21:20 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux PM list, Mika Westerberg, Aaron Lu, ACPI Devel Maling List,
	LKML

On Thu, 8 May 2014, Rafael J. Wysocki wrote:

> > > Wait a minute.  Following ->runtime_suspend(), you are going to call 
> > > ->suspend() and then ->runtime_resume()?  That doesn't seem like what 
> > > you really want; a ->suspend() call should always have a matching 
> > > ->resume().
> > 
> > Yes, it should, but I didn't see any other way to do that.
> 
> Actually, that's kind of easy to resolve. :-)
> 
> When ->suspend() leaves power.leave_runtime_suspended set, the PM core can
> simply skip the early/late and noirq callbacks and then call ->resume()
> that will be responsible for using whatever is necessary to resume the
> device.
> 
> And perhaps the flag should be called something different then, like
> direct_resume (meaning go directly for ->resume() without executing
> the intermediate callbacks)?

In light of what I wrote earlier, it should be okay for the ->prepare() 
callback to be responsible for setting leave_runtime_suspended.  Then 
there will be no need to call either ->suspend() or ->resume().

Alan Stern


^ permalink raw reply	[flat|nested] 52+ messages in thread
* Re: [RFC][PATCH 1/3] PM / sleep: Flags to speed up suspend-resume of runtime-suspended devices
@ 2014-05-07 15:43 Alan Stern
  2014-05-07 23:27 ` [RFC][PATCH 0/3] (was: Re: [RFC][PATCH 1/3] PM / sleep: Flags to speed up suspend-resume of runtime-suspended devices) Rafael J. Wysocki
  0 siblings, 1 reply; 52+ messages in thread
From: Alan Stern @ 2014-05-07 15:43 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux PM list, Mika Westerberg, Aaron Lu, ACPI Devel Maling List,
	LKML

On Wed, 7 May 2014, Rafael J. Wysocki wrote:

We seem to be in agreement that this is the way you want to go...

> > All right.  Then this seems to be what you want:
> > 
> > 	For some devices, it's okay to remain in runtime suspend 
> > 	throughout a complete system suspend/resume cycle (if the
> > 	device was in runtime suspend at the start of the cycle).
> > 	We would like to do this whenever possible, to avoid the
> > 	overhead of extra power-up and power-down events.
> 
> Yes.
> 
> > 	However, problems may arise because the device's descendants 
> > 	may require it to be at full power at various points during 
> > 	the cycle.  Therefore the only way to do this safely is if the 
> > 	device _and_ all its descendants can remain runtime suspended 
> > 	until the resume stage of system resume.
> 
> It may not be the only way, but it is *a* way to do this safely.
> 
> > 	To this end, introduce dev->power.leave_runtime_suspended.
> > 	If a subsystem or driver sets this flag during the ->prepare()
> > 	callback, and if the flag is set in all of the device's
> > 	descendants, and if the device is still in runtime suspend when
> > 	the ->suspend() callback would normally be invoked, then the PM
> > 	core will not invoke the device's ->suspend(), 
> > 	->suspend_late(), ->suspend_irq(), ->resume_irq(),
> > 	->resume_early(), or ->resume() callbacks.  Instead, it will 
> > 	invoke ->runtime_resume() during the resume stage of system
> > 	resume.
> 
> Yes.
> 
> > 	By setting this flag, a driver or subsystem tells the PM core
> > 	that the device is runtime suspended, it is in a suitable state
> > 	for system suspend (for example, the wakeup setting does not
> > 	need to be changed), and it does not need to return to full
> > 	power until the resume stage.
> 
> Yes.
> 
> > Does that correctly describe what you want to do, the potential
> > problems, and the proposed solution?
> 
> Almost.  Devices with power.ignore_children set are not covered by this.

I thought they were.  In what respect aren't they?  You mean because
they can be runtime suspended while their children remain active?

I don't think that matters here.  Suppose a parent device's
leave_runtime_suspended flag is set but one of its children isn't
runtime suspended.  Then that child's leave_runtime_suspended flag
won't be set, so the parent device won't meet the criterion for
skipping the normal PM callbacks.

Or do you mean that a child might expect the parent to be at full power
when the child is resumed (plus the fact that doing a runtime resume on
the child will not automatically resume the parent)?  That doesn't
matter either, because the PM core will do a runtime-resume of the
parent before the child's ->runtime_resume() is called.

> > If so, then it appears the parent_needed flag is unnecessary.
> 
> Well, I can agree with that.  It wasn't there in my first patchset and I added
> it kind of in the hope to be able to deal with the ignore_children devices
> with the help of it.

Yeah.  I contributed to that, by not understanding exactly what you 
were trying to accomplish.

> OK, I guess I need to prepare a new version without the parent_needed flag for
> further discussion. :-)

Consider using the description above (or some variant of it) for the
new Changelog.  IMNSHO it does a much better job of explaining the 
patch than your original version.  :-)

Alan Stern


^ permalink raw reply	[flat|nested] 52+ messages in thread
* Re: [PATCH 1/3] PM / sleep: New flag to speed up suspend-resume of suspended devices
@ 2014-02-27 15:02 Alan Stern
  2014-04-24 22:36 ` [RFC][PATCH 0/3] PM: Mechanism to avoid resuming runtime-suspended devices during system suspend, v2 Rafael J. Wysocki
  0 siblings, 1 reply; 52+ messages in thread
From: Alan Stern @ 2014-02-27 15:02 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux PM list, Mika Westerberg, Aaron Lu, ACPI Devel Maling List,
	LKML

On Thu, 27 Feb 2014, Rafael J. Wysocki wrote:

> > If the child knows about the problem beforehand, it can runtime-resume 
> > the parent during its ->suspend.
> 
> Well, it even should do that in those cases.  We may need to deal with children
> that don't do that, though.
> 
> > > Well, if power.fast_suspend set guarantees that ->suspend_late, ->suspend_noirq,
> > > ->resume_noirq, and ->resume_early will be skipped for a device, then we may
> > > restrict setting it for devices whose children have it set (or that have no
> > > children).  Initially, that will be equivalent to setting it for leaf devices
> > > only, but it might be extended over time in a natural way.
> > 
> > Initially, maybe.
> 
> Of course initially.
> 
> > But it's the wrong approach in general.
> 
> In the long run - I agree.
> 
> > The right approach is to restrict setting fast_suspend for devices whose
> > children don't mind their parent being suspended when their resume callbacks 
> > run -- not for devices whose children also have fast_suspend set.
> 
> I agree, but we need to know which children are OK with the parent being
> suspended.  Having fast_suspend set is a good indication of that. :-)
> 
> Of course, we may introduce a separate flag for that just fine if you prefer.
> 
> > That's the point I've been trying to express all along.
> 
> I see.

Okay.  I'll wait to see the next version.

Alan Stern


^ permalink raw reply	[flat|nested] 52+ messages in thread
* [RFC][PATCH 0/3] PM: Mechanism to avoid resuming runtime-suspended devices during system suspend
@ 2014-01-14 23:12 Rafael J. Wysocki
  2014-01-14 23:16 ` [RFC][PATCH 3/3] ACPI / PM: Avoid resuming devices in ACPI PM domain " Rafael J. Wysocki
  0 siblings, 1 reply; 52+ messages in thread
From: Rafael J. Wysocki @ 2014-01-14 23:12 UTC (permalink / raw)
  To: Linux PM list
  Cc: Alan Stern, Mika Westerberg, Aaron Lu, ACPI Devel Maling List,
	LKML

Hi,

The following experimental series of 3 patches implements a mechanism allowing
subsystems to avoid resuming runtime-suspended devices during system suspend.

As far as the PM core goes, it introduces a new flag, power.no_suspend, that
will be set by the core for devices which can stay suspended.  The idea is that
subsystems should know which devices can stay suspended over system suspend
and to allow them to tell the core about that patch [1/3] changes the calling
convention of the device PM .prepare() callback so that it can return a positive
value on success to be interpreted as "this device has been runtime-suspended
and doesn't need to be resumed" information.  If .prepare() returns a positive
number for certain device, the core will set power.no_suspend and will not run
suspend callbacks for device with that flag set going forward (during this
particular system suspend transition).

However, parents may generally need to be resumed so that the suspend of their
children can be carried out, so the PM core will clear power.no_suspend for
the parents of devices whose power.no_suspend is not set (unless those parents
have power.ignore_children set).

Patch [2/3] adds a new runtime PM helper function that subsystems can use to
check whether or not a given device is runtime-suspended when .prepare() is being
executed for it.

Patch [3/3] implements the subsystem part for the ACPI PM domain, because that
is relatively straightforward.  If the general approach makes sense, I'll think
about doing the same for PCI.

Comments welcome!

Thanks,
Rafael


^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2014-05-19 20:20 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-13  1:02 [RFC][PATCH 0/3] PM / sleep: Avoid resuming runtime-suspended devices during system suspend Rafael J. Wysocki
2014-05-13  1:03 ` [RFC][PATCH 1/3] PM / sleep: Move runtime PM barrier invocation to device_prepare() Rafael J. Wysocki
2014-05-13  9:16   ` Ulf Hansson
2014-05-13 10:35     ` Rafael J. Wysocki
2014-05-13 10:59       ` Ulf Hansson
2014-05-13 15:07         ` Rafael J. Wysocki
2014-05-13 15:19           ` Rafael J. Wysocki
2014-05-13  1:10 ` [RFC][PATCH 2/3] PM / sleep: Mechanism to avoid resuming runtime-suspended devices unnecessarily Rafael J. Wysocki
2014-05-13  9:30   ` Ulf Hansson
2014-05-13 14:49   ` Alan Stern
2014-05-13 15:13     ` Rafael J. Wysocki
2014-05-13 15:12       ` Alan Stern
2014-05-13 15:43         ` Rafael J. Wysocki
2014-05-13 15:46           ` Alan Stern
2014-05-13 16:16             ` Rafael J. Wysocki
2014-05-13 16:19               ` Alan Stern
2014-05-13 21:29                 ` Rafael J. Wysocki
2014-05-14 14:53                   ` Alan Stern
2014-05-15 11:13                     ` Rafael J. Wysocki
2014-05-16  0:45                       ` [PATCH 0/3] (was: Re: PM / sleep: Mechanism to avoid resuming runtime-suspended devices unnecessarily) Rafael J. Wysocki
2014-05-16  0:46                         ` [PATCH 1/3] PM / sleep: Mechanism to avoid resuming runtime-suspended devices unnecessarily Rafael J. Wysocki
2014-05-16 14:27                           ` Alan Stern
2014-05-16 21:10                             ` Rafael J. Wysocki
2014-05-16  0:47                         ` [PATCH 2/3] PM / sleep: Update device PM documentation to cover direct_complete Rafael J. Wysocki
2014-05-16  0:48                         ` [PATCH 3/3][Resend] ACPI / PM: Avoid resuming devices in ACPI PM domain during system suspend Rafael J. Wysocki
2014-05-16 22:18                           ` [PATCH 3/3][update] " Rafael J. Wysocki
2014-05-15 12:06                     ` [RFC][PATCH 2/3] PM / sleep: Mechanism to avoid resuming runtime-suspended devices unnecessarily Ulf Hansson
2014-05-15 12:55                       ` Rafael J. Wysocki
2014-05-15 17:35             ` Kevin Hilman
2014-05-14 22:24   ` Jacob Pan
2014-05-15 11:11     ` Rafael J. Wysocki
2014-05-15 13:09       ` Jacob Pan
2014-05-15 14:29         ` Alan Stern
2014-05-15  7:03           ` Jacob Pan
2014-05-15 15:58             ` Alan Stern
2014-05-16 15:20               ` Jacob Pan
2014-05-16 21:08                 ` Rafael J. Wysocki
2014-05-19  9:18                   ` Jacob Pan
2014-05-19 19:53                     ` Alan Stern
2014-05-19 20:13                       ` Rafael J. Wysocki
2014-05-19 20:20                     ` Rafael J. Wysocki
2014-05-13  1:10 ` [RFC][PATCH 3/3] ACPI / PM: Avoid resuming devices in ACPI PM domain during system suspend Rafael J. Wysocki
2014-05-13 14:45 ` [RFC][PATCH 0/3] PM / sleep: Avoid resuming runtime-suspended devices " Alan Stern
2014-05-13 15:25   ` Rafael J. Wysocki
2014-05-13 15:25     ` Alan Stern
2014-05-13 15:46       ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2014-05-08 21:20 [RFC][PATCH 1/3] PM / sleep: Flag to speed up suspend-resume of runtime-suspended devices Alan Stern
2014-05-08 21:50 ` Rafael J. Wysocki
2014-05-08 22:28   ` [RFC][PATCH 0/3] (was: Re: PM / sleep: Flag to speed up suspend-resume of runtime-suspended devices) Rafael J. Wysocki
2014-05-08 22:42     ` [RFC][PATCH 3/3] ACPI / PM: Avoid resuming devices in ACPI PM domain during system suspend Rafael J. Wysocki
2014-05-07 15:43 [RFC][PATCH 1/3] PM / sleep: Flags to speed up suspend-resume of runtime-suspended devices Alan Stern
2014-05-07 23:27 ` [RFC][PATCH 0/3] (was: Re: [RFC][PATCH 1/3] PM / sleep: Flags to speed up suspend-resume of runtime-suspended devices) Rafael J. Wysocki
2014-05-07 23:33   ` [RFC][PATCH 3/3] ACPI / PM: Avoid resuming devices in ACPI PM domain during system suspend Rafael J. Wysocki
2014-05-08 14:59     ` Alan Stern
2014-05-08 19:40       ` Rafael J. Wysocki
2014-02-27 15:02 [PATCH 1/3] PM / sleep: New flag to speed up suspend-resume of suspended devices Alan Stern
2014-04-24 22:36 ` [RFC][PATCH 0/3] PM: Mechanism to avoid resuming runtime-suspended devices during system suspend, v2 Rafael J. Wysocki
2014-04-24 22:40   ` [RFC][PATCH 3/3] ACPI / PM: Avoid resuming devices in ACPI PM domain during system suspend Rafael J. Wysocki
2014-01-14 23:12 [RFC][PATCH 0/3] PM: Mechanism to avoid resuming runtime-suspended devices " Rafael J. Wysocki
2014-01-14 23:16 ` [RFC][PATCH 3/3] ACPI / PM: Avoid resuming devices in ACPI PM domain " Rafael J. Wysocki

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).