[Pm-utils] Question about hooks and suspend-hybrid.

Stefan Seyfried seife at suse.de
Tue Jul 1 04:59:05 PDT 2008


Victor Lowther wrote:
> On Thu, 2008-06-26 at 14:02 +0200, Stefan Seyfried wrote:
>> - there is only one hook (01grub) that even takes the suspend_hybrid parameter
>> - there i no resume_hybrid at all
>> - the hook-running code does never pass the suspend_hybrid parameter to any code.
>> So how is this supposed to work? Reading the HOWTO.hooks also did not provide
>> any clues.
> A good guideline is "on a suspend_hybrid, run whichever of the suspend
> or hibernate hooks saves the most state".  For the grub hook, that would
> be the hibernate hook.  For the video hooks, that would be the suspend
> hook.  

Unfortunately, only the hooks themselves know what they are doing, so we need
to give them a parameter to tell them we are going to do s2both.
Am i correct in assuming that hooks should be called with "suspend_hybrid"
during suspend, even though this is not implemented yet?

>> Actually looking at src/pm-action.in it seems that for suspend_hybrid, also
>> plain "suspend" and "resume" actions are given to the hooks, but this is of
>> course not entirely correct, and it is contrary to the documentation in
>> HOWTO.hooks...
> More like the documentation documents a case we do not yet handle, and
> the code assumes that if anyone is actually using suspend_hybrid, in
> practice it ends up being a normal suspend/resume cycle the majority of
> the time.  Not a perfect way to handle things, granted, but without a
> way of telling what mode we woke up from the least confusing to code
> for.
>> Might i suggest we use a "suspend_hybrid"/"resume_hybrid"-combination for
>> telling the hooks what to do?
> I do not think that a resume_hybrid flag is the right thing to do -- it
> does not correspond to an actual wakeup state, we will always be either
> resuming from suspend or hibernate.

However, even if we resume from suspend, in the hybrid case i need to e.g.
reset the stuff that was done by the grub hook (which needs to prepare for a
possible s2disk).
To do it 100% correct, we might need a "resume_hybrid" and a "thaw_hybrid"
version. However, i'm not sure if this would not be seriously overengineered,
since only very few hooks might need to something special in the hybrid case,
and it probably will not really hurt to just do this all the time, even in the
"normal" resume case.

Another solution would be to give a second parameter to the hooks, like

./$hook suspend hybrid
./$hook resume hybrid

Old and non-hybrid-aware hooks would just ignore the second parameter, hooks
that need to know about hybrid can detect that it is there and act
accordingly. How does that sound?

> What we need is for the kernel to
> actually be able to tell us that information so that we can run the
> power hooks with the appropriate parameter for the state we are actually
> waking up from.

Well, i can code this in s2both. I need to overhaul the exit codes anyway.
In-kernel suspend cannot do hybrid anyway AFAIK.

So what i will be doing right now in my pm-utils version is:

 - call hooks with "suspend_hybrid" during suspend
 - call hooks with "resume", as if returning from s2ram. Some hooks will do
   just a bit more in this case, which should not hurt.

If we agree that the above 2-parameter version is better, i can quickly adapt
to that, but i want to start testing real soon.

Thanks, and have fun,

Stefan Seyfried
R&D Team Mobile Devices            |              "Any ideas, John?"
SUSE LINUX Products GmbH, Nürnberg | "Well, surrounding them's out."

This footer brought to you by insane German lawmakers:
SUSE Linux Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)

More information about the Pm-utils mailing list