From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raj Kumar Subject: Question about hibernation Date: Wed, 6 Oct 2010 03:10:31 +0530 Message-ID: References: , , , , , Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0592598620318705088==" 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, linux-pm@lists.linux-foundation.org List-Id: linux-pm@vger.kernel.org --===============0592598620318705088== Content-Type: multipart/alternative; boundary="_1ffd2ccb-6026-439d-b69d-b29557c5d1cb_" --_1ffd2ccb-6026-439d-b69d-b29557c5d1cb_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable =20 Hi Alan=2C =20 I have question regarding the hibernation mode in linux.=20 =20 1) In normal suspend to ram=2C is freezing of tasks necessary while suspend= to ram in current linux power management core? 2) In hibernation mode=2C is freezing of tasks done before normal suspend/r= esumes in order to that hibernation image is in sync? =20 My issue is because it might be possible that there is some part of device = driver which is user space and another part is kernel space then in suspend to ram and hibernation mode is freezing of all user space p= art is done before kernel side or it differs while suspend to ram and hibernation mode? =20 Regards Raj = --_1ffd2ccb-6026-439d-b69d-b29557c5d1cb_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable  =3B
Hi Alan=2C
 =3B
I have question regarding the hibernation mode in linux.
 =3B
1) In normal suspend to ram=2C is freezing of tasks necessary while suspend= to ram in current linux power management core?
2) In hibernation mode=2C is freezing of tasks done before normal suspend/r= esumes in order to that hibernation image is in sync?
 =3B
My issue is because it might be possible that there is some part of device = driver which is user space and another part is kernel space
then in suspend to ram and hibernation mode is freezing of all user space p= art is done before kernel side or it differs while
suspend to ram and hibernation mode?
 =3B
Regards
Raj
 =3B
= --_1ffd2ccb-6026-439d-b69d-b29557c5d1cb_-- --===============0592598620318705088== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============0592598620318705088==-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: Re: Question about hibernation Date: Wed, 6 Oct 2010 00:43:30 +0200 Message-ID: <201010060043.30489.rjw@sisk.pl> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org To: linux-pm@lists.linux-foundation.org List-Id: linux-pm@vger.kernel.org On Tuesday, October 05, 2010, Raj Kumar wrote: > > Hi Alan, > > I have question regarding the hibernation mode in linux. > > 1) In normal suspend to ram, is freezing of tasks necessary while suspend to ram in current linux power management core? Yes, it is. > 2) In hibernation mode, is freezing of tasks done before normal suspend/resumes in order to that hibernation image is in sync? That depends on what you mean by normal "suspend/resumes". Generally speaking, the hibernate code freezes tasks before preallocating image memory. > My issue is because it might be possible that there is some part of device driver which is user space and another part is kernel space > then in suspend to ram and hibernation mode is freezing of all user space part is done before kernel side or it differs while > suspend to ram and hibernation mode? User space is always frozen before suspend and hibernation. Thanks, Rafael From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raj Kumar Subject: Re: Question about hibernation Date: Fri, 8 Oct 2010 16:02:46 +0530 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3434992012592819108==" 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: linux-pm@lists.linux-foundation.org, rjw@sisk.pl List-Id: linux-pm@vger.kernel.org --===============3434992012592819108== Content-Type: multipart/alternative; boundary="_3b86c823-15d6-4507-9fcc-6f7ff3d6259d_" --_3b86c823-15d6-4507-9fcc-6f7ff3d6259d_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Rafael=2C =20 I am working on device driver whose some part is user space and some part i= s kernel space. So the user space part of the driver provides interface to user space applications.=20 1) Now=2C Suppose some user space is application is going on which is acces= sing the user space driver and user space driver scheduled some jobs to kernel space=2C Now suppose system hibernation start= =2C since it freezes all the user space processes so suppose jobs are not completed yet which are scheduled to kernel space b= y user space. =20 when the kernel space device driver completes the jobs and gives the notifi= cation to user space driver=2C since user space process is already frozen=2C so there will be problem if we suspend the dri= ver using suspend and resume. =20 right? =20 2) The other point I was seeing=2C when the power management core freezes a= ll the processes before suspending and resuming devices=2C it will take some time for freezing and after that if some devic= e driver refuses to suspend=2C then it will again resume the whole processes=2C so latency time be more. right? =20 3) Next question is regarding the kernel space threads=2C when these are fr= ozen during suspend/hibernation? =20 Thanks Raj =20 =20 =20 =20 =20 =20 > Date: Wed=2C 6 Oct 2010 00:43:30 +0200 > From: "Rafael J. Wysocki" > Subject: Re: [linux-pm] Question about hibernation > To: linux-pm@lists.linux-foundation.org > Message-ID: <201010060043.30489.rjw@sisk.pl> > Content-Type: Text/Plain=3B charset=3D"iso-8859-2" >=20 > On Tuesday=2C October 05=2C 2010=2C Raj Kumar wrote: > >=20 > > Hi Alan=2C > >=20 > > I have question regarding the hibernation mode in linux.=20 > >=20 > > 1) In normal suspend to ram=2C is freezing of tasks necessary while sus= pend to ram in current linux power management core? >=20 > Yes=2C it is. >=20 > > 2) In hibernation mode=2C is freezing of tasks done before normal suspe= nd/resumes in order to that hibernation image is in sync? >=20 > That depends on what you mean by normal "suspend/resumes". Generally spea= king=2C > the hibernate code freezes tasks before preallocating image memory. >=20 > > My issue is because it might be possible that there is some part of dev= ice driver which is user space and another part is kernel space > > then in suspend to ram and hibernation mode is freezing of all user spa= ce part is done before kernel side or it differs while > > suspend to ram and hibernation mode? >=20 > User space is always frozen before suspend and hibernation. >=20 > Thanks=2C > Rafael >=20 >=20 = --_3b86c823-15d6-4507-9fcc-6f7ff3d6259d_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Rafael=2C
 =3B
I am working on device driver whose some part is user space and some part i= s kernel space. So the user space part
of the driver provides interface to user space applications.
1) Now=2C Suppose some user space is application is going on which is acces= sing the user space driver and user space driver
scheduled some jobs to kernel space=2C Now suppose system hibernation start= =2C since it freezes all the user space processes
so suppose jobs are not completed yet which are scheduled to kernel space b= y user space.
 =3B
when the kernel space device driver completes the jobs and gives the notifi= cation to user space driver=2C since user space
process is already frozen=2C so there will be problem if we suspend the dri= ver using suspend and resume.
 =3B
right?
 =3B
2) The other point I was seeing=2C when the power management core freezes a= ll the processes before suspending and resuming
devices=2C it will take some time for freezing and after that if some devic= e driver refuses to suspend=2C then it will again resume
the whole processes=2C so latency time be more. right?
 =3B
3) Next question is regarding the kernel space threads=2C when these are fr= ozen during suspend/hibernation?
 =3B
Thanks
Raj
 =3B
 =3B
 =3B
 =3B
 =3B
 =3B
>=3B Date: Wed=2C 6 Oct 2010 00:43:30 +0200
>=3B From: "Rafael J. Wy= socki" <=3Brjw@sisk.pl>=3B
>=3B Subject: Re: [linux-pm] Question a= bout hibernation
>=3B To: linux-pm@lists.linux-foundation.org
>= =3B Message-ID: <=3B201010060043.30489.rjw@sisk.pl>=3B
>=3B Conten= t-Type: Text/Plain=3B charset=3D"iso-8859-2"
>=3B
>=3B On Tuesda= y=2C October 05=2C 2010=2C Raj Kumar wrote:
>=3B >=3B
>=3B >= =3B Hi Alan=2C
>=3B >=3B
>=3B >=3B I have question regarding= the hibernation mode in linux.
>=3B >=3B
>=3B >=3B 1) In n= ormal suspend to ram=2C is freezing of tasks necessary while suspend to ram= in current linux power management core?
>=3B
>=3B Yes=2C it is.=
>=3B
>=3B >=3B 2) In hibernation mode=2C is freezing of tasks= done before normal suspend/resumes in order to that hibernation image is i= n sync?
>=3B
>=3B That depends on what you mean by normal "suspe= nd/resumes". Generally speaking=2C
>=3B the hibernate code freezes tas= ks before preallocating image memory.
>=3B
>=3B >=3B My issue = is because it might be possible that there is some part of device driver wh= ich is user space and another part is kernel space
>=3B >=3B then in= suspend to ram and hibernation mode is freezing of all user space part is = done before kernel side or it differs while
>=3B >=3B suspend to ram= and hibernation mode?
>=3B
>=3B User space is always frozen bef= ore suspend and hibernation.
>=3B
>=3B Thanks=2C
>=3B Rafae= l
>=3B
>=3B

= --_3b86c823-15d6-4507-9fcc-6f7ff3d6259d_-- --===============3434992012592819108== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============3434992012592819108==-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: Re: Question about hibernation Date: Fri, 8 Oct 2010 21:31:48 +0200 Message-ID: <201010082131.48152.rjw@sisk.pl> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org To: Raj Kumar Cc: linux-pm@lists.linux-foundation.org List-Id: linux-pm@vger.kernel.org On Friday, October 08, 2010, you wrote: > > Hi Rafael, Hi, > I am working on device driver whose some part is user space and some part is kernel space. So the user space part > of the driver provides interface to user space applications. > 1) Now, Suppose some user space is application is going on which is accessing the user space driver and user space driver > scheduled some jobs to kernel space, Now suppose system hibernation start, since it freezes all the user space processes > so suppose jobs are not completed yet which are scheduled to kernel space by user space. > > when the kernel space device driver completes the jobs and gives the notification to user space driver, since user space > process is already frozen, so there will be problem if we suspend the driver using suspend and resume. > > right? Yes, there's going to be a problem if the driver is not prepared to handle such situations. Depending of the particular case, one possible approach is to use a PM notifier as described in Documentation/power/notifiers.txt. > 2) The other point I was seeing, when the power management core freezes all the processes before suspending and resuming > devices, it will take some time for freezing and after that if some device driver refuses to suspend, then it will again resume > the whole processes, so latency time be more. right? Yes, it works as described. > 3) Next question is regarding the kernel space threads, when these are frozen during suspend/hibernation? They are frozen immediately after user space has been frozen, but only a handful of kernel threads are frozen. Thanks, Rafael From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raj Kumar Subject: Re: Question about hibernation Date: Thu, 14 Oct 2010 13:50:20 +0530 Message-ID: References: , <201010082131.48152.rjw@sisk.pl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8854298935558676338==" Return-path: In-Reply-To: <201010082131.48152.rjw@sisk.pl> 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: rjw@sisk.pl Cc: linux-pm@lists.linux-foundation.org List-Id: linux-pm@vger.kernel.org --===============8854298935558676338== Content-Type: multipart/alternative; boundary="_07cb2958-52d9-429e-a2b6-df724518225a_" --_07cb2958-52d9-429e-a2b6-df724518225a_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable =20 =20 Hi Rafael=2C =20 1) I have question on system resume that e.g. in device driver let us say f= or example structure is defined global=2C e.g. =20 struct dev { int a=3B =20 } dev_t=3B =20 =20 this structure is global. Now during system suspend=2C suppose the value of= =20 =20 dev_t.a =3D2=3B =20 So when the resume happens=2C will the dev_t.a will remain the same i.e. 2? =20 2) During the system suspend=2C if the system hibernates=2C then the messag= e sent from power management core to all drivers is PMSG_HIBERNATE and if system suspends to ram=2C then message sent from powe= r management core to all drivers is PMSG_SUSPEND. =20 correct me if I am wrong. =20 Regards Raj =20 =20 =20 =20 =20 =20 =20 =20 > From: rjw@sisk.pl > To: rajkumar278@hotmail.com > Subject: Re: Question about hibernation > Date: Fri=2C 8 Oct 2010 21:31:48 +0200 > CC: linux-pm@lists.linux-foundation.org >=20 > On Friday=2C October 08=2C 2010=2C you wrote: > >=20 > > Hi Rafael=2C >=20 > Hi=2C >=20 > > I am working on device driver whose some part is user space and some pa= rt is kernel space. So the user space part > > of the driver provides interface to user space applications.=20 > > 1) Now=2C Suppose some user space is application is going on which is a= ccessing the user space driver and user space driver > > scheduled some jobs to kernel space=2C Now suppose system hibernation s= tart=2C since it freezes all the user space processes > > so suppose jobs are not completed yet which are scheduled to kernel spa= ce by user space. > >=20 > > when the kernel space device driver completes the jobs and gives the no= tification to user space driver=2C since user space > > process is already frozen=2C so there will be problem if we suspend the= driver using suspend and resume. > >=20 > > right? >=20 > Yes=2C there's going to be a problem if the driver is not prepared to han= dle such situations. >=20 > Depending of the particular case=2C one possible approach is to use a PM = notifier > as described in Documentation/power/notifiers.txt. >=20 > > 2) The other point I was seeing=2C when the power management core freez= es all the processes before suspending and resuming > > devices=2C it will take some time for freezing and after that if some d= evice driver refuses to suspend=2C then it will again resume > > the whole processes=2C so latency time be more. right? >=20 > Yes=2C it works as described. >=20 > > 3) Next question is regarding the kernel space threads=2C when these ar= e frozen during suspend/hibernation? >=20 > They are frozen immediately after user space has been frozen=2C but only = a > handful of kernel threads are frozen. >=20 > Thanks=2C > Rafael = --_07cb2958-52d9-429e-a2b6-df724518225a_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable  =3B
 =3B
Hi Rafael=2C
 =3B
1) I have question on system resume that e.g. in device driver let us say f= or example structure is defined global=2C
e.g.
 =3B
struct dev
{
int a=3B
 =3B
} dev_t=3B
 =3B
 =3B
this structure is global. Now during system suspend=2C suppose the value of=
 =3B
dev_t.a =3D2=3B
 =3B
So when the resume happens=2C will the dev_t.a will remain the same i.e. 2?=
 =3B
2) During the system suspend=2C if the system hibernates=2C then the messag= e sent from power management core to all drivers is
PMSG_HIBERNATE and if system suspends to ram=2C then message sent from powe= r management core to all drivers is PMSG_SUSPEND.
 =3B
correct me if I am wrong.
 =3B
Regards
Raj
 =3B
 =3B
 =3B
 =3B
 =3B
 =3B
 =3B

 =3B
>=3B From: rjw@sisk.pl
>=3B To: rajkumar278@hotmail.com
>=3B Su= bject: Re: Question about hibernation
>=3B Date: Fri=2C 8 Oct 2010 21:= 31:48 +0200
>=3B CC: linux-pm@lists.linux-foundation.org
>=3B >=3B On Friday=2C October 08=2C 2010=2C you wrote:
>=3B >=3B
= >=3B >=3B Hi Rafael=2C
>=3B
>=3B Hi=2C
>=3B
>=3B = >=3B I am working on device driver whose some part is user space and some= part is kernel space. So the user space part
>=3B >=3B of the drive= r provides interface to user space applications.
>=3B >=3B 1) Now= =2C Suppose some user space is application is going on which is accessing t= he user space driver and user space driver
>=3B >=3B scheduled some = jobs to kernel space=2C Now suppose system hibernation start=2C since it fr= eezes all the user space processes
>=3B >=3B so suppose jobs are not= completed yet which are scheduled to kernel space by user space.
>=3B= >=3B
>=3B >=3B when the kernel space device driver completes the= jobs and gives the notification to user space driver=2C since user space>=3B >=3B process is already frozen=2C so there will be problem if we= suspend the driver using suspend and resume.
>=3B >=3B
>=3B &= gt=3B right?
>=3B
>=3B Yes=2C there's going to be a problem if t= he driver is not prepared to handle such situations.
>=3B
>=3B D= epending of the particular case=2C one possible approach is to use a PM not= ifier
>=3B as described in Documentation/power/notifiers.txt.
>= =3B
>=3B >=3B 2) The other point I was seeing=2C when the power man= agement core freezes all the processes before suspending and resuming
&g= t=3B >=3B devices=2C it will take some time for freezing and after that i= f some device driver refuses to suspend=2C then it will again resume
>= =3B >=3B the whole processes=2C so latency time be more. right?
>=3B=
>=3B Yes=2C it works as described.
>=3B
>=3B >=3B 3) Ne= xt question is regarding the kernel space threads=2C when these are frozen = during suspend/hibernation?
>=3B
>=3B They are frozen immediatel= y after user space has been frozen=2C but only a
>=3B handful of kerne= l threads are frozen.
>=3B
>=3B Thanks=2C
>=3B Rafael
= = --_07cb2958-52d9-429e-a2b6-df724518225a_-- --===============8854298935558676338== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============8854298935558676338==-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: Re: Question about hibernation Date: Thu, 14 Oct 2010 11:51:05 +0200 Message-ID: <201010141151.05297.rjw@sisk.pl> References: <201010082131.48152.rjw@sisk.pl> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org To: Raj Kumar Cc: linux-pm@lists.linux-foundation.org List-Id: linux-pm@vger.kernel.org On Thursday, October 14, 2010, Raj Kumar wrote: > > Hi Rafael, > > 1) I have question on system resume that e.g. in device driver let us say for example structure is defined global, > e.g. > > struct dev > { > int a; > > } dev_t; > > > this structure is global. Now during system suspend, suppose the value of > > dev_t.a =2; > > So when the resume happens, will the dev_t.a will remain the same i.e. 2? Yes, it will. For hibernation, the contents of all memory from before the image was created is restored during resume. > 2) During the system suspend, if the system hibernates, then the message sent from power management core to all drivers is > PMSG_HIBERNATE and if system suspends to ram, then message sent from power management core to all drivers is PMSG_SUSPEND. That was in the old model, which isn't recommended any more. Currently, it is recommended that drivers implement callbacks in struct dev_pm_ops, as described in Documentation/power/devices.txt and Documentation/power/pci.txt. Thanks, Rafael > > From: rjw@sisk.pl > > To: rajkumar278@hotmail.com > > Subject: Re: Question about hibernation > > Date: Fri, 8 Oct 2010 21:31:48 +0200 > > CC: linux-pm@lists.linux-foundation.org > > > > On Friday, October 08, 2010, you wrote: > > > > > > Hi Rafael, > > > > Hi, > > > > > I am working on device driver whose some part is user space and some part is kernel space. So the user space part > > > of the driver provides interface to user space applications. > > > 1) Now, Suppose some user space is application is going on which is accessing the user space driver and user space driver > > > scheduled some jobs to kernel space, Now suppose system hibernation start, since it freezes all the user space processes > > > so suppose jobs are not completed yet which are scheduled to kernel space by user space. > > > > > > when the kernel space device driver completes the jobs and gives the notification to user space driver, since user space > > > process is already frozen, so there will be problem if we suspend the driver using suspend and resume. > > > > > > right? > > > > Yes, there's going to be a problem if the driver is not prepared to handle such situations. > > > > Depending of the particular case, one possible approach is to use a PM notifier > > as described in Documentation/power/notifiers.txt. > > > > > 2) The other point I was seeing, when the power management core freezes all the processes before suspending and resuming > > > devices, it will take some time for freezing and after that if some device driver refuses to suspend, then it will again resume > > > the whole processes, so latency time be more. right? > > > > Yes, it works as described. > > > > > 3) Next question is regarding the kernel space threads, when these are frozen during suspend/hibernation? > > > > They are frozen immediately after user space has been frozen, but only a > > handful of kernel threads are frozen. > > > > Thanks, > > Rafael > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raj Kumar Subject: Re: Question about hibernation Date: Thu, 14 Oct 2010 17:17:03 +0530 Message-ID: References: <201010082131.48152.rjw@sisk.pl> , <201010141151.05297.rjw@sisk.pl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8844964534760418496==" Return-path: In-Reply-To: <201010141151.05297.rjw@sisk.pl> 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: rjw@sisk.pl Cc: linux-pm@lists.linux-foundation.org List-Id: linux-pm@vger.kernel.org --===============8844964534760418496== Content-Type: multipart/alternative; boundary="_6610575e-f9c4-4200-afb4-d943525cd8d7_" --_6610575e-f9c4-4200-afb4-d943525cd8d7_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable =20 Hi Rafael=2C =20 Thanks for your quick reply. =20 =20 1) I already implemented this with dev_pm_ops. I used suspend and resume ca= llbacks whose prototype is like =20 struct dev_pm_ops power_mgmt_ops { .suspend =3D powermanagement_suspend=2C .resume =3D powermanagement_resume =20 } =20 int powermanagement_suspend(device *dev) { =20 } =20 In normal suspend to ram mode it will work. But will it work in case of hib= ernation also? =20 if yes=2C since in suspend and resume call backs=2C only the device structu= re is provided=2C so how can then person can identify it is suspend to ram or hibernation? =20 or for hibernation=2C poweroff and restore function should be implemented = which is similar to suspend and resume call backs in case of suspend to ram? =20 Regards Raj =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 =20 > From: rjw@sisk.pl > To: rajkumar278@hotmail.com > Subject: Re: Question about hibernation > Date: Thu=2C 14 Oct 2010 11:51:05 +0200 > CC: linux-pm@lists.linux-foundation.org >=20 > On Thursday=2C October 14=2C 2010=2C Raj Kumar wrote: > >=20 > > Hi Rafael=2C > >=20 > > 1) I have question on system resume that e.g. in device driver let us s= ay for example structure is defined global=2C > > e.g. > >=20 > > struct dev > > { > > int a=3B > >=20 > > } dev_t=3B > >=20 > >=20 > > this structure is global. Now during system suspend=2C suppose the valu= e of=20 > >=20 > > dev_t.a =3D2=3B > >=20 > > So when the resume happens=2C will the dev_t.a will remain the same i.e= . 2? >=20 > Yes=2C it will. For hibernation=2C the contents of all memory from before= the image > was created is restored during resume. >=20 > > 2) During the system suspend=2C if the system hibernates=2C then the me= ssage sent from power management core to all drivers is > > PMSG_HIBERNATE and if system suspends to ram=2C then message sent from = power management core to all drivers is PMSG_SUSPEND. >=20 > That was in the old model=2C which isn't recommended any more. >=20 > Currently=2C it is recommended that drivers implement callbacks in struct= dev_pm_ops=2C > as described in Documentation/power/devices.txt and Documentation/power/p= ci.txt. >=20 > Thanks=2C > Rafael >=20 >=20 > > > From: rjw@sisk.pl > > > To: rajkumar278@hotmail.com > > > Subject: Re: Question about hibernation > > > Date: Fri=2C 8 Oct 2010 21:31:48 +0200 > > > CC: linux-pm@lists.linux-foundation.org > > >=20 > > > On Friday=2C October 08=2C 2010=2C you wrote: > > > >=20 > > > > Hi Rafael=2C > > >=20 > > > Hi=2C > > >=20 > > > > I am working on device driver whose some part is user space and som= e part is kernel space. So the user space part > > > > of the driver provides interface to user space applications.=20 > > > > 1) Now=2C Suppose some user space is application is going on which = is accessing the user space driver and user space driver > > > > scheduled some jobs to kernel space=2C Now suppose system hibernati= on start=2C since it freezes all the user space processes > > > > so suppose jobs are not completed yet which are scheduled to kernel= space by user space. > > > >=20 > > > > when the kernel space device driver completes the jobs and gives th= e notification to user space driver=2C since user space > > > > process is already frozen=2C so there will be problem if we suspend= the driver using suspend and resume. > > > >=20 > > > > right? > > >=20 > > > Yes=2C there's going to be a problem if the driver is not prepared to= handle such situations. > > >=20 > > > Depending of the particular case=2C one possible approach is to use a= PM notifier > > > as described in Documentation/power/notifiers.txt. > > >=20 > > > > 2) The other point I was seeing=2C when the power management core f= reezes all the processes before suspending and resuming > > > > devices=2C it will take some time for freezing and after that if so= me device driver refuses to suspend=2C then it will again resume > > > > the whole processes=2C so latency time be more. right? > > >=20 > > > Yes=2C it works as described. > > >=20 > > > > 3) Next question is regarding the kernel space threads=2C when thes= e are frozen during suspend/hibernation? > > >=20 > > > They are frozen immediately after user space has been frozen=2C but o= nly a > > > handful of kernel threads are frozen. > > >=20 > > > Thanks=2C > > > Rafael > >=20 >=20 = --_6610575e-f9c4-4200-afb4-d943525cd8d7_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable  =3B
Hi Rafael=2C
 =3B
Thanks for your quick reply. =3B
 =3B
1) I already implemented this with dev_pm_ops. I used suspend and resume ca= llbacks
whose prototype is like
 =3B
struct dev_pm_ops power_mgmt_ops
{
 =3B =3B .suspend =3D =3B powermanagement_suspend=2C
 =3B =3B .resume =3D =3B powermanagement_resume
 =3B
}
 =3B
int powermanagement_suspend(device *dev)
{
 =3B
}
 =3B
In normal suspend to ram mode it will work. But will it work in case of hib= ernation also?
 =3B
if yes=2C since in suspend and resume call backs=2C only the device structu= re is provided=2C so how can
then person can identify it is suspend to ram or hibernation?
 =3B
or for hibernation=2C poweroff =3B and restore function should be imple= mented which is similar
to suspend and resume call backs in case of suspend to ram?
 =3B
Regards
Raj
 =3B
 =3B
 =3B
 =3B
 =3B
 =3B
 =3B
 =3B
 =3B
 =3B

 =3B
>=3B From: rjw@sisk.pl
>=3B To: rajkumar278@hotmail.com
>=3B Su= bject: Re: Question about hibernation
>=3B Date: Thu=2C 14 Oct 2010 11= :51:05 +0200
>=3B CC: linux-pm@lists.linux-foundation.org
>=3B >=3B On Thursday=2C October 14=2C 2010=2C Raj Kumar wrote:
>=3B &g= t=3B
>=3B >=3B Hi Rafael=2C
>=3B >=3B
>=3B >=3B 1) I= have question on system resume that e.g. in device driver let us say for e= xample structure is defined global=2C
>=3B >=3B e.g.
>=3B >= =3B
>=3B >=3B struct dev
>=3B >=3B {
>=3B >=3B int a= =3B
>=3B >=3B
>=3B >=3B } dev_t=3B
>=3B >=3B
>= =3B >=3B
>=3B >=3B this structure is global. Now during system su= spend=2C suppose the value of
>=3B >=3B
>=3B >=3B dev_t.a = =3D2=3B
>=3B >=3B
>=3B >=3B So when the resume happens=2C wi= ll the dev_t.a will remain the same i.e. 2?
>=3B
>=3B Yes=2C it = will. For hibernation=2C the contents of all memory from before the image>=3B was created is restored during resume.
>=3B
>=3B >=3B= 2) During the system suspend=2C if the system hibernates=2C then the messa= ge sent from power management core to all drivers is
>=3B >=3B PMSG_= HIBERNATE and if system suspends to ram=2C then message sent from power man= agement core to all drivers is PMSG_SUSPEND.
>=3B
>=3B That was = in the old model=2C which isn't recommended any more.
>=3B
>=3B = Currently=2C it is recommended that drivers implement callbacks in struct d= ev_pm_ops=2C
>=3B as described in Documentation/power/devices.txt and = Documentation/power/pci.txt.
>=3B
>=3B Thanks=2C
>=3B Rafae= l
>=3B
>=3B
>=3B >=3B >=3B From: rjw@sisk.pl
>=3B= >=3B >=3B To: rajkumar278@hotmail.com
>=3B >=3B >=3B Subject:= Re: Question about hibernation
>=3B >=3B >=3B Date: Fri=2C 8 Oct = 2010 21:31:48 +0200
>=3B >=3B >=3B CC: linux-pm@lists.linux-founda= tion.org
>=3B >=3B >=3B
>=3B >=3B >=3B On Friday=2C Octo= ber 08=2C 2010=2C you wrote:
>=3B >=3B >=3B >=3B
>=3B >= =3B >=3B >=3B Hi Rafael=2C
>=3B >=3B >=3B
>=3B >=3B &g= t=3B Hi=2C
>=3B >=3B >=3B
>=3B >=3B >=3B >=3B I am wor= king on device driver whose some part is user space and some part is kernel= space. So the user space part
>=3B >=3B >=3B >=3B of the driver= provides interface to user space applications.
>=3B >=3B >=3B &g= t=3B 1) Now=2C Suppose some user space is application is going on which is = accessing the user space driver and user space driver
>=3B >=3B >= =3B >=3B scheduled some jobs to kernel space=2C Now suppose system hibern= ation start=2C since it freezes all the user space processes
>=3B >= =3B >=3B >=3B so suppose jobs are not completed yet which are scheduled= to kernel space by user space.
>=3B >=3B >=3B >=3B
>=3B &= gt=3B >=3B >=3B when the kernel space device driver completes the jobs = and gives the notification to user space driver=2C since user space
>= =3B >=3B >=3B >=3B process is already frozen=2C so there will be prob= lem if we suspend the driver using suspend and resume.
>=3B >=3B >= =3B >=3B
>=3B >=3B >=3B >=3B right?
>=3B >=3B >=3B <= BR>>=3B >=3B >=3B Yes=2C there's going to be a problem if the driver = is not prepared to handle such situations.
>=3B >=3B >=3B
>= =3B >=3B >=3B Depending of the particular case=2C one possible approach= is to use a PM notifier
>=3B >=3B >=3B as described in Documentat= ion/power/notifiers.txt.
>=3B >=3B >=3B
>=3B >=3B >=3B &= gt=3B 2) The other point I was seeing=2C when the power management core fre= ezes all the processes before suspending and resuming
>=3B >=3B >= =3B >=3B devices=2C it will take some time for freezing and after that if= some device driver refuses to suspend=2C then it will again resume
>= =3B >=3B >=3B >=3B the whole processes=2C so latency time be more. ri= ght?
>=3B >=3B >=3B
>=3B >=3B >=3B Yes=2C it works as de= scribed.
>=3B >=3B >=3B
>=3B >=3B >=3B >=3B 3) Next qu= estion is regarding the kernel space threads=2C when these are frozen durin= g suspend/hibernation?
>=3B >=3B >=3B
>=3B >=3B >=3B The= y are frozen immediately after user space has been frozen=2C but only a
= >=3B >=3B >=3B handful of kernel threads are frozen.
>=3B >=3B= >=3B
>=3B >=3B >=3B Thanks=2C
>=3B >=3B >=3B Rafael>=3B >=3B
>=3B
= --_6610575e-f9c4-4200-afb4-d943525cd8d7_-- --===============8844964534760418496== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============8844964534760418496==-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: Re: Question about hibernation Date: Thu, 14 Oct 2010 20:59:26 +0200 Message-ID: <201010142059.26869.rjw@sisk.pl> References: <201010141151.05297.rjw@sisk.pl> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org To: Raj Kumar Cc: linux-pm@lists.linux-foundation.org List-Id: linux-pm@vger.kernel.org On Thursday, October 14, 2010, Raj Kumar wrote: > > Hi Rafael, Hi, > Thanks for your quick reply. > > 1) I already implemented this with dev_pm_ops. I used suspend and resume callbacks > whose prototype is like > > struct dev_pm_ops power_mgmt_ops > { > .suspend = powermanagement_suspend, > .resume = powermanagement_resume > > } > > int powermanagement_suspend(device *dev) > { > > } > > In normal suspend to ram mode it will work. But will it work in case of hibernation also? It may be sufficient to point hibernate-specific callback pointers to your suspend/resume routines: struct dev_pm_ops power_mgmt_ops { .suspend = powermanagement_suspend, .resume = powermanagement_resume, .freeze = powermanagement_suspend, .thaw = powermanagement_resume, .poweroff = powermanagement_suspend, .restore = powermanagement_resume, } depending on the particular needs of your driver. > if yes, since in suspend and resume call backs, only the device structure is provided, so how can > then person can identify it is suspend to ram or hibernation? See above. > or for hibernation, poweroff and restore function should be implemented which is similar > to suspend and resume call backs in case of suspend to ram? Yes. Thanks, Rafael From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raj Kumar Subject: Question about hibernation Date: Fri, 18 Mar 2011 19:15:24 +0530 Message-ID: References: <201101050005.42914.rjw@sisk.pl> , <201101050927.53977.rjw@sisk.pl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1479390644609038224==" Return-path: In-Reply-To: <201101050927.53977.rjw@sisk.pl> 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: linux-pm@lists.linux-foundation.org List-Id: linux-pm@vger.kernel.org --===============1479390644609038224== Content-Type: multipart/alternative; boundary="_4a65a21c-020a-43a3-94de-282c8e4fe9b1_" --_4a65a21c-020a-43a3-94de-282c8e4fe9b1_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi=2C I have following question regarding the hibernation. If a device driver use= s dedicated memory (dedicated memory in linux which is not OS addressable e= .g. device driver is using some pages from dedicated memory)=2C When the sy= stem hibernates=2C will this be responsibility of device driver to save thi= s area=20 or=20 OS hibernation procedure save this area of ram (dedicated memory area) into= swap image? Thanks Raj =20 = --_4a65a21c-020a-43a3-94de-282c8e4fe9b1_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi=2C

