* Re: Runtime power management during system resume
[not found] ` <Pine.LNX.4.44L0.1008241029000.1652-100000@iolanthe.rowland.org>
@ 2010-08-24 15:17 ` Raj Kumar
2010-08-24 17:50 ` Alan Stern
2010-08-25 13:27 ` Raj Kumar
0 siblings, 2 replies; 20+ messages in thread
From: Raj Kumar @ 2010-08-24 15:17 UTC (permalink / raw)
To: stern, linux-pm
Hi,
My question is:
1) When the system suspends, it invokes pm_runtime_put_sync when complete
callback is called which will again trigger to put device idle
means in runtime power management core, the device status is set to RPM_SUSPENDED.
right?
2) As you also said that during system resume, it does not increment the power_usage
counter,
that is ok, driver will increase the power_usage counter...
But will driver also set the state to RPM_ACTIVE means pm_runtime_set_active
right?
3) During hibernation, if the driver is registered using platform_driver_register...
When the system hibernates, will power management core call suspend, resume?
right?
Regards,
Raj
----------------------------------------
> Date: Tue, 24 Aug 2010 10:30:25 -0400
> From: stern@rowland.harvard.edu
> To: rajkumar278@hotmail.com
> CC: linux-kernel@vger.kernel.org
> Subject: Re: Runtime power management during system resume
>
> On Tue, 24 Aug 2010, Raj Kumar wrote:
>
>> Hi Alan,
>>
>> I have implemented the run time power management in my drivers. I have one
>> issue regarding System resume.
>>
>> When the system sleep is triggered as it is mentioned that Power management
>> core will increment the power_usage counter during prepare and decrements when complete
>> is called.
>>
>> Now I have few questions:
>>
>> 1) When the system resume is done, it does not increase the power_usage counter.
>> right?
>
> That's right.
>
>> So Does then the driver need to update the power_usage counter with run time power management
>> core and again set it to active means RPM_ACTIVE?
>
> Read section 6 of Documentation/power/runtime_pm.h. It explains this.
>
>> 2) Suppose device is active, means its power_usage counter is already one, Now during system
>> sleep, does the driver first suspend it with run time power management core and then continue
>> System suspend?
>
> No.
>
>> 3) Because I have seen the code of power management core and I did not see the that during
>> system suspend, run time power management status is updated means RPM_SUSPENDED.
>> right?
>
> I don't understand your question.
>
> Alan Stern
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Runtime power management during system resume
2010-08-24 15:17 ` Runtime power management during system resume Raj Kumar
@ 2010-08-24 17:50 ` Alan Stern
2010-08-25 13:27 ` Raj Kumar
1 sibling, 0 replies; 20+ messages in thread
From: Alan Stern @ 2010-08-24 17:50 UTC (permalink / raw)
To: Raj Kumar; +Cc: linux-pm
On Tue, 24 Aug 2010, Raj Kumar wrote:
>
>
> Hi,
>
> My question is:
>
> 1) When the system suspends, it invokes pm_runtime_put_sync when complete
> callback is called which will again trigger to put device idle
>
> means in runtime power management core, the device status is set to RPM_SUSPENDED.
> right?
If the runtime_idle callback routine decides to call
pm_runtime_suspend() then the status will be set to RPM_SUSPENDED.
Otherwise the status will remain RPM_ACTIVE.
> 2) As you also said that during system resume, it does not increment the power_usage
> counter,
>
> that is ok, driver will increase the power_usage counter...
>
> But will driver also set the state to RPM_ACTIVE means pm_runtime_set_active
>
> right?
The driver is supposed to do that.
> 3) During hibernation, if the driver is registered using platform_driver_register...
>
> When the system hibernates, will power management core call suspend, resume?
Yes.
Alan Stern
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Runtime power management during system resume
2010-08-24 15:17 ` Runtime power management during system resume Raj Kumar
2010-08-24 17:50 ` Alan Stern
@ 2010-08-25 13:27 ` Raj Kumar
2010-08-25 14:51 ` Alan Stern
2010-08-26 13:40 ` Raj Kumar
1 sibling, 2 replies; 20+ messages in thread
From: Raj Kumar @ 2010-08-25 13:27 UTC (permalink / raw)
To: stern, linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 2593 bytes --]
Hi Alan,
Thanks for quick replies. As you said
> >> 2) Suppose device is active, means its power_usage counter is already one, Now during system
> >> sleep, does the driver first suspend it with run time power management core and then continue
> >> System suspend?
> >
{ALAN} No.
But since during system suspend power_usage counter is incremented by 1 But if the device is active
means its state is RPM_ACTIVE, its power_usage counter is 1 in run time power management core.
when the system suspend happens, it will also increment the power_usage_counter by 1 during dpm_prepare
Now the power_usage_counter is 2.
So when dpm_complete is invoked, it will decrement the power_usage_counter by 1 during dpm_complete.
So now when the drivers gets system suspend, its power_usage counter is still 1.
So what in this scenario, does the device decrements the power_usage counter itself?
Thanks
Raj
>
>
>
> ----------------------------------------
> > Date: Tue, 24 Aug 2010 10:30:25 -0400
> > From: stern@rowland.harvard.edu
> > To: rajkumar278@hotmail.com
> > CC: linux-kernel@vger.kernel.org
> > Subject: Re: Runtime power management during system resume
> >
> > On Tue, 24 Aug 2010, Raj Kumar wrote:
> >
> >> Hi Alan,
> >>
> >> I have implemented the run time power management in my drivers. I have one
> >> issue regarding System resume.
> >>
> >> When the system sleep is triggered as it is mentioned that Power management
> >> core will increment the power_usage counter during prepare and decrements when complete
> >> is called.
> >>
> >> Now I have few questions:
> >>
> >> 1) When the system resume is done, it does not increase the power_usage counter.
> >> right?
> >
> > That's right.
> >
> >> So Does then the driver need to update the power_usage counter with run time power management
> >> core and again set it to active means RPM_ACTIVE?
> >
> > Read section 6 of Documentation/power/runtime_pm.h. It explains this.
> >
> >> 2) Suppose device is active, means its power_usage counter is already one, Now during system
> >> sleep, does the driver first suspend it with run time power management core and then continue
> >> System suspend?
> >
> > No.
> >
> >> 3) Because I have seen the code of power management core and I did not see the that during
> >> system suspend, run time power management status is updated means RPM_SUSPENDED.
> >> right?
> >
> > I don't understand your question.
> >
> > Alan Stern
> >
[-- Attachment #1.2: Type: text/html, Size: 3384 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Runtime power management during system resume
2010-08-25 13:27 ` Raj Kumar
@ 2010-08-25 14:51 ` Alan Stern
2010-08-26 13:40 ` Raj Kumar
1 sibling, 0 replies; 20+ messages in thread
From: Alan Stern @ 2010-08-25 14:51 UTC (permalink / raw)
To: Raj Kumar; +Cc: linux-pm
On Wed, 25 Aug 2010, Raj Kumar wrote:
> But since during system suspend power_usage counter is incremented by 1 But if the device is active
>
> means its state is RPM_ACTIVE, its power_usage counter is 1 in run time power management core.
>
>
>
> when the system suspend happens, it will also increment the power_usage_counter by 1 during dpm_prepare
>
>
>
> Now the power_usage_counter is 2.
>
>
>
> So when dpm_complete is invoked, it will decrement the power_usage_counter by 1 during dpm_complete.
>
>
>
> So now when the drivers gets system suspend, its power_usage counter is still 1.
>
>
>
> So what in this scenario, does the device decrements the power_usage counter itself?
Firstly, the _device_ can't change the power_usage counter. Only the
_driver_ can. You seem to keep forgetting this point; you need to keep
it straight:
Driver != Device
Secondly, after the system suspend the power_usage counter has the same
value as it did before. In your case the usage_counter was 1 before
the system suspend and it is 1 after the system suspend. Whatever
routine was responsible for setting the counter to 1 originally will
also be responsible for decrementing the counter to 0 some time later.
Alan Stern
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Runtime power management during system resume
2010-08-25 13:27 ` Raj Kumar
2010-08-25 14:51 ` Alan Stern
@ 2010-08-26 13:40 ` Raj Kumar
2010-08-26 14:33 ` Alan Stern
2010-09-18 11:49 ` (no subject) Raj Kumar
1 sibling, 2 replies; 20+ messages in thread
From: Raj Kumar @ 2010-08-26 13:40 UTC (permalink / raw)
To: stern, linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 3572 bytes --]
Hi Alan,
I have few more questions:
1) If the platform device driver is using platform_bus_type as its bus type, in that case is the parent of device is its bus?
2) Because I saw the code in platform_device_register, when any platform device is register, its parent is set to
platform bus?
right?
int platform_device_add(struct platform_device *pdev)
{
----------------------------------------
if (!pdev->dev.parent)
pdev->dev.parent = &platform_bus;
------------------------------------------------------
}
So when the platform device wants to use parent other than platform bus, is it possible to set the parent
of platform device to any other device rather than platform_bus?
3) The 3rd question is regarding, in this function
int __pm_runtime_resume(struct device *dev, bool from_wq)
__releases(&dev->power.lock) __acquires(&dev->power.lock)
{
-----------------------
if (dev->bus && dev->bus->pm && dev->bus->pm->runtime_resume) {
spin_unlock_irq(&dev->power.lock);
retval = dev->bus->pm->runtime_resume(dev);
spin_lock_irq(&dev->power.lock);
dev->power.runtime_error = retval;
}
--------------------
out:
if (parent) {
spin_unlock_irq(&dev->power.lock);
pm_runtime_put(parent);
spin_lock_irq(&dev->power.lock);
}
}
When the device is resumed and its status is set to RPM_ACTIVE, Now the control comes to
pm_runtime_put(parent) (suppose device is resumed correctly)
Now it decrements the power usage count and call idle for parent.
Why after resuming the device, It will try to schedule idle for its parent?
Since the device is resumed so its parent should be active.
Regards
Raj
> ----------------------------------------
> > Date: Tue, 24 Aug 2010 10:30:25 -0400
> > From: stern@rowland.harvard.edu
> > To: rajkumar278@hotmail.com
> > CC: linux-kernel@vger.kernel.org
> > Subject: Re: Runtime power management during system resume
> >
> > On Tue, 24 Aug 2010, Raj Kumar wrote:
> >
> >> Hi Alan,
> >>
> >> I have implemented the run time power management in my drivers. I have one
> >> issue regarding System resume.
> >>
> >> When the system sleep is triggered as it is mentioned that Power management
> >> core will increment the power_usage counter during prepare and decrements when complete
> >> is called.
> >>
> >> Now I have few questions:
> >>
> >> 1) When the system resume is done, it does not increase the power_usage counter.
> >> right?
> >
> > That's right.
> >
> >> So Does then the driver need to update the power_usage counter with run time power management
> >> core and again set it to active means RPM_ACTIVE?
> >
> > Read section 6 of Documentation/power/runtime_pm.h. It explains this.
> >
> >> 2) Suppose device is active, means its power_usage counter is already one, Now during system
> >> sleep, does the driver first suspend it with run time power management core and then continue
> >> System suspend?
> >
> > No.
> >
> >> 3) Because I have seen the code of power management core and I did not see the that during
> >> system suspend, run time power management status is updated means RPM_SUSPENDED.
> >> right?
> >
> > I don't understand your question.
> >
> > Alan Stern
> >
[-- Attachment #1.2: Type: text/html, Size: 5342 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Runtime power management during system resume
2010-08-26 13:40 ` Raj Kumar
@ 2010-08-26 14:33 ` Alan Stern
2010-09-18 11:49 ` (no subject) Raj Kumar
1 sibling, 0 replies; 20+ messages in thread
From: Alan Stern @ 2010-08-26 14:33 UTC (permalink / raw)
To: Raj Kumar; +Cc: Linux-pm mailing list
On Thu, 26 Aug 2010, Raj Kumar wrote:
> Hi Alan,
You know, it would be a lot easier to reply to your emails if you
didn't put so many blank lines in them and you told your email client
to wrap lines after 72 columns or so.
> I have few more questions:
>
>
>
> 1) If the platform device driver is using platform_bus_type as its bus type, in that case is the parent of device is its bus?
Maybe yes, maybe no.
>
>
>
> 2) Because I saw the code in platform_device_register, when any platform device is register, its parent is set to
>
> platform bus?
>
> right?
No. Look at the code again:
>
>
>
> int platform_device_add(struct platform_device *pdev)
> {
>
> ----------------------------------------
>
> if (!pdev->dev.parent)
> pdev->dev.parent = &platform_bus;
>
> ------------------------------------------------------
>
> }
The parent is set to platform_bus _only_ if the parent wasn't already
set.
>
>
>
> So when the platform device wants to use parent other than platform bus, is it possible to set the parent
>
> of platform device to any other device rather than platform_bus?
You're making that same mistake again. The _device_ doesn't get to
choose what the parent is; the _driver_ does.
Repeat after me:
Driver != Device
You need to learn that. If you can't remember the distinction between
a device and a driver then you will never be able to write kernel code.
Getting back to your question: Of course it is possible. The driver
merely has to set pdev->dev.parent before calling
platform_add_device().
>
>
>
>
>
> 3) The 3rd question is regarding, in this function
>
>
>
> int __pm_runtime_resume(struct device *dev, bool from_wq)
> __releases(&dev->power.lock) __acquires(&dev->power.lock)
> {
>
>
>
> -----------------------
> if (dev->bus && dev->bus->pm && dev->bus->pm->runtime_resume) {
> spin_unlock_irq(&dev->power.lock);
>
> retval = dev->bus->pm->runtime_resume(dev);
>
> spin_lock_irq(&dev->power.lock);
> dev->power.runtime_error = retval;
> }
>
>
>
> --------------------
>
> out:
> if (parent) {
> spin_unlock_irq(&dev->power.lock);
>
> pm_runtime_put(parent);
>
> spin_lock_irq(&dev->power.lock);
> }
>
> }
>
>
>
> When the device is resumed and its status is set to RPM_ACTIVE, Now the control comes to
>
> pm_runtime_put(parent) (suppose device is resumed correctly)
>
>
>
> Now it decrements the power usage count and call idle for parent.
Be careful. This calls pm_runtime_idle() for the parent, but
pm_runtime_idle() probably won't call the runtime_idle callback for the
parent. You'll see why if you read __pm_runtime_idle();
pm_children_suspended(parent) will return 0 unless
parent->power.ignore_children is set.
>
>
>
> Why after resuming the device, It will try to schedule idle for its parent?
>
>
>
> Since the device is resumed so its parent should be active.
Of course the parent is active. That's why pm_runtime_idle() is
called; only active devices get idle callbacks. The opposite of
"active" is "suspended" -- obviously we don't want to make idle
callbacks for suspended devices!
It is possible for an active device to have an idle or suspended
parent. This can happen if the parent's power.ignore_children flag is
set. For example, consider a situation where the device remains at
full power but the link between it and the computer has been powered
down. The device is still active, but its parent (the link) is
suspended.
Alan Stern
P.S.: You do not need to include copies of old emails at the bottom of
your messages. Please stop doing it.
> > ----------------------------------------
> > > Date: Tue, 24 Aug 2010 10:30:25 -0400
> > > From: stern@rowland.harvard.edu
> > > To: rajkumar278@hotmail.com
> > > CC: linux-kernel@vger.kernel.org
> > > Subject: Re: Runtime power management during system resume
> > >
> > > On Tue, 24 Aug 2010, Raj Kumar wrote:
> > >
> > >> Hi Alan,
> > >>
> > >> I have implemented the run time power management in my drivers. I have one
> > >> issue regarding System resume.
> > >>
> > >> When the system sleep is triggered as it is mentioned that Power management
> > >> core will increment the power_usage counter during prepare and decrements when complete
> > >> is called.
> > >>
> > >> Now I have few questions:
> > >>
> > >> 1) When the system resume is done, it does not increase the power_usage counter.
> > >> right?
> > >
> > > That's right.
> > >
> > >> So Does then the driver need to update the power_usage counter with run time power management
> > >> core and again set it to active means RPM_ACTIVE?
> > >
> > > Read section 6 of Documentation/power/runtime_pm.h. It explains this.
> > >
> > >> 2) Suppose device is active, means its power_usage counter is already one, Now during system
> > >> sleep, does the driver first suspend it with run time power management core and then continue
> > >> System suspend?
> > >
> > > No.
> > >
> > >> 3) Because I have seen the code of power management core and I did not see the that during
> > >> system suspend, run time power management status is updated means RPM_SUSPENDED.
> > >> right?
> > >
> > > I don't understand your question.
> > >
> > > Alan Stern
> > >
>
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* (no subject)
2010-08-26 13:40 ` Raj Kumar
2010-08-26 14:33 ` Alan Stern
@ 2010-09-18 11:49 ` Raj Kumar
2010-09-18 15:36 ` your mail Alan Stern
2010-10-05 21:40 ` Question about hibernation Raj Kumar
1 sibling, 2 replies; 20+ messages in thread
From: Raj Kumar @ 2010-09-18 11:49 UTC (permalink / raw)
To: stern, linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 710 bytes --]
Hi Alan,
I have question regarding the CPU frequency subsystem through which the frequency of the CPU is scaled.
e.g. If we have device driver (X device contains processor) that wants to scale its own processor based
upon the workload, (DVFS driver for this processor is implemented and registered with cpufreq subsystem)
then X device driver when detects waorkload, Can this X device driver call policy governor APIS for scaling clock or
this X device driver can directly calls DVFS driver APIs directly?
I just want to know from our device driver how do call DVFS driver if DVFS driver is registered with cpu frequency subsystem?
Regards
Raj
[-- Attachment #1.2: Type: text/html, Size: 1000 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: your mail
2010-09-18 11:49 ` (no subject) Raj Kumar
@ 2010-09-18 15:36 ` Alan Stern
2010-09-18 15:56 ` Dominik Brodowski
2010-10-05 21:40 ` Question about hibernation Raj Kumar
1 sibling, 1 reply; 20+ messages in thread
From: Alan Stern @ 2010-09-18 15:36 UTC (permalink / raw)
To: Raj Kumar; +Cc: linux-pm
On Sat, 18 Sep 2010, Raj Kumar wrote:
> Hi Alan,
>
>
>
> I have question regarding the CPU frequency subsystem through which the frequency of the CPU is scaled.
>
> e.g. If we have device driver (X device contains processor) that wants to scale its own processor based
>
> upon the workload, (DVFS driver for this processor is implemented and registered with cpufreq subsystem)
>
> then X device driver when detects waorkload, Can this X device driver call policy governor APIS for scaling clock or
>
> this X device driver can directly calls DVFS driver APIs directly?
I don't know. I have never used cpufreq and I don't know how it works.
> I just want to know from our device driver how do call DVFS driver if DVFS driver is registered with cpu frequency subsystem?
Then you should ask somebody else.
Alan Stern
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: your mail
2010-09-18 15:36 ` your mail Alan Stern
@ 2010-09-18 15:56 ` Dominik Brodowski
0 siblings, 0 replies; 20+ messages in thread
From: Dominik Brodowski @ 2010-09-18 15:56 UTC (permalink / raw)
To: Raj Kumar, linux-pm
Hi Raj,
On Sat, Sep 18, 2010 at 11:36:16AM -0400, Alan Stern wrote:
> > I have question regarding the CPU frequency subsystem through which the frequency of the CPU is scaled.
> >
> > e.g. If we have device driver (X device contains processor) that wants to scale its own processor based
> >
> > upon the workload, (DVFS driver for this processor is implemented and registered with cpufreq subsystem)
> >
> > then X device driver when detects waorkload, Can this X device driver call policy governor APIS for scaling clock or
> >
> > this X device driver can directly calls DVFS driver APIs directly?
Best would be to register a cpufreq policy notifier,
(cpufreq_register_notifier()), and then call cpufreq_update_policy()
whenever the "X device driver" needs to modify its frequency constraints.
In addition, it would be best to discuss this on the cpufreq mailing list at
cpufreq@vger.kernel.org
Best,
Dominik
^ permalink raw reply [flat|nested] 20+ messages in thread
* Question about hibernation
2010-09-18 11:49 ` (no subject) Raj Kumar
2010-09-18 15:36 ` your mail Alan Stern
@ 2010-10-05 21:40 ` Raj Kumar
2010-10-05 22:43 ` Rafael J. Wysocki
1 sibling, 1 reply; 20+ messages in thread
From: Raj Kumar @ 2010-10-05 21:40 UTC (permalink / raw)
To: stern, linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 664 bytes --]
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?
2) In hibernation mode, is freezing of tasks done before normal suspend/resumes in order to that hibernation image is in sync?
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?
Regards
Raj
[-- Attachment #1.2: Type: text/html, Size: 951 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Question about hibernation
2010-10-05 21:40 ` Question about hibernation Raj Kumar
@ 2010-10-05 22:43 ` Rafael J. Wysocki
0 siblings, 0 replies; 20+ messages in thread
From: Rafael J. Wysocki @ 2010-10-05 22:43 UTC (permalink / raw)
To: linux-pm
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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Question about hibernation
[not found] <mailman.23.1286318684.6175.linux-pm@lists.linux-foundation.org>
@ 2010-10-08 10:32 ` Raj Kumar
2010-10-08 19:31 ` Rafael J. Wysocki
0 siblings, 1 reply; 20+ messages in thread
From: Raj Kumar @ 2010-10-08 10:32 UTC (permalink / raw)
To: linux-pm, rjw
[-- Attachment #1.1: Type: text/plain, Size: 2516 bytes --]
Hi Rafael,
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?
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?
3) Next question is regarding the kernel space threads, when these are frozen during suspend/hibernation?
Thanks
Raj
> Date: Wed, 6 Oct 2010 00:43:30 +0200
> From: "Rafael J. Wysocki" <rjw@sisk.pl>
> 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; charset="iso-8859-2"
>
> 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
>
>
[-- Attachment #1.2: Type: text/html, Size: 3087 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Question about hibernation
2010-10-08 10:32 ` Raj Kumar
@ 2010-10-08 19:31 ` Rafael J. Wysocki
2010-10-14 8:20 ` Raj Kumar
0 siblings, 1 reply; 20+ messages in thread
From: Rafael J. Wysocki @ 2010-10-08 19:31 UTC (permalink / raw)
To: Raj Kumar; +Cc: linux-pm
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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Question about hibernation
2010-10-08 19:31 ` Rafael J. Wysocki
@ 2010-10-14 8:20 ` Raj Kumar
2010-10-14 9:51 ` Rafael J. Wysocki
0 siblings, 1 reply; 20+ messages in thread
From: Raj Kumar @ 2010-10-14 8:20 UTC (permalink / raw)
To: rjw; +Cc: linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 2606 bytes --]
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?
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.
correct me if I am wrong.
Regards
Raj
> 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
[-- Attachment #1.2: Type: text/html, Size: 3298 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Question about hibernation
2010-10-14 8:20 ` Raj Kumar
@ 2010-10-14 9:51 ` Rafael J. Wysocki
2010-10-14 11:47 ` Raj Kumar
0 siblings, 1 reply; 20+ messages in thread
From: Rafael J. Wysocki @ 2010-10-14 9:51 UTC (permalink / raw)
To: Raj Kumar; +Cc: linux-pm
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
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Question about hibernation
2010-10-14 9:51 ` Rafael J. Wysocki
@ 2010-10-14 11:47 ` Raj Kumar
2010-10-14 18:59 ` Rafael J. Wysocki
0 siblings, 1 reply; 20+ messages in thread
From: Raj Kumar @ 2010-10-14 11:47 UTC (permalink / raw)
To: rjw; +Cc: linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 4223 bytes --]
Hi Rafael,
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?
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?
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?
Regards
Raj
> From: rjw@sisk.pl
> To: rajkumar278@hotmail.com
> Subject: Re: Question about hibernation
> Date: Thu, 14 Oct 2010 11:51:05 +0200
> CC: linux-pm@lists.linux-foundation.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
> >
>
[-- Attachment #1.2: Type: text/html, Size: 5513 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Question about hibernation
2010-10-14 11:47 ` Raj Kumar
@ 2010-10-14 18:59 ` Rafael J. Wysocki
0 siblings, 0 replies; 20+ messages in thread
From: Rafael J. Wysocki @ 2010-10-14 18:59 UTC (permalink / raw)
To: Raj Kumar; +Cc: linux-pm
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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Question about hibernation
2011-01-05 8:27 ` Rafael J. Wysocki
@ 2011-03-18 13:45 ` Raj Kumar
2011-03-18 14:09 ` Oliver Neukum
0 siblings, 1 reply; 20+ messages in thread
From: Raj Kumar @ 2011-03-18 13:45 UTC (permalink / raw)
To: linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 439 bytes --]
Hi,
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 memory), When the system hibernates, will this be responsibility of device driver to save this area
or
OS hibernation procedure save this area of ram (dedicated memory area) into swap image?
Thanks
Raj
[-- Attachment #1.2: Type: text/html, Size: 659 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Question about hibernation
2011-03-18 13:45 ` Question about hibernation Raj Kumar
@ 2011-03-18 14:09 ` Oliver Neukum
2011-03-19 23:47 ` Raj Kumar
0 siblings, 1 reply; 20+ messages in thread
From: Oliver Neukum @ 2011-03-18 14:09 UTC (permalink / raw)
To: linux-pm; +Cc: Raj Kumar
Am Freitag, 18. März 2011, 14:45:24 schrieb Raj Kumar:
>
> Hi,
>
> 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 memory), When the system hibernates, will this be responsibility of device driver to save this area
> or
> OS hibernation procedure save this area of ram (dedicated memory area) into 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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: Question about hibernation
2011-03-18 14:09 ` Oliver Neukum
@ 2011-03-19 23:47 ` Raj Kumar
0 siblings, 0 replies; 20+ messages in thread
From: Raj Kumar @ 2011-03-19 23:47 UTC (permalink / raw)
To: oneukum, linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 1136 bytes --]
Hi,
Thanks for reply. What if memory is allocated using dma_alloc_coherent where the physical address is from dedicated area of RAM(which is not addressable by OS)? I also believe that all the buffers and state variables are taken care by OS kernel. Right?
Thanks
Raj
> From: oneukum@suse.de
> To: linux-pm@lists.linux-foundation.org
> Subject: Re: [linux-pm] Question about hibernation
> Date: Fri, 18 Mar 2011 15:09:02 +0100
> CC: rajkumar278@hotmail.com
>
> Am Freitag, 18. März 2011, 14:45:24 schrieb Raj Kumar:
> >
> > Hi,
> >
> > 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 memory), When the system hibernates, will this be responsibility of device driver to save this area
> > or
> > OS hibernation procedure save this area of ram (dedicated memory area) into 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
[-- Attachment #1.2: Type: text/html, Size: 1500 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2011-03-19 23:47 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <BLU102-W1030ED196ED7B94722F2A7EB830@phx.gbl>
[not found] ` <Pine.LNX.4.44L0.1008241029000.1652-100000@iolanthe.rowland.org>
2010-08-24 15:17 ` Runtime power management during system resume Raj Kumar
2010-08-24 17:50 ` Alan Stern
2010-08-25 13:27 ` Raj Kumar
2010-08-25 14:51 ` Alan Stern
2010-08-26 13:40 ` Raj Kumar
2010-08-26 14:33 ` Alan Stern
2010-09-18 11:49 ` (no subject) Raj Kumar
2010-09-18 15:36 ` your mail Alan Stern
2010-09-18 15:56 ` Dominik Brodowski
2010-10-05 21:40 ` Question about hibernation Raj Kumar
2010-10-05 22:43 ` Rafael J. Wysocki
[not found] <mailman.23.1286318684.6175.linux-pm@lists.linux-foundation.org>
2010-10-08 10:32 ` Raj Kumar
2010-10-08 19:31 ` Rafael J. Wysocki
2010-10-14 8:20 ` Raj Kumar
2010-10-14 9:51 ` Rafael J. Wysocki
2010-10-14 11:47 ` Raj Kumar
2010-10-14 18:59 ` Rafael J. Wysocki
2011-01-04 21:14 Question about timers during system suspend Raj Kumar
2011-01-04 23:05 ` Rafael J. Wysocki
2011-01-04 23:57 ` Raj Kumar
2011-01-05 8:27 ` Rafael J. Wysocki
2011-03-18 13:45 ` Question about hibernation Raj Kumar
2011-03-18 14:09 ` Oliver Neukum
2011-03-19 23:47 ` Raj Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox