2017-08-04 17:01:44

by Mario Limonciello

[permalink] [raw]
Subject: [PATCH] intel-vbtn: match power button on press rather than release

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 <[email protected]>
---
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 */
--
2.7.4


2017-08-04 17:29:58

by Darren Hart

[permalink] [raw]
Subject: Re: [PATCH] intel-vbtn: match power button on press rather than release

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 <[email protected]>

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).

--
Darren Hart
VMware Open Source Technology Center

2017-08-04 23:38:35

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] intel-vbtn: match power button on press rather than release

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 <[email protected]>
>
> 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

2017-08-05 20:58:06

by Darren Hart

[permalink] [raw]
Subject: Re: [PATCH] intel-vbtn: match power button on press rather than release

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 <[email protected]>
> >
> > 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.

--
Darren Hart
VMware Open Source Technology Center

2017-08-05 22:28:38

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] intel-vbtn: match power button on press rather than release

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 <[email protected]>
> > >
> > > 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!


2017-08-06 23:24:26

by Darren Hart

[permalink] [raw]
Subject: Re: [PATCH] intel-vbtn: match power button on press rather than release

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 <[email protected]>
> > > >
> > > > 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).

--
Darren Hart
VMware Open Source Technology Center

2017-08-07 00:38:11

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] intel-vbtn: match power button on press rather than release

On Mon, Aug 7, 2017 at 1:24 AM, Darren Hart <[email protected]> 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 <[email protected]>
>> > > >
>> > > > 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!

2017-08-07 00:59:33

by AceLan Kao

[permalink] [raw]
Subject: Re: [PATCH] intel-vbtn: match power button on press rather than release

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 <[email protected]>:
> On Mon, Aug 7, 2017 at 1:24 AM, Darren Hart <[email protected]> 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 <[email protected]>
>>> > > >
>>> > > > 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!

2017-08-07 03:54:35

by Darren Hart

[permalink] [raw]
Subject: Re: [PATCH] intel-vbtn: match power button on press rather than release

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.

--
Darren Hart
VMware Open Source Technology Center

2017-09-16 13:45:45

by Pali Rohár

[permalink] [raw]
Subject: Re: intel-vbtn: match power button on press rather than release

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 <[email protected]>
> ---
> 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.

--
Pali Rohár
[email protected]


Attachments:
signature.asc (198.00 B)
This is a digitally signed message part.