diff mbox

intel-vbtn: match power button on press rather than release

Message ID 1501866006-24811-1-git-send-email-mario.limonciello@dell.com (mailing list archive)
State Accepted, archived
Delegated to: Darren Hart
Headers show

Commit Message

Limonciello, Mario Aug. 4, 2017, 5 p.m. UTC
This fixes a problem where the system gets stuck in a loop
unable to wakeup via power button in s2idle.

The problem happens because:
 - press power button:
   - system emits 0xc0 (power press), event ignored
   - system emits 0xc1 (power release), event processed,
     emited as KEY_POWER
   - set wakeup_mode to true
   - system goes to s2idle
 - press power button
   - system emits 0xc0 (power press), wakeup_mode is true,
     system wakes
   - system emits 0xc1 (power release), event processed,
     emited as KEY_POWER
   - system goes to s2idle again

To avoid this situation, process the presses (which matches what
intel-hid does too).

Verified on an Dell XPS 9365

Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
---
 drivers/platform/x86/intel-vbtn.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Darren Hart Aug. 4, 2017, 5:29 p.m. UTC | #1
On Fri, Aug 04, 2017 at 12:00:06PM -0500, Mario Limonciello wrote:
> This fixes a problem where the system gets stuck in a loop
> unable to wakeup via power button in s2idle.
> 
> The problem happens because:
>  - press power button:
>    - system emits 0xc0 (power press), event ignored
>    - system emits 0xc1 (power release), event processed,
>      emited as KEY_POWER
>    - set wakeup_mode to true
>    - system goes to s2idle
>  - press power button
>    - system emits 0xc0 (power press), wakeup_mode is true,
>      system wakes
>    - system emits 0xc1 (power release), event processed,
>      emited as KEY_POWER
>    - system goes to s2idle again
> 
> To avoid this situation, process the presses (which matches what
> intel-hid does too).
> 
> Verified on an Dell XPS 9365
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>

This looks good to me - responding to the release is non-intuitive IMHO
anyway.  I'd like to see agreement from AceLan, but this should go into
the 4.13 rc cycle (at rc3 currently).
Rafael J. Wysocki Aug. 4, 2017, 11:30 p.m. UTC | #2
On Friday, August 4, 2017 7:29:53 PM CEST Darren Hart wrote:
> On Fri, Aug 04, 2017 at 12:00:06PM -0500, Mario Limonciello wrote:
> > This fixes a problem where the system gets stuck in a loop
> > unable to wakeup via power button in s2idle.
> > 
> > The problem happens because:
> >  - press power button:
> >    - system emits 0xc0 (power press), event ignored
> >    - system emits 0xc1 (power release), event processed,
> >      emited as KEY_POWER
> >    - set wakeup_mode to true
> >    - system goes to s2idle
> >  - press power button
> >    - system emits 0xc0 (power press), wakeup_mode is true,
> >      system wakes
> >    - system emits 0xc1 (power release), event processed,
> >      emited as KEY_POWER
> >    - system goes to s2idle again
> > 
> > To avoid this situation, process the presses (which matches what
> > intel-hid does too).
> > 
> > Verified on an Dell XPS 9365
> > 
> > Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
> 
> This looks good to me - responding to the release is non-intuitive IMHO
> anyway.  I'd like to see agreement from AceLan, but this should go into
> the 4.13 rc cycle (at rc3 currently).

Yes, it should, and I'm not sure if the original author's opinion matters here.

The patch makes sense to everyone involved and fixes an annoying issue, so
I don't see any real arguments against applying it.

Please feel free to add my ACK to it if that helps.

In any case, it has to go in before https://patchwork.kernel.org/patch/9873163/
does, is if it doesn't go into 4.13-rc after all, please let me know.

Thanks,
Rafael
Darren Hart Aug. 5, 2017, 8:57 p.m. UTC | #3
On Sat, Aug 05, 2017 at 01:30:20AM +0200, Rafael Wysocki wrote:
> On Friday, August 4, 2017 7:29:53 PM CEST Darren Hart wrote:
> > On Fri, Aug 04, 2017 at 12:00:06PM -0500, Mario Limonciello wrote:
> > > This fixes a problem where the system gets stuck in a loop
> > > unable to wakeup via power button in s2idle.
> > > 
> > > The problem happens because:
> > >  - press power button:
> > >    - system emits 0xc0 (power press), event ignored
> > >    - system emits 0xc1 (power release), event processed,
> > >      emited as KEY_POWER
> > >    - set wakeup_mode to true
> > >    - system goes to s2idle
> > >  - press power button
> > >    - system emits 0xc0 (power press), wakeup_mode is true,
> > >      system wakes
> > >    - system emits 0xc1 (power release), event processed,
> > >      emited as KEY_POWER
> > >    - system goes to s2idle again
> > > 
> > > To avoid this situation, process the presses (which matches what
> > > intel-hid does too).
> > > 
> > > Verified on an Dell XPS 9365
> > > 
> > > Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
> > 
> > This looks good to me - responding to the release is non-intuitive IMHO
> > anyway.  I'd like to see agreement from AceLan, but this should go into
> > the 4.13 rc cycle (at rc3 currently).
> 
> Yes, it should, and I'm not sure if the original author's opinion matters here.
> 
> The patch makes sense to everyone involved and fixes an annoying issue, so
> I don't see any real arguments against applying it.
> 
> Please feel free to add my ACK to it if that helps.

