platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] platform/x86: intel-hid: Fix spurious wakeups caused by tablet-mode events during suspend
@ 2021-04-04 14:38 Hans de Goede
  2021-04-04 15:50 ` Elia Devito
  0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2021-04-04 14:38 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko
  Cc: Hans de Goede, Elia Devito, platform-driver-x86

Some devices send (duplicate) tablet-mode events when moved around even
though the mode has not changed; and they do this even when suspended.

Change the tablet-mode event handling when priv->wakeup_mode is set to
update the switch state in case it changed and then return immediately
(without calling pm_wakeup_hard_event()) to avoid spurious wakeups.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212537
Fixes: 537b0dd4729e ("platform/x86: intel-hid: Add support for SW_TABLET_MODE")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel-hid.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/intel-hid.c b/drivers/platform/x86/intel-hid.c
index 57cc92891a57..078648a9201b 100644
--- a/drivers/platform/x86/intel-hid.c
+++ b/drivers/platform/x86/intel-hid.c
@@ -483,11 +483,16 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 			goto wakeup;
 
 		/*
-		 * Switch events will wake the device and report the new switch
-		 * position to the input subsystem.
+		 * Some devices send (duplicate) tablet-mode events when moved
+		 * around even though the mode has not changed; and they do this
+		 * even when suspended.
+		 * Update the switch state in case it changed and then return
+		 * without waking up to avoid spurious wakeups.
 		 */
-		if (priv->switches && (event == 0xcc || event == 0xcd))
-			goto wakeup;
+		if (event == 0xcc || event == 0xcd) {
+			report_tablet_mode_event(priv->switches, event);
+			return;
+		}
 
 		/* Wake up on 5-button array events only. */
 		if (event == 0xc0 || !priv->array)
@@ -501,9 +506,6 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 wakeup:
 		pm_wakeup_hard_event(&device->dev);
 
-		if (report_tablet_mode_event(priv->switches, event))
-			return;
-
 		return;
 	}
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] platform/x86: intel-hid: Fix spurious wakeups caused by tablet-mode events during suspend
  2021-04-04 14:38 [PATCH] platform/x86: intel-hid: Fix spurious wakeups caused by tablet-mode events during suspend Hans de Goede
@ 2021-04-04 15:50 ` Elia Devito
  2021-04-06 16:03   ` Hans de Goede
  0 siblings, 1 reply; 3+ messages in thread
From: Elia Devito @ 2021-04-04 15:50 UTC (permalink / raw)
  To: Hans de Goede, Mark Gross, Andy Shevchenko; +Cc: platform-driver-x86

Hi Hans,
> Some devices send (duplicate) tablet-mode events when moved around even
> though the mode has not changed; and they do this even when suspended.
> 
> Change the tablet-mode event handling when priv->wakeup_mode is set to
> update the switch state in case it changed and then return immediately
> (without calling pm_wakeup_hard_event()) to avoid spurious wakeups.
> 
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212537
> Fixes: 537b0dd4729e ("platform/x86: intel-hid: Add support for
> SW_TABLET_MODE")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/platform/x86/intel-hid.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel-hid.c
> b/drivers/platform/x86/intel-hid.c
> index 57cc92891a57..078648a9201b 100644
> --- a/drivers/platform/x86/intel-hid.c
> +++ b/drivers/platform/x86/intel-hid.c
> @@ -483,11 +483,16 @@ static void notify_handler(acpi_handle handle,
> u32 event, void *context)
>                         goto wakeup;
>  
>                 /*
> -                * Switch events will wake the device and report the
> new switch
> -                * position to the input subsystem.
> +                * Some devices send (duplicate) tablet-mode events
> when moved
> +                * around even though the mode has not changed; and
> they do this
> +                * even when suspended.
> +                * Update the switch state in case it changed and then
> return
> +                * without waking up to avoid spurious wakeups.
>                  */
> -               if (priv->switches && (event == 0xcc || event == 0xcd))
> -                       goto wakeup;
> +               if (event == 0xcc || event == 0xcd) {
> +                       report_tablet_mode_event(priv->switches,
> event);
> +                       return;
> +               }
>  
>                 /* Wake up on 5-button array events only. */
>                 if (event == 0xc0 || !priv->array)
> @@ -501,9 +506,6 @@ static void notify_handler(acpi_handle handle, u32
> event, void *context)
>  wakeup:
>                 pm_wakeup_hard_event(&device->dev);
>  
> -               if (report_tablet_mode_event(priv->switches, event))
> -                       return;
> -
>                 return;
>         }
> 

No regression noted on HP Spectre x360 15-df0xxx.

Reviewed-by: Elia Devito <eliadevito@gmail.com>

Regards,
Elia



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] platform/x86: intel-hid: Fix spurious wakeups caused by tablet-mode events during suspend
  2021-04-04 15:50 ` Elia Devito
