From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raj Kumar Subject: Re: Questions about run time power management Date: Sat, 24 Jul 2010 19:56:45 +0530 Message-ID: References: , Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6101379631808505462==" Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org To: stern@rowland.harvard.edu Cc: linux-pm@lists.linux-foundation.org List-Id: linux-pm@vger.kernel.org --===============6101379631808505462== Content-Type: multipart/alternative; boundary="_7057c46e-0556-48e1-a726-c721fd6f4639_" --_7057c46e-0556-48e1-a726-c721fd6f4639_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Alan=2C =20 Please see my following points: =20 Suppose when device is idle=2C it says to run time power management framew= ork i am idle and run time power management asks the device's bus (if bus is being used)= =2C and=20 probably the case is if the device does not want to get suspended because o= f the starting of the activities immediately =2C it will return the error to platform bus = and platform bus returns this error to run time power management framework and run time power management will m= ake the device status active. In the code of=20 =20 int __pm_runtime_suspend(arguments...) { =20 if (retval) { dev->power.runtime_status =3D RPM_ACTIVE=3B pm_runtime_cancel_pending(dev)=3B if (retval =3D=3D -EAGAIN || retval =3D=3D -EBUSY) { notify =3D true=3B dev->power.runtime_error =3D 0=3B } } else { =20 } =20 So if the retval is -EAGAIN and -EBUSY=2C so it means it will again try to= make it idle but if the device is already doing activities =2C since it is started doing activities then in t= hat case is this error code ECANCELED is appropriate? =20 Regards Raj =20 =20 =20 =20 =20 =20 > Date: Fri=2C 23 Jul 2010 10:26:07 -0400 > From: stern@rowland.harvard.edu > To: rajkumar278@hotmail.com > CC: linux-pm@lists.linux-foundation.org > Subject: Re: [linux-pm] Questions about run time power management >=20 > On Fri=2C 23 Jul 2010=2C Raj Kumar wrote: >=20 > > Hi=2C > >=20 > >=20 > > I am implementing the run time power management in my drivers. So i hav= e the following > > questions: > >=20 > >=20 > > 1) I am using the work queue approach for run time power management=2C = Now the thing is > > when the device is idle and it notifies the run time power management v= ia helper function > > pm_request_idle=2C and at the same time if resume is done then in that = case does the runtime power management > > cancels the idle and does not invoke any callback like runtime_suspend = of driver?=20 >=20 > How can a resume occur while the device is idle? Idle means that the=20 > device isn't suspended -- it's at full power but not doing anything.=20 > Hence a resume cannot occur at the same time. >=20 > > 2) like as mentioned in run time power management document=2C when the = usage_count of device > > reaches zero=2C is there any run time power management thread in backgr= ound that will immediately suspends > > the device or it is again via helper functions. It seems from the code = that usage_count is zero and suspended > > via helper functions. Is it correct? >=20 > All suspends occur via the helper functions=2C whether a background=20 > thread is involved or not. >=20 > > 3) The third question is more specific about platform bus usage? can th= e char device driver use platform bus? > > can char device register as platform device? >=20 > Yes. Devices can be registered on any bus. >=20 > Alan Stern >=20 = --_7057c46e-0556-48e1-a726-c721fd6f4639_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Alan=2C
 =3B
Please see my following points:
 =3B
 =3BSuppose when device is idle=2C it says to run time power management= framework i am idle
and run time power management asks the device's bus (if bus is being used)= =2C and
probably the case is if the device does not want to get suspended because o= f the starting
of the activities immediately =3B=2C it will return the error to platfo= rm bus and platform bus returns this error
to run time power management framework and run time power management will m= ake
the device status active. In the code of
 =3B
int =3B __pm_runtime_suspend(arguments...)
{

 =3B
 =3B if (retval) {
 =3B =3B =3B =3B =3B =3B&= nbsp=3B =3B =3B =3B =3B =3B =3B =3B =3B dev= ->=3Bpower.runtime_status =3D RPM_ACTIVE=3B
 =3B =3B =3B&n= bsp=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B pm_runtime_cancel_pending(dev)=3B
 =3B =3B =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B =3B if (retval =3D=3D -EAGAIN || = retval =3D=3D -EBUSY) {
 =3B =3B =3B =3B =3B =3B=  =3B =3B =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B =3B =3B =3B notify =3D tr= ue=3B
 =3B =3B =3B =3B =3B =3B =3B =3B&n= bsp=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B =3B =3B =3B dev->=3Bpower.runtime_error = =3D 0=3B
 =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B =3B =3B =3B =3B =3B }
 =3B&n= bsp=3B =3B =3B =3B =3B =3B } else {

 =3B
}
 =3B
So if the retval is -EAGAIN and -EBUSY=2C =3B so it means it will again= try to make it idle but if the device is
already doing activities =2C since it is started doing activities then in t= hat case is this error code
ECANCELED is appropriate?
 =3B
Regards
Raj
 =3B
 =3B
 =3B
 =3B
 =3B
 =3B
>=3B Date: Fri=2C 23 Jul 2010 10:26:07 -0400
>=3B From: = stern@rowland.harvard.edu
>=3B To: rajkumar278@hotmail.com
>=3B C= C: linux-pm@lists.linux-foundation.org
>=3B Subject: Re: [linux-pm] Qu= estions about run time power management
>=3B
>=3B On Fri=2C 23 J= ul 2010=2C Raj Kumar wrote:
>=3B
>=3B >=3B Hi=2C
>=3B >= =3B
>=3B >=3B
>=3B >=3B I am implementing the run time powe= r management in my drivers. So i have the following
>=3B >=3B questi= ons:
>=3B >=3B
>=3B >=3B
>=3B >=3B 1) I am using the= work queue approach for run time power management=2C Now the thing is
&= gt=3B >=3B when the device is idle and it notifies the run time power man= agement via helper function
>=3B >=3B pm_request_idle=2C and at the = same time if resume is done then in that case does the runtime power manage= ment
>=3B >=3B cancels the idle and does not invoke any callback lik= e runtime_suspend of driver?
>=3B
>=3B How can a resume occur w= hile the device is idle? Idle means that the
>=3B device isn't suspen= ded -- it's at full power but not doing anything.
>=3B Hence a resume= cannot occur at the same time.
>=3B
>=3B >=3B 2) like as ment= ioned in run time power management document=2C when the usage_count of devi= ce
>=3B >=3B reaches zero=2C is there any run time power management = thread in background that will immediately suspends
>=3B >=3B the de= vice or it is again via helper functions. It seems from the code that usage= _count is zero and suspended
>=3B >=3B via helper functions. Is it c= orrect?
>=3B
>=3B All suspends occur via the helper functions=2C= whether a background
>=3B thread is involved or not.
>=3B
&= gt=3B >=3B 3) The third question is more specific about platform bus usag= e? can the char device driver use platform bus?
>=3B >=3B can char d= evice register as platform device?
>=3B
>=3B Yes. Devices can be= registered on any bus.
>=3B
>=3B Alan Stern
>=3B
= = --_7057c46e-0556-48e1-a726-c721fd6f4639_-- --===============6101379631808505462== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============6101379631808505462==--