~sforshee/powerd/fix-display-timing

Viewing all changes in revision 105.

  • Committer: Seth Forshee
  • Date: 2014-01-03 15:07:52 UTC
  • Revision ID: seth.forshee@canonical.com-20140103150752-2fke19cpx2y04iv2
libsuspend: Make earlysuspend enter/exit with kernel early suspend processing

When writing to /sys/power/state with a kernel using the
earlysuspend implementation the kernel will queue up processing
for the request on a separate kernel thread. The work done here
can included suspending and resuming certain devices without
freezing userspace tasks.

This is causing issues with the display handling on mako. The
display is one of the devices suspended and resumed while
userspace is active, and the kernel exports the status of the
device via the /sys/power/wait_for_fb_{sleep,wake,status} files.
However, the early suspend / late resume processing is slow
enough that mashing on the power button quickly can cause powerd
to get ahead of the kernel suspend workqueue, causing us to turn
the display off and then back on _before_ the kernel has gotten
around to suspending the display device. The kernel reports that
the display device is awake, powerd tries to turn it on, but
then the kernel tries to suspend it. This leads to failed
requests to the display driver and sometims some sort of deadlock
situation (due to apparent bugs in the display driver).

To avoid this, make entering and exiting suspend synchronous with
the kernel's internal suspend work. The only window we have into
this is via the wait_for_fb_* files. When the earlysuspend
implementation is detected a thread is launched to monitor the
status of these files and set an internal state variable. Any
request to enter/exit suspend will block until the framebuffer is
in the desired state, ensuring that at least the display device
has been suspended or resumed before returning to the caller.
Since entering/exiting resume and turning the display on/off are
all handled on the main loop this prevents any attempts to
modify the state of the display until the device has transitioned
to its new state.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: