From: Lukas Wunner <lukas@wunner.de>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-pci@vger.kernel.org, linux-pm@vger.kernel.org,
Andreas Noever <andreas.noever@gmail.com>,
Alan Stern <stern@rowland.harvard.edu>
Subject: Re: [PATCH v2 11/13] PM / sleep: Allow opt-out from runtime resume after direct-complete
Date: Sun, 7 Aug 2016 11:56:27 +0200 [thread overview]
Message-ID: <20160807095627.GB5679@wunner.de> (raw)
In-Reply-To: <10830072.vubE73bdx4@vostro.rjw.lan>
On Mon, Jul 18, 2016 at 03:18:25PM +0200, Rafael J. Wysocki wrote:
> On Friday, May 13, 2016 01:15:31 PM Lukas Wunner wrote:
> > Since commit aae4518b3124 ("PM / sleep: Mechanism to avoid resuming
> > runtime-suspended devices unnecessarily"), we no longer wake up devices
> > which are already runtime suspended upon entering system sleep
> > ("direct-complete").
> >
> > However commit 58a1fbbb2ee8 ("PM / PCI / ACPI: Kick devices that might
> > have been reset by firmware") changed this to mandatorily runtime resume
> > such devices after the system is woken. The motivation was to ensure
> > that devices do not remain in a reset-power-on state after system
> > resume, potentially preventing deep SoC-wide low-power states from being
> > entered on idle.
> >
> > This is counter-productive for devices of which we know that the
> > mandatory runtime resume is unnecessary. Thunderbolt on the Mac is a
> > case in point: Runtime resume not just powers up the controller, but
> > multiple adjacent chips, including a 15V boost converter, multiplexers
> > and an eeprom. Gratuitously powering this up after every system sleep
> > burns a not insignificant amount of energy and needlessly strains the
> > hardware.
> >
> > Perhaps it would have been better to carry out the mandatory runtime
> > resume only for those devices that actually need it, but at least we
> > should allow an opt-out.
> >
> > Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > Cc: Alan Stern <stern@rowland.harvard.edu>
> > Signed-off-by: Lukas Wunner <lukas@wunner.de>
>
> I don't like this patch and especially adding a new dev_pm_ops flag to
> work around something that you're seeing as an issue in the generic ops.
>
> It is sort of like saying "the generic ops don't work for me, so modify
> them as well as struct dev_pm_ops", but maybe it's better to change the
> PCI bus type to do something different from calling the generic function?
>
> Or you can add a ->complete callback to your driver that will clear
> power.direct_complete for the device in question.
First of all, the direct_complete flag is marked "Owned by the PM core"
in include/linux/pm.h. So I would have expected that a driver is not
supposed to fudge it.
Second, yes it's possible to make it work by clearing direct_complete
in the ->complete callback, but there's a catch: The device tree is
traversed bottom-up in dpm_complete(). Recall that a Thunderbolt
controller consists of multiple devices and that power control is
governed by its top-most device (upstream bridge). But because we're
going bottom-up, clearing the direct_complete flag must be done by
the bottom-most device (NHI)! So I've got all the power management
stuff nicely separated in functions executed for the upstream bridge,
but a small portion needs to be executed for the NHI. That's ugly.
Normally the device hierarchy is traversed bottom-up during suspend
and top-down during resume. However ->prepare and ->complete do it
the other way round. In the case of ->prepare, this is even documented
in Documentation/power/devices.txt but the reason thereof is not.
Could you explain this please?
Third, I'm irritated by your question "maybe it's better to change the
PCI bus type to do something different from calling the generic function".
What should that be? Under which circumstances can we leave a PCI device
asleep after direct-complete?
I'm generally irritated by commit 58a1fbbb2ee8, it's a significant change
to mandatorily wake all devices, it wastes a not insignificant amount of
energy, yet the reasoning in the commit message sounds vague and handwavy
("There is a concern [...] devices that are most likely to be affected").
Are there clear indications for or against a device requiring a resume?
E.g. the commit message names SoCs, perhaps those can be recognized by
having child devices of certain types?
Thanks,
Lukas
>
> > ---
> > drivers/base/power/generic_ops.c | 3 ++-
> > include/linux/pm.h | 1 +
> > 2 files changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/base/power/generic_ops.c b/drivers/base/power/generic_ops.c
> > index 07c3c4a..6e88f55 100644
> > --- a/drivers/base/power/generic_ops.c
> > +++ b/drivers/base/power/generic_ops.c
> > @@ -316,7 +316,8 @@ void pm_complete_with_resume_check(struct device *dev)
> > * the sleep state it is going out of and it has never been resumed till
> > * now, resume it in case the firmware powered it up.
> > */
> > - if (dev->power.direct_complete && pm_resume_via_firmware())
> > + if (dev->power.direct_complete && pm_resume_via_firmware() &&
> > + !dev->power.direct_complete_noresume)
> > pm_request_resume(dev);
> > }
> > EXPORT_SYMBOL_GPL(pm_complete_with_resume_check);
> > diff --git a/include/linux/pm.h b/include/linux/pm.h
> > index 6a5d654..023de94 100644
> > --- a/include/linux/pm.h
> > +++ b/include/linux/pm.h
> > @@ -596,6 +596,7 @@ struct dev_pm_info {
> > unsigned int use_autosuspend:1;
> > unsigned int timer_autosuspends:1;
> > unsigned int memalloc_noio:1;
> > + unsigned int direct_complete_noresume:1;
> > enum rpm_request request;
> > enum rpm_status runtime_status;
> > int runtime_error;
> >
next prev parent reply other threads:[~2016-08-07 9:55 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-13 11:15 [PATCH v2 00/13] Runtime PM for Thunderbolt on Macs Lukas Wunner
2016-05-13 11:15 ` [PATCH v2 02/13] PCI: Allow D3 for Thunderbolt ports Lukas Wunner
2016-05-13 11:15 ` [PATCH v2 09/13] PCI: Do not write to PM control register while in D3cold Lukas Wunner
2016-06-17 21:18 ` Bjorn Helgaas
2016-07-18 13:55 ` Rafael J. Wysocki
2016-05-13 11:15 ` [PATCH v2 08/13] PCI: Allow runtime PM for Thunderbolt hotplug ports on Macs Lukas Wunner
2016-06-14 9:08 ` [PATCH v2 08/13 REBASED] " Lukas Wunner
2016-06-17 21:53 ` [PATCH v2 08/13] " Bjorn Helgaas
2016-05-13 11:15 ` [PATCH v2 06/13] PCI: pciehp: Support runtime pm Lukas Wunner
2016-05-13 11:15 ` [PATCH v2 01/13] PCI: Recognize Thunderbolt devices Lukas Wunner
2016-05-13 11:15 ` [PATCH v2 13/13] thunderbolt: Support runtime pm on NHI Lukas Wunner
2016-05-13 11:15 ` [PATCH v2 10/13] PCI: Avoid going from D3cold to D3hot for system sleep Lukas Wunner
2016-06-17 21:09 ` Bjorn Helgaas
2016-06-17 22:14 ` Lukas Wunner
2016-07-18 13:39 ` Rafael J. Wysocki
2016-08-03 12:28 ` Lukas Wunner
2016-08-03 23:50 ` Rafael J. Wysocki
2016-08-04 0:45 ` Lukas Wunner
2016-08-04 1:07 ` Rafael J. Wysocki
2016-08-04 8:14 ` Lukas Wunner
2016-08-04 15:30 ` Rafael J. Wysocki
2016-08-07 9:03 ` Lukas Wunner
2016-08-07 23:32 ` Rafael J. Wysocki
2016-08-11 13:20 ` Lukas Wunner
2016-08-12 0:50 ` Rafael J. Wysocki
2016-08-12 16:16 ` Lukas Wunner
2016-08-12 22:18 ` Rafael J. Wysocki
2016-08-12 22:37 ` Rafael J. Wysocki
2016-08-14 10:27 ` Lukas Wunner
2016-08-15 23:05 ` Rafael J. Wysocki
2016-05-13 11:15 ` [PATCH v2 04/13] PCI: Generalize portdrv pm iterator Lukas Wunner
2016-05-13 11:15 ` [PATCH v2 07/13] PCI: pciehp: Ignore interrupts during D3cold Lukas Wunner
2016-06-17 22:52 ` Bjorn Helgaas
2016-08-02 16:27 ` Lukas Wunner
2016-08-05 0:29 ` Rafael J. Wysocki
2016-05-13 11:15 ` [PATCH v2 12/13] thunderbolt: Support runtime pm on upstream bridge Lukas Wunner
2016-05-13 11:15 ` [PATCH v2 11/13] PM / sleep: Allow opt-out from runtime resume after direct-complete Lukas Wunner
2016-07-18 13:18 ` Rafael J. Wysocki
2016-08-07 9:56 ` Lukas Wunner [this message]
2016-08-07 15:33 ` Alan Stern
2016-08-12 16:39 ` Lukas Wunner
2016-08-12 17:30 ` Alan Stern
2016-08-12 22:40 ` Rafael J. Wysocki
2016-05-13 11:15 ` [PATCH v2 05/13] PCI: Use portdrv pm iterator on further callbacks Lukas Wunner
2016-05-13 11:15 ` [PATCH v2 03/13] PCI: Add Thunderbolt portdrv service type Lukas Wunner
2016-06-17 22:51 ` Bjorn Helgaas
2016-07-20 0:30 ` Rafael J. Wysocki
2016-07-20 6:59 ` Lukas Wunner
2016-05-21 9:48 ` [PATCH v2 00/13] Runtime PM for Thunderbolt on Macs Andreas Noever
2016-06-14 16:37 ` Bjorn Helgaas
2016-06-14 19:14 ` Andreas Noever
2016-06-14 20:22 ` Bjorn Helgaas
2016-06-15 18:40 ` Lukas Wunner
2016-06-16 1:55 ` Linus Torvalds
2016-07-07 17:39 ` Andreas Noever
2016-07-09 5:23 ` Greg KH
2016-07-12 21:46 ` Andreas Noever
2016-06-13 20:58 ` Bjorn Helgaas
2016-06-14 9:27 ` Lukas Wunner
2016-07-07 15:02 ` Lukas Wunner
2016-07-08 1:28 ` Rafael J. Wysocki
2016-07-20 7:23 ` Lukas Wunner
2016-07-20 12:48 ` Rafael J. Wysocki
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=20160807095627.GB5679@wunner.de \
--to=lukas@wunner.de \
--cc=andreas.noever@gmail.com \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--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).