powerd always uses autosleep, whereas early_suspend would be more appropriate for some kernels

Bug #1323286 reported by John McAleely
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
powerd
Fix Released
Undecided
Yuan-Chen Cheng
powerd (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Some android BSPs (and associated kernels) use 'early_suspend' for power managment purposes. On some of these kernels, powerd 'finds autosleep and doesn't look for anything else'.

Powerd should be altered to support these Android BSPs, such that they can use early_suspend to do their power managment, since Ubuntu Touch aims to support a broad number of Android BSPs.

Related branches

Revision history for this message
John McAleely (john.mcaleely) wrote :

Is the description suffient? (It may be for a power expert, but I'm not 100% confident)

Revision history for this message
Seth Forshee (sforshee) wrote :

Fundamentally it only makes sense to use one interface to suspend the system. This is basically how powerd decides which to use:

 1) If /sys/power/autosleep exists, use autosleep
 2) Else if /sys/power/wake_{lock,unlock} exist, use early suspend (note that autosleep also has these nodes, so we can't simply swap 1 & 2 to prefer early suspend)
 3) Else assume the legacy /sys/power/state behavior

Not all Android devices use early suspend (e.g. the Nexus 10 uses autosleep), and I had seen public comments that indicated Android was planning to move to autosleep.

From this description here though I get the impression that some device has /sys/power/autosleep but expects to use early suspend, and that makes no sense to me. I seem to recall that having early suspend and autosleep in the same kernel would be impossible because the implementations would conflict with each other. Possibly someone might have added support for early suspend (thus probably breaking autosleep) but still left CONFIG_PM_AUTOSLEEP enabled and ended up with an ineffective autosleep file. In that case, why not disable CONFIG_PM_AUTOSLEEP?

However, if Android has some different mechanism for detecting which interface to use then it might make sense to make powerd compatible. In that case I'd suggest detailing the detection algorithm Android uses (or even better point to the code).

Revision history for this message
Seth Forshee (sforshee) wrote :

Okay, it looks like Android does it this way:

 1) Open /sys/power/state and write "on". If this doesn't return an error, use early suspend.
 2) Else open /sys/power/autosleep. If this is successful, use autosleep.
 3) Else attempt to use the legacy PM interfaces (I won't go into detail).
 4) Else fail

So I guess powerd should do similar to be compatible. It's still nonsensical to have an autosleep file which doesn't work, but I guess the reality is that this works okay with Android.

References:

https://android.googlesource.com/platform/system/core/+/android-4.4.2_r2/libsuspend/autosuspend.c
https://android.googlesource.com/platform/system/core/+/android-4.4.2_r2/libsuspend/autosuspend_earlysuspend.c
https://android.googlesource.com/platform/system/core/+/android-4.4.2_r2/libsuspend/autosuspend_autosleep.c
https://android.googlesource.com/platform/system/core/+/android-4.4.2_r2/libsuspend/autosuspend_wakeup_count.c

Revision history for this message
John McAleely (john.mcaleely) wrote :

I think the reality is the key point - I assume that once something works, most android BSPs simply move along to the next problem. So I agree we should do the selection in the same way, so ubuntu works on such BSPs 'out of the box'.

Changed in powerd:
status: New → Confirmed
Changed in powerd:
assignee: nobody → Yuan-Chen Cheng (ycheng-twn)
status: Confirmed → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package powerd - 0.16+14.10.20140903-0ubuntu1

---------------
powerd (0.16+14.10.20140903-0ubuntu1) utopic; urgency=low

  [ Yuan-Chen Cheng ]
  * Use android standard way on libsuspend detection. (LP: #1323286)
 -- Ubuntu daily release <email address hidden> Wed, 03 Sep 2014 04:56:50 +0000

Changed in powerd (Ubuntu):
status: New → Fix Released
Changed in powerd:
status: In Progress → Fix Committed
status: Fix Committed → Fix Released
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.