GNOME Bugzilla – Bug 604362
GPM suspends twice on lid close
Last modified: 2010-01-23 14:52:58 UTC
Computer is suspended twice if suspended by lid close i.e.: 1. Lid is closed 2. Computer suspends (like in suspend-to-ram) according to the preferences 3. Lid is opened 4. Computer resumes 5. Computer suspends (vt1 is shown) 6. Power button is pressed 7. Computer resumes Expected behaviour: lack of 5-7 What is strange is that it seems to be caused by fixing settings of pm-utils by setting suspend module form default to ususpend.
I cannot reproduce it any more.
I reproduce it twice. It seems to happen sometimes when suspend is set for both AC and Battery lid close.
Also see https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/492649 Ubuntu bug: Laptop automatically suspends right after resume if power cable was disconnected before resuming. Steps to reproduce: 1) Suspend your laptop with power cable plugged in 2) Disconnect power cable 3) Resume from suspend 4) Laptop goes to sleep right after wake up Also the reverse is possible - suspend on battery, connect power cable, resume - laptop will autosuspend. See my log (gnome-power-manager --verbose): http://launchpadlibrarian.net/37743253/gnome-power-manager.out
Created attachment 151235 [details] [review] Manually check lid status in gpm_manager_client_changed_cb. Fixes double suspend issue
Review of attachment 151235 [details] [review]: I think this is the right fix (the ordering of the callbacks are not predictable), but the comment doesn't reflect reality -- you mean GpmButton, not GpmBacklight. You also need to group the g_object_get calls. I'll make the changes, and commit to git. Thanks.
commit e95c1fd06ed177990f1dd37d989388cb1c349c87 Author: Richard Hughes <richard@hughsie.com> Date: Tue Jan 19 09:53:28 2010 +0000 Fix a race in the callback ordering so that we never suspend twice when the lid is closed. Fixes #604362 Based on a patch from Maciej Piechotka, many thanks. This problem has been fixed in our software repository. The fix will go into the next software release. Thank you for your bug report.
> Based on a patch from Maciej Piechotka, many thanks. > i am so sorry but I haven't send any patch. Chow Loong Jin is the author.
Actually there is another race condition in gpm_manager_console_kit_active_changed_cb. Found by Adam Stark in http://bugs.launchpad.net/bugs/425411. I propose changing gpm_button_is_lid_closed to return an updated value from DeviceKit instead of its own locally stored value to fix both race conditions at once. I'll attach a patch shortly. Please reopen this bug.
Created attachment 152071 [details] [review] Make gpm_backlight_is_lid_closed return an updated value from devkit.
The previously committed patch in commit e95c1fd06ed177990f1dd37d989388cb1c349c87 should be reverted in favour of this, though nothing bad should happen if it's left in place.
commit b10f242af345f01415d26e35edb147dd7177453b Author: Chow Loong Jin <hyperair@ubuntu.com> Date: Sat Jan 23 14:51:46 2010 +0000 Don't rely on the cached value of the lid status, to properly fix the double suspend. Signed-off-by: Richard Hughes <richard@hughsie.com>