public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Linux PCI <linux-pci@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: Re: [PATCH] PCI: PM: Fix ordering of operations in pci_back_from_sleep()
Date: Wed, 20 Oct 2021 20:00:41 -0500	[thread overview]
Message-ID: <20211021010041.GA2655223@bhelgaas> (raw)
In-Reply-To: <11844217.O9o76ZdvQC@kreacher>

On Fri, Oct 15, 2021 at 06:45:59PM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> The ordering of operations in pci_back_from_sleep() is incorrect,
> because the device may be in D3cold when it runs and pci_enable_wake()
> needs to access the device's configuration space which cannot be
> done in D3cold.
> 
> Fix this by calling pci_set_power_state() to put the device into D0
> before calling pci_enable_wake() for it.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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

Thanks!

> ---
>  drivers/pci/pci.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> Index: linux-pm/drivers/pci/pci.c
> ===================================================================
> --- linux-pm.orig/drivers/pci/pci.c
> +++ linux-pm/drivers/pci/pci.c
> @@ -2638,8 +2638,13 @@ EXPORT_SYMBOL(pci_prepare_to_sleep);
>   */
>  int pci_back_from_sleep(struct pci_dev *dev)
>  {
> +	int ret = pci_set_power_state(dev, PCI_D0);
> +
> +	if (ret)
> +		return ret;
> +
>  	pci_enable_wake(dev, PCI_D0, false);
> -	return pci_set_power_state(dev, PCI_D0);
> +	return 0;
>  }
>  EXPORT_SYMBOL(pci_back_from_sleep);
>  
> 
> 
> 

      parent reply	other threads:[~2021-10-21  1:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 16:45 [PATCH] PCI: PM: Fix ordering of operations in pci_back_from_sleep() Rafael J. Wysocki
2021-10-20 14:24 ` Rafael J. Wysocki
2021-10-21  1:00 ` Bjorn Helgaas [this message]

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=20211021010041.GA2655223@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox