From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Lu Subject: [PATCH v4 1/5] sd: put to stopped power state when runtime suspend Date: Fri, 9 Nov 2012 15:27:51 +0800 Message-ID: <1352446075-1814-2-git-send-email-aaron.lu@intel.com> References: <1352446075-1814-1-git-send-email-aaron.lu@intel.com> Return-path: Received: from mga11.intel.com ([192.55.52.93]:34949 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750793Ab2KIH2R (ORCPT ); Fri, 9 Nov 2012 02:28:17 -0500 In-Reply-To: <1352446075-1814-1-git-send-email-aaron.lu@intel.com> Sender: linux-pm-owner@vger.kernel.org List-Id: linux-pm@vger.kernel.org To: James Bottomley Cc: Alan Stern , "Rafael J. Wysocki" , linux-pm@vger.kernel.org, linux-scsi@vger.kernel.org, Aaron Lu , Aaron Lu 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 Acked-by: Alan Stern Acked-by: Rafael J. Wysocki --- drivers/scsi/sd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 12f6fdf..8b6e004 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2911,7 +2911,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); } -- 1.7.12.21.g871e293