Commit 8f18eca9ebc5 ("HID: ite: Add USB id match for Acer SW5-012 keyboard
dock") added the USB id for the Acer SW5-012's keyboard dock to the
hid-ite driver to fix the rfkill driver not working.
Most keyboard docks with an ITE 8595 keyboard/touchpad controller have the
"Wireless Radio Control" bits which need the special hid-ite driver on the
second USB interface (the mouse interface) and their touchpad only supports
mouse emulation, so using generic hid-input handling for anything but
the "Wireless Radio Control" bits is fine. On these devices we simply bind
to all USB interfaces.
But unlike other ITE8595 using keyboard docks, the Acer Aspire Switch 10
(SW5-012)'s touchpad not only does mouse emulation it also supports
HID-multitouch and all the keys including the "Wireless Radio Control"
bits have been moved to the first USB interface (the keyboard intf).
So we need hid-ite to handle the first (keyboard) USB interface and have
it NOT bind to the second (mouse) USB interface so that that can be
handled by hid-multitouch.c and we get proper multi-touch support.
This commit adds a match callback to hid-ite which makes it only
match the first USB interface when running on the Acer SW5-012,
fixing the regression to mouse-emulation mode introduced by adding the
keyboard dock USB id.
Note the match function only does the special only bind to the first
USB interface on the Acer SW5-012, on other devices the hid-ite driver
actually must bind to the second interface as that is where the
"Wireless Radio Control" bits are.
Cc: stable(a)vger.kernel.org
Fixes: 8f18eca9ebc5 ("HID: ite: Add USB id match for Acer SW5-012 keyboard dock")
Reported-by: Zdeněk Rampas <zdenda.rampas(a)gmail.com>
Signed-off-by: Hans de Goede <hdegoede(a)redhat.com>
---
drivers/hid/hid-ite.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/hid/hid-ite.c b/drivers/hid/hid-ite.c
index c436e12feb23..69a4ddfd033d 100644
--- a/drivers/hid/hid-ite.c
+++ b/drivers/hid/hid-ite.c
@@ -8,9 +8,12 @@
#include <linux/input.h>
#include <linux/hid.h>
#include <linux/module.h>
+#include <linux/usb.h>
#include "hid-ids.h"
+#define ITE8595_KBD_USB_INTF 0
+
static int ite_event(struct hid_device *hdev, struct hid_field *field,
struct hid_usage *usage, __s32 value)
{
@@ -37,6 +40,36 @@ static int ite_event(struct hid_device *hdev, struct hid_field *field,
return 0;
}
+static bool ite_match(struct hid_device *hdev, bool ignore_special_driver)
+{
+ struct usb_interface *intf;
+
+ if (ignore_special_driver)
+ return false;
+
+ /*
+ * Most keyboard docks with an ITE 8595 keyboard/touchpad controller
+ * have the "Wireless Radio Control" bits which need this special
+ * driver on the second USB interface (the mouse interface). On
+ * these devices we simply bind to all USB interfaces.
+ *
+ * The Acer Aspire Switch 10 (SW5-012) is special, its touchpad
+ * not only does mouse emulation it also supports HID-multitouch
+ * and all the keys including the "Wireless Radio Control" bits
+ * have been moved to the first USB interface (the keyboard intf).
+ *
+ * We want the hid-multitouch driver to bind to the touchpad, so on
+ * the Acer SW5-012 we should only bind to the keyboard USB intf.
+ */
+ if (hdev->bus != BUS_USB || hdev->vendor != USB_VENDOR_ID_SYNAPTICS ||
+ hdev->product != USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5_012)
+ return true;
+
+ intf = to_usb_interface(hdev->dev.parent);
+
+ return intf->altsetting->desc.bInterfaceNumber == ITE8595_KBD_USB_INTF;
+}
+
static const struct hid_device_id ite_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE8595) },
{ HID_USB_DEVICE(USB_VENDOR_ID_258A, USB_DEVICE_ID_258A_6A88) },
@@ -50,6 +83,7 @@ MODULE_DEVICE_TABLE(hid, ite_devices);
static struct hid_driver ite_driver = {
.name = "itetech",
.id_table = ite_devices,
+ .match = ite_match,
.event = ite_event,
};
module_hid_driver(ite_driver);
--
2.23.0
Some (somewhat older) laptops have a correct BGRT table, except that the
version field is 0 instead of 1.
This has been seen on several Ivy Bridge based Lenovo models.
For now the spec. only defines version 1, so it is reasonably safe to
assume that tables with a version of 0 really are version 1 too,
which is what this commit does so that the BGRT table will be accepted
by the kernel on laptop models with this issue.
Cc: stable(a)vger.kernel.org
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1791273
Signed-off-by: Hans de Goede <hdegoede(a)redhat.com>
---
Changes in v2:
- Simply always accept version 0 everywhere as suggested by Ard
---
drivers/firmware/efi/efi-bgrt.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c
index b07c17643210..6aafdb67dbca 100644
--- a/drivers/firmware/efi/efi-bgrt.c
+++ b/drivers/firmware/efi/efi-bgrt.c
@@ -42,7 +42,12 @@ void __init efi_bgrt_init(struct acpi_table_header *table)
return;
}
*bgrt = *(struct acpi_table_bgrt *)table;
- if (bgrt->version != 1) {
+ /*
+ * Only version 1 is defined but some older laptops (seen on Lenovo
+ * Ivy Bridge models) have a correct version 1 BGRT table with the
+ * version set to 0, so we accept version 0 and 1.
+ */
+ if (bgrt->version > 1) {
pr_notice("Ignoring BGRT: invalid version %u (expected 1)\n",
bgrt->version);
goto out;
--
2.23.0
These patches include few backported fixes for the 4.4 stable
tree.
I would appreciate if you could kindly consider including them in the
next release.
Ajay
---
[Changes from v2]:
Merged following changes from Vlastimil's series [1]:
- Added page_ref_count() in [Patch v3 5/8]
- Added missing refcount overflow checks on x86 and s390 [Patch v3 5/8]
- Added [Patch v3 8/8]
- Removed 7aef4172c795 i.e. [Patch v2 3/8]
[1] https://lore.kernel.org/stable/20191108093814.16032-1-vbabka@suse.cz/
---
[PATCH v3 1/8]:
Backporting of upstream commit f958d7b528b1:
mm: make page ref count overflow check tighter and more explicit
[PATCH v3 2/8]:
Backporting of upstream commit 88b1a17dfc3e:
mm: add 'try_get_page()' helper function
[PATCH v3 3/8]:
Backporting of upstream commit a3e328556d41:
mm, gup: remove broken VM_BUG_ON_PAGE compound check for hugepages
[PATCH v3 4/8]:
Backporting of upstream commit d63206ee32b6:
mm, gup: ensure real head page is ref-counted when using hugepages
[PATCH v3 5/8]:
Backporting of upstream commit 8fde12ca79af:
mm: prevent get_user_pages() from overflowing page refcount
[PATCH v3 6/8]:
Backporting of upstream commit 7bf2d1df8082:
pipe: add pipe_buf_get() helper
[PATCH v3 7/8]:
Backporting of upstream commit 15fab63e1e57:
fs: prevent page refcount overflow in pipe_buf_get
[PATCH v3 8/8]:
x86, mm, gup: prevent get_page() race with munmap in paravirt guest
Some (somewhat older) Lenovo laptops have a correct BGRT table, except
that the version field is 0 instead of 1.
Quickly after finding this out, even before submitting a first version of
this patch upstream, the list of DMI matches for affected models grew to
3 models (all Ivy Bridge based).
So rather then maintaining an ever growing list with DMI matches for
affected Lenovo models, this commit simply checks if the vendor is Lenovo
when the version is 0 and in that case accepts the out of spec version
working around the Lenovo firmware bug.
Cc: stable(a)vger.kernel.org
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1791273
Signed-off-by: Hans de Goede <hdegoede(a)redhat.com>
---
drivers/firmware/efi/efi-bgrt.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c
index b07c17643210..3a2d6d3a590b 100644
--- a/drivers/firmware/efi/efi-bgrt.c
+++ b/drivers/firmware/efi/efi-bgrt.c
@@ -15,6 +15,7 @@
#include <linux/acpi.h>
#include <linux/efi.h>
#include <linux/efi-bgrt.h>
+#include <linux/dmi.h>
struct acpi_table_bgrt bgrt_tab;
size_t bgrt_image_size;
@@ -42,7 +43,12 @@ void __init efi_bgrt_init(struct acpi_table_header *table)
return;
}
*bgrt = *(struct acpi_table_bgrt *)table;
- if (bgrt->version != 1) {
+ /*
+ * Some older Lenovo laptops have a correct BGRT table, except that
+ * the version field is 0 instead of 1.
+ */
+ if (bgrt->version != 1 &&
+ !(bgrt->version == 0 && dmi_name_in_vendors("LENOVO"))) {
pr_notice("Ignoring BGRT: invalid version %u (expected 1)\n",
bgrt->version);
goto out;
--
2.24.1