@@ -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;
}
/*
@@ -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);
}
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@intel.com> --- drivers/ata/libata-scsi.c | 1 + drivers/scsi/sd.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)