Skip to contentSkip to conversation

PCI: Set up runtime PM on devices that don't support PCI PM

PATCH Superseded Mario Limonciello 2 participants 2 messages Jun 11, 2025 PCI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: Set up runtime PM on devices that don't support PCI PM

From: Mario Limonciello <[email protected]>

commit 4d4c10f763d7 ("PCI: Explicitly put devices into D0 when initializing") intended to put PCI devices into D0, but in doing so unintentionally changed runtime PM initialization not to occur on devices that don't support PCI PM. This caused a regression in vfio-pci due to an imbalance with it's use.

Adjust the logic in pci_pm_init() so that even if PCI PM isn't supported runtime PM is still initialized.

---
 drivers/pci/pci.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pci/pci.c +5 -2
index 3dd44d1ad829b..c495c3c692f5f 100644
@@ -3221,15 +3221,17 @@ void pci_pm_init(struct pci_dev *dev)
 
 	/* find PCI PM capability in list */
 	pm = pci_find_capability(dev, PCI_CAP_ID_PM);
-	if (!pm)
+	if (!pm) {
+		goto poweron;
 		return;
+	}
 	/* Check device's ability to generate PME# */
 	pci_read_config_word(dev, pm + PCI_PM_PMC, &pmc);
 
 	if ((pmc & PCI_PM_CAP_VER_MASK) > 3) {
 		pci_err(dev, "unsupported PM cap regs version (%u)\n",
 			pmc & PCI_PM_CAP_VER_MASK);
-		return;
+		goto poweron;
 	}
 
 	dev->pm_cap = pm;
@@ -3274,6 +3276,7 @@ void pci_pm_init(struct pci_dev *dev)
 	pci_read_config_word(dev, PCI_STATUS, &status);
 	if (status & PCI_STATUS_IMM_READY)
 		dev->imm_ready = 1;
+poweron:
 	pci_pm_power_up_and_verify_state(dev);
 	pm_runtime_forbid(&dev->dev);
 	pm_runtime_set_active(&dev->dev);
Signature · 1 line
2.43.0
#1 lore raw
Quoted 28 lines · On Wed, 11 Jun 2025 17:28:28 -0500 Mario Limonciello <[email protected]> wrote:

From: Mario Limonciello <[email protected]>

commit 4d4c10f763d7 ("PCI: Explicitly put devices into D0 when initializing") intended to put PCI devices into D0, but in doing so unintentionally changed runtime PM initialization not to occur on devices that don't support PCI PM. This caused a regression in vfio-pci due to an imbalance with it's use.

Adjust the logic in pci_pm_init() so that even if PCI PM isn't supported runtime PM is still initialized.

---
 drivers/pci/pci.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pci/pci.c +0 -0
index 3dd44d1ad829b..c495c3c692f5f 100644

drivers/pci/pci.c void pci_pm_init(struct pci_dev *dev) · line 3226

Quoted 7 lines
drivers/pci/pci.c +2 -1
@@ -3221,15 +3221,17 @@ void pci_pm_init(struct pci_dev *dev)
 
 	/* find PCI PM capability in list */
 	pm = pci_find_capability(dev, PCI_CAP_ID_PM);
-	if (!pm)
+	if (!pm) {
+		goto poweron;
 		return;

Unreachable return. Thanks,

Alex

Quoted 20 lines
drivers/pci/pci.c +3 -1
+	}
 	/* Check device's ability to generate PME# */
 	pci_read_config_word(dev, pm + PCI_PM_PMC, &pmc);
 
 	if ((pmc & PCI_PM_CAP_VER_MASK) > 3) {
 		pci_err(dev, "unsupported PM cap regs version (%u)\n",
 			pmc & PCI_PM_CAP_VER_MASK);
-		return;
+		goto poweron;
 	}
 
 	dev->pm_cap = pm;
@@ -3274,6 +3276,7 @@ void pci_pm_init(struct pci_dev *dev)
 	pci_read_config_word(dev, PCI_STATUS, &status);
 	if (status & PCI_STATUS_IMM_READY)
 		dev->imm_ready = 1;
+poweron:
 	pci_pm_power_up_and_verify_state(dev);
 	pm_runtime_forbid(&dev->dev);
 	pm_runtime_set_active(&dev->dev);