PCI PM: Read device power state from register after updating it
authorRafael J. Wysocki <rjw@sisk.pl>
Sun, 4 Oct 2009 22:48:40 +0000 (00:48 +0200)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Tue, 6 Oct 2009 17:27:51 +0000 (10:27 -0700)
commite13cdbd71fe12c4e191b737c4a3dbfdb4b2de03b
treeb46e5213273a569becbcf94cd3f4a60daab026f7
parentb812cca4e2efe9a05de20ccf3f8587e7ac6e12fa
PCI PM: Read device power state from register after updating it

After attempting to change the power state of a PCI device
pci_raw_set_power_state() doesn't check if the value it wrote into
the device's PCI_PM_CTRL register has been stored in there, but
unconditionally modifies the device's current_state field to reflect
the change.  This may cause problems to happen if the power state of
the device hasn't been changed in fact, because it will make the PCI
PM core make a wrong assumption.

To prevent such situations from happening modify
pci_raw_set_power_state() so that it reads the device's PCI_PM_CTRL
register after writing into it and uses the value read from the
register to update the device's current_state field.  Also make it
print a message saying that the device refused to change its power
state as requested (returning an error code in such cases would cause
suspend regressions to appear on some systems, where device drivers'
suspend routines return error codes if pci_set_power_state() fails).

Reviewed-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/pci/pci.c