After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 604362 - GPM suspends twice on lid close
GPM suspends twice on lid close
Status: RESOLVED FIXED
Product: gnome-power-manager
Classification: Deprecated
Component: general
2.28.x
Other Linux
: Normal minor
: ---
Assigned To: GNOME Power Manager Maintainer(s)
GNOME Power Manager Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2009-12-11 12:30 UTC by Maciej (Matthew) Piechotka
Modified: 2010-01-23 14:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Manually check lid status in gpm_manager_client_changed_cb. Fixes double suspend issue (1.68 KB, patch)
2010-01-12 09:47 UTC, Chow Loong Jin
needs-work Details | Review
Make gpm_backlight_is_lid_closed return an updated value from devkit. (925 bytes, patch)
2010-01-23 09:55 UTC, Chow Loong Jin
none Details | Review

Description Maciej (Matthew) Piechotka 2009-12-11 12:30: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.
Comment 1 Maciej (Matthew) Piechotka 2009-12-25 11:42:36 UTC
I cannot reproduce it any more.
Comment 2 Maciej (Matthew) Piechotka 2009-12-26 10:38:02 UTC
I reproduce it twice. It seems to happen sometimes when suspend is set for both AC and Battery lid close.
Comment 3 Przemysław Kulczycki 2010-01-12 09:38:45 UTC
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
Comment 4 Chow Loong Jin 2010-01-12 09:47:11 UTC
Created attachment 151235 [details] [review]
Manually check lid status in gpm_manager_client_changed_cb. Fixes double suspend issue
Comment 5 Richard Hughes 2010-01-19 09:50:44 UTC
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.
Comment 6 Richard Hughes 2010-01-19 09:54:27 UTC
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.
Comment 7 Maciej (Matthew) Piechotka 2010-01-19 11:39:52 UTC
>     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.
Comment 8 Chow Loong Jin 2010-01-23 09:53:57 UTC
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.
Comment 9 Chow Loong Jin 2010-01-23 09:55:19 UTC
Created attachment 152071 [details] [review]
Make gpm_backlight_is_lid_closed return an updated value from devkit.
Comment 10 Chow Loong Jin 2010-01-23 09:56:36 UTC
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.
Comment 11 Richard Hughes 2010-01-23 14:52:58 UTC
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>