Skip to content

Commit

Permalink
PCI / PM: Block races between runtime PM and system sleep
Browse files Browse the repository at this point in the history
After commit e866500
(PM: Allow pm_runtime_suspend() to succeed during system suspend) it
is possible that a device resumed by the pm_runtime_resume(dev) in
pci_pm_prepare() will be suspended immediately from a work item,
timer function or otherwise, defeating the very purpose of calling
pm_runtime_resume(dev) from there.  To prevent that from happening
it is necessary to increment the runtime PM usage counter of the
device by replacing pm_runtime_resume() with pm_runtime_get_sync().
Moreover, the incremented runtime PM usage counter has to be
decremented by the corresponding pci_pm_complete(), via
pm_runtime_put_sync().

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: stable@kernel.org
Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
  • Loading branch information
Rafael J. Wysocki committed Jun 21, 2011
1 parent ca9c689 commit a5f76d5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/pci/pci-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ static int pci_pm_prepare(struct device *dev)
* system from the sleep state, we'll have to prevent it from signaling
* wake-up.
*/
pm_runtime_resume(dev);
pm_runtime_get_sync(dev);

if (drv && drv->pm && drv->pm->prepare)
error = drv->pm->prepare(dev);
Expand All @@ -638,6 +638,8 @@ static void pci_pm_complete(struct device *dev)

if (drv && drv->pm && drv->pm->complete)
drv->pm->complete(dev);

pm_runtime_put_sync(dev);
}

#else /* !CONFIG_PM_SLEEP */
Expand Down

0 comments on commit a5f76d5

Please sign in to comment.