Skip to contentSkip to conversation

Question about hibernation

DISCUSSION Raj Kumar 2 participants 6 messages Oct 8, 2010 – Oct 14, 2010 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Raj Kumar

author
#1 lore raw

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

Quoted 32 lines

Date: Wed, 6 Oct 2010 00:43:30 +0200
From: "Rafael J. Wysocki" <[email protected]>
Subject: Re: [linux-pm] Question about hibernation
To: [email protected]
Message-ID: <[email protected]>
Content-Type: Text/Plain; charset="iso-8859-2"

Quoted 6 lines · Raj Kumar

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.

Quoted 1 line

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.

Quoted 3 lines

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

#2 lore raw
Quoted 2 lines · you

Hi Rafael,

Hi,

Quoted 10 lines

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.

Quoted 3 lines

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.

Quoted 1 line

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

author
#3 lore raw

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

Quoted 41 lines

From: [email protected]
To: [email protected]
Subject: Re: Question about hibernation
Date: Fri, 8 Oct 2010 21:31:48 +0200
CC: [email protected]

Quoted 2 lines · you

Hi Rafael,

Hi,

Quoted 10 lines

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.

Quoted 3 lines

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.

Quoted 1 line

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

#4 lore raw
Quoted 10 lines · Raj Kumar

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;

Quoted 8 lines

} 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.

Quoted 2 lines

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

Quoted 42 lines
Quoted 41 lines

From: [email protected]
To: [email protected]
Subject: Re: Question about hibernation
Date: Fri, 8 Oct 2010 21:31:48 +0200
CC: [email protected]

Quoted 2 lines · you

Hi Rafael,

Hi,

Quoted 10 lines

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.

Quoted 3 lines

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.

Quoted 1 line

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

author
#5 lore raw

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

Quoted 84 lines

From: [email protected]
To: [email protected]
Subject: Re: Question about hibernation
Date: Thu, 14 Oct 2010 11:51:05 +0200
CC: [email protected]

Quoted 10 lines · Raj Kumar

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;

Quoted 8 lines

} 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.

Quoted 2 lines

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

Quoted 42 lines
Quoted 41 lines

From: [email protected]
To: [email protected]
Subject: Re: Question about hibernation
Date: Fri, 8 Oct 2010 21:31:48 +0200
CC: [email protected]

Quoted 2 lines · you

Hi Rafael,

Hi,

Quoted 10 lines

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.

Quoted 3 lines

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.

Quoted 1 line

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

#6 lore raw
Quoted 2 lines · Raj Kumar

Hi Rafael,

Hi,

Quoted 10 lines

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

Quoted 8 lines

}

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.

Quoted 2 lines

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.

Quoted 2 lines

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