From: Lukas Wunner <lukas@wunner.de>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
Linux PCI <linux-pci@vger.kernel.org>,
Linux PM <linux-pm@vger.kernel.org>,
Andreas Noever <andreas.noever@gmail.com>
Subject: Re: [PATCH v2 10/13] PCI: Avoid going from D3cold to D3hot for system sleep
Date: Sun, 7 Aug 2016 11:03:47 +0200 [thread overview]
Message-ID: <20160807090347.GA5679@wunner.de> (raw)
In-Reply-To: <CAJZ5v0hPbeaUotiFxg_BbkS86HEz=u0ThkdwJju5WyXOuDgd6A@mail.gmail.com>
On Thu, Aug 04, 2016 at 05:30:47PM +0200, Rafael J. Wysocki wrote:
> On Thu, Aug 4, 2016 at 10:14 AM, Lukas Wunner <lukas@wunner.de> wrote:
> > On Thu, Aug 04, 2016 at 03:07:56AM +0200, Rafael J. Wysocki wrote:
> >> On Thu, Aug 4, 2016 at 2:45 AM, Lukas Wunner <lukas@wunner.de> wrote:
> >> > On Thu, Aug 04, 2016 at 01:50:39AM +0200, Rafael J. Wysocki wrote:
> >> >> On Wed, Aug 3, 2016 at 2:28 PM, Lukas Wunner <lukas@wunner.de> wrote:
> >> >> > I will update this patch with Bjorn's suggestion to also leave the
> >> >> > device in D3cold if it is wakeup-capable. The idea is to just change
> >> >> > the default state in the first line of the function like this:
> >> >> >
> >> >> > - pci_power_t target_state = PCI_D3hot;
> >> >> > + pci_power_t target_state =
> >> >> > + dev->current_state == PCI_D3cold ? PCI_D3cold : PCI_D3hot;
> >> >>
> >> >> That should work (even though it is a little clumsy IMO).
> >> >
> >> > Not sure why that is clumsy but happy to use something else if you
> >> > have a suggestion?
> >>
> >> The clumsy thing is that we'd take the target_state as D3cold only if
> >> the device already was in that state.
> >>
> >> Otherwise, we'd take D3hot as the target state for the same device,
> >> which doesn't seem particularly consistent to me.
> >>
> >> Not that I have better ideas ATM, but then the current code works for
> >> my use cases. :-)
> >
> > The goal is to afford direct-complete to devices which are not power-
> > manageable by the platform but can still be runtime suspended to D3cold.
>
> Well, this is a bit misleading.
>
> According to the PCI spec there are two ways to put a device into
> D3cold: either by putting its bus into B3 (which for PCIe means
> turning the link off IIRC) which happens when the bridge goes into
> D3hot, or through the platform.
>
> You aren't talking about any of those cases, though, so we go outside
> of the spec here.
Yes. With Nvidia Optimus / AMD PowerXpress hybrid graphics on non-Macs
and Thunderbolt on Macs, it could still be argued that D3cold is
facilitated by the platform, albeit with custom methods instead of _PS3.
With hybrid graphics on Macs, the discrete GPU is turned off by
a gmux controller on the LPC bus which is controlled via I/O ports.
So the ACPI platform isn't involved at all and at least then we're
in completely nonstandard territory.
> > Right now we wake those devices up from D3cold to D3hot before going to
> > sleep, which is a waste of energy and prolongs the suspend sequence
> > (waking up the Thunderbolt controller takes 2 seconds).
>
> Understood.
>
> > The de facto standard to power manage such devices seems to be with
> > dev_pm_domain_set(). That's what vga_switcheroo does and I'll move
> > to that as well for v3 of this series.
>
> OK
>
> > I could add a "bool can_power_off" to struct dev_pm_domain.
>
> I'm not sure if dev_pm_domain is the right level. The "can_power_off"
> thing would be sort of specific to your particular use case.
>
> Say you have something like
>
> struct pci_pm_domain {
> struct dev_pm_domain pd;
> ...
> };
>
> > Then I could change pci_target_state() like this:
> >
> > pci_power_t target_state = PCI_D3hot;
> >
> > if (platform_pci_power_manageable(dev)) {
> > [...]
> > + } else if (dev->dev.pm_domain && dev->dev.pm_domain.can_power_off) {
>
> so you can do something like
>
> } else if (dev->dev.pm_domain) {
> struct pci_pm_domain *pci_pd =
> to_pci_pm_domain(dev->dev.pm_domain);
>
> ....
> } else if [...]
>
> and it may be a bit more PCI-oriented without expanding generic data types.
>
> > + target_state = PCI_D3cold;
> > } else if [...]
> >
> > Another idea would be to add a ->choose_state hook to dev_pm_domain,
> > but that would have to return a PCI-specific power state, so we'd be
> > in clumsy territory again.
>
> Right.
>
> > Thoughts?
>
> Essentially, the PCI PM code needs to be told that there is a way to
> put the device into D3cold by non-standard means. There are a couple
> of ways to do that (a new flag in struct pci_dev, the above, probably
> more), but in any case it needs to be clear that this is non-standard
> IMO.
The more I think about it, the more I lean towards the one-line change
at the top of this e-mail, even though you found it clumsy. It's small
and simple and fixes the problem without overengineering things.
The reasoning is that going from D3cold to D3hot before system sleep
just never makes sense, no matter if the device got there by standard
or nonstandard means. So the default target state should be D3cold if
the device is already there, and D3hot otherwise. I could perhaps try
to make this clearer by adding a comment.
Thanks,
Lukas
next prev parent reply other threads:[~2016-08-07 9:03 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 01/13] PCI: Recognize Thunderbolt devices Lukas Wunner
2016-05-13 11:15 ` [PATCH v2 06/13] PCI: pciehp: Support runtime pm Lukas Wunner
2016-05-13 11:15 ` [PATCH v2 04/13] PCI: Generalize portdrv pm iterator Lukas Wunner
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 05/13] PCI: Use portdrv pm iterator on further callbacks 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 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 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 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
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 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 [this message]
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 12/13] thunderbolt: Support runtime pm on upstream bridge 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=20160807090347.GA5679@wunner.de \
--to=lukas@wunner.de \
--cc=andreas.noever@gmail.com \
--cc=helgaas@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
/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).