USB-Keyboard-issue since 4.17

Hi,

i’ve noticed that my usb-keyboard is not working in 4.19…lsusb shows it, but i cannot write on fbdev-console…generic HID and usb-hid is activated

dmesg reports it like this:

[  208.393513] evbug: Connected device: input18 (USB USB Keykoard System Control at usb-1a240000.usb-1/input1)
[  208.394228] hid-generic 0003:1C4F:0002.000C: input,hidraw1: USB HID v1.10 Device [USB USB Keykoard] on usb-1a240000.usb-1/input1

but i cannot switch num-lock on/off or write anything

when running “dmesg -w” i see that keyboard is disconnected every time i type anything on it…strange…

log on keydown
[   77.292068] usb 1-1: USB disconnect, device number 2
[   77.292068] usb 1-1: USB disconnect, device number 2
[   77.472554] evbug: Disconnected device: input0
[   77.472554] evbug: Disconnected device: input0
[   77.632390] evbug: Disconnected device: input1
[   77.632390] evbug: Disconnected device: input1
[   77.773255] evbug: Disconnected device: input2
[   77.773255] evbug: Disconnected device: input2
[   78.342590] usb 1-1: new low-speed USB device number 3 using xhci-mtk
[   78.342590] usb 1-1: new low-speed USB device number 3 using xhci-mtk
[   78.545576] input: USB USB Keykoard as /devices/platform/1a1c0000.usb/usb1/1-1/1-1:1.0/0003:1C4F:0002.0003/input/input4
[   78.545576] input: USB USB Keykoard as /devices/platform/1a1c0000.usb/usb1/1-1/1-1:1.0/0003:1C4F:0002.0003/input/input4
[   78.627589] evbug: Connected device: input4 (USB USB Keykoard at usb-1a1c0000.usb-1/input0)
[   78.636266] hid-generic 0003:1C4F:0002.0003: input,hidraw0: USB HID v1.10 Keyboard [USB USB Keykoard] on usb-1a1c0000.usb-1/input0
[   78.627589] evbug: Connected device: input4 (USB USB Keykoard at usb-1a1c0000.usb-1/input0)
[   78.655044] input: USB USB Keykoard Consumer Control as /devices/platform/1a1c0000.usb/usb1/1-1/1-1:1.1/0003:1C4F:0002.0004/input/input5
[   78.636266] hid-generic 0003:1C4F:0002.0003: input,hidraw0: USB HID v1.10 Keyboard [USB USB Keykoard] on usb-1a1c0000.usb-1/input0
[   78.655044] input: USB USB Keykoard Consumer Control as /devices/platform/1a1c0000.usb/usb1/1-1/1-1:1.1/0003:1C4F:0002.0004/input/input5
[   78.734340] evbug: Connected device: input5 (USB USB Keykoard Consumer Control at usb-1a1c0000.usb-1/input1)
[   78.746118] input: USB USB Keykoard System Control as /devices/platform/1a1c0000.usb/usb1/1-1/1-1:1.1/0003:1C4F:0002.0004/input/input6
[   78.734340] e[   78.760069] evbug: Connected device: input6 (USB USB Keykoard System Control at usb-1a1c0000.usb-1/input1)
vbug: Connected [   78.770893] hid-generic 0003:1C4F:0002.0004: input,hidraw1: USB HID v1.10 Device [USB USB Keykoard] on usb-1a1c0000.usb-1/inpu
t1
device: input5 (USB USB Keykoard Consumer Control at usb-1a1c0000.usb-1/input1)
[   78.746118] input: USB USB Keykoard System Control as /devices/platform/1a1c0000.usb/usb1/1-1/1-1:1.1/0003:1C4F:0002.0004/input/input6
[   78.760069] evbug: Connected device: input6 (USB USB Keykoard System Control at usb-1a1c0000.usb-1/input1)
[   78.770893] hid-generic 0003:1C4F:0002.0004: input,hidraw1: USB HID v1.10 Device [USB USB Keykoard] on usb-1a1c0000.usb-1/input1

same issue with 4.18.1 and 4.17.3 but not with 4.16.14 and 4.14.66

