Skip to contentSkip to conversation

scsi: pm: resume device if suspend failed

RFC PATCH Superseded Aaron Lu 2 participants 2 messages May 11, 2012 SCSI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Aaron Lu

author
#0 lore raw

RFC PATCH 1/1 scsi: pm: resume device if suspend failed

For scsi devices which use scsi bus runtime callback, runtime suspend will call scsi_dev_type_suspend, and if the drv->suspend failed, the device will still be in active state. But since scsi_device_quiesce is called, the device will not be able to respond any more commands. So add a check here to see if err occured, if so, bring the device back to normal state with scsi_device_resume.

---
 drivers/scsi/scsi_pm.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/scsi_pm.c +4 -1
index c467064..33b8bf9 100644
@@ -24,8 +24,11 @@ static int scsi_dev_type_suspend(struct device *dev, pm_message_t msg)
 	err = scsi_device_quiesce(to_scsi_device(dev));
 	if (err == 0) {
 		drv = dev->driver;
-		if (drv && drv->suspend)
+		if (drv && drv->suspend) {
 			err = drv->suspend(dev, msg);
+			if (err)
+				scsi_device_resume(dev);
+		}
 	}
 	dev_dbg(dev, "scsi suspend: %d\n", err);
 	return err;
Signature · 1 line
1.7.9.6
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Aaron Lu

For scsi devices which use scsi bus runtime callback, runtime suspend will call scsi_dev_type_suspend, and if the drv->suspend failed, the device will still be in active state. But since scsi_device_quiesce is called, the device will not be able to respond any more commands. So add a check here to see if err occured, if so, bring the device back to normal state with scsi_device_resume.

Good catch.

Quoted 21 lines
---
 drivers/scsi/scsi_pm.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/scsi_pm.c +4 -1
index c467064..33b8bf9 100644
@@ -24,8 +24,11 @@ static int scsi_dev_type_suspend(struct device *dev, pm_message_t msg)
 	err = scsi_device_quiesce(to_scsi_device(dev));
 	if (err == 0) {
 		drv = dev->driver;
-		if (drv && drv->suspend)
+		if (drv && drv->suspend) {
 			err = drv->suspend(dev, msg);
+			if (err)
+				scsi_device_resume(dev);
+		}
 	}
 	dev_dbg(dev, "scsi suspend: %d\n", err);
 	return err;