All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] platform/x86: intel-vbtn: Switch to an allow-list for SW_TABLET_MODE reporting
@ 2020-09-30 13:19 Hans de Goede
  2020-10-02 14:54 ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Hans de Goede @ 2020-09-30 13:19 UTC (permalink / raw)
  To: Darren Hart, Andy Shevchenko, Mark Gross
  Cc: Hans de Goede, Mario Limonciello, platform-driver-x86,
	Barnab1s PY1cze, Takashi Iwai

2 recent commits:
cfae58ed681c ("platform/x86: intel-vbtn: Only blacklist SW_TABLET_MODE
on the 9 / "Laptop" chasis-type")
1fac39fd0316 ("platform/x86: intel-vbtn: Also handle tablet-mode switch on
"Detachable" and "Portable" chassis-types")

Enabled reporting of SW_TABLET_MODE on more devices since the vbtn ACPI
interface is used by the firmware on some of those devices to report this.

Testing has shown that unconditionally enabling SW_TABLET_MODE reporting
on all devices with a chassis type of 8 ("Portable") or 10 ("Notebook")
which support the VGBS method is a very bad idea.

Many of these devices are normal laptops (non 2-in-1) models with a VGBS
which always returns 0, which we translate to SW_TABLET_MODE=1. This in
turn causes userspace (libinput) to suppress events from the builtin
keyboard and touchpad, making the laptop essentially unusable.

Since the problem of wrongly reporting SW_TABLET_MODE=1 in combination
with libinput, leads to a non-usable system. Where as OTOH many people will
not even notice when SW_TABLET_MODE is not being reported, this commit
changes intel_vbtn_has_switches() to use a DMI based allow-list.

The new DMI based allow-list matches on the 31 ("Convertible") and
32 ("Detachable") chassis-types, as these clearly are 2-in-1s and
so far if they support the intel-vbtn ACPI interface they all have
properly working SW_TABLET_MODE reporting.

Besides these 2 generic matches, it also contains model specific matches
for 2-in-1 models which use a different chassis-type and which are known
to have properly working SW_TABLET_MODE reporting.

This has been tested on the following 2-in-1 devices:

Dell Venue 11 Pro 7130 vPro
HP Pavilion X2 10-p002nd
HP Stream x360 Convertible PC 11
Medion E1239T

Fixes: cfae58ed681c ("platform/x86: intel-vbtn: Only blacklist SW_TABLET_MODE on the 9 / "Laptop" chasis-type")
BugLink: https://forum.manjaro.org/t/keyboard-and-touchpad-only-work-on-kernel-5-6/22668
BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1175599
Cc: Barnab1s PY1cze <pobrn@protonmail.com>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel-vbtn.c | 52 +++++++++++++++++++++++++------
 1 file changed, 43 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
index e85d8e58320c..f5901b0b07cd 100644
--- a/drivers/platform/x86/intel-vbtn.c
+++ b/drivers/platform/x86/intel-vbtn.c
@@ -167,20 +167,54 @@ static bool intel_vbtn_has_buttons(acpi_handle handle)
 	return ACPI_SUCCESS(status);
 }
 
+/*
+ * There are several laptops (non 2-in-1) models out there which support VGBS,
+ * but simply always return 0, which we translate to SW_TABLET_MODE=1. This in
+ * turn causes userspace (libinput) to suppress events from the builtin
+ * keyboard and touchpad, making the laptop essentially unusable.
+ *
+ * Since the problem of wrongly reporting SW_TABLET_MODE=1 in combination
+ * with libinput, leads to a non-usable system. Where as OTOH many people will
+ * not even notice when SW_TABLET_MODE is not being reported, a DMI based allow
+ * list is used here. This list mainly matches on the chassis-type of 2-in-1s.
+ *
+ * There are also some 2-in-1s which use the intel-vbtn ACPI interface to report
+ * SW_TABLET_MODE with a chassis-type of 8 ("Portable") or 10 ("Notebook"),
+ * these are matched on a per model basis, since many normal laptops with a
+ * possible broken VGBS ACPI-method also use these chassis-types.
+ */
+static const struct dmi_system_id dmi_switches_allow_list[] = {
+	{
+		.matches = {
+			DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "31" /* Convertible */),
+		},
+	},
+	{
+		.matches = {
+			DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "32" /* Detachable */),
+		},
+	},
+	{
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"),
+		},
+	},
+	{
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "HP Stream x360 Convertible PC 11"),
+		},
+	},
+	{} /* Array terminator */
+};
+
 static bool intel_vbtn_has_switches(acpi_handle handle)
 {
-	const char *chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE);
 	unsigned long long vgbs;
 	acpi_status status;
 
-	/*
-	 * Some normal laptops have a VGBS method despite being non-convertible
-	 * and their VGBS method always returns 0, causing detect_tablet_mode()
-	 * to report SW_TABLET_MODE=1 to userspace, which causes issues.
-	 * These laptops have a DMI chassis_type of 9 ("Laptop"), do not report
-	 * switches on any devices with a DMI chassis_type of 9.
-	 */
-	if (chassis_type && strcmp(chassis_type, "9") == 0)
+	if (!dmi_check_system(dmi_switches_allow_list))
 		return false;
 
 	status = acpi_evaluate_integer(handle, "VGBS", NULL, &vgbs);
-- 
2.28.0


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

* Re: [PATCH] platform/x86: intel-vbtn: Switch to an allow-list for SW_TABLET_MODE reporting
  2020-09-30 13:19 [PATCH] platform/x86: intel-vbtn: Switch to an allow-list for SW_TABLET_MODE reporting Hans de Goede
@ 2020-10-02 14:54 ` Andy Shevchenko
  2020-10-02 15:01   ` Barnabás Pőcze
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2020-10-02 14:54 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Darren Hart, Andy Shevchenko, Mark Gross, Mario Limonciello,
	Platform Driver, Barnab1s PY1cze, Takashi Iwai

On Wed, Sep 30, 2020 at 4:19 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> 2 recent commits:
> cfae58ed681c ("platform/x86: intel-vbtn: Only blacklist SW_TABLET_MODE
> on the 9 / "Laptop" chasis-type")
> 1fac39fd0316 ("platform/x86: intel-vbtn: Also handle tablet-mode switch on
> "Detachable" and "Portable" chassis-types")
>
> Enabled reporting of SW_TABLET_MODE on more devices since the vbtn ACPI
> interface is used by the firmware on some of those devices to report this.
>
> Testing has shown that unconditionally enabling SW_TABLET_MODE reporting
> on all devices with a chassis type of 8 ("Portable") or 10 ("Notebook")
> which support the VGBS method is a very bad idea.
>
> Many of these devices are normal laptops (non 2-in-1) models with a VGBS
> which always returns 0, which we translate to SW_TABLET_MODE=1. This in
> turn causes userspace (libinput) to suppress events from the builtin
> keyboard and touchpad, making the laptop essentially unusable.
>
> Since the problem of wrongly reporting SW_TABLET_MODE=1 in combination
> with libinput, leads to a non-usable system. Where as OTOH many people will
> not even notice when SW_TABLET_MODE is not being reported, this commit
> changes intel_vbtn_has_switches() to use a DMI based allow-list.
>
> The new DMI based allow-list matches on the 31 ("Convertible") and
> 32 ("Detachable") chassis-types, as these clearly are 2-in-1s and
> so far if they support the intel-vbtn ACPI interface they all have
> properly working SW_TABLET_MODE reporting.
>
> Besides these 2 generic matches, it also contains model specific matches
> for 2-in-1 models which use a different chassis-type and which are known
> to have properly working SW_TABLET_MODE reporting.
>
> This has been tested on the following 2-in-1 devices:
>
> Dell Venue 11 Pro 7130 vPro
> HP Pavilion X2 10-p002nd
> HP Stream x360 Convertible PC 11
> Medion E1239T

I have reverted previous attempts and applied this one, but...

> Fixes: cfae58ed681c ("platform/x86: intel-vbtn: Only blacklist SW_TABLET_MODE on the 9 / "Laptop" chasis-type")
> BugLink: https://forum.manjaro.org/t/keyboard-and-touchpad-only-work-on-kernel-5-6/22668
> BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1175599

> Cc: Barnab1s PY1cze <pobrn@protonmail.com>

...seems like a broken name to me. I'll try to fix this.

> Cc: Takashi Iwai <tiwai@suse.de>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/platform/x86/intel-vbtn.c | 52 +++++++++++++++++++++++++------
>  1 file changed, 43 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
> index e85d8e58320c..f5901b0b07cd 100644
> --- a/drivers/platform/x86/intel-vbtn.c
> +++ b/drivers/platform/x86/intel-vbtn.c
> @@ -167,20 +167,54 @@ static bool intel_vbtn_has_buttons(acpi_handle handle)
>         return ACPI_SUCCESS(status);
>  }
>
> +/*
> + * There are several laptops (non 2-in-1) models out there which support VGBS,
> + * but simply always return 0, which we translate to SW_TABLET_MODE=1. This in
> + * turn causes userspace (libinput) to suppress events from the builtin
> + * keyboard and touchpad, making the laptop essentially unusable.
> + *
> + * Since the problem of wrongly reporting SW_TABLET_MODE=1 in combination
> + * with libinput, leads to a non-usable system. Where as OTOH many people will
> + * not even notice when SW_TABLET_MODE is not being reported, a DMI based allow
> + * list is used here. This list mainly matches on the chassis-type of 2-in-1s.
> + *
> + * There are also some 2-in-1s which use the intel-vbtn ACPI interface to report
> + * SW_TABLET_MODE with a chassis-type of 8 ("Portable") or 10 ("Notebook"),
> + * these are matched on a per model basis, since many normal laptops with a
> + * possible broken VGBS ACPI-method also use these chassis-types.
> + */
> +static const struct dmi_system_id dmi_switches_allow_list[] = {
> +       {
> +               .matches = {
> +                       DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "31" /* Convertible */),
> +               },
> +       },
> +       {
> +               .matches = {
> +                       DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "32" /* Detachable */),
> +               },
> +       },
> +       {
> +               .matches = {
> +                       DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> +                       DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"),
> +               },
> +       },
> +       {
> +               .matches = {
> +                       DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
> +                       DMI_MATCH(DMI_PRODUCT_NAME, "HP Stream x360 Convertible PC 11"),
> +               },
> +       },
> +       {} /* Array terminator */
> +};
> +
>  static bool intel_vbtn_has_switches(acpi_handle handle)
>  {
> -       const char *chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE);
>         unsigned long long vgbs;
>         acpi_status status;
>
> -       /*
> -        * Some normal laptops have a VGBS method despite being non-convertible
> -        * and their VGBS method always returns 0, causing detect_tablet_mode()
> -        * to report SW_TABLET_MODE=1 to userspace, which causes issues.
> -        * These laptops have a DMI chassis_type of 9 ("Laptop"), do not report
> -        * switches on any devices with a DMI chassis_type of 9.
> -        */
> -       if (chassis_type && strcmp(chassis_type, "9") == 0)
> +       if (!dmi_check_system(dmi_switches_allow_list))
>                 return false;
>
>         status = acpi_evaluate_integer(handle, "VGBS", NULL, &vgbs);
> --
> 2.28.0
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] platform/x86: intel-vbtn: Switch to an allow-list for SW_TABLET_MODE reporting
  2020-10-02 14:54 ` Andy Shevchenko
@ 2020-10-02 15:01   ` Barnabás Pőcze
  2020-10-02 15:07     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Barnabás Pőcze @ 2020-10-02 15:01 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Hans de Goede, Darren Hart, Andy Shevchenko, Mark Gross,
	Mario Limonciello, Platform Driver, Takashi Iwai

> [...]
> I have reverted previous attempts and applied this one, but...
>
> > Fixes: cfae58ed681c ("platform/x86: intel-vbtn: Only blacklist SW_TABLET_MODE on the 9 / "Laptop" chasis-type")
> > BugLink: https://forum.manjaro.org/t/keyboard-and-touchpad-only-work-on-kernel-5-6/22668
> > BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1175599
>
> > Cc: Barnab1s PY1cze pobrn@protonmail.com
>
> ...seems like a broken name to me. I'll try to fix this.
> [...]

Yes, it is. :-(
Maybe I shouldn't have used accented characters, sorry. I thought UTF-8
was reasonably well-supported in 2020.


Regards,
Barnabás Pőcze

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

* Re: [PATCH] platform/x86: intel-vbtn: Switch to an allow-list for SW_TABLET_MODE reporting
  2020-10-02 15:01   ` Barnabás Pőcze
@ 2020-10-02 15:07     ` Andy Shevchenko
  2020-10-02 19:24       ` Hans de Goede
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2020-10-02 15:07 UTC (permalink / raw)
  To: Barnabás Pőcze
  Cc: Hans de Goede, Darren Hart, Andy Shevchenko, Mark Gross,
	Mario Limonciello, Platform Driver, Takashi Iwai

On Fri, Oct 2, 2020 at 6:01 PM Barnabás Pőcze <pobrn@protonmail.com> wrote:
> > I have reverted previous attempts and applied this one, but...
> >
> > > Fixes: cfae58ed681c ("platform/x86: intel-vbtn: Only blacklist SW_TABLET_MODE on the 9 / "Laptop" chasis-type")
> > > BugLink: https://forum.manjaro.org/t/keyboard-and-touchpad-only-work-on-kernel-5-6/22668
> > > BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1175599
> >
> > > Cc: Barnab1s PY1cze pobrn@protonmail.com
> >
> > ...seems like a broken name to me. I'll try to fix this.

> Yes, it is. :-(
> Maybe I shouldn't have used accented characters, sorry. I thought UTF-8
> was reasonably well-supported in 2020.

Sorry for that. I agree that UTF-8 must be supported well. I think
Hans can check what happened and act accordingly.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] platform/x86: intel-vbtn: Switch to an allow-list for SW_TABLET_MODE reporting
  2020-10-02 15:07     ` Andy Shevchenko
@ 2020-10-02 19:24       ` Hans de Goede
  0 siblings, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2020-10-02 19:24 UTC (permalink / raw)
  To: Andy Shevchenko, Barnabás Pőcze
  Cc: Darren Hart, Andy Shevchenko, Mark Gross, Mario Limonciello,
	Platform Driver, Takashi Iwai

Hi,

On 10/2/20 5:07 PM, Andy Shevchenko wrote:
> On Fri, Oct 2, 2020 at 6:01 PM Barnabás Pőcze <pobrn@protonmail.com> wrote:
>>> I have reverted previous attempts and applied this one, but...
>>>
>>>> Fixes: cfae58ed681c ("platform/x86: intel-vbtn: Only blacklist SW_TABLET_MODE on the 9 / "Laptop" chasis-type")
>>>> BugLink: https://forum.manjaro.org/t/keyboard-and-touchpad-only-work-on-kernel-5-6/22668
>>>> BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1175599
>>>
>>>> Cc: Barnab1s PY1cze pobrn@protonmail.com
>>>
>>> ...seems like a broken name to me. I'll try to fix this.
> 
>> Yes, it is. :-(
>> Maybe I shouldn't have used accented characters, sorry. I thought UTF-8
>> was reasonably well-supported in 2020.
> 
> Sorry for that. I agree that UTF-8 must be supported well. I think
> Hans can check what happened and act accordingly.

Ugh, no idea what happened there, it is already broken in my
local git tree. IIRC just copy and pasted it out of thunderbird.
I just did that again and this time it is fine ...  Maybe I picked
the wrong email as source and it got mangled by some email system
on the way.

Anyways I've just send out a v2 with this fixed.

Regards,

Hans


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

end of thread, other threads:[~2020-10-02 19:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 13:19 [PATCH] platform/x86: intel-vbtn: Switch to an allow-list for SW_TABLET_MODE reporting Hans de Goede
2020-10-02 14:54 ` Andy Shevchenko
2020-10-02 15:01   ` Barnabás Pőcze
2020-10-02 15:07     ` Andy Shevchenko
2020-10-02 19:24       ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.