Skip to contentSkip to conversation

PCI: PM: Power up all devices during runtime resume

PATCH Superseded Rafael J. Wysocki 4 participants 6 messages Apr 6, 2022 – Apr 8, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: PM: Power up all devices during runtime resume

From: Rafael J. Wysocki <[email protected]>

Currently, endpoint devices may not be powered up entirely during runtime resume that follows a D3hot -> D0 transition of the parent bridge.

Namely, even if the power state of an endpoint device, as indicated by its PCI_PM_CTRL register, is D0 after powering up its parent bridge, it may be still necessary to bring its ACPI companion into D0 and that should be done before accessing it. However, the current code assumes that reading the PCI_PM_CTRL register is sufficient to establish the endpoint device's power state, which may lead to problems.

Address that by forcing a power-up of all PCI devices, including the platform firmware part of it, during runtime resume.

Fixes 5775b843a619 ("PCI: Restore config space on runtime resume despite being unbound")
---
 drivers/pci/pci-driver.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-driver.c +1 -1
Index: linux-pm/drivers/pci/pci-driver.c
===================================================================
@@ -1312,7 +1312,7 @@ static int pci_pm_runtime_resume(struct
 	 * to a driver because although we left it in D0, it may have gone to
 	 * D3cold when the bridge above it runtime suspended.
 	 */
-	pci_restore_standard_config(pci_dev);
+	pci_pm_default_resume_early(pci_dev);
 
 	if (!pci_dev->driver)
 		return 0;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Currently, endpoint devices may not be powered up entirely during runtime resume that follows a D3hot -> D0 transition of the parent bridge.

Namely, even if the power state of an endpoint device, as indicated by its PCI_PM_CTRL register, is D0 after powering up its parent bridge, it may be still necessary to bring its ACPI companion into D0 and that should be done before accessing it. However, the current code assumes that reading the PCI_PM_CTRL register is sufficient to establish the endpoint device's power state, which may lead to problems.

Quoted 8 lines

Address that by forcing a power-up of all PCI devices, including the platform firmware part of it, during runtime resume.

Fixes 5775b843a619 ("PCI: Restore config space on runtime resume despite being unbound")
#2 lore raw
In reply to Rafael J. Wysocki
Quoted 14 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Currently, endpoint devices may not be powered up entirely during runtime resume that follows a D3hot -> D0 transition of the parent bridge.

Namely, even if the power state of an endpoint device, as indicated by its PCI_PM_CTRL register, is D0 after powering up its parent bridge, it may be still necessary to bring its ACPI companion into D0 and that should be done before accessing it. However, the current code assumes that reading the PCI_PM_CTRL register is sufficient to establish the endpoint device's power state, which may lead to problems.

Quoted 8 lines

Address that by forcing a power-up of all PCI devices, including the platform firmware part of it, during runtime resume.

Fixes 5775b843a619 ("PCI: Restore config space on runtime resume despite being unbound")

Applied with Mika's reviewed-by to pci/pm for v5.19, thanks!

Quoted 20 lines
---
 drivers/pci/pci-driver.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-pm/drivers/pci/pci-driver.c
===================================================================

drivers/pci/pci-driver.c +1 -1
@@ -1312,7 +1312,7 @@ static int pci_pm_runtime_resume(struct
 	 * to a driver because although we left it in D0, it may have gone to
 	 * D3cold when the bridge above it runtime suspended.
 	 */
-	pci_restore_standard_config(pci_dev);
+	pci_pm_default_resume_early(pci_dev);
 
 	if (!pci_dev->driver)
 		return 0;
#3 lore raw
Quoted 19 lines · Bjorn Helgaas
Quoted 17 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Currently, endpoint devices may not be powered up entirely during runtime resume that follows a D3hot -> D0 transition of the parent bridge.

Namely, even if the power state of an endpoint device, as indicated by its PCI_PM_CTRL register, is D0 after powering up its parent bridge, it may be still necessary to bring its ACPI companion into D0 and that should be done before accessing it. However, the current code assumes that reading the PCI_PM_CTRL register is sufficient to establish the endpoint device's power state, which may lead to problems.

Address that by forcing a power-up of all PCI devices, including the platform firmware part of it, during runtime resume.

Quoted 7 lines
Quoted 5 lines
Fixes 5775b843a619 ("PCI: Restore config space on runtime resume despite being unbound")

Applied with Mika's reviewed-by to pci/pm for v5.19, thanks!

This doesn't compile when CONFIG_PM_SLEEP in uset, sorry about this.

I'll send a v2, but if you prefer an incremental fix, please let me know.

Quoted 21 lines
Quoted 21 lines
---
 drivers/pci/pci-driver.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-pm/drivers/pci/pci-driver.c
===================================================================

drivers/pci/pci-driver.c +1 -1
@@ -1312,7 +1312,7 @@ static int pci_pm_runtime_resume(struct
       * to a driver because although we left it in D0, it may have gone to
       * D3cold when the bridge above it runtime suspended.
       */
-     pci_restore_standard_config(pci_dev);
+     pci_pm_default_resume_early(pci_dev);
 
      if (!pci_dev->driver)
              return 0;
#4 lore raw

PATCH v2 1/1 PCI: PM: Power up all devices during runtime resume

In reply to Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>
Subject: [PATCH] PCI: PM: Power up all devices during runtime resume

Currently, endpoint devices may not be powered up entirely during runtime resume that follows a D3hot -> D0 transition of the parent bridge.

Namely, even if the power state of an endpoint device, as indicated by its PCI_PM_CTRL register, is D0 after powering up its parent bridge, it may be still necessary to bring its ACPI companion into D0 and that should be done before accessing it. However, the current code assumes that reading the PCI_PM_CTRL register is sufficient to establish the endpoint device's power state, which may lead to problems.

Address that by forcing a power-up of all PCI devices, including the platform firmware part of it, during runtime resume.

Fixes 5775b843a619 ("PCI: Restore config space on runtime resume despite being unbound")

---

v1 -> v2:
* Move pci_pm_default_resume_early() away from #ifdef CONFIG_PM_SLEEP.
* Add R-by from Mika.

---
 drivers/pci/pci-driver.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/pci/pci-driver.c +5 -5
Index: linux-pm/drivers/pci/pci-driver.c
===================================================================
@@ -551,10 +551,6 @@ static void pci_pm_default_resume(struct
 	pci_enable_wake(pci_dev, PCI_D0, false);
 }
 
-#endif
-
-#ifdef CONFIG_PM_SLEEP
-
 static void pci_pm_default_resume_early(struct pci_dev *pci_dev)
 {
 	pci_power_up(pci_dev);
@@ -563,6 +559,10 @@ static void pci_pm_default_resume_early(
 	pci_pme_restore(pci_dev);
 }
 
+#endif
+
+#ifdef CONFIG_PM_SLEEP
+
 /*
  * Default "suspend" method for devices that have no driver provided suspend,
  * or not even a driver at all (second part).
@@ -1312,7 +1312,7 @@ static int pci_pm_runtime_resume(struct
 	 * to a driver because although we left it in D0, it may have gone to
 	 * D3cold when the bridge above it runtime suspended.
 	 */
-	pci_restore_standard_config(pci_dev);
+	pci_pm_default_resume_early(pci_dev);
 
 	if (!pci_dev->driver)
 		return 0;
#5 lore raw
Quoted 18 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>
Subject: [PATCH] PCI: PM: Power up all devices during runtime resume

Currently, endpoint devices may not be powered up entirely during runtime resume that follows a D3hot -> D0 transition of the parent bridge.

Namely, even if the power state of an endpoint device, as indicated by its PCI_PM_CTRL register, is D0 after powering up its parent bridge, it may be still necessary to bring its ACPI companion into D0 and that should be done before accessing it. However, the current code assumes that reading the PCI_PM_CTRL register is sufficient to establish the endpoint device's power state, which may lead to problems.

Address that by forcing a power-up of all PCI devices, including the platform firmware part of it, during runtime resume.

Quoted 6 lines
Fixes 5775b843a619 ("PCI: Restore config space on runtime resume despite being unbound")

I replaced the v1 patch with this one on pci/pm, thanks!

Quoted 48 lines

---

v1 -> v2:
* Move pci_pm_default_resume_early() away from #ifdef CONFIG_PM_SLEEP.
* Add R-by from Mika.

---
 drivers/pci/pci-driver.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Index: linux-pm/drivers/pci/pci-driver.c
===================================================================

drivers/pci/pci-driver.c +5 -5
@@ -551,10 +551,6 @@ static void pci_pm_default_resume(struct
 	pci_enable_wake(pci_dev, PCI_D0, false);
 }
 
-#endif
-
-#ifdef CONFIG_PM_SLEEP
-
 static void pci_pm_default_resume_early(struct pci_dev *pci_dev)
 {
 	pci_power_up(pci_dev);
@@ -563,6 +559,10 @@ static void pci_pm_default_resume_early(
 	pci_pme_restore(pci_dev);
 }
 
+#endif
+
+#ifdef CONFIG_PM_SLEEP
+
 /*
  * Default "suspend" method for devices that have no driver provided suspend,
  * or not even a driver at all (second part).
@@ -1312,7 +1312,7 @@ static int pci_pm_runtime_resume(struct
 	 * to a driver because although we left it in D0, it may have gone to
 	 * D3cold when the bridge above it runtime suspended.
 	 */
-	pci_restore_standard_config(pci_dev);
+	pci_pm_default_resume_early(pci_dev);
 
 	if (!pci_dev->driver)
 		return 0;