@ 2021-04-06 16:03   ` Hans de Goede
  0 siblings, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2021-04-06 16:03 UTC (permalink / raw)
  To: Elia Devito, Mark Gross, Andy Shevchenko; +Cc: platform-driver-x86

Hi,

On 4/4/21 5:50 PM, Elia Devito wrote:
> Hi Hans,
>> Some devices send (duplicate) tablet-mode events when moved around even
>> though the mode has not changed; and they do this even when suspended.
>>
>> Change the tablet-mode event handling when priv->wakeup_mode is set to
>> update the switch state in case it changed and then return immediately
>> (without calling pm_wakeup_hard_event()) to avoid spurious wakeups.
>>
>> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212537
>> Fixes: 537b0dd4729e ("platform/x86: intel-hid: Add support for
>> SW_TABLET_MODE")
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>  drivers/platform/x86/intel-hid.c | 16 +++++++++-------
>>  1 file changed, 9 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/platform/x86/intel-hid.c
>> b/drivers/platform/x86/intel-hid.c
>> index 57cc92891a57..078648a9201b 100644
>> --- a/drivers/platform/x86/intel-hid.c
>> +++ b/drivers/platform/x86/intel-hid.c
>> @@ -483,11 +483,16 @@ static void notify_handler(acpi_handle handle,
>> u32 event, void *context)
>>                         goto wakeup;
>>  
>>                 /*
>> -                * Switch events will wake the device and report the
>> new switch
>> -                * position to the input subsystem.
>> +                * Some devices send (duplicate) tablet-mode events
>> when moved
>> +                * around even though the mode has not changed; and
>> they do this
>> +                * even when suspended.
>> +                * Update the switch state in case it changed and then
>> return
>> +                * without waking up to avoid spurious wakeups.
>>                  */
>> -               if (priv->switches && (event == 0xcc || event == 0xcd))
>> -                       goto wakeup;
>> +               if (event == 0xcc || event == 0xcd) {
>> +                       report_tablet_mode_event(priv->switches,
>> event);
>> +                       return;
>> +               }
>>  
>>                 /* Wake up on 5-button array events only. */
>>                 if (event == 0xc0 || !priv->array)
>> @@ -501,9 +506,6 @@ static void notify_handler(acpi_handle handle, u32
>> event, void *context)
>>  wakeup:
>>                 pm_wakeup_hard_event(&device->dev);
>>  
>> -               if (report_tablet_mode_event(priv->switches, event))
>> -                       return;
>> -
>>                 return;
>>         }
>>
> 
> No regression noted on HP Spectre x360 15-df0xxx.
> 
> Reviewed-by: Elia Devito <eliadevito@gmail.com>

Thank you for the testing and the review. I'll push this out to the for-next and fixes branches.

Regards,

Hans


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-06 16:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-04 14:38 [PATCH] platform/x86: intel-hid: Fix spurious wakeups caused by tablet-mode events during suspend Hans de Goede
2021-04-04 15:50 ` Elia Devito
2021-04-06 16:03   ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).