linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Huang Ying <ying.huang@intel.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden
Date: Tue, 13 Nov 2012 13:12:19 +0800	[thread overview]
Message-ID: <1352783539.7176.212.camel@yhuang-dev> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1211122120140.6961-100000@netrider.rowland.org>

On Mon, 2012-11-12 at 21:32 -0500, Alan Stern wrote:
> On Tue, 13 Nov 2012, Huang Ying wrote:
> 
> > Sorry, my original idea is:
> > 
> > 	pm_runtime_disable will put device into SUSPENDED state if
> > 	dev->power.runtime_auto is clear.  pm_runtime_allow will put
> > 	device into SUSPENDED state if dev->power.disable_depth > 0.
> 
> That's close to what I suggested.
> 
> > So in general, my original idea is to manage device runtime power state
> > automatically instead of manually, especially when device is in disabled
> > state.
> > 
> > 	disabled + forbidden	-> ACTIVE
> > 	disabled + !forbidden	-> SUSPENDED
> 
> This is not quite right.  Consider a device that is in runtime suspend 
> when a system sleep starts.  When the system sleep ends, the device 
> will be resumed but the PM core will still think its state is 
> SUSPENDED.  The subsystem has to tell the PM core that the device is 
> now ACTIVE.  Currently, subsystems do this by calling 
> pm_runtime_disable, pm_runtime_set_active, pm_runtime_enable.  Under 
> your scheme this wouldn't work; the pm_runtime_set_active call would 
> fail because the device was !forbidden.

Thanks for your information.  For this specific situation, is it
possible to call pm_runtime_resume() or pm_request_resume() for the
device?

> > 	enabled + forbidden	-> ACTIVE
> > 	enabled + !forbidden	-> auto
> > 
> > Why we can not do that?
> 
> See above.  What we can do instead is:
> 
> 	disabled + forbidden	-> ACTIVE
> 	disabled + !forbidden	-> anything
> 
> which is basically what I proposed.
>
> > > This means:
> > > 
> > > 	pm_runtime_set_suspended should fail if dev->power.runtime_auto
> > > 	is clear.
> > 
> > I think we can WARN_ON() here.  Because the caller should responsible
> > for state consistence if they decide to manage runtime power state
> > manually.
> 
> No.  Drivers should not have to worry about whether runtime PM is 
> forbidden.  Worrying about that is the PM core's job.

En...  It appears that what caller can do is just do not call
pm_runtime_set_suspended() if forbidden.  So your method should be
better.

> > > 	pm_runtime_forbid should call pm_runtime_set_active if
> > > 	dev->power.disable_depth > 0.  (This would run into a problem
> > > 	if the parent is suspended and disabled.  Maybe 
> > > 	pm_runtime_forbid should fail when this happens.)
> > 
> > pm_runtime_forbid() may be called via echo "on" > .../power/control.  I
> > think it is hard to refuse the request from user space to forbid runtime
> > PM.  Device can always work with full power.
> 
> It can't if the parent is in SUSPEND.  If necessary, the user can write 
> "on" to the parent's power/control attribute first.

Is it possible to call pm_runtime_set_active() for the parent if the
parent is disabled and SUSPENDED.

> > > Finally, we probably should make a third change even though it isn't
> > > strictly necessary:
> > > 
> > > 	pm_runtime_allow should call pm_runtime_set_suspended if
> > > 	dev->power.disable_depth > 0.
> > 
> > I think this is something similar to manage device power state
> > automatically if disabled.
> 
> Yes, it is similar but not exactly the same as your proposal.

It appears that there is race condition between this and the
pm_runtime_disable, pm_runtime_set_active, pm_runtime_enable sequence
you mentioned ealier.

thread 1			thread 2
pm_runtime_disable
pm_runtime_set_active
				pm_runtime_allow
				  pm_runtime_set_suspended
pm_runtime_enable

Best Regards,
Huang Ying



  reply	other threads:[~2012-11-13  5:12 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-05  1:17 [BUGFIX] PM: Fix active child counting when disabled and forbidden Huang Ying
2012-11-05  1:56 ` Alan Stern
2012-11-06  0:43   ` Huang Ying
2012-11-06 15:17     ` Alan Stern
2012-11-07  0:26       ` Huang Ying
2012-11-07 15:49         ` Alan Stern
2012-11-07 16:09           ` Rafael J. Wysocki
2012-11-07 17:17             ` Alan Stern
2012-11-07 20:21               ` Rafael J. Wysocki
2012-11-07 20:47                 ` Alan Stern
2012-11-07 21:44                   ` Rafael J. Wysocki
2012-11-07 21:56                     ` Alan Stern
2012-11-07 22:51                       ` Rafael J. Wysocki
2012-11-07 23:09                         ` Rafael J. Wysocki
2012-11-08  1:15                           ` Huang Ying
2012-11-08  1:35                             ` Rafael J. Wysocki
2012-11-08  2:04                               ` Huang Ying
2012-11-08  9:56                                 ` Rafael J. Wysocki
2012-11-08 17:07                                   ` Alan Stern
2012-11-09  2:36                                     ` Huang Ying
2012-11-09 16:41                                       ` Alan Stern
2012-11-12  0:37                                         ` Huang Ying
2012-11-12  2:36                                           ` Alan Stern
2012-11-12  5:55                                             ` Huang Ying
2012-11-12 16:32                                               ` Alan Stern
2012-11-13  1:19                                                 ` Huang Ying
2012-11-13  2:32                                                   ` Alan Stern
2012-11-13  5:12                                                     ` Huang Ying [this message]
2012-11-13 16:10                                                       ` Alan Stern
2012-11-14  1:08                                                         ` Huang Ying
2012-11-14  9:52                                                           ` Rafael J. Wysocki
2012-11-14 13:35                                                             ` Huang Ying
2012-11-14 16:06                                                               ` Alan Stern
2012-11-13 23:43                                                 ` Rafael J. Wysocki
2012-11-14 10:05                                     ` Rafael J. Wysocki
2012-11-14 16:42                                       ` Alan Stern
2012-11-14 19:42                                         ` Rafael J. Wysocki
2012-11-14 21:45                                           ` Alan Stern
2012-11-14 23:10                                             ` Rafael J. Wysocki
2012-11-15  1:03                                               ` Huang Ying
2012-11-15  9:51                                                 ` Rafael J. Wysocki
2012-11-15 10:09                                                   ` Rafael J. Wysocki
2012-11-15 15:27                                                     ` Alan Stern
2012-11-16  0:36                                                   ` Huang Ying
2012-11-16  0:44                                                     ` Rafael J. Wysocki
2012-11-16  0:48                                                       ` Huang Ying
2012-11-16  0:55                                                       ` Rafael J. Wysocki
2012-11-16  0:54                                                         ` Huang Ying
2012-11-16  1:29                                                           ` Rafael J. Wysocki
2012-11-16  1:27                                                             ` Huang Ying
2012-11-16 10:10                                                               ` Rafael J. Wysocki
2012-11-16  3:11                                                   ` Huang Ying

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=1352783539.7176.212.camel@yhuang-dev \
    --to=ying.huang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).