public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@deeprootsystems.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>, <linux-pm@vger.kernel.org>,
	<linux-omap@vger.kernel.org>,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	Grygorii Strashko <grygorii.strashko@ti.com>,
	Nishanth Menon <nm@ti.com>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RESEND] PM / Runtime: let rpm_resume() succeed if RPM_ACTIVE, even when disabled
Date: Fri, 21 Sep 2012 14:40:52 -0700	[thread overview]
Message-ID: <87vcf7dpgb.fsf@deeprootsystems.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1209211611020.1323-100000@iolanthe.rowland.org> (Alan Stern's message of "Fri, 21 Sep 2012 16:22:13 -0400 (EDT)")

Alan Stern <stern@rowland.harvard.edu> writes:

> On Fri, 21 Sep 2012, Rafael J. Wysocki wrote:
>
>> > Kevin makes a good case that pm_runtime_resume() and related functions 
>> > should succeed even when runtime PM is disabled, if the device is 
>> > already in the desired state.
>> > 
>> > The same may be true for pm_runtime_suspend().  What do you think?
>> 
>> I've discussed that with Kevin.  The problem is that the runtime PM
>> status may be changed at will when runtime PM is disabled by using
>> __pm_runtime_set_status(), so the status generally cannod be trusted
>> if power.disable_depth > 0.
>
> Hmmm.  That same argument applies even when is_suspended is true.  
> Runtime PM might have been disabled beforehand by the driver, so you 
> still don't know whether to believe the status.
>
>> During system suspend, however, runtime PM is disabled by the core and
>> if neither the driver nor the subsystem has disabled it in the meantime,
>> the status should be actually valid.
>
> I suppose you could check that .disable_depth == 1.  That would mean 
> only the core had disabled runtime PM.
>
>> > The way the patch is written contradicts the documentation:
>> > 
>> >   * A request to execute ->runtime_resume() will cancel any pending or
>> >     scheduled requests to execute the other callbacks for the same device,
>> >     except for scheduled autosuspends.
>> 
>> I'm not sure where the contradiction is.  The patch simply changes the
>> behavior for disabled runtime PM, which is to return a nonzero value immediately
>> anyway.
>
> It changes an error return to a non-error return.
>
> However, if we limit the effects to times when the system is 
> suspending then there shouldn't be any pending or scheduled requests 
> anyway.  So okay, this isn't an issue.
>
>> > > > @@ -510,7 +510,8 @@ static int rpm_resume(struct device *dev, int rpmflags)
>> > > >  	if (dev->power.runtime_error)
>> > > >  		retval = -EINVAL;
>> > > >  	else if (dev->power.disable_depth > 0)
>> > > > -		retval = -EACCES;
>> > > > +		retval = dev->power.is_suspended && 
>> > > > +			dev->power.runtime_status == RPM_ACTIVE ? 1 : -EACCES;
>> > > >  	if (retval)
>> > > >  		goto out;
>> > 
>> > Also, the is_suspended test seems irrelevant in general -- it makes 
>> > sense in terms of the scenario Kevin described but that's not the 
>> > stated purpose of the patch.
>> 
>> Well, it is, although the changelog doesn't state it sufficiently clearly. :-)
>
> Good point.  The changelog needs to be improved.
>
>> > Both of these problems can be addressed by writing the code as follows:
>> > 
>> > 	if (dev->power.runtime_error)
>> > 		retval = -EINVAL;
>> > 	else if (dev->power.disable_depth > 0) {
>> > 
>> > 		/* Special case: allow this if the device is already active */
>> > 		if (dev->power.runtime_status != RPM_ACTIVE)
>> > 			retval = -EACCES;
>> > 	}
>> > 	if (retval)
>> > 		goto out;
>> 
>> We could do that too, but I'm a bit concerned about the situations where
>> runtime PM is disabled by the driver itself or by the subsystem, because
>> in those cases whoever disables runtime PM would have to make sure that the
>> status still reflects the actual hardware state, but that's what the runtime
>> PM framework is for (among other things).
>
> All right, let's use Kevin's original scheme but add a test for 
> disable_depth == 1.  I suggest changing the ?: operator to a regular 
> "if" statement, because the new condition will be even longer than the 
> old one (which I found a little hard to read in the first place).
>
> And of course, a comment should be added to explain the reason for the
> exception.
>
> Kevin, how does this sound?
>

Sounds good to me.

I'll respin and try to make the changelog more clear.

Thanks,

Kevin



      reply	other threads:[~2012-09-21 21:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1348176542-28983-1-git-send-email-khilman@deeprootsystems.com>
2012-09-20 21:58 ` [PATCH RESEND] PM / Runtime: let rpm_resume() succeed if RPM_ACTIVE, even when disabled Rafael J. Wysocki
2012-09-21 17:50   ` Alan Stern
2012-09-21 19:29     ` Rafael J. Wysocki
2012-09-21 20:22       ` Alan Stern
2012-09-21 21:40         ` Kevin Hilman [this message]

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=87vcf7dpgb.fsf@deeprootsystems.com \
    --to=khilman@deeprootsystems.com \
    --cc=grygorii.strashko@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=rjw@sisk.pl \
    --cc=santosh.shilimkar@ti.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox