Patchwork [v2,2/7] scsi: pm: use autosuspend if device supports it

login
register
mail settings
Submitter Aaron Lu
Date July 24, 2012, 9:37 a.m.
Message ID <1343122665-18711-3-git-send-email-aaron.lu@amd.com>
Download mbox | patch
Permalink /patch/172814/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Aaron Lu - July 24, 2012, 9:37 a.m.
If the device is using autosuspend, when scsi_autopm_put_device is
called for it, use autosuspend runtime pm calls instead of the sync
call.

Signed-off-by: Aaron Lu <aaron.lu@amd.com>
---
 drivers/scsi/scsi_pm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch

diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
index d4201de..a002fbf 100644
--- a/drivers/scsi/scsi_pm.c
+++ b/drivers/scsi/scsi_pm.c
@@ -196,7 +196,12 @@  EXPORT_SYMBOL_GPL(scsi_autopm_get_device);
 
 void scsi_autopm_put_device(struct scsi_device *sdev)
 {
-	pm_runtime_put_sync(&sdev->sdev_gendev);
+	if (sdev->sdev_gendev.power.use_autosuspend) {
+		pm_runtime_mark_last_busy(&sdev->sdev_gendev);
+		pm_runtime_put_autosuspend(&sdev->sdev_gendev);
+	} else {
+		pm_runtime_put_sync(&sdev->sdev_gendev);
+	}
 }
 EXPORT_SYMBOL_GPL(scsi_autopm_put_device);