]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[SCSI] sd: put to stopped power state when runtime suspend
authorAaron Lu <aaron.lu@intel.com>
Fri, 9 Nov 2012 07:27:51 +0000 (15:27 +0800)
committerJames Bottomley <JBottomley@Parallels.com>
Fri, 30 Nov 2012 09:22:09 +0000 (09:22 +0000)
When device is runtime suspended, put it to stopped power state to save
some power.

This will also make the behaviour consistent with what the scsi_pm.c
thinks about sd as the comment says:
sd treats runtime suspend, system suspend and system hibernate identical.
With this patch, it is now identical.
And sd_shutdown will also do nothing when it finds the device has been
runtime suspended, if we do not spin down the disk in runtime suspend
by putting it into stopped power state, the disk will be shut down
incorrectly.
And the the same problem can be solved for runtime power off after
runtime suspended case by this change.

With the current runtime scheme for disk, it will only be runtime
suspended when no process opens the disk, so this shouldn't happen a
lot, which makes it acceptable to spin down the disk when runtime
suspended. If some day a more aggressive runtime scheme is used, like
the 'request based runtime pm for disk' that Alan Stern and Lin Ming
has been working, we can introduce some policy to control this. But for
now, make it simple and correct by spinning down the disk.

Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/sd.c

index c5a189c50286d1c1537a842ffe6f403a49951295..b1195fd537b6fdb24cce9952ad9de4ccf98a1011 100644 (file)
@@ -3069,7 +3069,8 @@ 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 (((mesg.event & PM_EVENT_SLEEP) || PMSG_IS_AUTO(mesg)) &&
+                       sdkp->device->manage_start_stop) {
                sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
                ret = sd_start_stop_device(sdkp, 0);
        }