public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hong Liu <hong.liu@intel.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Alan Cox <alan@linux.intel.com>,
	Kernel development list <linux-kernel@vger.kernel.org>,
	Linux-pm mailing list <linux-pm@lists.linux-foundation.org>
Subject: Re: [PATCH] apds9802als: add runtime PM support
Date: Wed, 27 Oct 2010 08:39:21 +0800	[thread overview]
Message-ID: <1288139961.19329.401.camel@hongdev> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1010260944270.1634-100000@iolanthe.rowland.org>

On Tue, 2010-10-26 at 21:51 +0800, Alan Stern wrote:
> On Tue, 26 Oct 2010, Hong Liu wrote:
> 
> > > > diff --git a/drivers/misc/apds9802als.c b/drivers/misc/apds9802als.c
> > > > index fbe4960..15f9436 100644
> > > > --- a/drivers/misc/apds9802als.c
> > > > +++ b/drivers/misc/apds9802als.c
> > > 
> > > > @@ -265,13 +274,34 @@ static int apds9802als_suspend(struct i2c_client *client, pm_message_t mesg)
> > > >  
> > > >  static int apds9802als_resume(struct i2c_client *client)
> > > >  {
> > > > -	struct als_data *data = i2c_get_clientdata(client);
> > > > +	als_set_default_config(client);
> > > > +
> > > > +	pm_runtime_get(&client->dev);
> > > > +	pm_runtime_put(&client->dev);
> > > > +	return 0;
> > > > +}
> > > 
> > 
> > Hi, Alan
> > 
> > Thanks for your review.
> > 
> > > This almost certainly does not do what you think.
> > > 
> > > pm_runtime_get() will increment the device's usage count and queue an 
> > > asynchronous resume request.  However, since the PM workqueue is frozen 
> > > during system sleep transitions, the device will remain suspended.
> > > 
> > > The pm_runtime_put() will decrement the usage count again, but since
> > > there is already an async resume on the queue it will not queue an
> > > async suspend.  The final result will be that when tasks are unfrozen,
> > > the device will finally be resumed -- long after it should have been.
> > > 
> > > It looks like what you want to do here is simply call
> > > apds9802als_runtime_resume() directly.  
> > 
> > You mean apds9802als_runtime_suspend()?
> 
> This is about the function listed above: apds9802als_resume().  It
> should call apds9802als_runtime_resume() directly.  I don't see any
> reason why you would want it to call apds9802als_runtime_suspend() --
> having a resume function that actually suspends the device doesn't make
> any sense.

In apds9802als_resume, I just want to power up the device, do some
configuration, and then runtime_suspend the device.

We don't have runtime_idle() implemented, the driver exported sysfs
entries to user space for data reading, and we do runtime_resume,
measaure data, runtime_suspend in the read/write funciton of those sysfs
entries. This is why I want to put the device into runtime suspend
manually whenever possible.


> 
> > I want to put the device into
> > runtime suspended state, can I just call pm_runtime_suspend() directly?
> 
> Why do you want apds9802als_resume() to put the device into a suspended 
> state?  Shouldn't it _resume_ the device?
> 
> > > And according to the advice in
> > > Documentation/power/runtime_pm.txt section 6, you should also call
> 
> Have you read that document?
> 
> > > 	pm_runtime_disable(dev);
> > > 	pm_runtime_set_active(dev);
> > > 	pm_runtime_enable(dev);
> > > 
> > > You probably also do not want the asynchronous calls to 
> > > pm_runtime_get() and pm_runtime_put() in apds9802als_probe().  A more 
> > > common sequence is:
> > > 
> > > 	pm_runtime_set_active(dev);
> > > 	pm_runtime_enable(dev);
> > 
> > I want to put the device into runtime suspend state after probe, so
> > pm_runtime_suspend() after these two calls is OK?
> 
> No.  Try doing what I said.  You should find that the device _does_ get
> runtime-suspended when the probe function returns.  Assuming you have
> defined a proper apds9802als_runtime_idle() function.

We don't have runtime_idle() implemented, so I have to manually put the
device into runtime suspend.

Thanks,
Hong

> 
> Alan Stern
> 



  reply	other threads:[~2010-10-27  0:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-21 18:34 [PATCH] apds9802als: add runtime PM support Alan Stern
2010-10-26  6:05 ` Hong Liu
2010-10-26 13:51   ` Alan Stern
2010-10-27  0:39     ` Hong Liu [this message]
2010-10-27 14:13       ` Alan Stern
  -- strict thread matches above, loose matches on Subject: below --
2010-10-15 13:47 Alan Cox
2010-10-22 20:03 ` Andrew Morton

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=1288139961.19329.401.camel@hongdev \
    --to=hong.liu@intel.com \
    --cc=alan@linux.intel.com \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox