sriemer / fix-linux-mouse

Hints how to fix USB mouse issues on Linux
44 stars 5 forks source link

2019..2023 Collecting further mice with disconnect issues #22

Closed sriemer closed 6 months ago

sriemer commented 4 years ago

I've fixed several mice at upstream Linux kernel with HID_QUIRK_ALWAYS_POLL (0x00000400) already.

So please let me know if your mouse disconnects every x seconds or every minute when no user-space driver is running and nothing polls the mouse this way (usually on a virtual terminal [VT] without gpm running).

Please test if the kernel boot option

usbhid.quirks=0xaaaa:0xbbbb:0x00000400

fixes the issue while aaaa is the USB vendor ID and bbbb is the USB product ID in hex from lsusb or lsusb -vvv output.

If this fixes your issue, please let me know the USB IDs, your mouse model, which distro you use and if you need it for kernel < 4.16.

Thanks in advance!

sriemer commented 4 years ago

Suspects still open from #15: Acer Lite-On 04ca:0061, Lenovo 17ef:602e, another Lenovo 17ef:6019, and Jesis J1 1a81:2804 PixArt mice. All of those are still not fixed with kernel v5.3.

sriemer commented 4 years ago

Jinke Fan fixed the HP MSU1465 PixArt mouse: https://lkml.org/lkml/2019/11/12/1877 :+1: for linking my howto!

sriemer commented 4 years ago

There is another PixArt USB device ID with 093a:2532 - PixArt gaming mouse. According to Google translate the guy is complaining about disconnects/reconnects at: https://www.linux.org.ru/forum/general/15054466

sriemer commented 4 years ago

There is a rare Dynex PixArt mouse (19ff:0238) disconnecting it seems: https://archives.gentoo.org/gentoo-user/message/557d5e687f4436cc88232a5d43861e3a

sriemer commented 4 years ago

Third Lenovo PixArt mouse (17ef:608d) has been fixed by @tonyfischetti for Linux kernel v5.6: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=819d578d51d0ce73f06e35d69395ef55cd683a74 :+1: I knew that I know your name from the stargazers. Thank you very much! :smiley:

hktry commented 4 years ago

My mouse disconnected almost exactly every 60 seconds. USB ID 046d:c077 Strings simply say "Logitech, Inc. M105 Optical Mouse'. Confirmed that booting with usbhid.quirks=0x046d:0xc077:0x00000400 resolved the issue for me.

sriemer commented 4 years ago

@hktry Thanks. This ID is very common. It is implemented upstream since v4.0. Which kernel/distro are you running that the quirk is missing? TIA

hktry commented 4 years ago

@sriemer 3.10.0-693.11.1.el7.x86_64

sriemer commented 4 years ago

Okay, so it is the Red Hat kernel. If it is RHEL7, then enterprise support could be contacted. For CentOS7 there is likely not enough priority to backport the kernel patch.

hktry commented 4 years ago

@sriemer Thanks. We will upgrade the linux kernel later to fix this problem

dietrichm commented 4 years ago

Hello

I came across this repository through a post and comment on Reddit about fixing a similar issue for a keyboard (Anne Pro 2). I'm not sure whether you consider supplying fixes for keyboards as well, but here goes:

The device is recognized as OBINS AnnePro2 with manufacturer OBINS. IDs are: idVendor=04d9, idProduct=a293.

Specifying usbhid.quirks=0x04d9:0xa293:0x00000400 fixes the disconnection/lockup issue on Ubuntu 18.04.4 LTS with kernel 4.15.0-101-generic.

Thanks!

Dietrich

sriemer commented 4 years ago

Hi @dietrichm, thanks for reporting. usbhid device is usbhid device. I‘ll prepare the upstream kernel patch and the backports later on. Then I can send it to the Ubuntu kernel team.

sriemer commented 4 years ago

Vendor ID 04d9 is already known in the v5.7 kernel as USB_VENDOR_ID_HOLTEK_ALT.

sriemer commented 4 years ago

@dietrichm I've sent the Linux kernel patch [PATCH] HID: quirks: Always poll Obins Anne Pro 2 keyboard to the linux-input maintainers/mailing list with stable v4.16+ in Cc. It is in the archives: https://www.spinics.net/lists/linux-input/, https://www.spinics.net/lists/linux-input/msg67824.html.

dietrichm commented 4 years ago

Thanks!

wyatt8740 commented 3 years ago

My Lenovo ThinkPad USB Travel Mouse (wired, optical) which I bought around two years ago also exhibits this behavior on multiple systems when not using a usbhid quirk at boot. All my systems run Debian Sid (unstable); I am currently using kernel 5.6.0-1-amd64 on the two Intel systems I tested on, and 5.7.0-1-powerpc on my PowerBook G4 (via debian ports; powerpc (32-bit) is not an official release architecture anymore).

Relevant lines of lsusb -v output:

Bus 001 Device 007: ID 17ef:6093 Lenovo 

--snip--

  idVendor           0x17ef Lenovo
  idProduct          0x6093
  bcdDevice            1.00
  iManufacturer           1 PixArt
  iProduct                2 ThinkPad USB Optical Mouse
  iSerial                 0

I don't really need anything, but I thought I'd pitch in since you're collecting info and I have one such mouse. Thanks for the boot argument advice.

sriemer commented 3 years ago

Thanks for the report, @wyatt8740. Patch HID: quirks: Always poll three more Lenovo PixArt mice sent to linux-input where it will be accepted soon. I've combined this with the queued 17ef:602e and 17ef:6019.

Couldn't send this to stable as commits 8d5037dca7c2089f27e5903c2aecfc5bb10d7806 and 819d578d51d0ce73f06e35d69395ef55cd683a74 would have to be applied to stable kernels as well or this would require a whole bunch of backports.

sriemer commented 2 years ago

@dietrichm There is a second hardware revision of the Obins Anne Pro 2 keyboard (C15, 0x04d9:0xa292) which is getting the fix as well now: https://www.spinics.net/lists/linux-input/msg75883.html. They actually said they would fix the firmware when I reported the bug to them. 🧐

dietrichm commented 2 years ago

Hey

Great! Not sure about all the hardware revisions. Might as well be a revision that's been in production for a while already.

I never thought of submitting a bug to them either. Still I think it's valuable to have a kernel fix as I suspect not everybody will actually perform firmware updates on a keyboard.

Dietrich

artforlife commented 1 year ago

Greetings! I am inspecting this fix as I have an Anne Pro 2 keyboard. At the moment I am running Linux 5.16 kernel on Ubuntu 22.04, and the problem still persists. Is it expected that the patch is included in that version? Does it make sense to try the kernel boot option fix?

artforlife commented 1 year ago

Nevermind, I have just seen @dietrichm comment on the second revision of firmware. I have that earlier firmware, which got the fix later. I probably do not have it yet in my kernel build.

artforlife commented 1 year ago

@sriemer I have built the 5.18 version of the kernel to fix this issue with Anne Pro 2 keyboard. We shall see how it goes. However, I have noticed that whenever I reboot, the keyboard works at the point of selecting the kernel version in UEFI, but then stops working at the Ubuntu 22.04 login screen. I had to reset it via unplugging the cable to get it working. Do you have any ideas for this issue?

P.S. In case it matters, I believe I have the C15 version of Anne Pro 2, the device code is A292 instead of A293.

sriemer commented 1 year ago

@artforlife AFAIK the fix for C15 never made it to the upstream kernel as the author refused to comply to the Linux kernel contribution rules (provide full real author name). Have you tried to set the quirk via kernel boot option usbhid.quirks=0x04d9:0xa292:0x00000400?

artforlife commented 1 year ago

@artforlife AFAIK the fix for C15 never made it to the upstream kernel as the author refused to comply to the Linux kernel contribution rules (provide full real author name). Have you tried to set the quirk via kernel boot option usbhid.quirks=0x04d9:0xa292:0x00000400?

I have the following in my Grub file GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt video=efifb:off splash usbhid.quirks=0x04d9:0xa292:0x00000400" Overall, the keyboard has become much more stable. It turns off very rarely, but unfortunately still does. What's more, whenever I suspend my Ubuntu 22.04 machine, I am unable to awake the machine via the keyboard. I always resort to using the mouse. Furthermore, whenever I reboot the machine, I still need to unplug the keyboard and plug it back in at the Ubuntu login screen. So, to summarize, what the Grub line did for me was to make the keyboard a lot more stable and usable but didn't fully fix the issue.

One other thing I have implemented is the following changes to the kernel that I am running. That was my attempt to fix this issue in lieu of an official patch. I am currently running this kernel

index d9eb676abe96..ed427ca36c81 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -656,6 +656,7 @@
 #define USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A0C2    0xa0c2
 #define USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD_A096 0xa096
 #define USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD_A293 0xa293
+#define USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD_A292  0xa292

 #define USB_VENDOR_ID_IMATION          0x0718
 #define USB_DEVICE_ID_DISC_STAKKA      0xd000
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
index dc67717d2dab..e89b734c643e 100644
--- a/drivers/hid/hid-quirks.c
+++ b/drivers/hid/hid-quirks.c
@@ -95,6 +95,7 @@ static const struct hid_device_id hid_quirks[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING), HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
        { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD_A096), HID_QUIRK_NO_INIT_REPORTS },
        { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD_A293), HID_QUIRK_ALWAYS_POLL },
+       { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD_A292), HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0A4A), HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0B4A), HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE), HID_QUIRK_ALWAYS_POLL },
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 67cd420dcf89..0c7ce7853f3d 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -220,7 +220,7 @@ fi
sriemer commented 1 year ago

@artforlife sounds good. Consider checking for latest keyboard firmware (ObinsKit I suppose) and filing a support case at https://getannepro.com/. Your second issue sounds like usbcore quirks are required as well. See #21 for the quirks definitions. If none of this helps, then contact the linux-input mailing list for debugging help.

laf0rge commented 1 year ago

I'm observing this problem on Debian 11 (kernel 5.10.0-20-amd64) with Bus 005 Device 003: ID 046a:000c Cherry GmbH USB Optical Mouse and can report it fixed using usbhid.quirks=0x046a:0x000c=0x00000400.

The label on the mouse calls it a Cherry M5400

sriemer commented 1 year ago

Thank you very much for reporting @laf0rge. :+1: As you are a famous kernel developer yourself, I hope that you haven't sent the kernel patch yourself yet. I'll create and send the kernel patch from your report. :smiley:

sriemer commented 1 year ago

@laf0rge Ankit Patel (NVIDIA) already fixed that mouse in November 2022 upstream. Patch link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f6d910a89a2391e5ce1f275d205023880a33d3f8

If Debian hasn't backported it yet, then a Debian bug can be opened for this if needed.

N0th1ngM4tt3rs commented 7 months ago

I was getting a constant disconnect/reconnect issue with an aikeec handbrake for sim racing I bought. This modprobe conf fixed it for me: options usbhid quirks=0x1020:0x8888:0x00000400

usb 3-4.3: USB disconnect, device number 5 usb 3-3: new full-speed USB device number 6 using xhci_hcd usb 3-3: New USB device found, idVendor=1020, idProduct=8888, bcdDevice= 0.01 usb 3-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0 usb 3-3: Product: ODDOR-handbrake input: ODDOR-handbrake as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/0000:03:08.0/0000:08:00.1/usb3/3-3/3-3:1.0/0003:1020:8888.000D/input/input38 hid-generic 0003:1020:8888.000D: input,hidraw6: USB HID v1.11 Joystick [ODDOR-handbrake] on usb-0000:08:00.1-3/input0

sriemer commented 7 months ago

@N0th1ngM4tt3rs Thanks for reporting. I'll check the latest kernel source and submit an upstream patch if needed. :smiley:

sriemer commented 7 months ago

@N0th1ngM4tt3rs Patch sent to the HID maintainers and the linux-input mailing list. Subject: HID: Add quirk for Labtec/ODDOR/aikeec handbrake :tada:

sriemer commented 7 months ago

@N0th1ngM4tt3rs Patch https://www.spinics.net/lists/linux-input/msg88778.html has been applied upstream. Thanks again for reporting. 😃

sriemer commented 6 months ago

Closing. Thanks for all the great input here. :smiley: :penguin: :+1: :handshake: :raised_hands: :pray: Follow-up: #28