Skip to content

Commit 4d4c10f

Browse files
superm1bjorn-helgaas
authored andcommitted
PCI: Explicitly put devices into D0 when initializing
AMD BIOS team has root caused an issue that NVMe storage failed to come back from suspend to a lack of a call to _REG when NVMe device was probed. 112a7f9 ("PCI/ACPI: Call _REG when transitioning D-states") added support for calling _REG when transitioning D-states, but this only works if the device actually "transitions" D-states. 967577b ("PCI/PM: Keep runtime PM enabled for unbound PCI devices") added support for runtime PM on PCI devices, but never actually 'explicitly' sets the device to D0. To make sure that devices are in D0 and that platform methods such as _REG are called, explicitly set all devices into D0 during initialization. Fixes: 967577b ("PCI/PM: Keep runtime PM enabled for unbound PCI devices") Signed-off-by: Mario Limonciello <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Denis Benato <[email protected]> Tested-By: Yijun Shen <[email protected]> Tested-By: David Perry <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 0a0829b commit 4d4c10f

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

drivers/pci/pci-driver.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,12 +555,6 @@ static void pci_pm_default_resume(struct pci_dev *pci_dev)
555555
pci_enable_wake(pci_dev, PCI_D0, false);
556556
}
557557

558-
static void pci_pm_power_up_and_verify_state(struct pci_dev *pci_dev)
559-
{
560-
pci_power_up(pci_dev);
561-
pci_update_current_state(pci_dev, PCI_D0);
562-
}
563-
564558
static void pci_pm_default_resume_early(struct pci_dev *pci_dev)
565559
{
566560
pci_pm_power_up_and_verify_state(pci_dev);

drivers/pci/pci.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,6 +3192,12 @@ void pci_d3cold_disable(struct pci_dev *dev)
31923192
}
31933193
EXPORT_SYMBOL_GPL(pci_d3cold_disable);
31943194

3195+
void pci_pm_power_up_and_verify_state(struct pci_dev *pci_dev)
3196+
{
3197+
pci_power_up(pci_dev);
3198+
pci_update_current_state(pci_dev, PCI_D0);
3199+
}
3200+
31953201
/**
31963202
* pci_pm_init - Initialize PM functions of given PCI device
31973203
* @dev: PCI device to handle.
@@ -3202,9 +3208,6 @@ void pci_pm_init(struct pci_dev *dev)
32023208
u16 status;
32033209
u16 pmc;
32043210

3205-
pm_runtime_forbid(&dev->dev);
3206-
pm_runtime_set_active(&dev->dev);
3207-
pm_runtime_enable(&dev->dev);
32083211
device_enable_async_suspend(&dev->dev);
32093212
dev->wakeup_prepared = false;
32103213

@@ -3266,6 +3269,10 @@ void pci_pm_init(struct pci_dev *dev)
32663269
pci_read_config_word(dev, PCI_STATUS, &status);
32673270
if (status & PCI_STATUS_IMM_READY)
32683271
dev->imm_ready = 1;
3272+
pci_pm_power_up_and_verify_state(dev);
3273+
pm_runtime_forbid(&dev->dev);
3274+
pm_runtime_set_active(&dev->dev);
3275+
pm_runtime_enable(&dev->dev);
32693276
}
32703277

32713278
static unsigned long pci_ea_flags(struct pci_dev *dev, u8 prop)

drivers/pci/pci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ void pci_dev_adjust_pme(struct pci_dev *dev);
148148
void pci_dev_complete_resume(struct pci_dev *pci_dev);
149149
void pci_config_pm_runtime_get(struct pci_dev *dev);
150150
void pci_config_pm_runtime_put(struct pci_dev *dev);
151+
void pci_pm_power_up_and_verify_state(struct pci_dev *pci_dev);
151152
void pci_pm_init(struct pci_dev *dev);
152153
void pci_ea_init(struct pci_dev *dev);
153154
void pci_msi_init(struct pci_dev *dev);

0 commit comments

Comments
 (0)