All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Oliver Neukum <oneukum@suse.com>,
	linux-pci@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-acpi@vger.kernel.org, Peter Wu <peter@lekensteyn.nl>,
	Andreas Noever <andreas.noever@gmail.com>
Subject: Re: [PATCH v2 5/5] PCI: Avoid unnecessary resume on shutdown
Date: Wed, 5 Oct 2016 14:32:27 +0200	[thread overview]
Message-ID: <20161005123227.GA5855@wunner.de> (raw)
In-Reply-To: <19951801.HyPAFRyVuO@vostro.rjw.lan>

On Sat, Sep 24, 2016 at 02:50:05AM +0200, Rafael J. Wysocki wrote:
> On Monday, September 19, 2016 12:14:02 PM Lukas Wunner wrote:
> > On Mon, Sep 19, 2016 at 11:12:23AM +0200, Oliver Neukum wrote:
> > > On Sun, 2016-09-18 at 05:39 +0200, Lukas Wunner wrote:
> > > > We currently perform a mandatory runtime resume of all PCI devices
> > > > on ->shutdown.  However it is pointless to wake devices only to
> > > > immediately power them down afterwards.  (Or have the firmware
> > > > reset them, in case of a reboot.)
> > > > 
> > > > It seems there are only two cases when a runtime resume is actually
> > > > necessary:  If the driver has declared a ->shutdown callback or if
> > > > kexec is in progress.
> > > > 
> > > > Constrain resume of a device to these cases and let it slumber
> > > > otherwise, thereby conserving energy and speeding up shutdown.
> > > 
> > > What happens if you get a wakeup event while going down?
> > 
> > Hm, I should probably disable that with
> > 
> > 	__pci_enable_wake(pci_dev, pci_dev->current_state, true, false);
> > 
> 
> What if the user wants, say, WoL to power on the system?

When the PCI device is runtime resumed, the function call above
will be executed by pci_pm_runtime_resume(), so WoL will be disabled
as well.

There are a few drivers which re-enable WoL from their ->shutdown
hook, but that isn't impacted by this patch because the fast path
isn't taken if the driver has a ->shutdown hook.


> But there's another theoretical issue here.
> 
> On systems with ACPI some devices may need to be reconfigured for wakeup
> from S5 even though they have been configured for signaling wakeup while
> in S0.  Those would still need to be resumed.

Hm, why does the device have to be resumed for that?  The ACPI 6.0 spec
says for _DSW:

"This control method can only access Operation Regions that are either
always available while in a system working state or that are available
when the Power Resources referenced by the _PRW object are all ON."

Before _DSW is executed, all power resources are turned on, so whatever
_DSW does, the device should be powered up and accessible.  Does OSPM
really have to runtime resume the device for _DSW?


Another potential issue that crossed my mind is I/O virtualization:
If a PCI device is passed through to a guest VM, the VM may enable
PME, put the device in D3, etc.  If the VM is shut down, can anything
go wrong if the fast path is taken for runtime suspended devices?
(To be fair, if the VM crashes and doesn't shut down passed through
devices orderly, we'd be in the same situation.)  PME would be disabled
as described above, and leaving the device in D3hot should be fine as well.
If the host or another guest VM wants to use the PCI device afterwards,
it will resume it to D0 with pci_enable_device() in the driver's ->probe
hook.  Let me know if you find flaws in this line of thought.

Thanks!

Lukas

  reply	other threads:[~2016-10-05 12:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-18  3:39 [PATCH v2 0/5] PCI PM refinements Lukas Wunner
2016-09-18  3:39 ` [PATCH v2 1/5] PCI: Afford direct-complete to devices with nonstandard PM Lukas Wunner
2016-09-18  3:39 ` [PATCH v2 5/5] PCI: Avoid unnecessary resume on shutdown Lukas Wunner
2016-09-19  9:12   ` Oliver Neukum
2016-09-19 10:14     ` Lukas Wunner
2016-09-24  0:50       ` Rafael J. Wysocki
2016-10-05 12:32         ` Lukas Wunner [this message]
2016-09-18  3:39 ` [PATCH v2 4/5] PCI: Avoid unnecessary resume after direct-complete Lukas Wunner
2016-09-24  0:47   ` Rafael J. Wysocki
2016-09-18  3:39 ` [PATCH v2 3/5] PCI: Recognize D3cold in pci_update_current_state() Lukas Wunner
2016-09-24  0:46   ` Rafael J. Wysocki
2016-09-18  3:39 ` [PATCH v2 2/5] PCI: Query platform firmware for device power state Lukas Wunner
2016-09-24  0:46   ` Rafael J. Wysocki
2016-09-28 16:54 ` [PATCH v2 0/5] PCI PM refinements Bjorn Helgaas
2016-09-29 12:11   ` Lukas Wunner

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=20161005123227.GA5855@wunner.de \
    --to=lukas@wunner.de \
    --cc=andreas.noever@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=peter@lekensteyn.nl \
    --cc=rjw@rjwysocki.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.