Skip to contentSkip to conversation

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

PATCH In review Mario Limonciello 5 participants 5 messages Jun 11, 2025 – Jun 13, 2025 PCI

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---
v2:
* remove pointless return

---
 drivers/pci/pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/pci.c +3 -2
index 3dd44d1ad829b..160a9a482c732 100644
@@ -3222,14 +3222,14 @@ 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)
-		return;
+		goto poweron;
 	/* 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 +3274,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
Reviewed-by on v2 1/1
#1 lore raw
Quoted 19 lines · Mario Limonciello

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.

Quoted 1 line

---

Looks fine to me.

Quoted 35 lines

v2:
* remove pointless return

---
  drivers/pci/pci.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/pci.c +3 -2
index 3dd44d1ad829b..160a9a482c732 100644
@@ -3222,14 +3222,14 @@ 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)
-		return;
+		goto poweron;
  	/* 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 +3274,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 · 2 lines
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
Tested-by on v2 1/1
#2 lore raw
In reply to Mario Limonciello

Le 12/06/2025 à 01:31, Mario Limonciello a écrit :

Quoted 11 lines

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.

Quoted 8 lines

Thanks for the quick fix!

Regards,
Nicolas

Acked-by on v2 1/1
#3 lore raw
In reply to Mario Limonciello
Quoted 12 lines · Mario Limonciello

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.

Quoted 8 lines
Quoted 39 lines

---
v2:
* remove pointless return

---
 drivers/pci/pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/pci.c +3 -3
index 3dd44d1ad829b..160a9a482c732 100644
@@ -3222,14 +3222,14 @@ 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)
-               return;
+               goto poweron;
        /* 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 +3274,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);
--

2.43.0

#4 lore raw
In reply to Mario Limonciello
Quoted 11 lines · Mario Limonciello

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.

Quoted 8 lines

4d4c10f763d7 appeared in v6.16-rc1, so I applied this to pci/for-linus for v6.16, thanks for the quick resolution!

Quoted 39 lines

---
v2:
* remove pointless return

---
 drivers/pci/pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/pci.c +3 -2
index 3dd44d1ad829b..160a9a482c732 100644
@@ -3222,14 +3222,14 @@ 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)
-		return;
+		goto poweron;
 	/* 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 +3274,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