PCI / PM: Block races between runtime PM and system sleep
commitd1657494cad496bf8e45cad7c236236c4a1a5a0d
authorRafael J. Wysocki <rjw@sisk.pl>
Tue, 21 Jun 2011 21:47:15 +0000 (21 23:47 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 9 Jul 2011 06:15:25 +0000 (8 23:15 -0700)
tree442e6fb907218c64e82d7c8ce7081b1d643b9da4
parent01251271a43e01b1fbdffcb92136304f6650993e
PCI / PM: Block races between runtime PM and system sleep

commit a5f76d5eba157bf637beb2dd18026db2917c512e upstream.

After commit e8665002477f0278f84f898145b1f141ba26ee26
(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>
Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/pci/pci-driver.c