linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PCI <linux-pci@vger.kernel.org>
Cc: Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Bjorn Helgaas <helgaas@kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: [PATCH v1 2/2] PCI: PM: Resume bus after putting the bridge into D0 entirely
Date: Mon, 04 Apr 2022 17:42:27 +0200	[thread overview]
Message-ID: <1807986.atdPhlSkOF@kreacher> (raw)
In-Reply-To: <4198163.ejJDZkT8p0@kreacher>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

It is rather counter-intuitive to attempt to resume devices on a bus
segment before completing a transition of their parent bridge into
D0, so do that when the transition is complete.

This matters especially when the transition in question is not
successful, in which case it doesn't make sense to even try to
resume the child devices at all.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/pci/pci.c |   21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

Index: linux-pm/drivers/pci/pci.c
===================================================================
--- linux-pm.orig/drivers/pci/pci.c
+++ linux-pm/drivers/pci/pci.c
@@ -1310,15 +1310,24 @@ static int pci_dev_wait(struct pci_dev *
 int pci_power_up(struct pci_dev *dev)
 {
 	pci_power_t old_state = dev->current_state;
+	int ret;
 
 	pci_platform_power_transition(dev, PCI_D0);
+	/*
+	 * For transitions from D3hot or deeper (including unknown), force
+	 * PCI_PM_CTRL register write, D3*->D0 transition delay and BARS
+	 * restoration.
+	 */
+	if (old_state >= PCI_D3hot)
+		dev->current_state = PCI_D3hot;
 
+	ret = pci_raw_set_power_state(dev, PCI_D0);
 	/*
 	 * Mandatory power management transition delays are handled in
 	 * pci_pm_resume_noirq() and pci_pm_runtime_resume() of the
 	 * corresponding bridge.
 	 */
-	if (dev->runtime_d3cold) {
+	if (!ret && dev->runtime_d3cold) {
 		/*
 		 * When powering on a bridge from D3cold, the whole hierarchy
 		 * may be powered on into D0uninitialized state, resume them to
@@ -1327,15 +1336,7 @@ int pci_power_up(struct pci_dev *dev)
 		pci_resume_bus(dev->subordinate);
 	}
 
-	/*
-	 * For transitions from D3hot or deeper and initial power-up, force
-	 * PCI_PM_CTRL register write, D3*->D0 transition delay and BARS
-	 * restoration.
-	 */
-	if (old_state >= PCI_D3hot)
-		dev->current_state = PCI_D3hot;
-
-	return pci_raw_set_power_state(dev, PCI_D0);
+	return ret;
 }
 
 /**




  parent reply	other threads:[~2022-04-04 15:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04 15:38 [PATCH v1 0/2]: PCI: PM: Improvements related to D3cold -> D0 transitions Rafael J. Wysocki
2022-04-04 15:41 ` [PATCH v1 1/2] PCI: PM: Avoid leaving devices in D0-uninitialized in pci_power_up() Rafael J. Wysocki
2022-04-05  9:53   ` Mika Westerberg
2022-04-07 19:01     ` Rafael J. Wysocki
2022-04-08 12:43       ` Mika Westerberg
2022-04-04 15:42 ` Rafael J. Wysocki [this message]
2022-04-05  9:54   ` [PATCH v1 2/2] PCI: PM: Resume bus after putting the bridge into D0 entirely Mika Westerberg

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=1807986.atdPhlSkOF@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=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 \
    /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).