@@ -13,6 +13,7 @@
#include <linux/ioport.h>
#include <linux/proc_fs.h>
#include <linux/slab.h>
+#include <linux/pm_runtime.h>
#include "pci.h"
@@ -335,9 +336,12 @@ void pci_bus_add_device(struct pci_dev *dev)
int retval;
/*
- * Can not put in pci_device_add yet because resources
- * are not assigned yet for some devices.
+ * Enable runtime PM only here, since otherwise we may
+ * try to suspend a device that isn't fully configured
+ * yet, which causes problems.
*/
+ pm_runtime_enable(&dev->dev);
+
pcibios_bus_add_device(dev);
pci_fixup_device(pci_fixup_final, dev);
pci_create_sysfs_dev_files(dev);
@@ -1278,6 +1278,9 @@ static int pci_pm_runtime_suspend(struct device *dev)
pci_power_t prev = pci_dev->current_state;
int error;
+ if (WARN_ON(!pci_dev_is_added(pci_dev)))
+ return -EBUSY;
+
pci_suspend_ptm(pci_dev);
/*
@@ -3140,7 +3140,6 @@ void pci_pm_init(struct pci_dev *dev)
pm_runtime_forbid(&dev->dev);
pm_runtime_set_active(&dev->dev);
- pm_runtime_enable(&dev->dev);
device_enable_async_suspend(&dev->dev);
dev->wakeup_prepared = false;