All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Arve Hjønnevåg" <arve@android.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: swetland@google.com, Nigel Cunningham <ncunningham@crca.org.au>,
	linux-pm@lists.linux-foundation.org
Subject: Re: [RFC][PATCH 00/11] Android PM extensions
Date: Thu, 29 Jan 2009 20:40:16 -0800	[thread overview]
Message-ID: <d6200be20901292040l5f540cf5ybbda03db9627c477@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0901292203470.4063-100000@netrider.rowland.org>

On Thu, Jan 29, 2009 at 7:27 PM, Alan Stern <stern@rowland.harvard.edu> wrote:
> On Thu, 29 Jan 2009, Arve Hjønnevåg wrote:
>> A wakelock prevents the system from entering suspend or other low-power
>> states when active.
>
> I wish your writing was clearer.  "when active" could mean "when the
> system is active" or "when the wakelock is active".  Try to be less
> ambiguous.  For example: "When a wakelock is locked, it blocks the
> system from entering suspend or other low-power states."

OK.

>> If the type is set to WAKE_LOCK_SUSPEND, the wakelock
>> prevents a full system suspend. If the type is WAKE_LOCK_IDLE, low-power
>> states that cause large interrupt latencies or that disable a set of
>> interrupts will not be entered from idle until the wakelocks are released.
>
> Here you talk about "will not be entered from idle", whereas above you
> mention "when active".  So which is it?  Does a wakelock affect an
> active system or an idle system?

Most of the document refers to wakelocks of type WAKE_LOCK_SUSPEND. If
create a wakelock of type WAKE_LOCK_IDLE affects the idle power state
instead.

>> - The Keypad driver gets an interrupt. It then locks the keypad-scan wakelock
>>   and starts scanning the keypad.
>
> Is the system asleep to begin with?  If it is, how does the keypad
> driver get this interrupt unless the system first wakes up?

It may have been. If it was, wake up should be for the interrupt using
the existing set_irq_wake call.

> Conversely, what happens if the PM core has just started a system
> suspend?  Does locking the wakelock force the suspend to be aborted?

Yes, assuming is has not already suspended all the drivers and
disabled interrupts.

>
>> - The keypad-scan code detects a key change and reports it to the input-event
>>   driver.
>> - The input-event driver sees the key change, enqueues an event, and locks
>>   the input-event-queue wakelock.
>> - The keypad-scan code detects that no keys are held and unlocks the
>>   keypad-scan wakelock.
>
> What use is the keypad-scan wakelock?  Isn't the fact that the keypad
> driver's interrupt handler is running already sufficient to prevent or
> delay a system suspend?

Once you hold one key down, you cannot get another interrupt if you
press another key on the same input line. The driver uses a timer to
scan the keypad matrix until all keys are released. A key on a
dedicated input with both rising and falling edge detect interrupt
would not need this wakelock.

>> - The user-space input-event thread returns from select/poll, locks the
>>   process-input-events wakelock and then calls read in the input-event device.
>> - The input-event driver dequeues the key-event and, since the queue is now
>>   empty, it unlocks the input-event-queue wakelock.
>
> Does the input-event-queue wakelock always prevent the system from
> suspending whenever the input queue is nonempty?

Yes.

> Does that mean if I
> type ahead while a program is running, I can't suspend the computer
> until the program processes the keystrokes?

The actual suspend will not happen until all the keys are processed,
but user-space can turn the screen off at any time.

> Does the wakelock mechanism distinguish between suspend or power-state
> transitions that happen automatically and transitions requested
> directly by userspace?

No.

> This would be a little more understandable if
> the wakelocks only prevent the system from suspending itself and don't
> prevent me from suspending the system.

When the user decides to suspend, we use the early-suspend api to tell
the kernel to turn of the screen and possibly some other devices.
Wakelocks are useful without early-suspend, but it must always enter
suspend when the last wakelock is unlocked.

>
>> - The user-space input-event thread returns from read. It determines that the
>>   key should not wake up the system, releases the process-input-events
>>   wakelock and calls select or poll.
>
> This makes no sense.  If the system wasn't asleep to begin with, how
> could the key wake it up?  And if the system _was_ asleep to begin
> with, how could all of this happen without waking the system up?

What I mean here is that the screen turns on and the system does not
immediately go back to sleep. The user-space framework has its own
idea of whether the system is awake or not. I can change this to
"fully wake up" or "turn on the screen".

