Re: [RFD] Automatic suspend
From: Arve Hjønnevåg
Date: Fri Feb 20 2009 - 06:26:49 EST
On Fri, Feb 20, 2009 at 2:49 AM, Rafael J. Wysocki <rjw@xxxxxxx> wrote:
> On Friday 20 February 2009, Arve Hjønnevåg wrote:
>> On Thu, Feb 19, 2009 at 2:08 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
>> >> > It might have to be platform-specific. The Android people seem to have a
>> >> > pretty good idea of what criteria will work for them.
>> >>
>> >> I'd really like to know in what situations Androind is supposed to suspend
>> >> automatically.
>> >
>> > It might be better to ask in what situations Android is _not_ supposed
>> > to sleep automatically. In other words, in what situations is a
>> > wakelock acquired? Since the whole system is only a phone, this
>> > question should have a reasonably well-defined answer.
>>
>> On an android phone, any code that needs to run when the screen is off
>> must hold a wakelock (directly or indirectly). In general if an
>> application or the system is processing an event that may cause a user
>> notification (new email, incoming phone call, alarm, etc.) it needs to
>> prevent suspend. But, we also use wakelocks to upload stats or
>> download system updates in the background, and for media player or
>> (gps) data logging applications.
>
> All of this doesn't seem to require wakelocks acuired from kernel space.
> What do you need those wakelocks for?
Most events do not originate in user-space. Alarms start in our alarm
driver which locks a wakelock when its timer interrupt occurs. This
wakelock stays locked until the user-space alarm manager calls the
driver to wait for the next alarm. I've described how input events are
handled before. Without kernel wakelocks, if the user space power
manager had already turned off the screen and decided to suspend right
before a wakeup key is pressed, then that key could sit in the
in-kernel input queue until another key is pressed. Even if the
user-space thread read the key event before being frozen, it cannot
abort the suspend operation that was already started.
--
Arve Hjønnevåg
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/