guidance-power-manager needs restarting after resume in order to suspend again

Bug #151648 reported by Luis Silva
4
Affects Status Importance Assigned to Milestone
kde-guidance (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: kde-guidance-powermanager

First of all I am running kubuntu gutsy fully up to date.
Suspend to RAM works flawlessly on my machine (laptop, Acer Aspire 1690 Wlmi, Pentium M 2GHz, 512MB RAM).
The problem happens when I suspend (to RAM) a second time by closing the lid. It simply does nothing. Note that any other method to suspend the computer works fine. I have to quit and restart the tray app. (the one that shows the battery left) in order to have the lid button to work again.

As a side note, I removed the files lidbtn and lm_lid from /etc/acpi.d/events because they were causing successive suspends after resume. The lid button really behaves like a button and not a switch drowning my acpid with events.

Installed version for guidance-backends, kde-guidance and kde-guidance-power-manager is 0.8.0svn20070928-0ubuntu5.

Revision history for this message
Laurie Bradshaw (lauriebradshaw) wrote :

I'm seeing the same problem (minus successive events), also on gutsy, same package versions (having eventually discovered my hp dv8333ea had the widely documented nvidia lockup problem, required a bios update, and acpi_osi=!Linux on the kernel command line in order to resume from suspend to ram at all ;) )

Revision history for this message
Stijn Vansummeren (stijn.vansummeren) wrote :

I have the same problem on my Dell XPS M1210 laptop running KUbuntu 7.10 Gutsy Gibbon.

* Summary:
The first time the lid is closed the laptop goes into sleep perfectly, after that I need to restart the power manager.

* Analysis of the problem:

I added some print statements to both guidance-power-manager.py and powermanage.py in /usr/share/python-support/kde-guidance-powermanager/
These print statements show that after resuming from the first sleep, the call
  self.powermanager.getLidClosedState()
in line 723 of guidance-power-manager.py trigger a KeyError exception in getLidClosedState() of powermanage.py.

I suspect that the problem lies in the following section of /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux:

#Refresh devices as a resume can do funny things
for type in button battery ac_adapter
do
        devices=`hal-find-by-capability --capability $type`
        for device in $devices
        do
                dbus-send --system --print-reply --dest=org.freedesktop.Hal \
                          $device org.freedesktop.Hal.Device.Rescan
        done
done

Could it be that after the rescan the lidObject of powermanage.py becomes invalid?

Revision history for this message
Stijn Vansummeren (stijn.vansummeren) wrote :

Attached is a fix to this bug.

The problem is that after a resume HAL re-inserts all button objects. These button objects are not necessarily re-inserted in the same order that they were in before resuming however. As such, the lid object can be "/org/freedesktop/Hal/devices/computer_logicaldev_input_0" before resume but "/org/freedesktop/Hal/devices/computer_logicaldev_input_2" after. In short, all references to the lid object in powermanage.py become invalid after resume.

This can be fixed by changing the function suspend in /usr/share/python-support/kde-guidance-powermanager/powermanage.py such that it reads:

    def suspend(self):
        """ Run a suspend command, either via HAL or script. """
        if SUSPEND_USE_HAL:
            try:
                self.computerObject.Suspend(3, dbus_interface="org.freedesktop.Hal.Device.SystemPowerManagement")

            except dbus.DBusException, e:
                pass #we get a DBusException: No reply within specified time
            finally:
                #Suspend causes HAL to re-insert all of its button devices (which may end up in a different order).
                #Make sure we have the up-to-date reference
                #We put this call in the finally clause as resume may throw an exception despite resuming OK
                self._initLid()
        else:
            self._sleepMode(S3_COMMAND)

This causes all reference to the lid object to be updated after resuming.

I am willing to update the corresponding .deb package for inclusion in KUbuntu if someone is willing to give me some pointers as how to do it and where to submit it to.

(It is possible that this bug has already been fixed in the current development version of kde-guidance. I have been unable to find where to get the development version, however.)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.