On runtime suspend, put device into stop power condition. For standard scsi device, no need to synchronize cache. For ata devices, issue synchronize cache before enter standby state as reflected by the sync_before_stop flag. Signed-off-by: Aaron Lu <aaron.lu@xxxxxxxxx> --- drivers/ata/libata-scsi.c | 1 + drivers/scsi/sd.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 8ec81ca..9307f52 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -1117,6 +1117,7 @@ static int ata_scsi_dev_config(struct scsi_device *sdev, } else { sdev->sector_size = ata_id_logical_sector_size(dev->id); sdev->manage_start_stop = 1; + sdev->sync_before_stop = 1; } /* diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 4df73e5..7b0f07a 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2866,18 +2866,24 @@ static int sd_suspend(struct device *dev, pm_message_t mesg) { struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); int ret = 0; + bool sync; if (!sdkp) return 0; /* this can happen */ - if (sdkp->WCE) { + if (!sdkp->device->manage_start_stop) + sync = !!sdkp->WCE; + else + sync = sdkp->device->sync_before_stop && !!sdkp->WCE; + + if (sync) { sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); ret = sd_sync_cache(sdkp); if (ret) goto done; } - if ((mesg.event & PM_EVENT_SLEEP) && sdkp->device->manage_start_stop) { + if (sdkp->device->manage_start_stop) { sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); ret = sd_start_stop_device(sdkp, 0); } -- 1.7.12.21.g871e293 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html