* [PATCH] platform/x86/intel: hid: Add DMI switches allow list
@ 2021-09-20 16:03 José Expósito
2021-09-20 18:43 ` Barnabás Pőcze
0 siblings, 1 reply; 6+ messages in thread
From: José Expósito @ 2021-09-20 16:03 UTC (permalink / raw)
To: hdegoede
Cc: alex.hung, mgross, platform-driver-x86, linux-kernel,
José Expósito, Tobias Gurtzick
Some devices, even non convertible ones, can send incorrect
SW_TABLET_MODE reports.
Add an allow list and accept such reports only from devices in it.
Bug reported for Dell XPS 17 9710 on:
https://gitlab.freedesktop.org/libinput/libinput/-/issues/662
Reported-by: Tobias Gurtzick <magic@wizardtales.com>
Suggested-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Tobias Gurtzick <magic@wizardtales.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/platform/x86/intel/hid.c | 33 +++++++++++++++++++++++++++-----
1 file changed, 28 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/intel/hid.c b/drivers/platform/x86/intel/hid.c
index a33a5826e81a..24d26336e39a 100644
--- a/drivers/platform/x86/intel/hid.c
+++ b/drivers/platform/x86/intel/hid.c
@@ -118,6 +118,24 @@ static const struct dmi_system_id dmi_vgbs_allow_list[] = {
{ }
};
+/*
+ * Some devices, even non convertible ones, can send incorrect SW_TABLET_MODE
+ * reports. Accept such reports only from devices in this list.
+ */
+static const struct dmi_system_id dmi_switches_auto_add_allow_list[] = {
+ {
+ .matches = {
+ DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "31" /* Convertible */),
+ },
+ },
+ {
+ .matches = {
+ DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "32" /* Detachable */),
+ },
+ },
+ {} /* Array terminator */
+};
+
struct intel_hid_priv {
struct input_dev *input_dev;
struct input_dev *array;
@@ -455,11 +473,16 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
*
* See dual_accel_detect.h for more info on the dual_accel check.
*/
- if (!priv->switches && !priv->dual_accel && (event == 0xcc || event == 0xcd)) {
- dev_info(&device->dev, "switch event received, enable switches supports\n");
- err = intel_hid_switches_setup(device);
- if (err)
- pr_err("Failed to setup Intel HID switches\n");
+ if (event == 0xcc || event == 0xcd) {
+ if (!dmi_check_system(dmi_switches_auto_add_allow_list))
+ return;
+
+ if (!priv->switches && !priv->dual_accel) {
+ dev_info(&device->dev, "switch event received, enable switches supports\n");
+ err = intel_hid_switches_setup(device);
+ if (err)
+ pr_err("Failed to setup Intel HID switches\n");
+ }
}
if (priv->wakeup_mode) {
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] platform/x86/intel: hid: Add DMI switches allow list
2021-09-20 16:03 [PATCH] platform/x86/intel: hid: Add DMI switches allow list José Expósito
@ 2021-09-20 18:43 ` Barnabás Pőcze
2021-09-21 13:13 ` Hans de Goede
0 siblings, 1 reply; 6+ messages in thread
From: Barnabás Pőcze @ 2021-09-20 18:43 UTC (permalink / raw)
To: José Expósito
Cc: hdegoede, alex.hung, mgross, platform-driver-x86, linux-kernel,
Tobias Gurtzick
Hi
2021. szeptember 20., hétfő 18:03 keltezéssel, José Expósito írta:
> Some devices, even non convertible ones, can send incorrect
> SW_TABLET_MODE reports.
>
> Add an allow list and accept such reports only from devices in it.
>
> Bug reported for Dell XPS 17 9710 on:
> https://gitlab.freedesktop.org/libinput/libinput/-/issues/662
>
> Reported-by: Tobias Gurtzick <magic@wizardtales.com>
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Tested-by: Tobias Gurtzick <magic@wizardtales.com>
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> ---
> drivers/platform/x86/intel/hid.c | 33 +++++++++++++++++++++++++++-----
> 1 file changed, 28 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/platform/x86/intel/hid.c b/drivers/platform/x86/intel/hid.c
> index a33a5826e81a..24d26336e39a 100644
> --- a/drivers/platform/x86/intel/hid.c
> +++ b/drivers/platform/x86/intel/hid.c
> @@ -118,6 +118,24 @@ static const struct dmi_system_id dmi_vgbs_allow_list[] = {
> { }
> };
>
> +/*
> + * Some devices, even non convertible ones, can send incorrect SW_TABLET_MODE
> + * reports. Accept such reports only from devices in this list.
> + */
> +static const struct dmi_system_id dmi_switches_auto_add_allow_list[] = {
> + {
> + .matches = {
> + DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "31" /* Convertible */),
> + },
> + },
> + {
> + .matches = {
> + DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "32" /* Detachable */),
> + },
> + },
> + {} /* Array terminator */
> +};
> +
> struct intel_hid_priv {
> struct input_dev *input_dev;
> struct input_dev *array;
> @@ -455,11 +473,16 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
> *
> * See dual_accel_detect.h for more info on the dual_accel check.
> */
> - if (!priv->switches && !priv->dual_accel && (event == 0xcc || event == 0xcd)) {
> - dev_info(&device->dev, "switch event received, enable switches supports\n");
> - err = intel_hid_switches_setup(device);
> - if (err)
> - pr_err("Failed to setup Intel HID switches\n");
> + if (event == 0xcc || event == 0xcd) {
> + if (!dmi_check_system(dmi_switches_auto_add_allow_list))
> + return;
I think you should not check it every time. Maybe add a `bool` member
to `struct intel_hid_priv`. Or maybe better: rename `dual_accel` to something like
`autodetect_switch` and initialize it with `!dual_accel_detect() && dmi_check_system(...)`.
> +
> + if (!priv->switches && !priv->dual_accel) {
> + dev_info(&device->dev, "switch event received, enable switches supports\n");
> + err = intel_hid_switches_setup(device);
> + if (err)
> + pr_err("Failed to setup Intel HID switches\n");
> + }
> }
>
> if (priv->wakeup_mode) {
> --
> 2.25.1
>
>
Regards,
Barnabás Pőcze
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] platform/x86/intel: hid: Add DMI switches allow list
2021-09-20 18:43 ` Barnabás Pőcze
@ 2021-09-21 13:13 ` Hans de Goede
2021-09-21 16:28 ` José Expósito
0 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2021-09-21 13:13 UTC (permalink / raw)
To: Barnabás Pőcze, José Expósito
Cc: alex.hung, mgross, platform-driver-x86, linux-kernel, Tobias Gurtzick
Hi,
On 9/20/21 8:43 PM, Barnabás Pőcze wrote:
> Hi
>
>
> 2021. szeptember 20., hétfő 18:03 keltezéssel, José Expósito írta:
>> Some devices, even non convertible ones, can send incorrect
>> SW_TABLET_MODE reports.
>>
>> Add an allow list and accept such reports only from devices in it.
>>
>> Bug reported for Dell XPS 17 9710 on:
>> https://gitlab.freedesktop.org/libinput/libinput/-/issues/662
>>
>> Reported-by: Tobias Gurtzick <magic@wizardtales.com>
>> Suggested-by: Hans de Goede <hdegoede@redhat.com>
>> Tested-by: Tobias Gurtzick <magic@wizardtales.com>
>> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
>> ---
>> drivers/platform/x86/intel/hid.c | 33 +++++++++++++++++++++++++++-----
>> 1 file changed, 28 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/platform/x86/intel/hid.c b/drivers/platform/x86/intel/hid.c
>> index a33a5826e81a..24d26336e39a 100644
>> --- a/drivers/platform/x86/intel/hid.c
>> +++ b/drivers/platform/x86/intel/hid.c
>> @@ -118,6 +118,24 @@ static const struct dmi_system_id dmi_vgbs_allow_list[] = {
>> { }
>> };
>>
>> +/*
>> + * Some devices, even non convertible ones, can send incorrect SW_TABLET_MODE
>> + * reports. Accept such reports only from devices in this list.
>> + */
>> +static const struct dmi_system_id dmi_switches_auto_add_allow_list[] = {
>> + {
>> + .matches = {
>> + DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "31" /* Convertible */),
>> + },
>> + },
>> + {
>> + .matches = {
>> + DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "32" /* Detachable */),
>> + },
>> + },
>> + {} /* Array terminator */
>> +};
>> +
>> struct intel_hid_priv {
>> struct input_dev *input_dev;
>> struct input_dev *array;
>> @@ -455,11 +473,16 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
>> *
>> * See dual_accel_detect.h for more info on the dual_accel check.
>> */
>> - if (!priv->switches && !priv->dual_accel && (event == 0xcc || event == 0xcd)) {
>> - dev_info(&device->dev, "switch event received, enable switches supports\n");
>> - err = intel_hid_switches_setup(device);
>> - if (err)
>> - pr_err("Failed to setup Intel HID switches\n");
>> + if (event == 0xcc || event == 0xcd) {
>> + if (!dmi_check_system(dmi_switches_auto_add_allow_list))
>> + return;
>
> I think you should not check it every time. Maybe add a `bool` member
> to `struct intel_hid_priv`. Or maybe better: rename `dual_accel` to something like
> `autodetect_switch` and initialize it with `!dual_accel_detect() && dmi_check_system(...)`.
These events don't happen all that often. But this still is a good suggestion.
Since this is a regression fix of sorts I've gone ahead and made the suggested
changes myself (keeping José as author) and I've applied this to my tree,
see the version in the review-hans branch to see what the merged version
looks like.
Thank you for your patch, I've applied this patch to my review-hans
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
I will also add this to the pdx86 fixes branch and include it in my
next pdx86-fixes for 5.15 pull-req to Linus.
Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.
Regards,
Hans
>
>
>> +
>> + if (!priv->switches && !priv->dual_accel) {
>> + dev_info(&device->dev, "switch event received, enable switches supports\n");
>> + err = intel_hid_switches_setup(device);
>> + if (err)
>> + pr_err("Failed to setup Intel HID switches\n");
>> + }
>> }
>>
>> if (priv->wakeup_mode) {
>> --
>> 2.25.1
>>
>>
>
>
> Regards,
> Barnabás Pőcze
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] platform/x86/intel: hid: Add DMI switches allow list
2021-09-21 13:13 ` Hans de Goede
@ 2021-09-21 16:28 ` José Expósito
0 siblings, 0 replies; 6+ messages in thread
From: José Expósito @ 2021-09-21 16:28 UTC (permalink / raw)
To: Hans de Goede
Cc: Barnabás Pőcze, alex.hung, mgross, platform-driver-x86,
linux-kernel, Tobias Gurtzick
On Tue, Sep 21, 2021 at 03:13:31PM +0200, Hans de Goede wrote:
> These events don't happen all that often. But this still is a good suggestion.
>
> Since this is a regression fix of sorts I've gone ahead and made the suggested
> changes myself (keeping José as author) and I've applied this to my tree,
> see the version in the review-hans branch to see what the merged version
> looks like.
I was going to work on the patch tonight, but you were faster :)
Thanks for your review Barnabás and for applying the changes Hans.
Jose
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] platform/x86/intel: hid: Add DMI switches allow list
2021-10-01 10:09 Hans de Goede
@ 2021-10-03 14:06 ` Greg KH
0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2021-10-03 14:06 UTC (permalink / raw)
To: Hans de Goede; +Cc: stable, José Expósito, Tobias Gurtzick
On Fri, Oct 01, 2021 at 12:09:32PM +0200, Hans de Goede wrote:
> From: José Expósito <jose.exposito89@gmail.com>
>
> commit b201cb0ebe87b209e252d85668e517ac1929e250 upstream.
>
> Some devices, even non convertible ones, can send incorrect
> SW_TABLET_MODE reports.
>
> Add an allow list and accept such reports only from devices in it.
>
> Bug reported for Dell XPS 17 9710 on:
> https://gitlab.freedesktop.org/libinput/libinput/-/issues/662
>
> Fixes: ac32bae00083 ("platform/x86: intel-hid: Add alternative method to enable switches")
> Depends-on: 153cca9caa81 ("platform/x86: Add and use a dual_accel_detect() helper")
> Reported-by: Tobias Gurtzick <magic@wizardtales.com>
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Tested-by: Tobias Gurtzick <magic@wizardtales.com>
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> Link: https://lore.kernel.org/r/20210920160312.9787-1-jose.exposito89@gmail.com
> [hdegoede@redhat.com: Check dmi_switches_auto_add_allow_list only once]
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/platform/x86/intel-hid.c | 27 ++++++++++++++++++++++-----
> 1 file changed, 22 insertions(+), 5 deletions(-)
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] platform/x86/intel: hid: Add DMI switches allow list
@ 2021-10-01 10:09 Hans de Goede
2021-10-03 14:06 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2021-10-01 10:09 UTC (permalink / raw)
To: stable; +Cc: Hans de Goede, José Expósito, Tobias Gurtzick
From: José Expósito <jose.exposito89@gmail.com>
commit b201cb0ebe87b209e252d85668e517ac1929e250 upstream.
Some devices, even non convertible ones, can send incorrect
SW_TABLET_MODE reports.
Add an allow list and accept such reports only from devices in it.
Bug reported for Dell XPS 17 9710 on:
https://gitlab.freedesktop.org/libinput/libinput/-/issues/662
Fixes: ac32bae00083 ("platform/x86: intel-hid: Add alternative method to enable switches")
Depends-on: 153cca9caa81 ("platform/x86: Add and use a dual_accel_detect() helper")
Reported-by: Tobias Gurtzick <magic@wizardtales.com>
Suggested-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Tobias Gurtzick <magic@wizardtales.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Link: https://lore.kernel.org/r/20210920160312.9787-1-jose.exposito89@gmail.com
[hdegoede@redhat.com: Check dmi_switches_auto_add_allow_list only once]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/platform/x86/intel-hid.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/intel-hid.c b/drivers/platform/x86/intel-hid.c
index 2e4e97a626a5..7b03b497d93b 100644
--- a/drivers/platform/x86/intel-hid.c
+++ b/drivers/platform/x86/intel-hid.c
@@ -118,12 +118,30 @@ static const struct dmi_system_id dmi_vgbs_allow_list[] = {
{ }
};
+/*
+ * Some devices, even non convertible ones, can send incorrect SW_TABLET_MODE
+ * reports. Accept such reports only from devices in this list.
+ */
+static const struct dmi_system_id dmi_auto_add_switch[] = {
+ {
+ .matches = {
+ DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "31" /* Convertible */),
+ },
+ },
+ {
+ .matches = {
+ DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "32" /* Detachable */),
+ },
+ },
+ {} /* Array terminator */
+};
+
struct intel_hid_priv {
struct input_dev *input_dev;
struct input_dev *array;
struct input_dev *switches;
bool wakeup_mode;
- bool dual_accel;
+ bool auto_add_switch;
};
#define HID_EVENT_FILTER_UUID "eeec56b3-4442-408f-a792-4edd4d758054"
@@ -452,10 +470,8 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
* Some convertible have unreliable VGBS return which could cause incorrect
* SW_TABLET_MODE report, in these cases we enable support when receiving
* the first event instead of during driver setup.
- *
- * See dual_accel_detect.h for more info on the dual_accel check.
*/
- if (!priv->switches && !priv->dual_accel && (event == 0xcc || event == 0xcd)) {
+ if (!priv->switches && priv->auto_add_switch && (event == 0xcc || event == 0xcd)) {
dev_info(&device->dev, "switch event received, enable switches supports\n");
err = intel_hid_switches_setup(device);
if (err)
@@ -596,7 +612,8 @@ static int intel_hid_probe(struct platform_device *device)
return -ENOMEM;
dev_set_drvdata(&device->dev, priv);
- priv->dual_accel = dual_accel_detect();
+ /* See dual_accel_detect.h for more info on the dual_accel check. */
+ priv->auto_add_switch = dmi_check_system(dmi_auto_add_switch) && !dual_accel_detect();
err = intel_hid_input_setup(device);
if (err) {
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-10-03 14:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 16:03 [PATCH] platform/x86/intel: hid: Add DMI switches allow list José Expósito
2021-09-20 18:43 ` Barnabás Pőcze
2021-09-21 13:13 ` Hans de Goede
2021-09-21 16:28 ` José Expósito
2021-10-01 10:09 Hans de Goede
2021-10-03 14:06 ` Greg KH
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.