Bug 218172 - Hardware Buttons on Logitech G502 X Plus stop working on 6.6.X
Summary: Hardware Buttons on Logitech G502 X Plus stop working on 6.6.X
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Input Devices (show other bugs)
Hardware: All Linux
: P3 normal
Assignee: drivers_input-devices
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-21 10:12 UTC by André J. D. Kunz
Modified: 2024-11-24 10:17 UTC (History)
7 users (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Dmsg (140.69 KB, text/plain)
2023-11-21 10:12 UTC, André J. D. Kunz
Details
Dmsg 6.6.2 (140.69 KB, text/plain)
2023-11-21 10:13 UTC, André J. D. Kunz
Details
Dmsg 6.5.12 (118.33 KB, text/plain)
2023-11-21 10:14 UTC, André J. D. Kunz
Details
rdesc1 (446 bytes, text/plain)
2023-11-21 10:41 UTC, André J. D. Kunz
Details
rdesc2 (24.85 KB, text/plain)
2023-11-21 10:42 UTC, André J. D. Kunz
Details
Patch with the correct descriptors (9.37 KB, patch)
2023-11-30 17:30 UTC, Mavroudis Chatzilazaridis
Details | Diff

Description André J. D. Kunz 2023-11-21 10:12:46 UTC
Created attachment 305445 [details]
Dmsg

Hey there guys,

as discussed via LKML I'm filing this thread as a bug report for Logitech G502 X Plus wireless mouse, whose mouse buttons all work on kernel 6.5.X, but some of them stop working on 6.6.X.

To be more precise, the G502 X Plus has 5 additional buttons (Besides left and right mousebutton) and only 2 of them work after upgrading to 6.6.X. The side buttons work as intended, while the 3 buttons "on top" of the mouse, next to the left mouse button, don't.
Comment 1 André J. D. Kunz 2023-11-21 10:13:29 UTC
Created attachment 305446 [details]
Dmsg 6.6.2
Comment 2 André J. D. Kunz 2023-11-21 10:14:02 UTC
Created attachment 305447 [details]
Dmsg 6.5.12
Comment 3 André J. D. Kunz 2023-11-21 10:17:07 UTC
Further, it seems like under 6.6. those 3 mouse buttons aren't even recognized, as if they don't exist to the system, as they're not recognized by my OS (KDE) either when I try to assign them new macros.

Also, the buttons that do not work after upgrading, are all assigned my macros and/or personal key-press sequences, so maybe that's the culprit?
Comment 4 Hans de Goede 2023-11-21 10:36:31 UTC
So as I mentioned in the email discussion this seems to be caused by commit 9d1bd9346241 ("ID: logitech-dj: Add support for a new lightspeed receiver iteration") which has changed the driver for the receiver from the generic HID driver to hid-logitech-dj.

The extra buttons may explain why the unnumbered reports for the mouse with the new receiver are bigger and I wonder if the issue is that those are missing from the emulated descriptor which hid-logitech-hidpp is using for the mouse.

André can you collect the HID descriptors for your receiver please?

To do this, do the following in a terminal:

1. Become root "sudo su -"

2. Do "ls /sys/kernel/debug/hid/"

3. There should be 2 directories starting with "0003:046D:C547." there. For these 2 dirs run:

cat /sys/kernel/debug/hid/0003:046D\:C547.xxxx/rdesc > /home/andre/rdesc1.txt
cat /sys/kernel/debug/hid/0003:046D\:C547.xxxx/rdesc > /home/andre/rdesc2.txt

Where the 2 xxxx -s should be replaced by the actual numbers used in the 2 dirs, also I made up that your username is andre, so you probably need to correct the /home/andre/rdesc?.txt path.

And then attach the 2 rdesc?.txt files from your homedir here to bugzilla.
Comment 5 André J. D. Kunz 2023-11-21 10:41:44 UTC
Created attachment 305448 [details]
rdesc1
Comment 6 André J. D. Kunz 2023-11-21 10:42:08 UTC
Created attachment 305449 [details]
rdesc2
Comment 7 André J. D. Kunz 2023-11-21 10:42:38 UTC
Hey there Hans,

Done. I've uploaded the 2 requested files
Comment 8 Marcelo 2023-11-21 13:22:01 UTC
Notice this same commit broke g915 keyboards in wireless mode
https://bugzilla.kernel.org/show_bug.cgi?id=218094
Comment 9 Mavroudis Chatzilazaridis 2023-11-21 13:55:06 UTC
Apologies for the late reply, I've been looking into this.

Unless I'm mistaken the rdesc2.txt from Comment #6 seems to match the descriptor sent by hid-logitech-dj. I then dumped the descriptor from my receiver and noticed that it was different compared to the one provided above.

sudo usbhid-dump -m 046d:c547
001:005:002:DESCRIPTOR         1700572499.758476
 06 00 FF 09 01 A1 01 85 10 95 06 75 08 15 00 26
 FF 00 09 01 81 00 09 01 91 00 C0 06 00 FF 09 02
 A1 01 85 11 95 13 75 08 15 00 26 FF 00 09 02 81
 00 09 02 91 00 C0

001:005:001:DESCRIPTOR         1700572499.763473
 05 01 09 06 A1 01 85 01 05 07 19 E0 29 E7 15 00
 25 01 75 01 95 08 81 02 95 05 05 08 19 01 29 05
 91 02 95 01 75 03 91 03 95 70 75 01 05 07 19 04
 29 73 81 02 95 05 19 87 29 8B 81 02 95 03 19 90
 29 92 81 02 C0 05 0C 09 01 A1 01 85 03 95 02 75
 10 15 01 26 FF 02 19 01 2A FF 02 81 00 C0 05 01
 09 80 A1 01 85 04 95 01 75 02 15 01 25 03 09 82
 09 81 09 83 81 00 75 01 15 00 25 01 09 9B 81 06
 75 05 81 03 C0

001:005:000:DESCRIPTOR         1700572499.767426
 05 01 09 02 A1 01 09 01 A1 00 95 10 75 01 15 00
 25 01 05 09 19 01 29 10 81 02 95 02 75 10 16 01
 80 26 FF 7F 05 01 09 30 09 31 81 06 95 01 75 08
 15 81 25 7F 09 38 81 06 95 01 05 0C 0A 38 02 81
 06 C0 06 00 FF 09 F1 75 08 95 05 15 00 26 FF 00
 81 00 C0

The mouse usage part of the descriptor contains an extra 5 bytes at the end that are vendor defined. I'm not sure how this is supposed to be handled but I assume that's where the extra buttons reside.

Regarding the keyboard issue mentioned in Comment #8, the reports have been moved around and the minimums and maximums are different.

My G PRO X Superlight only has two side buttons and thus I did not catch this issue.
Comment 10 André J. D. Kunz 2023-11-26 21:20:41 UTC
Hey there guys,

any updates on this? Is there anything I can help you with smashing that 'bug'?
Comment 11 Hans de Goede 2023-11-27 08:41:26 UTC
A revert for the commit causing this problem has been merged into the main kernel tree:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5b4ffb176d7979ac66b349addf3f7de433335e00

This has a Cc: stable, so it should get backported to a 6.6.y stable release soon.

Note the revert is really just a workaround. Please help Mavroudis with testing patches (once there are some patches) to come up with a real fix for this.
Comment 12 Mario Georgiev 2023-11-27 11:36:36 UTC
I'll preface this with apology that I don't have enough knowledge about the inner workings, so, please, don't be too harsh to me. So here are my two cents as an owner of G915TKL (keyboard) + G502X (mouse) combo.

The Lighspeed receiver (046d:C545) can actually support two devices (as in my case) and I think that it is not correct to parse the events as 13 bytes because this may be valid just for one of the devices (maybe the Pro X Superlight?). My point is that the events probably have some marking to tell the driver if this should be a 9 bytes payload or 13 bytes payload and should be handled by that marking instead of assuming that the receiver would only publish 13 bytes.
Comment 13 Mario Georgiev 2023-11-27 11:50:08 UTC
Sorry, I've made a mistake. Instead of 046d:C545 I wanted to write 046d:C547.
Comment 14 Mavroudis Chatzilazaridis 2023-11-30 17:30:58 UTC
Created attachment 305521 [details]
Patch with the correct descriptors

Hey everyone, I have attached a new patch that should fix the issues. I would appreciate it if you could test it.

For those of you that have an affected keyboard, make sure your keyboard's functionality works (modifiers such as Ctrl, indicator LEDs, letters, media keys, etc).

For those of you with a G502 X plus (or another affected mouse), please check that all the mouse buttons work as you'd expect with their default bindings, as well as your regular key-press macros that previously didn't work.
Comment 15 André J. D. Kunz 2023-11-30 17:34:10 UTC
Hey there,

appreciate the patch, which I would gladly like to test right away, but as these are my first ever interactions on bugzilla, could you briefly explain to me how I could test your patch? Can I download something or do I have to paste the code? (Sorry, those are very newbish questions, but I genuinely have no idea)
Comment 16 André J. D. Kunz 2023-11-30 17:35:07 UTC
"Can I download something or"

Found the file, but how do I apply this patch to my Kernel?
Comment 17 Hans de Goede 2023-11-30 17:52:33 UTC
> Found the file, but how do I apply this patch to my Kernel?

I talked to an Arch developer (Manjaro is an Arch derative) and I was told that this is the best / easiest way to test a kernel patch on an Arch system:

https://wiki.archlinux.org/title/Kernel/Arch_build_system
Comment 18 André J. D. Kunz 2023-11-30 18:00:05 UTC
Hey there,

I've found this article https://www.kernel.org/doc/html/next/process/applying-patches.html but I somehow get an error message when trying to apply the patch

File to patch: linux-6.6.3.tar.xz
patching file linux-6.6.3.tar.xz
Hunk #1 FAILED at 868.
1 out of 1 hunk FAILED -- saving rejects to file linux-6.6.3.tar.xz.rej
can't find file to patch at input line 43
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
Comment 19 André J. D. Kunz 2023-11-30 18:21:46 UTC
https://wiki.archlinux.org/title/Kernel/Arch_build_system

Also, this is for building kernels I think, not patching them if I understood it correctly. 

However, I've been trying for half an hour to apply the patch with no success. Maybe somebody else can go ahead and apply it
Comment 20 Mavroudis Chatzilazaridis 2023-11-30 18:26:05 UTC
Hey André,

The patch is failing to apply because it was based against the hid tree, to obtain the source code you need to run: git clone https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git .

I'm not very familiar with arch derivatives at the moment, so I'm not entirely sure as to how I can help. You can try following Hans' suggestion and try asking for help through your linux distribution's support channels.

For clarification, the patch is applied to the source code which is then built.
Comment 21 André J. D. Kunz 2023-11-30 18:39:26 UTC
Hey Mavroudis,

Thank you very much for the follow-up, this helps a lot. 

And yes, I'll try to make my way through it and if I can't make it myself, I'll ask in the Manjaro forum, good suggestion.

Will report as soon as I've successfully patched the kernel
Comment 22 Marcelo 2023-11-30 18:47:57 UTC
I believe linux-git aur package as base should be good as well.
Patch applied successfully
I'm about to test it (although on a g915)
Comment 23 Mavroudis Chatzilazaridis 2023-11-30 18:58:11 UTC
(In reply to Mario Georgiev from comment #12)

> The Lighspeed receiver (046d:C545) can actually support two devices (as in
> my case) and I think that it is not correct to parse the events as 13 bytes
> because this may be valid just for one of the devices (maybe the Pro X
> Superlight?). My point is that the events probably have some marking to tell
> the driver if this should be a 9 bytes payload or 13 bytes payload and
> should be handled by that marking instead of assuming that the receiver
> would only publish 13 bytes.


Hi Mario,

This receiver always sends 13 bytes for mouse reports and that specific if statement in the patch is just a check for a maximum number of bytes. Other receivers send less than that. From my understanding the length depends on the receiver type and not the device it receives data from. I looked at the data from my receiver and the extra bytes did not appear to relate to mouse button functionality.

The keyboard data is sent separately in a different format (it's a separate HID report with its own report ID) and I think it was being misinterpreted due to the descriptor, and thus the mouse buttons with macro key-press functionality and your keyboard weren't working as expected.

Hope that helps clear things up a bit.
Comment 24 Marcelo 2023-11-30 19:12:57 UTC
G915 seems to be working fine even after dongle being recognized as 1.2 with the proposed patch
Multimedia keys work
modifiers seems fine as well


[    6.662469] logitech-djreceiver 0003:046D:C547.0006: device of type eQUAD Lightspeed 1.2 
(0x11) connected on slot 1
Comment 25 Térence Clastres 2023-12-01 22:05:58 UTC
I confirm the patch with the correct descriptors applied on top of 6.6.3 makes my G502x behave correctly with all the keys working and with the correct keycode.

I however see an error being reported : 

```
logitech-djreceiver 0003:046D:C547.0004: hidraw3: USB HID v1.11 Mouse [Logitech USB Receiver] on usb-0000:01:00.0-13/input0
logitech-djreceiver 0003:046D:C547.0005: hidraw4: USB HID v1.11 Keyboard [Logitech USB Receiver] on usb-0000:01:00.0-13/input1
logitech-djreceiver 0003:046D:C547.0006: hiddev98,hidraw5: USB HID v1.11 Device [Logitech USB Receiver] on usb-0000:01:00.0-13/input2
logitech-djreceiver 0003:046D:C547.0006: device of type eQUAD Lightspeed 1.2 (0x11) connected on slot 1
input: Logitech Wireless Mouse PID:409f Keyboard as /devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-13/1-13:1.2/0003:046D:C547.0006/0003:046D:409F.0007/input/input20
input: Logitech Wireless Mouse PID:409f Mouse as /devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-13/1-13:1.2/0003:046D:C547.0006/0003:046D:409F.0007/input/input21
logitech-hidpp-device 0003:046D:409F.0007: hidpp_root_get_protocol_version: received protocol error 0x08
input: Logitech G502 X LS as /devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-13/1-13:1.2/0003:046D:C547.0006/0003:046D:409F.0007/input/input25
logitech-hidpp-device 0003:046D:409F.0007: input,hidraw6: USB HID v1.11 Keyboard [Logitech G502 X LS] on usb-0000:01:00.0-13/input2:1
logitech-hidpp-device 0003:046D:409F.0007: HID++ 4.2 device connected.
```
Comment 26 Linus Lotz 2024-01-04 19:14:18 UTC
I have a Logitech G PRO X Superlight 2, and added the new receiver (c54d) with the same driver_data from this patch. Not sure if this is correct, but all the buttons work correctly with my mouse. I don't have a keyboard to test it with unfortunately.
Comment 27 Christian Mayer 2024-11-24 10:17:25 UTC
My G915 is working too, after adding C541 with recvr_type_gaming_hidpp_ls_1_2 introduced with this patch.
Multimedia keys are working, modifiers as well, battery level is reported.

Also getting the protocol error like Térence
[  825.648390] logitech-djreceiver 0003:046D:C541.002F: hidraw4: USB HID v1.11 Mouse [Logitech USB Receiver] on usb-0000:06:00.3-1/input0
[  825.703525] logitech-djreceiver 0003:046D:C541.0030: hidraw6: USB HID v1.11 Keyboard [Logitech USB Receiver] on usb-0000:06:00.3-1/input1
[  825.759423] logitech-djreceiver 0003:046D:C541.0031: hiddev99,hidraw14: USB HID v1.11 Device [Logitech USB Receiver] on usb-0000:06:00.3-1/input2
[  825.817516] logitech-djreceiver 0003:046D:C541.0031: device of type eQUAD Lightspeed 1.2 (0x11) connected on slot 1
[  825.823458] input: Logitech G915 KEYBOARD as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/0000:03:08.0/0000:06:00.3/usb3/3-1/3-1:1.2/0003:046D:C541.0031/0003:046D:407C.0032/input/input125
[  825.955896] logitech-hidpp-device 0003:046D:407C.0032: input,hidraw15: USB HID v1.11 Keyboard [Logitech G915 KEYBOARD] on usb-0000:06:00.3-1/input2:1
[  825.963275] logitech-hidpp-device 0003:046D:407C.0032: hidpp_root_get_protocol_version: received protocol error 0x08


As soon i hit a button on the keyboard i see the connected message and the keyboard works fine.
[  852.396684] logitech-hidpp-device 0003:046D:407C.0032: HID++ 4.2 device connected.

This error only appears by hot plugging the usb dongle.
With rmmod+modprobe the hid-logitech-dj module the protocol error message isn't shown.
If i read the hidpp documentation correctly 0x08 means "ERR_UNKNOWN_DEVICE" which might be okay after plugging in the dongle, because the keyboard needs some time to connect?

Hope that helps to get this patch merged.

Note You need to log in before you can comment on or make changes to this bug.