stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] platform/x86: intel-vbtn: Stop reporting SW_DOCK events
@ 2021-03-21 16:35 Hans de Goede
  2021-03-21 16:45 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Hans de Goede @ 2021-03-21 16:35 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko; +Cc: Hans de Goede, platform-driver-x86, stable

Stop reporting SW_DOCK events because this breaks suspend-on-lid-close.

SW_DOCK should only be reported for docking stations, but all the DSDTs in
my DSDT collection which use the intel-vbtn code, always seem to use this
for 2-in-1s / convertibles and set SW_DOCK=1 when in laptop-mode (in tandem
with setting SW_TABLET_MODE=0).

This causes userspace to think the laptop is docked to a port-replicator
and to disable suspend-on-lid-close, which is undesirable.

Map the dock events to KEY_IGNORE to avoid this broken SW_DOCK reporting.

Note this may theoretically cause us to stop reporting SW_DOCK on some
device where the 0xCA and 0xCB intel-vbtn events are actually used for
reporting docking to a classic docking-station / port-replicator but
I'm not aware of any such devices.

Also the most important thing is that we only report SW_DOCK when it
reliably reports being docked to a classic docking-station without any
false positives, which clearly is not the case here. If there is a
chance of reporting false positives then it is better to not report
SW_DOCK at all.

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel-vbtn.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
index 8a8017f9ca91..3fdf4cbec9ad 100644
--- a/drivers/platform/x86/intel-vbtn.c
+++ b/drivers/platform/x86/intel-vbtn.c
@@ -48,8 +48,16 @@ static const struct key_entry intel_vbtn_keymap[] = {
 };
 
 static const struct key_entry intel_vbtn_switchmap[] = {
-	{ KE_SW,     0xCA, { .sw = { SW_DOCK, 1 } } },		/* Docked */
-	{ KE_SW,     0xCB, { .sw = { SW_DOCK, 0 } } },		/* Undocked */
+	/*
+	 * SW_DOCK should only be reported for docking stations, but DSDTs using the
+	 * intel-vbtn code, always seem to use this for 2-in-1s / convertibles and set
+	 * SW_DOCK=1 when in laptop-mode (in tandem with setting SW_TABLET_MODE=0).
+	 * This causes userspace to think the laptop is docked to a port-replicator
+	 * and to disable suspend-on-lid-close, which is undesirable.
+	 * Map the dock events to KEY_IGNORE to avoid this broken SW_DOCK reporting.
+	 */
+	{ KE_IGNORE, 0xCA, { .sw = { SW_DOCK, 1 } } },		/* Docked */
+	{ KE_IGNORE, 0xCB, { .sw = { SW_DOCK, 0 } } },		/* Undocked */
 	{ KE_SW,     0xCC, { .sw = { SW_TABLET_MODE, 1 } } },	/* Tablet */
 	{ KE_SW,     0xCD, { .sw = { SW_TABLET_MODE, 0 } } },	/* Laptop */
 	{ KE_END }
-- 
2.30.2


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

* Re: [PATCH] platform/x86: intel-vbtn: Stop reporting SW_DOCK events
  2021-03-21 16:35 [PATCH] platform/x86: intel-vbtn: Stop reporting SW_DOCK events Hans de Goede
@ 2021-03-21 16:45 ` Hans de Goede
  0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2021-03-21 16:45 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko; +Cc: platform-driver-x86, stable

Hi,

On 3/21/21 5:35 PM, Hans de Goede wrote:
> Stop reporting SW_DOCK events because this breaks suspend-on-lid-close.
> 
> SW_DOCK should only be reported for docking stations, but all the DSDTs in
> my DSDT collection which use the intel-vbtn code, always seem to use this
> for 2-in-1s / convertibles and set SW_DOCK=1 when in laptop-mode (in tandem
> with setting SW_TABLET_MODE=0).
> 
> This causes userspace to think the laptop is docked to a port-replicator
> and to disable suspend-on-lid-close, which is undesirable.
> 
> Map the dock events to KEY_IGNORE to avoid this broken SW_DOCK reporting.
> 
> Note this may theoretically cause us to stop reporting SW_DOCK on some
> device where the 0xCA and 0xCB intel-vbtn events are actually used for
> reporting docking to a classic docking-station / port-replicator but
> I'm not aware of any such devices.
> 
> Also the most important thing is that we only report SW_DOCK when it
> reliably reports being docked to a classic docking-station without any
> false positives, which clearly is not the case here. If there is a
> chance of reporting false positives then it is better to not report
> SW_DOCK at all.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

I've added this patch to the pdx86/review-hans and pdx86/fixes branches,
so it should show up in linux-next soon and it will also be included
in my next pull-req to Linus for 5.12.

Regards,

Hans



> ---
>  drivers/platform/x86/intel-vbtn.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
> index 8a8017f9ca91..3fdf4cbec9ad 100644
> --- a/drivers/platform/x86/intel-vbtn.c
> +++ b/drivers/platform/x86/intel-vbtn.c
> @@ -48,8 +48,16 @@ static const struct key_entry intel_vbtn_keymap[] = {
>  };
>  
>  static const struct key_entry intel_vbtn_switchmap[] = {
> -	{ KE_SW,     0xCA, { .sw = { SW_DOCK, 1 } } },		/* Docked */
> -	{ KE_SW,     0xCB, { .sw = { SW_DOCK, 0 } } },		/* Undocked */
> +	/*
> +	 * SW_DOCK should only be reported for docking stations, but DSDTs using the
> +	 * intel-vbtn code, always seem to use this for 2-in-1s / convertibles and set
> +	 * SW_DOCK=1 when in laptop-mode (in tandem with setting SW_TABLET_MODE=0).
> +	 * This causes userspace to think the laptop is docked to a port-replicator
> +	 * and to disable suspend-on-lid-close, which is undesirable.
> +	 * Map the dock events to KEY_IGNORE to avoid this broken SW_DOCK reporting.
> +	 */
> +	{ KE_IGNORE, 0xCA, { .sw = { SW_DOCK, 1 } } },		/* Docked */
> +	{ KE_IGNORE, 0xCB, { .sw = { SW_DOCK, 0 } } },		/* Undocked */
>  	{ KE_SW,     0xCC, { .sw = { SW_TABLET_MODE, 1 } } },	/* Tablet */
>  	{ KE_SW,     0xCD, { .sw = { SW_TABLET_MODE, 0 } } },	/* Laptop */
>  	{ KE_END }
> 


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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-21 16:35 [PATCH] platform/x86: intel-vbtn: Stop reporting SW_DOCK events Hans de Goede
2021-03-21 16:45 ` 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).