Re: [RFC][PATCH 0/8] PM: Implement autosleep and "wake locks"

Arve Hjønnevåg
2012-02-14T02:07:30Z

On Mon, Feb 6, 2012 at 5:00 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
...
> All in all, it's not as much code as I thought it would be and it seems to be
> relatively simple (which rises the question why the Android people didn't
> even _try_ to do something like this instead of slapping the "real" wakelocks
> onto the kernel FWIW).  IMHO it doesn't add anything really new to the kernel,
> except for the user space interfaces that should be maintainable.  At least I
> think I should be able to maintain them. :-)
>

Replacing a working solution with an untested one takes time. That
said, I have recently tried replacing all our kernel wake-locks with a
thin wrapper around wake-sources. This appears to mostly work, but the
wake-source timeout feature has some bugs or incompatible apis. An
init api would also be useful for embedding wake-sources in other data
structures without adding another memory allocation. Your patch to
move the spinlock init to wakeup_source_add still require the struct
to be zero initialized and the name set manually.

I needed to use two wake-sources per wake-lock since calling
__pm_stay_awake after __pm_wakeup_event on a wake-source does not
cancel the timeout. Unless there is a reason to keep this behavior I
would like __pm_stay_awake to cancel any active timeout.

Destroying a wake-source also has some problems. If you call
wakeup_source_destroy it will spin forever if the wake-source is
active without a timeout. And, if you call __pm_relax then
wakeup_source_destroy it could free the wake-source memory while the
timer function is still running. It also looks as if the wake_source
can be immediately deactivated if you call __pm_wakeup_event at the
same time as the previous timeout expired.

--
Arve Hjønnevåg