I have following question regarding the hibernation. If a = device driver uses dedicated memory (dedicated memory in linux which is not= OS addressable e.g. device driver is using some pages from dedicated memor= y)=2C When the system hibernates=2C will this be responsibility of device d= river to save this area
or
OS hibernation procedure save this area = of ram (dedicated memory area) into swap image?

Thanks
Raj = =3B
= --_4a65a21c-020a-43a3-94de-282c8e4fe9b1_-- --===============1479390644609038224== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============1479390644609038224==-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oliver Neukum Subject: Re: Question about hibernation Date: Fri, 18 Mar 2011 15:09:02 +0100 Message-ID: <201103181509.02943.oneukum@suse.de> References: <201101050927.53977.rjw@sisk.pl> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org To: linux-pm@lists.linux-foundation.org Cc: Raj Kumar List-Id: linux-pm@vger.kernel.org Am Freitag, 18. M=E4rz 2011, 14:45:24 schrieb Raj Kumar: > = > Hi, > = > I have following question regarding the hibernation. If a device driver u= ses dedicated memory (dedicated memory in linux which is not OS addressable= e.g. device driver is using some pages from dedicated memory), When the sy= stem hibernates, will this be responsibility of device driver to save this = area = > or = > OS hibernation procedure save this area of ram (dedicated memory area) in= to swap image? If you got it from get_free_pages (at the end of a long call chain) the kernel saves it. If not, it is your problem. HTH Oliver From mboxrd@z Thu Jan 1 00:00:00 1970 From: Raj Kumar Subject: Re: Question about hibernation Date: Sun, 20 Mar 2011 05:17:23 +0530 Message-ID: References: <201101050927.53977.rjw@sisk.pl> , <201103181509.02943.oneukum@suse.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3552556263759473415==" Return-path: In-Reply-To: <201103181509.02943.oneukum@suse.de> 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: oneukum@suse.de, linux-pm@lists.linux-foundation.org List-Id: linux-pm@vger.kernel.org --===============3552556263759473415== Content-Type: multipart/alternative; boundary="_a1d3a9e1-7c51-4a35-8fd2-765fc4b55406_" --_a1d3a9e1-7c51-4a35-8fd2-765fc4b55406_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi=2C =20 Thanks for reply. What if memory is allocated using dma_alloc_coherent wher= e the physical address is from dedicated area of RAM(which is not addressab= le by OS)? I also believe that all the buffers and state variables are take= n care by OS kernel. Right? =20 Thanks Raj =20 =20 > From: oneukum@suse.de > To: linux-pm@lists.linux-foundation.org > Subject: Re: [linux-pm] Question about hibernation > Date: Fri=2C 18 Mar 2011 15:09:02 +0100 > CC: rajkumar278@hotmail.com >=20 > Am Freitag=2C 18. M=E4rz 2011=2C 14:45:24 schrieb Raj Kumar: > >=20 > > Hi=2C > >=20 > > I have following question regarding the hibernation. If a device driver= uses dedicated memory (dedicated memory in linux which is not OS addressab= le e.g. device driver is using some pages from dedicated memory)=2C When th= e system hibernates=2C will this be responsibility of device driver to save= this area=20 > > or=20 > > OS hibernation procedure save this area of ram (dedicated memory area) = into swap image? >=20 > If you got it from get_free_pages (at the end of a long call chain) the > kernel saves it. If not=2C it is your problem. >=20 > HTH > Oliver = --_a1d3a9e1-7c51-4a35-8fd2-765fc4b55406_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi=2C
 =3B
Thanks for reply. What if memory is allocated using dma_alloc_coherent wher= e the physical address is from dedicated area of RAM(which is not addressab= le by OS)? I also believe that all the buffers and state variables are take= n care by OS kernel. Right?
 =3B
Thanks
Raj
 =3B

 =3B
>=3B From: oneukum@suse.de
>=3B To: linux-pm@lists.linux-foundation.= org
>=3B Subject: Re: [linux-pm] Question about hibernation
>=3B = Date: Fri=2C 18 Mar 2011 15:09:02 +0100
>=3B CC: rajkumar278@hotmail.c= om
>=3B
>=3B Am Freitag=2C 18. M=E4rz 2011=2C 14:45:24 schrieb R= aj Kumar:
>=3B >=3B
>=3B >=3B Hi=2C
>=3B >=3B
>= =3B >=3B I have following question regarding the hibernation. If a device= driver uses dedicated memory (dedicated memory in linux which is not OS ad= dressable e.g. device driver is using some pages from dedicated memory)=2C = When the system hibernates=2C will this be responsibility of device driver = to save this area
>=3B >=3B or
>=3B >=3B OS hibernation pro= cedure save this area of ram (dedicated memory area) into swap image?
&g= t=3B
>=3B If you got it from get_free_pages (at the end of a long cal= l chain) the
>=3B kernel saves it. If not=2C it is your problem.
&g= t=3B
>=3B HTH
>=3B Oliver
= --_a1d3a9e1-7c51-4a35-8fd2-765fc4b55406_-- --===============3552556263759473415== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============3552556263759473415==--