Messages in this thread | | | Date | Mon, 17 Oct 2011 09:34:01 +1100 | From | NeilBrown <> | Subject | Re: [RFC][PATCH 0/2] PM / Sleep: Extended control of suspend/hibernate interfaces |
| |
On Sun, 16 Oct 2011 10:51:01 -0400 (EDT) Alan Stern <stern@rowland.harvard.edu> wrote:
> On Sat, 15 Oct 2011, Alan Stern wrote: > > > Basically, what we need is a reliable way to intercept the existing > > mechanisms for suspend/hibernate and to redirect the requests to the PM > > daemon. When the daemon is started up in "legacy" mode, it assumes > > there is a legacy client (representing the entire set of > > non-wakeup-aware programs) that always forbids suspend _except_ when > > one of the old mechanisms is invoked. > > The more I think about this, the better it seems. In essence, it > amounts to "virtualizing" the existing PM interface.
While "virtualizing" does sound attractive in some way, I think it would be the wrong thing to do. In practice there is only one process at a time that is likely to suspend the system. I've just been exploring how that works.
gnome-power-manager talks to upowerd over dbus to ask for a suspend. upowerd then runs /usr/sbin/pm-suspend. pm-suspend then runs all the script in /usr/lib/pm-utils/sleep.d/ and the calls "do_suspend" which is defined in /usr/lib/pm-utils/pm-functions
Ugghh.. That is a very deep stack that is doing things the "wrong" way. i.e. it is structured about request to suspend rather than requests to stay awake.
Nonetheless, we only really need to worry about the bottom of the stack. Rather than virtualize /sys/power/state, just modify pm-function, which you can probably do by putting appropriate content into /usr/lib/pm-utils/defaults. Get that to define a do_suspend which interacts with the new suspend-daemon to say "now would be a good time to suspend" - if nothing else is blocking suspend, it does.
Put it another way: power-management has always been "virtualized" via lots of shell scripts in pm-utils (and various daemons stacked on top of that). We just need to plug in to that virtualisation.
This is all based on gnome. kde might be different, but I suspect that it only at the top levels. I would be surprised if kde and the other desktops don't all end up going through pm-utils.
NeilBrown
[unhandled content-type:application/pgp-signature] | |