public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "ivan.khoronzhuk" <ivan.khoronzhuk@ti.com>
To: NeilBrown <neilb@suse.de>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	<linux-kernel@vger.kernel.org>, <linux-input@vger.kernel.org>,
	Bengt Jonsson <bengt.g.jonsson@stericsson.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Bill Pemberton <wfp5p@virginia.edu>
Subject: Re: [RFC PATCH] Input: gpio_keys: Fix suspend/resume press event lost
Date: Mon, 28 Jan 2013 18:13:14 +0200	[thread overview]
Message-ID: <5106A39A.5010402@ti.com> (raw)
In-Reply-To: <20130122162434.5bcf3e14@notabene.brown>

On 01/22/2013 07:24 AM, NeilBrown wrote:
> On Mon, 21 Jan 2013 15:57:18 -0800 Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
>
>> Hi Ivan,
>>
>> On Mon, Jan 21, 2013 at 03:15:14PM +0200, Ivan Khoronzhuk wrote:
>>> Rebased on linux_omap/master.
>>>
>>> During suspend/resume the key press can be lost if time of resume
>>> sequence is significant.
>>>
>>> If press event cannot be remembered then the driver can read the
>>> current button state only in time of interrupt handling. But in some
>>> cases when time between IRQ and IRQ handler is significant we can
>>> read incorrect state. As a particular case, when device is in suspend
>>> we press wakupable key and up it back in a jiffy, the interrupt
>>> handler read the state of up but the interrupt source is press indeed.
>>> As a result, in a OS like android, we resume then suspend right away
>>> because the key state is not changed.
>>>
>>> This patch add to gpio_keys framework opportunity to recover lost of
>>> press key event at resuming. The variable "key_pressed" from
>>> gpio_button_data structure is not used for gpio keys, it is only used
>>> for gpio irq keys, so it is logically used to remember press lost
>>> while resuming.
>> The same could happen if you delay processing of interrupt long enough
>> during normal operation. If key is released by the time you get around
>> to reading it you will not see a key press.
>>
>> To me this sounds like you need to speed up your resume process so that
>> you can start serving interrupts quicker.
>>
> Agreed.  When I was looking at this I found that any genuine button press
> would have at least 70msec between press and release, while the device could
> wake up to the point of being able to handle interrupts in about 14msec.
> That is enough of a gap to make it pointless to try to 'fix' the code.
>
> With enough verbose debugging enabled that 14msec can easily grow to
> hundreds, but then if  you have debugging enabled to can discipline yourself
> to hold the button for longer.
>
> Ivan: What sort of delay are you seeing between the button press and the
> interrupt routine running?  And can you measure how long the button is
> typically down for?
>
> NeilBrown

In my case I have the delay between the button press and the ISR
about 145ms. If the button down for 120ms the IRQ press event is
lost and if 160ms event is captured. I cannot speed up resume
process enough to guarantee correct work, so I wrote this fix.

-- 
Regards,
Ivan Khoronzhuk


  reply	other threads:[~2013-01-28 16:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-21 13:15 [RFC PATCH] Input: gpio_keys: Fix suspend/resume press event lost Ivan Khoronzhuk
2013-01-21 23:57 ` Dmitry Torokhov
2013-01-22  5:24   ` NeilBrown
2013-01-28 16:13     ` ivan.khoronzhuk [this message]
2013-01-28 18:51       ` NeilBrown
2013-01-31 13:25         ` ivan.khoronzhuk
2013-02-04 22:40           ` NeilBrown
2013-02-06 16:57             ` ivan.khoronzhuk
  -- strict thread matches above, loose matches on Subject: below --
2013-01-18 12:51 Ivan Khoronzhuk

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=5106A39A.5010402@ti.com \
    --to=ivan.khoronzhuk@ti.com \
    --cc=bengt.g.jonsson@stericsson.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=wfp5p@virginia.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox