All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aaron Lu <aaron.lu@intel.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	linux-scsi@vger.kernel.org, linux-pm@vger.kernel.org,
	Aaron Lu <aaron.lwe@gmail.com>
Subject: Re: [PATCH v2 1/5] sd: put to stopped power state when runtime suspend
Date: Fri, 12 Oct 2012 14:45:20 +0800	[thread overview]
Message-ID: <20121012064518.GA2165@mint-spring.sh.intel.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1210111039510.1170-100000@iolanthe.rowland.org>

On Thu, Oct 11, 2012 at 10:50:37AM -0400, Alan Stern wrote:
> On Thu, 11 Oct 2012, Aaron Lu wrote:
> 
> > 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>
> > ---
> >  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) {
> 
> This is more complicated than it needs to be.  Any suspend is either a
> system sleep or an autosuspend, so the test doesn't have to be there at

There is also the freeze case, in which no need to stop the drive.

> all.  But since you remove the test anyway in patch 5/5, this doesn't
> matter very much.  If you end up resubmitting these patches, you might
> as well get rid of the test in this one.
> 
> Overall this series is much better than before; thanks for rewriting 
> it.

Thanks for your suggestion which made the patch a lot better :-)

-Aaron


  reply	other threads:[~2012-10-12  6:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-11  5:08 [PATCH v2 0/5] Migrate SCSI drivers to use dev_pm_ops Aaron Lu
2012-10-11  5:08 ` [PATCH v2 1/5] sd: put to stopped power state when runtime suspend Aaron Lu
2012-10-11 14:50   ` Alan Stern
2012-10-12  6:45     ` Aaron Lu [this message]
2012-10-11  5:08 ` [PATCH v2 2/5] Revert "[SCSI] scsi_pm: set device runtime state before parent suspended" Aaron Lu
2012-10-11  5:08 ` [PATCH v2 3/5] Revert "[SCSI] runtime resume parent for child's system-resume" Aaron Lu
2012-10-11  5:08 ` [PATCH v2 4/5] pm: use callbacks from dev_pm_ops for scsi devices Aaron Lu
2012-10-11 14:57   ` Alan Stern
2012-10-12  6:48     ` Aaron Lu
2012-10-11  5:08 ` [PATCH v2 5/5] sd: update sd to use the new pm callbacks Aaron Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121012064518.GA2165@mint-spring.sh.intel.com \
    --to=aaron.lu@intel.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=aaron.lwe@gmail.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.