Message ID | 1349854086-2502-3-git-send-email-aaron.lu@intel.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
On Wed, 10 Oct 2012, Aaron Lu wrote: > Update sd driver to use the callbacks defined in dev_pm_ops. > > sd_freeze is NULL, the bus level callback has taken care of quiescing > the device so there should be nothing needs to be done here. > Consequently, sd_thaw is not needed here either. > > Both suspend and poweroff shares the same routine sd_suspend, which will > sync flush and then stop the drive, this is the same as before. > > sd_runtime_suspend also uses sd_suspend, so when a scsi disk is runtime > suspended, it will be placed to stopped power state. This is not the same as before. The existing code does not spin down the disk during runtime suspend. Now maybe it should -- I don't know. The point is that this patch makes two separate changes, which is generally not a good idea. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Oct 10, 2012 at 02:35:47PM -0400, Alan Stern wrote: > On Wed, 10 Oct 2012, Aaron Lu wrote: > > > Update sd driver to use the callbacks defined in dev_pm_ops. > > > > sd_freeze is NULL, the bus level callback has taken care of quiescing > > the device so there should be nothing needs to be done here. > > Consequently, sd_thaw is not needed here either. > > > > Both suspend and poweroff shares the same routine sd_suspend, which will > > sync flush and then stop the drive, this is the same as before. > > > > sd_runtime_suspend also uses sd_suspend, so when a scsi disk is runtime > > suspended, it will be placed to stopped power state. > > This is not the same as before. The existing code does not spin down > the disk during runtime suspend. > > Now maybe it should -- I don't know. The point is that this patch > makes two separate changes, which is generally not a good idea. Agree. Will seperate, thanks. -Aaron -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 12f6fdf..09ab14a 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -104,7 +104,7 @@ static void sd_unlock_native_capacity(struct gendisk *disk); static int sd_probe(struct device *); static int sd_remove(struct device *); static void sd_shutdown(struct device *); -static int sd_suspend(struct device *, pm_message_t state); +static int sd_suspend(struct device *); static int sd_resume(struct device *); static void sd_rescan(struct device *); static int sd_done(struct scsi_cmnd *); @@ -423,15 +423,23 @@ static struct class sd_disk_class = { .dev_attrs = sd_disk_attrs, }; +static struct dev_pm_ops sd_pm_ops = { + .suspend = sd_suspend, + .resume = sd_resume, + .poweroff = sd_suspend, + .restore = sd_resume, + .runtime_suspend = sd_suspend, + .runtime_resume = sd_resume, +}; + static struct scsi_driver sd_template = { .owner = THIS_MODULE, .gendrv = { .name = "sd", .probe = sd_probe, .remove = sd_remove, - .suspend = sd_suspend, - .resume = sd_resume, .shutdown = sd_shutdown, + .pm = &sd_pm_ops, }, .rescan = sd_rescan, .done = sd_done, @@ -2896,7 +2904,7 @@ exit: scsi_disk_put(sdkp); } -static int sd_suspend(struct device *dev, pm_message_t mesg) +static int sd_suspend(struct device *dev) { struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); int ret = 0; @@ -2911,7 +2919,7 @@ static int sd_suspend(struct device *dev, pm_message_t mesg) 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); }
Update sd driver to use the callbacks defined in dev_pm_ops. sd_freeze is NULL, the bus level callback has taken care of quiescing the device so there should be nothing needs to be done here. Consequently, sd_thaw is not needed here either. Both suspend and poweroff shares the same routine sd_suspend, which will sync flush and then stop the drive, this is the same as before. sd_runtime_suspend also uses sd_suspend, so when a scsi disk is runtime suspended, it will be placed to stopped power state. Signed-off-by: Aaron Lu <aaron.lu@intel.com> --- drivers/scsi/sd.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)