diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index bdbf8a94b4d0..f60c91cb2b3e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2433,7 +2433,6 @@ static void pci_pme_list_scan(struct work_struct *work) if (pdev->pme_poll) { struct pci_dev *bridge = pdev->bus->self; struct device *dev = &pdev->dev; - int pm_status; /* * If bridge is in low power state, the @@ -2444,18 +2443,17 @@ static void pci_pme_list_scan(struct work_struct *work) continue; /* - * If the device is in a low power state it - * should not be polled either. + * Acquire a reference to runtime power management + * use counter and flush pending requests to avoid + * races against transition to D3cold. */ - pm_status = pm_runtime_get_if_active(dev, true); - if (!pm_status) - continue; + pm_runtime_get_noresume(dev); + pm_runtime_barrier(dev); if (pdev->current_state != PCI_D3cold) pci_pme_wakeup(pdev, NULL); - if (pm_status > 0) - pm_runtime_put(dev); + pm_runtime_put(dev); } else { list_del(&pme_dev->list); kfree(pme_dev);