All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Linux ACPI <linux-acpi@vger.kernel.org>,
	Linux PCI <linux-pci@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Linux USB <linux-usb@vger.kernel.org>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	Felipe Balbi <balbi@kernel.org>,
	Mario Limonciello <mario_limonciello@dell.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Dominik Brodowski <linux@dominikbrodowski.net>,
	Hans De Goede <hdegoede@redhat.com>,
	Alan Stern <stern@rowland.harvard.edu>
Subject: Re: [PATCH v2 6/8] PCI / PM: Restore PME Enable if skipping wakeup setup
Date: Wed, 14 Jun 2017 13:10:04 -0500	[thread overview]
Message-ID: <20170614181004.GB20778@bhelgaas-glaptop.roam.corp.google.com> (raw)
In-Reply-To: <1667474.rysFhR2k32@aspire.rjw.lan>

On Mon, Jun 12, 2017 at 10:53:36PM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> The wakeup_prepared PCI device flag is used for preventing subsequent
> changes of PCI device wakeup settings in the same way (e.g. enabling
> device wakeup twice in a row).
> 
> However, in some cases PME Enable may be updated by things like PCI
> configuration space restoration in the meantime and it may need to be
> set again even though the rest of the settings need not change, so
> modify __pci_enable_wake() to do that when it is about to return
> early.
> 
> Also, it is reasonable to expect that __pci_enable_wake() will always
> clear PME Status when invoked to disable device wakeup, so make it do
> so even if it is going to return early then.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> ---
>  drivers/pci/pci.c |   26 ++++++++++++++++++++++++--
>  1 file changed, 24 insertions(+), 2 deletions(-)
> 
> Index: linux-pm/drivers/pci/pci.c
> ===================================================================
> --- linux-pm.orig/drivers/pci/pci.c
> +++ linux-pm/drivers/pci/pci.c
> @@ -1805,6 +1805,23 @@ static void __pci_pme_active(struct pci_
>  	pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr);
>  }
>  
> +static void pci_pme_restore(struct pci_dev *dev)
> +{
> +	u16 pmcsr;
> +
> +	if (!dev->pme_support)
> +		return;
> +
> +	pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
> +	if (dev->wakeup_prepared) {
> +		pmcsr |= PCI_PM_CTRL_PME_ENABLE;
> +	} else {
> +		pmcsr &= ~PCI_PM_CTRL_PME_ENABLE;
> +		pmcsr |= PCI_PM_CTRL_PME_STATUS;
> +	}
> +	pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr);
> +}
> +
>  /**
>   * pci_pme_active - enable or disable PCI device's PME# function
>   * @dev: PCI device to handle.
> @@ -1899,9 +1916,14 @@ int __pci_enable_wake(struct pci_dev *de
>  	if (enable && !runtime && !device_may_wakeup(&dev->dev))
>  		return -EINVAL;
>  
> -	/* Don't do the same thing twice in a row for one device. */
> -	if (!!enable == !!dev->wakeup_prepared)
> +	/*
> +	 * Don't do the same thing twice in a row for one device, but restore
> +	 * PME Enable in case it has been updated by config space restoration.
> +	 */
> +	if (!!enable == !!dev->wakeup_prepared) {
> +		pci_pme_restore(dev);
>  		return 0;
> +	}
>  
>  	/*
>  	 * According to "PCI System Architecture" 4th ed. by Tom Shanley & Don
> 

  reply	other threads:[~2017-06-14 18:10 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-08  0:00 [PATCH 0/6] ACPI / PM: Suspend-to-idle rework to deal with spurious ACPI wakeups Rafael J. Wysocki
2017-06-08  0:01 ` [PATCH 1/6] ACPI / PM: Run wakeup notify handlers synchronously Rafael J. Wysocki
2017-06-08  0:02 ` [PATCH 2/6] USB / PCI / PM: Allow the PCI core to do the resume cleanup Rafael J. Wysocki
2017-06-08 15:24   ` Alan Stern
2017-06-08 23:01     ` Rafael J. Wysocki
     [not found] ` <8918199.uo13RZ8hZk-yvgW3jdyMHm1GS7QM15AGw@public.gmane.org>
2017-06-08  0:03   ` [PATCH 3/6] ACPI / PM: Change log level of wakeup-related message Rafael J. Wysocki
2017-06-08  0:03     ` Rafael J. Wysocki
2017-06-08  0:04   ` [PATCH 4/6] ACPI / PM: Clean up device wakeup enable/disable code Rafael J. Wysocki
2017-06-08  0:04     ` Rafael J. Wysocki
2017-06-08  0:05 ` [PATCH 5/6] PM / sleep: Print timing information if debug is enabled Rafael J. Wysocki
2017-06-08  0:06 ` [PATCH 6/6] ACPI / PM: Ignore spurious SCI wakeups from suspend-to-idle Rafael J. Wysocki
2017-06-08  7:24 ` [PATCH 0/6] ACPI / PM: Suspend-to-idle rework to deal with spurious ACPI wakeups Hans de Goede
2017-06-08  8:42 ` Dominik Brodowski
2017-06-08 11:56   ` Rafael J. Wysocki
2017-06-12 20:46 ` [PATCH v2 0/8] " Rafael J. Wysocki
2017-06-12 20:48   ` [PATCH v2 1/8] ACPI / PM: Run wakeup notify handlers synchronously Rafael J. Wysocki
2017-06-14 18:09     ` Bjorn Helgaas
2017-06-14 22:22       ` Rafael J. Wysocki
2017-06-12 20:49   ` [PATCH v2 2/8] USB / PCI / PM: Allow the PCI core to do the resume cleanup Rafael J. Wysocki
2017-06-13  8:52     ` Greg KH
2017-06-13 11:14       ` Rafael J. Wysocki
2017-06-12 20:50   ` [PATCH v2 3/8] ACPI / PM: Change log level of wakeup-related message Rafael J. Wysocki
2017-06-12 20:51   ` [PATCH v2 4/8] ACPI / PM: Clean up device wakeup enable/disable code Rafael J. Wysocki
2017-06-12 20:51   ` [PATCH v2 5/8] PM / sleep: Print timing information if debug is enabled Rafael J. Wysocki
2017-06-12 22:18     ` Joe Perches
2017-06-12 20:53   ` [PATCH v2 6/8] PCI / PM: Restore PME Enable if skipping wakeup setup Rafael J. Wysocki
2017-06-14 18:10     ` Bjorn Helgaas [this message]
2017-06-12 20:55   ` [PATCH v2 7/8] platform/x86: Add driver for ACPI INT0002 Virtual GPIO device Rafael J. Wysocki
2017-06-12 20:56   ` [PATCH v2 8/8] ACPI / PM: Ignore spurious SCI wakeups from suspend-to-idle Rafael J. Wysocki
2017-06-13  5:54   ` [PATCH v2 0/8] ACPI / PM: Suspend-to-idle rework to deal with spurious ACPI wakeups Dominik Brodowski
2017-06-13 11:14     ` 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=20170614181004.GB20778@bhelgaas-glaptop.roam.corp.google.com \
    --to=helgaas@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=balbi@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=mario_limonciello@dell.com \
    --cc=mathias.nyman@linux.intel.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=srinivas.pandruvada@linux.intel.com \
    --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 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.