@moore @Ryder.Lee @linkerosa @Jackzeng is there any change in usb-driver/mtk_xhci? drivers/usb/host/xhci-mtk.c seems to be completely rewritten in 4.17

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/usb/host/xhci-mtk.c?h=v4.17-rc1&id=6ae9f5062aa6f5a301c16715c601c05bc9aa450e

here the hcd is introduced: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v4.17-rc1&id=07dbff0ddbd86c08c42088e9f996c2650095d684

maybe some changes to dts are needed?? tested all patches i’ve found on patchwork, but problem stays the same…usb-storage (stick) not affected by this…seems to only affect low-speed-device / keyboard

could you use mouse?

mouse is recognized and not disconnected on movement/buttonclick…i see no pointer-movement, but this can be an xserver-issue

cannot start console-application from debug-uart (export DISPLAY=:0;mate-terminal &) will be silent closed. xev brings up a small window

tried to cat /dev/input/by-path/platform-1a240000.usb-usb-0:1:1.0-event-mouse but this shows also no values (tested on laptop with working mouse shows “binary data”)

root@bpi-r2-ubuntu:~# ls -lR /dev/input
/dev/input:                                                                                                                                                   
total 0                                                                                                                                                       
drwxr-xr-x 2 root root     100 Sep  3 15:03 by-id                                                                                                             
drwxr-xr-x 2 root root     120 Sep  3 15:03 by-path                                                                                                           
crw-rw---- 1 root input 13, 64 Sep  3 15:03 event0                                                                                                            
crw-rw---- 1 root input 13, 65 Sep  3 15:03 event1                                                                                                            
crw-rw---- 1 root input 13, 66 Sep  3 15:03 event2                                                                                                            
crw-rw---- 1 root input 13, 67 Jan 28  2018 event3                                                                                                            
crw-rw---- 1 root input 13, 68 Sep  3 15:03 event4                                                                                                            
                                                                                                                                                              
/dev/input/by-id:                                                                                                                                             
total 0                                                                                                                                                       
lrwxrwxrwx 1 root root 9 Sep  3 15:03 usb-15d9_USB_OPTICAL_MOUSE-event-mouse -> ../event4                                                                     
lrwxrwxrwx 1 root root 9 Sep  3 15:03 usb-USB_USB_Keykoard-event-if01 -> ../event2                                                                            
lrwxrwxrwx 1 root root 9 Sep  3 15:03 usb-USB_USB_Keykoard-event-kbd -> ../event0                                                                             
                                                                                                                                                              
/dev/input/by-path:                                                                                                                                           
total 0                                                                                                                                                       
lrwxrwxrwx 1 root root 9 Sep  3 15:03 platform-1a1c0000.usb-usb-0:1:1.0-event-kbd -> ../event0                                                                
lrwxrwxrwx 1 root root 9 Sep  3 15:03 platform-1a1c0000.usb-usb-0:1:1.1-event -> ../event2                                                                    
lrwxrwxrwx 1 root root 9 Sep  3 15:03 platform-1a240000.usb-usb-0:1:1.0-event-mouse -> ../event4                                                              
lrwxrwxrwx 1 root root 9 Jan 28  2018 platform-mtk-pmic-keys-event -> ../event3

This issue is caused by the commit : 27082e2654dc (“xhci: Clear the host side toggle manually when endpoint is ‘soft reset’”)

We will send a patch to fix it.

1 Like

How did you figured it out? Patch is older than 4.16…

i only found such patch from 2015 which was reverted

I don’t see when it is merged to official kernel tree

I can test patch if you send it to me directly…

Add below lines to fix this issue:

drivers/usb/host/xhci-mem.c line:1616

if (xhci->quirks & XHCI_MTK_HOST) {
	in_ep_ctx->reserved[0] = out_ep_ctx->reserved[0];
	in_ep_ctx->reserved[1] = out_ep_ctx->reserved[1];
}
1 Like

this seems to fix it, i had some troubles getting a terminal on x running (mate-terminal and gnome-terminal not started…installed a very basic x-server :), but i can press keys without disconnects and mouse also works

now installed lxterm and can write to it :wink: thank you for fast solution

how did you traced that?

had added it to my repo (4.19-rc and 4.18-main):

1 Like