All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Linux PM mailing list <linux-pm@lists.linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Jesse Barnes <jbarnes@virtuousgeek.org>
Subject: Re: [PATCH] PCI / PM: Block races between runtime PM and system sleep
Date: Thu, 23 Jun 2011 23:16:56 +0200	[thread overview]
Message-ID: <201106232316.56769.rjw__42356.1072595932$1308868056$gmane$org@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1106231656340.2033-100000@iolanthe.rowland.org>

On Thursday, June 23, 2011, Alan Stern wrote:
> On Thu, 23 Jun 2011, Rafael J. Wysocki wrote:
> 
> > > > Index: linux-2.6/drivers/base/power/runtime.c
> > > > ===================================================================
> > > > --- linux-2.6.orig/drivers/base/power/runtime.c
> > > > +++ linux-2.6/drivers/base/power/runtime.c
> > > > @@ -455,12 +455,14 @@ static int rpm_resume(struct device *dev
> > > >  	dev_dbg(dev, "%s flags 0x%x\n", __func__, rpmflags);
> > > >  
> > > >   repeat:
> > > > -	if (dev->power.runtime_error)
> > > > +	if (dev->power.runtime_error) {
> > > >  		retval = -EINVAL;
> > > > -	else if (dev->power.disable_depth > 0)
> > > > -		retval = -EAGAIN;
> > > > -	if (retval)
> > > >  		goto out;
> > > > +	} else if (dev->power.disable_depth > 0) {
> > > > +		if (!(rpmflags & RPM_GET_PUT))
> > > > +			retval = -EAGAIN;
> > > 
> > > Do you also want to check the current status?  If it isn't RPM_ACTIVE 
> > > then perhaps you should return an error.
> > 
> > That depends on whether or not we want RPM_ACTIVE to have any meaning for
> > devices whose power.disable_depth is nonzero.  My opinion is that if
> > power.disable_depth is nonzero, the runtime PM status of the device
> > shouldn't matter (it may be changed on the fly in ways that need not
> > reflect the real status).
> 
> Then maybe this disable_depth > 0 case should return something other
> than 0.  Something new, like -EACCES.  That way the caller would
> realize something strange was going on but wouldn't have to treat the 
> situation as an error.

I would be fine with that, but then we'd need to reserve that error code,
so that it's not returned by subsystem callbacks (or even we should convert
it to a different error code if it is returned by the subsystem callback in
rpm_resume()). 

> After all, the return value from pm_runtime_get_sync() is documented to 
> be the error code for the underlying pm_runtime_resume().  It doesn't 
> refer to the increment operation -- that always succeeds.

That means we should change the caller, which is the SCSI subsystem in this
particular case, to check the error code.  The problem with this approach
is that the same error code may be returned in a different situation, so
we should prevent that from happening in the first place.  Still, suppose
that we do that and that the caller checks the error code.  What is it
supposed to do in that situation?  The only reasonable action for the
caller is to ignore the error code if it means disable_depth > 0 and go
on with whatever it has to do, but that's what it will do if the
pm_runtime_get_sync() returns 0 in that situation.

So, in my opinion it simply may be best to update the documentation of
pm_runtime_get_sync() along with the code changes. :-)

Thanks,
Rafael

  reply	other threads:[~2011-06-23 21:16 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-19 19:49 [PATCH] PCI / PM: Block races between runtime PM and system sleep Rafael J. Wysocki
2011-06-20 14:46 ` Alan Stern
2011-06-20 14:46 ` Alan Stern
2011-06-20 19:42   ` Rafael J. Wysocki
2011-06-20 19:42   ` Rafael J. Wysocki
2011-06-20 21:00     ` Alan Stern
2011-06-20 21:28       ` Rafael J. Wysocki
2011-06-20 21:28       ` Rafael J. Wysocki
2011-06-21 14:52         ` Alan Stern
2011-06-21 14:52         ` Alan Stern
2011-06-21 23:49           ` Rafael J. Wysocki
2011-06-21 23:49           ` Rafael J. Wysocki
2011-06-22 14:20             ` Alan Stern
2011-06-22 14:20             ` Alan Stern
2011-06-23 17:46               ` Rafael J. Wysocki
2011-06-23 17:46               ` Rafael J. Wysocki
2011-06-23 18:35                 ` Alan Stern
2011-06-23 20:49                   ` Rafael J. Wysocki
2011-06-23 20:49                   ` Rafael J. Wysocki
2011-06-23 21:02                     ` Alan Stern
2011-06-23 21:02                     ` Alan Stern
2011-06-23 21:16                       ` Rafael J. Wysocki [this message]
2011-06-23 21:16                       ` Rafael J. Wysocki
2011-06-23 21:38                         ` Alan Stern
2011-06-23 22:35                           ` Rafael J. Wysocki
2011-06-23 22:35                           ` Rafael J. Wysocki
2011-06-23 22:59                             ` Rafael J. Wysocki
2011-06-23 22:59                             ` Rafael J. Wysocki
2011-06-26  2:39                               ` Alan Stern
2011-06-26 12:22                                 ` Rafael J. Wysocki
2011-06-26 12:22                                   ` Rafael J. Wysocki
2011-06-26  2:39                               ` Alan Stern
2011-06-23 21:38                         ` Alan Stern
2011-06-23 18:35                 ` Alan Stern
2011-06-20 21:00     ` Alan Stern
2011-06-19 19:49 Rafael J. Wysocki

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='201106232316.56769.rjw__42356.1072595932$1308868056$gmane$org@sisk.pl' \
    --to=rjw@sisk.pl \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --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.