-- 
Arve Hjønnevåg

  reply	other threads:[~2009-01-30  4:40 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-14  1:27 [RFC][PATCH 00/11] Android PM extensions Arve Hjønnevåg
2009-01-14  1:27 ` [PATCH 01/11] PM: Add wake lock api Arve Hjønnevåg
2009-01-14  1:27   ` [PATCH 02/11] PM: Add early suspend api Arve Hjønnevåg
2009-01-14  1:27     ` [PATCH 03/11] PM: Implement wakelock api Arve Hjønnevåg
2009-01-14  1:27       ` [PATCH 04/11] PM: Implement early suspend api Arve Hjønnevåg
2009-01-14  1:27         ` [PATCH 05/11] PM: Enable early suspend through /sys/power/state Arve Hjønnevåg
2009-01-14  1:27           ` [PATCH 06/11] PM: Add user-space wake lock api Arve Hjønnevåg
2009-01-14  1:27             ` [PATCH 07/11] PM: wakelock: Abort task freezing if a wake lock is held Arve Hjønnevåg
2009-01-14  1:27               ` [PATCH 08/11] PM: earlysuspend: Add console switch when user requested sleep state changes Arve Hjønnevåg
2009-01-14  1:27                 ` [PATCH 09/11] PM: earlysuspend: Removing dependence on console Arve Hjønnevåg
2009-01-14  1:27                   ` [PATCH 10/11] Input: Hold wake lock while event queue is not empty Arve Hjønnevåg
2009-01-14  1:27                     ` [PATCH 11/11] ledtrig-sleep: Add led trigger for sleep debugging Arve Hjønnevåg
2009-01-30 12:43             ` [PATCH 06/11] PM: Add user-space wake lock api Uli Luckas
2009-01-31  0:17               ` Arve Hjønnevåg
2009-01-31  7:24               ` Brian Swetland
2009-01-28 19:34           ` [PATCH 05/11] PM: Enable early suspend through /sys/power/state Pavel Machek
2009-01-31  3:13             ` Arve Hjønnevåg
2009-01-31 15:49               ` Alan Stern
2009-02-02 11:44                 ` Pavel Machek
2009-02-02 11:45               ` Pavel Machek
2009-02-02 22:36                 ` Arve Hjønnevåg
2009-01-14  9:48         ` [PATCH 04/11] PM: Implement early suspend api Nigel Cunningham
2009-01-14 23:57           ` Arve Hjønnevåg
2009-01-14  9:30       ` [PATCH 03/11] PM: Implement wakelock api Nigel Cunningham
2009-01-14 23:28         ` Arve Hjønnevåg
2009-01-14  9:17     ` [PATCH 02/11] PM: Add early suspend api Nigel Cunningham
2009-01-14 23:18       ` Arve Hjønnevåg
2009-01-14  9:09   ` [PATCH 01/11] PM: Add wake lock api Nigel Cunningham
2009-01-14 23:07     ` Arve Hjønnevåg
2009-01-14  9:01 ` [RFC][PATCH 00/11] Android PM extensions Nigel Cunningham
2009-01-15  0:10   ` Arve Hjønnevåg
2009-01-15  4:42   ` Arve Hjønnevåg
2009-01-15 15:08     ` Alan Stern
2009-01-15 20:34       ` Arve Hjønnevåg
2009-01-29 13:04       ` Pavel Machek
2009-01-30  1:16         ` Arve Hjønnevåg
2009-01-30  3:27           ` Alan Stern
2009-01-30  4:40             ` Arve Hjønnevåg [this message]
2009-01-30  6:04               ` Arve Hjønnevåg
2009-02-02 11:49                 ` Pavel Machek
2009-01-30  9:11               ` Pavel Machek
2009-01-30 12:34                 ` Uli Luckas
2009-02-02 11:46                   ` Pavel Machek
2009-01-30 15:13               ` Alan Stern
2009-01-31  0:02                 ` Arve Hjønnevåg
2009-01-31 16:19                   ` Alan Stern
2009-01-31 23:28                     ` Arve Hjønnevåg
2009-02-02 10:42                     ` Uli Luckas
2009-02-02 15:05                       ` Alan Stern
2009-02-02 16:15                         ` Uli Luckas
2009-02-02 16:35                           ` Alan Stern
2009-02-03 20:15                           ` Pavel Machek
2009-01-31  7:47                 ` Brian Swetland
2009-01-31 15:41                   ` Alan Stern
2009-01-31 18:39                     ` Rafael J. Wysocki
2009-01-31 18:54                       ` Igor Stoppa
2009-02-01  1:04                       ` Arve Hjønnevåg
2009-02-02 11:55                       ` Pavel Machek
2009-01-31 22:41                     ` Arve Hjønnevåg
2009-01-31 23:20                       ` Rafael J. Wysocki
2009-01-31 23:32                         ` Arve Hjønnevåg
2009-02-01  0:18                           ` Rafael J. Wysocki
2009-02-01  1:17                             ` Arve Hjønnevåg
2009-02-01  1:32                               ` Rafael J. Wysocki
2009-02-01  2:14                                 ` Arve Hjønnevåg
2009-02-01 12:30                                   ` Rafael J. Wysocki
2009-02-01 14:03                                     ` Woodruff, Richard
2009-02-01 17:43                                     ` Alan Stern
2009-02-01 19:27                                       ` Woodruff, Richard
2009-02-02 11:00                                       ` Uli Luckas
2009-02-02 15:09                                         ` Alan Stern
2009-02-02 16:24                                           ` Uli Luckas
2009-02-02 21:47                                           ` Nigel Cunningham
2009-02-02 23:21                                             ` Arve Hjønnevåg
2009-02-02 23:51                                               ` Nigel Cunningham
2009-02-03  0:08                                                 ` Arve Hjønnevåg
2009-02-04 13:25                                               ` Pavel Machek
2009-02-02 23:10                                           ` Arve Hjønnevåg
2009-02-03  3:27                                             ` Alan Stern
2009-02-03  4:18                                               ` Arve Hjønnevåg
2009-02-03 20:30                                                 ` Alan Stern
2009-02-04 13:29                                                 ` Pavel Machek
2009-02-02 11:56                         ` Pavel Machek
2009-02-02 12:38                           ` Uli Luckas
2009-01-30  9:08           ` Pavel Machek
2009-01-30  9:25             ` Brian Swetland
2009-01-28 19:31 ` Pavel Machek
2009-02-05  2:50 Arve Hjønnevåg
2009-02-06 23:51 ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d6200be20901292040l5f540cf5ybbda03db9627c477@mail.gmail.com \
    --to=arve@android.com \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=ncunningham@crca.org.au \
    --cc=stern@rowland.harvard.edu \
    --cc=swetland@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.