I always try to give those in MAINTAINERS a chance to respond, but I will queue
this up to fixes now.
Rafael J. Wysocki Aug. 5, 2017, 10:20 p.m. UTC | #4
On Saturday, August 5, 2017 10:57:53 PM CEST Darren Hart wrote:
> On Sat, Aug 05, 2017 at 01:30:20AM +0200, Rafael Wysocki wrote:
> > On Friday, August 4, 2017 7:29:53 PM CEST Darren Hart wrote:
> > > On Fri, Aug 04, 2017 at 12:00:06PM -0500, Mario Limonciello wrote:
> > > > This fixes a problem where the system gets stuck in a loop
> > > > unable to wakeup via power button in s2idle.
> > > > 
> > > > The problem happens because:
> > > >  - press power button:
> > > >    - system emits 0xc0 (power press), event ignored
> > > >    - system emits 0xc1 (power release), event processed,
> > > >      emited as KEY_POWER
> > > >    - set wakeup_mode to true
> > > >    - system goes to s2idle
> > > >  - press power button
> > > >    - system emits 0xc0 (power press), wakeup_mode is true,
> > > >      system wakes
> > > >    - system emits 0xc1 (power release), event processed,
> > > >      emited as KEY_POWER
> > > >    - system goes to s2idle again
> > > > 
> > > > To avoid this situation, process the presses (which matches what
> > > > intel-hid does too).
> > > > 
> > > > Verified on an Dell XPS 9365
> > > > 
> > > > Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
> > > 
> > > This looks good to me - responding to the release is non-intuitive IMHO
> > > anyway.  I'd like to see agreement from AceLan, but this should go into
> > > the 4.13 rc cycle (at rc3 currently).
> > 
> > Yes, it should, and I'm not sure if the original author's opinion matters here.
> > 
> > The patch makes sense to everyone involved and fixes an annoying issue, so
> > I don't see any real arguments against applying it.
> > 
> > Please feel free to add my ACK to it if that helps.
> 
> I always try to give those in MAINTAINERS a chance to respond, but I will queue
> this up to fixes now.

Thanks!
Darren Hart Aug. 6, 2017, 11:24 p.m. UTC | #5
On Sun, Aug 06, 2017 at 12:20:22AM +0200, Rafael Wysocki wrote:
> On Saturday, August 5, 2017 10:57:53 PM CEST Darren Hart wrote:
> > On Sat, Aug 05, 2017 at 01:30:20AM +0200, Rafael Wysocki wrote:
> > > On Friday, August 4, 2017 7:29:53 PM CEST Darren Hart wrote:
> > > > On Fri, Aug 04, 2017 at 12:00:06PM -0500, Mario Limonciello wrote:
> > > > > This fixes a problem where the system gets stuck in a loop
> > > > > unable to wakeup via power button in s2idle.
> > > > > 
> > > > > The problem happens because:
> > > > >  - press power button:
> > > > >    - system emits 0xc0 (power press), event ignored
> > > > >    - system emits 0xc1 (power release), event processed,
> > > > >      emited as KEY_POWER
> > > > >    - set wakeup_mode to true
> > > > >    - system goes to s2idle
> > > > >  - press power button
> > > > >    - system emits 0xc0 (power press), wakeup_mode is true,
> > > > >      system wakes
> > > > >    - system emits 0xc1 (power release), event processed,
> > > > >      emited as KEY_POWER
> > > > >    - system goes to s2idle again
> > > > > 
> > > > > To avoid this situation, process the presses (which matches what
> > > > > intel-hid does too).
> > > > > 
> > > > > Verified on an Dell XPS 9365
> > > > > 
> > > > > Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
> > > > 
> > > > This looks good to me - responding to the release is non-intuitive IMHO
> > > > anyway.  I'd like to see agreement from AceLan, but this should go into
> > > > the 4.13 rc cycle (at rc3 currently).
> > > 
> > > Yes, it should, and I'm not sure if the original author's opinion matters here.
> > > 
> > > The patch makes sense to everyone involved and fixes an annoying issue, so
> > > I don't see any real arguments against applying it.
> > > 
> > > Please feel free to add my ACK to it if that helps.
> > 
> > I always try to give those in MAINTAINERS a chance to respond, but I will queue
> > this up to fixes now.
> 
> Thanks!

Rafael,

Merged to mainline (in case you were waiting on this for the dependent
patch you mentioned).
Rafael J. Wysocki Aug. 7, 2017, 12:38 a.m. UTC | #6
On Mon, Aug 7, 2017 at 1:24 AM, Darren Hart <dvhart@infradead.org> wrote:
> On Sun, Aug 06, 2017 at 12:20:22AM +0200, Rafael Wysocki wrote:
>> On Saturday, August 5, 2017 10:57:53 PM CEST Darren Hart wrote:
>> > On Sat, Aug 05, 2017 at 01:30:20AM +0200, Rafael Wysocki wrote:
>> > > On Friday, August 4, 2017 7:29:53 PM CEST Darren Hart wrote:
>> > > > On Fri, Aug 04, 2017 at 12:00:06PM -0500, Mario Limonciello wrote:
>> > > > > This fixes a problem where the system gets stuck in a loop
>> > > > > unable to wakeup via power button in s2idle.
>> > > > >
>> > > > > The problem happens because:
>> > > > >  - press power button:
>> > > > >    - system emits 0xc0 (power press), event ignored
>> > > > >    - system emits 0xc1 (power release), event processed,
>> > > > >      emited as KEY_POWER
>> > > > >    - set wakeup_mode to true
>> > > > >    - system goes to s2idle
>> > > > >  - press power button
>> > > > >    - system emits 0xc0 (power press), wakeup_mode is true,
>> > > > >      system wakes
>> > > > >    - system emits 0xc1 (power release), event processed,
>> > > > >      emited as KEY_POWER
>> > > > >    - system goes to s2idle again
>> > > > >
>> > > > > To avoid this situation, process the presses (which matches what
>> > > > > intel-hid does too).
>> > > > >
>> > > > > Verified on an Dell XPS 9365
>> > > > >
>> > > > > Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
>> > > >
>> > > > This looks good to me - responding to the release is non-intuitive IMHO
>> > > > anyway.  I'd like to see agreement from AceLan, but this should go into
>> > > > the 4.13 rc cycle (at rc3 currently).
>> > >
>> > > Yes, it should, and I'm not sure if the original author's opinion matters here.
>> > >
>> > > The patch makes sense to everyone involved and fixes an annoying issue, so
>> > > I don't see any real arguments against applying it.
>> > >
>> > > Please feel free to add my ACK to it if that helps.
>> >
>> > I always try to give those in MAINTAINERS a chance to respond, but I will queue
>> > this up to fixes now.
>>
>> Thanks!
>
> Rafael,
>
> Merged to mainline (in case you were waiting on this for the dependent
> patch you mentioned).

Awesome, thanks!
Chia-Lin Kao (AceLan) Aug. 7, 2017, 12:59 a.m. UTC | #7
Looks like I'm one hour late to ack the patch.
Thanks any way for the quick response.

2017-08-07 8:38 GMT+08:00 Rafael J. Wysocki <rafael@kernel.org>:
> On Mon, Aug 7, 2017 at 1:24 AM, Darren Hart <dvhart@infradead.org> wrote:
>> On Sun, Aug 06, 2017 at 12:20:22AM +0200, Rafael Wysocki wrote:
>>> On Saturday, August 5, 2017 10:57:53 PM CEST Darren Hart wrote:
>>> > On Sat, Aug 05, 2017 at 01:30:20AM +0200, Rafael Wysocki wrote:
>>> > > On Friday, August 4, 2017 7:29:53 PM CEST Darren Hart wrote:
>>> > > > On Fri, Aug 04, 2017 at 12:00:06PM -0500, Mario Limonciello wrote:
>>> > > > > This fixes a problem where the system gets stuck in a loop
>>> > > > > unable to wakeup via power button in s2idle.
>>> > > > >
>>> > > > > The problem happens because:
>>> > > > >  - press power button:
>>> > > > >    - system emits 0xc0 (power press), event ignored
>>> > > > >    - system emits 0xc1 (power release), event processed,
>>> > > > >      emited as KEY_POWER
>>> > > > >    - set wakeup_mode to true
>>> > > > >    - system goes to s2idle
>>> > > > >  - press power button
>>> > > > >    - system emits 0xc0 (power press), wakeup_mode is true,
>>> > > > >      system wakes
>>> > > > >    - system emits 0xc1 (power release), event processed,
>>> > > > >      emited as KEY_POWER
>>> > > > >    - system goes to s2idle again
>>> > > > >
>>> > > > > To avoid this situation, process the presses (which matches what
>>> > > > > intel-hid does too).
>>> > > > >
>>> > > > > Verified on an Dell XPS 9365
>>> > > > >
>>> > > > > Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
>>> > > >
>>> > > > This looks good to me - responding to the release is non-intuitive IMHO
>>> > > > anyway.  I'd like to see agreement from AceLan, but this should go into
>>> > > > the 4.13 rc cycle (at rc3 currently).
>>> > >
>>> > > Yes, it should, and I'm not sure if the original author's opinion matters here.
>>> > >
>>> > > The patch makes sense to everyone involved and fixes an annoying issue, so
>>> > > I don't see any real arguments against applying it.
>>> > >
>>> > > Please feel free to add my ACK to it if that helps.
>>> >
>>> > I always try to give those in MAINTAINERS a chance to respond, but I will queue
>>> > this up to fixes now.
>>>
>>> Thanks!
>>
>> Rafael,
>>
>> Merged to mainline (in case you were waiting on this for the dependent
>> patch you mentioned).
>
> Awesome, thanks!
Darren Hart Aug. 7, 2017, 3:54 a.m. UTC | #8
On Mon, Aug 07, 2017 at 08:59:30AM +0800, AceLan Kao wrote:
> Looks like I'm one hour late to ack the patch.
> Thanks any way for the quick response.

Thanks for chiming in all the same - and normally I'd have provided for
more time. In this case, I will be away for a few days, and it was
important to get this in sooner rather than later in the RC cycle.
Pali Rohár Sept. 16, 2017, 1:45 p.m. UTC | #9
On Friday 04 August 2017 19:00:06 Mario Limonciello wrote:
> This fixes a problem where the system gets stuck in a loop
> unable to wakeup via power button in s2idle.
> 
> The problem happens because:
>  - press power button:
>    - system emits 0xc0 (power press), event ignored
>    - system emits 0xc1 (power release), event processed,
>      emited as KEY_POWER
>    - set wakeup_mode to true
>    - system goes to s2idle
>  - press power button
>    - system emits 0xc0 (power press), wakeup_mode is true,
>      system wakes
>    - system emits 0xc1 (power release), event processed,
>      emited as KEY_POWER
>    - system goes to s2idle again
> 
> To avoid this situation, process the presses (which matches what
> intel-hid does too).
> 
> Verified on an Dell XPS 9365
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
> ---
>  drivers/platform/x86/intel-vbtn.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel-vbtn.c
> b/drivers/platform/x86/intel-vbtn.c index 61f1063..4809267 100644
> --- a/drivers/platform/x86/intel-vbtn.c
> +++ b/drivers/platform/x86/intel-vbtn.c
> @@ -36,8 +36,8 @@ static const struct acpi_device_id intel_vbtn_ids[]
> = {
> 
>  /* In theory, these are HID usages. */
>  static const struct key_entry intel_vbtn_keymap[] = {
> -	{ KE_IGNORE, 0xC0, { KEY_POWER } },	/* power key press */
> -	{ KE_KEY, 0xC1, { KEY_POWER } },	/* power key release */
> +	{ KE_KEY, 0xC0, { KEY_POWER } },	/* power key press */
> +	{ KE_IGNORE, 0xC1, { KEY_POWER } },	/* power key release */
>  	{ KE_KEY, 0xC4, { KEY_VOLUMEUP } },		/* volume-up key press */
>  	{ KE_IGNORE, 0xC5, { KEY_VOLUMEUP } },		/* volume-up key release 
*/
>  	{ KE_KEY, 0xC6, { KEY_VOLUMEDOWN } },		/* volume-down key press */

Hello, maybe a stupid question, but why to not report both events "key 
pressed" and "key released" to userspace? IIRC kernel input layer can 
distinguish between these two type of events. But in intel-vbtn.c source 
code I see that all "release" ACPI events are ignored and just "press" 
are processed.
diff mbox

Patch

diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
index 61f1063..4809267 100644
--- a/drivers/platform/x86/intel-vbtn.c
+++ b/drivers/platform/x86/intel-vbtn.c
@@ -36,8 +36,8 @@  static const struct acpi_device_id intel_vbtn_ids[] = {
 
 /* In theory, these are HID usages. */
 static const struct key_entry intel_vbtn_keymap[] = {
-	{ KE_IGNORE, 0xC0, { KEY_POWER } },	/* power key press */
-	{ KE_KEY, 0xC1, { KEY_POWER } },	/* power key release */
+	{ KE_KEY, 0xC0, { KEY_POWER } },	/* power key press */
+	{ KE_IGNORE, 0xC1, { KEY_POWER } },	/* power key release */
 	{ KE_KEY, 0xC4, { KEY_VOLUMEUP } },		/* volume-up key press */
 	{ KE_IGNORE, 0xC5, { KEY_VOLUMEUP } },		/* volume-up key release */
 	{ KE_KEY, 0xC6, { KEY_VOLUMEDOWN } },		/* volume-down key press */