Hi.
On Wed, 2007-05-30 at 23:11 +0200, Rafael J. Wysocki wrote:
quoted text > On Wednesday, 30 May 2007 22:44, Rafael J. Wysocki wrote:
> > Hi,
> >=20
> > On Wednesday, 30 May 2007 17:37, Pavel Machek wrote:
> > > Hi!
> > >=20
> > > > +Suspend notifiers
> > > > + (C) 2007 Rafael J. Wysocki <rjw@sisk.pl>, GPL
> > > > +
> > > > +There are some operations that device drivers may want to carry ou=
t in their
quoted text > > > > +.suspend() routines, but shouldn't, because they can cause the hib=
ernation or
quoted text > > > > +suspend to fail. For example, a driver may want to allocate a subs=
tantial amount
quoted text > > > > +of memory (like 50 MB) in .suspend(), but that shouldn't be done a=
fter the
quoted text > > > > +swsusp's memory shrinker has run.
> > > > +
> > > > +Also, there may be some operations, that subsystems want to carry =
out before a
quoted text > > > > +hibernation/suspend or after a restore/resume, requiring the syste=
m to be fully
quoted text > > > > +functional, so the drivers' .suspend() and .resume() routines are =
not suitable
quoted text > > > > +for this purpose. For example, device drivers may want to upload =
firmware to
quoted text > > > > +their devices after a restore from a hibernation image, but they c=
annot do it by
quoted text > > > > +calling request_firmware() from their .resume() routines (user lan=
d processes
quoted text > > > > +are frozen at this point). The solution may be to load the firmwa=
re into
quoted text > > > > +memory before processes are frozen and upload it from there in the=
.resume()
quoted text > > > > +routine. Of course, a hibernation notifier may be used for this p=
urpose.
quoted text > > > > +
> > > > +The subsystems that have such needs can register suspend notifiers=
that will be
quoted text > > > > +called upon the following events by the suspend core:
> > > > +
> > > > +PM_PRE_FREEZE The system is going to hibernate or suspend, tasks =
will
quoted text > > > > + be frozen immediately
> > >=20
> > > Hmm, looks like bad idea if we are going to remove freezer from
> > > suspend...?
> >=20
> > We need PM_PRE_FREEZE anyway and it's a different question whether or n=
ot
quoted text > > it'll be used for suspend (STR) too.
> >=20
> > The timing is not the best one, but so far the freezer is in the suspen=
d code
quoted text > > path and I need to take this into account.
> > =20
> > > > +PM_POST_THAW Tasks have just been thawed after a resume or restor=
e
quoted text > > > > + from a hibernation image
> > > > +
> > > > +PM_HIBERNATION_PREPARE The system is preparing for hibernation. T=
asks have
quoted text > > > > + been frozen, memory is going to be freed and devices
> > > > + are going to be suspended.
> > >=20
> > > Is not PRE_FREEZE enough? We can allocate memory for drivers there,
> > > too...
> >=20
> > Well, there is a reason for not doing this. Namely, if the memory if f=
reed on
quoted text > > PM_POST_HIBERNATION after the image has been created, we can use it for=
saving
quoted text > > the image (and speed up the saving).
> >=20
> > Besides, if the freezer is dropped from the suspend code, the notifiers=
will be
quoted text > > useful to it anyway IMO, and PRE_FREEZE won't make sense in that case.
> >=20
> > I think the rule should be: If you need to do something _before_ tasks =
are
quoted text > > frozen, do it in PM_PRE_FREEZE, but if you can do that after the tasks =
have
quoted text > > been frozen, do it on PM_HIBERNATION_PREPARE (or PM_SUSPEND_PREPARE in =
the
quoted text > > suspend case).
>=20
> OTOH, having considered it for a while, I think that for now I can add ju=
st
quoted text > PM_PRE_FREEZE and PM_POST_THAW, as I don't have any user for the other on=
es.
quoted text > The other events may be added in the future if need be (along with some u=
sers).
quoted text >=20
> I'll post revised patches in a new thread.
I haven't been giving this much attention, so forgive me if I'm about to
ask a silly question... which notifiers would you see the avenrun
saving/restoring using?
Regards,
Nigel