Bug 2201 - Keyboard found randomly as mouse, keyboard or both
Summary: Keyboard found randomly as mouse, keyboard or both
Status: REJECTED INSUFFICIENT_DATA
Alias: None
Product: Drivers
Classification: Unclassified
Component: USB (show other bugs)
Hardware: i386 Linux
: P2 high
Assignee: Vojtech Pavlik
URL:
Keywords:
Depends on:
Blocks: USB
  Show dependency tree
 
Reported: 2004-02-26 07:11 UTC by Dennis Haney
Modified: 2005-09-15 08:35 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.3 and below
Subsystem:
Regression: ---
Bisected commit-id:


Attachments
Get descriptor retry patch (1.34 KB, patch)
2004-09-21 09:00 UTC, Vojtech Pavlik
Details | Diff

Description Dennis Haney 2004-02-26 07:11:07 UTC
Distribution: gentoo and debian tried, 2.6 and 2.4 tried
Hardware Environment: Logitech iTouch keyboard Internet Navigator
Software Environment: NA
Problem Description:

Depending on whether using mousedev/keybdev or hid and depending on whether the
used is compiled into the kernel the keyboard will be found as either a mouse, a
keybord or both.
When found as both mouse and keyboard, some (but not all) of the special keys
are interpreted as mouse keys. When found only as keyboard, the same keys does
not work at all. When found as a mouse, it is very useless as a keyboard.

(Please not that I also have a [Logitech USB-PS/2 Optical Mouse], that always works)

When using hid, when compiled as a module the keyboard is detected as a mouse:
ehci_hcd 0000:00:03.3: EHCI Host Controller
ehci_hcd 0000:00:03.3: irq 225, pci mem e1835000
ehci_hcd 0000:00:03.3: new USB bus registered, assigned bus number 1
PCI: cache line size of 128 is not supported by device 0000:00:03.3
ehci_hcd 0000:00:03.3: USB 2.0 enabled, EHCI 1.00, driver 2003-Dec-29
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 6 ports detected
drivers/usb/core/usb.c: registered new driver hiddev
drivers/usb/core/usb.c: registered new driver hid
drivers/usb/input/hid-core.c: v2.0:USB HID core driver
ohci_hcd: 2004 Feb 02 USB 1.1 'Open' Host Controller (OHCI) Driver (PCI)
ohci_hcd: block sizes: ed 64 td 64
ohci_hcd 0000:00:03.0: OHCI Host Controller
ohci_hcd 0000:00:03.0: irq 169, pci mem e18ed000
ohci_hcd 0000:00:03.0: new USB bus registered, assigned bus number 2
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 2 ports detected
ohci_hcd 0000:00:03.1: OHCI Host Controller
ohci_hcd 0000:00:03.1: irq 209, pci mem e1b0d000
ohci_hcd 0000:00:03.1: new USB bus registered, assigned bus number 3
hub 3-0:1.0: USB hub found
hub 3-0:1.0: 2 ports detected
ohci_hcd 0000:00:03.2: OHCI Host Controller
ohci_hcd 0000:00:03.2: irq 217, pci mem e1b0f000
ohci_hcd 0000:00:03.2: new USB bus registered, assigned bus number 4
hub 4-0:1.0: USB hub found
hub 4-0:1.0: 2 ports detected
usb 2-1: new low speed USB device using address 2
hid: probe of 2-1:1.0 failed with error -5
input: USB HID v1.10 Mouse [Logitech Logitech USB Keyboard] on usb-0000:00:03.0-1
drivers/usb/host/uhci-hcd.c: USB Universal Host Controller Interface driver v2.1
usb 3-1: new low speed USB device using address 2
input: USB HID v1.10 Mouse [Logitech USB-PS/2 Optical Mouse] on usb-0000:00:03.1-1
usbfs: USBDEVFS_CONTROL failed cmd usbmodules dev 2 rqt 128 rq 6 len 9 ret -32

When pulling the cable and pluggin it in again I get (i.e. still failing):

usb 3-1: USB disconnect, address 5
usb 4-1: new low speed USB device using address 3
hid: probe of 4-1:1.0 failed with error -5
input: USB HID v1.10 Mouse [Logitech Logitech USB Keyboard] on usb-0000:00:03.2-1
usb 4-1: USB disconnect, address 3
usb 2-2: new low speed USB device using address 7
hid: probe of 2-2:1.0 failed with error -5
hid: probe of 2-2:1.1 failed with error -5


When HID is compiled into the kernel it behaves a bit differently:
Feb 26 13:12:49 [kernel] ohci_hcd: 2004 Feb 02 USB 1.1 'Open' Host Controller
(OHCI) Driver (PCI)
Feb 26 13:12:49 [kernel] ohci_hcd: block sizes: ed 64 td 64
Feb 26 13:12:49 [kernel] ohci_hcd 0000:00:03.0: OHCI Host Controller
Feb 26 13:12:49 [kernel] ohci_hcd 0000:00:03.0: irq 169, pci mem e1867000
Feb 26 13:12:49 [kernel] ohci_hcd 0000:00:03.0: new USB bus registered, assigned
bus number 2
Feb 26 13:12:49 [kernel] hub 2-0:1.0: USB hub found
Feb 26 13:12:49 [kernel] hub 2-0:1.0: 2 ports detected
Feb 26 13:12:49 [kernel] ohci_hcd 0000:00:03.1: OHCI Host Controller
Feb 26 13:12:49 [kernel] ohci_hcd 0000:00:03.1: irq 209, pci mem e189f000
Feb 26 13:12:49 [kernel] ohci_hcd 0000:00:03.1: new USB bus registered, assigned
bus number 3
Feb 26 13:12:49 [kernel] hub 3-0:1.0: USB hub found
Feb 26 13:12:49 [kernel] hub 3-0:1.0: 2 ports detected
Feb 26 13:12:49 [kernel] ohci_hcd 0000:00:03.2: OHCI Host Controller
Feb 26 13:12:49 [kernel] ohci_hcd 0000:00:03.2: irq 217, pci mem e18a1000
Feb 26 13:12:49 [kernel] ohci_hcd 0000:00:03.2: new USB bus registered, assigned
bus number 4
Feb 26 13:12:49 [kernel] hub 4-0:1.0: USB hub found
Feb 26 13:12:49 [kernel] hub 4-0:1.0: 2 ports detected
Feb 26 13:12:49 [kernel] usb 2-1: new low speed USB device using address 2
Feb 26 13:12:50 [kernel] drivers/usb/core/message.c: error getting string
descriptor 0 (error=-110)
Feb 26 13:12:50 [kernel] HID device not claimed by input or hiddev
Feb 26 13:12:50 [kernel] input: USB HID v1.10 Mouse [Logitech Logitech USB
Keyboard] on usb-0000:00:03.0-1
Feb 26 13:12:50 [kernel] drivers/usb/host/uhci-hcd.c: USB Universal Host
Controller Interface driver v2.1
Feb 26 13:12:50 [kernel] usb 3-1: new low speed USB device using address 2
Feb 26 13:12:50 [kernel] input: USB HID v1.10 Mouse [Logitech USB-PS/2 Optical
Mouse] on usb-0000:00:03.1-1

When pulling the cable and pluggin it in again I get (and then it works):

Feb 26 13:20:19 [kernel] usb 2-1: USB disconnect, address 2
Feb 26 13:20:19 [kernel] usb 3-1: USB disconnect, address 2
Feb 26 13:20:23 [kernel] usb 2-1: new low speed USB device using address 3
Feb 26 13:20:23 [kernel] input: USB HID v1.10 Keyboard [Logitech Logitech USB
Keyboard] on usb-0000:00:03.0-1
Feb 26 13:20:23 [kernel] input: USB HID v1.10 Mouse [Logitech Logitech USB
Keyboard] on usb-0000:00:03.0-1
Feb 26 13:20:24 [kernel] usb 3-1: new low speed USB device using address 3
Feb 26 13:20:24 [kernel] input: USB HID v1.10 Mouse [Logitech USB-PS/2 Optical
Mouse] on usb-0000:00:03.1-1

When using mousedev/keybdev they must be compiled as modules to detect they
keyboard. It is quite random whether the mouse part is found:

Feb 25 20:29:35 cine kernel: drivers/usb/core/usb.c: registered new driver usbfs
Feb 25 20:29:35 cine kernel: drivers/usb/core/usb.c: registered new driver hub
Feb 25 20:29:35 cine kernel: ehci_hcd 0000:00:03.3: EHCI Host Controller
Feb 25 20:29:35 cine kernel: ehci_hcd 0000:00:03.3: irq 9, pci mem e0926000
Feb 25 20:29:35 cine kernel: ehci_hcd 0000:00:03.3: new USB bus registered,
assigned bus number 1
Feb 25 20:29:35 cine kernel: PCI: cache line size of 128 is not supported by
device 0000:00:03.3
Feb 25 20:29:35 cine kernel: ehci_hcd 0000:00:03.3: USB 2.0 enabled, EHCI 1.00,
driver 2003-Jun-13
Feb 25 20:29:35 cine kernel: hub 1-0:1.0: USB hub found
Feb 25 20:29:35 cine kernel: hub 1-0:1.0: 6 ports detected
Feb 25 20:29:35 cine kernel: ohci_hcd 0000:00:03.0: OHCI Host Controller
Feb 25 20:29:35 cine kernel: ohci_hcd 0000:00:03.0: irq 6, pci mem e092c000
Feb 25 20:29:35 cine kernel: ohci_hcd 0000:00:03.0: new USB bus registered,
assigned bus number 2
Feb 25 20:29:35 cine kernel: hub 2-0:1.0: USB hub found
Feb 25 20:29:35 cine kernel: hub 2-0:1.0: 2 ports detected
Feb 25 20:29:35 cine kernel: ohci_hcd 0000:00:03.1: OHCI Host Controller
Feb 25 20:29:35 cine kernel: ohci_hcd 0000:00:03.1: irq 9, pci mem e094e000
Feb 25 20:29:35 cine kernel: ohci_hcd 0000:00:03.1: new USB bus registered,
assigned bus number 3
Feb 25 20:29:35 cine kernel: hub 3-0:1.0: USB hub found
Feb 25 20:29:35 cine kernel: hub 3-0:1.0: 2 ports detected
Feb 25 20:29:35 cine kernel: ohci_hcd 0000:00:03.2: OHCI Host Controller
Feb 25 20:29:35 cine kernel: ohci_hcd 0000:00:03.2: irq 9, pci mem e09ff000
Feb 25 20:29:35 cine kernel: ohci_hcd 0000:00:03.2: new USB bus registered,
assigned bus number 4
Feb 25 20:29:35 cine kernel: hub 4-0:1.0: USB hub found
Feb 25 20:29:35 cine kernel: hub 4-0:1.0: 2 ports detected
Feb 25 20:29:35 cine kernel: drivers/usb/host/uhci-hcd.c: USB Universal Host
Controller Interface driver v2.1
Feb 25 20:29:35 cine kernel: Initializing USB Mass Storage driver...
Feb 25 20:29:35 cine kernel: drivers/usb/core/usb.c: registered new driver
usb-storage
Feb 25 20:29:35 cine kernel: USB Mass Storage support registered.
Feb 25 20:29:35 cine kernel: hub 2-0:1.0: new USB device on port 1, assigned
address 2
Feb 25 20:29:35 cine kernel: hub 3-0:1.0: new USB device on port 1, assigned
address 2
Feb 25 20:29:38 cine kernel: drivers/usb/core/usb.c: registered new driver hiddev
Feb 25 20:29:38 cine kernel: hid: probe of 2-1:1.0 failed with error -5
Feb 25 20:29:38 cine kernel: drivers/usb/input/hid-core.c: ctrl urb status -32
received
Feb 25 20:29:38 cine kernel: input: USB HID v1.10 Mouse [Logitech Logitech USB
Keyboard] on usb-0000:00:03.0-1
Feb 25 20:29:38 cine kernel: input: USB HID v1.10 Mouse [Logitech USB-PS/2
Optical Mouse] on usb-0000:00:03.1-1
Feb 25 20:29:38 cine kernel: drivers/usb/core/usb.c: registered new driver hid
Feb 25 20:29:38 cine kernel: drivers/usb/input/hid-core.c: v2.0:USB HID core driver
Feb 25 20:29:38 cine input.agent[795]: kernel driver evdev already loaded
Feb 25 20:29:38 cine input.agent[788]: kernel driver evdev already loaded
Feb 25 20:29:38 cine input.agent[788]: kernel driver mousedev already loaded
Feb 25 20:29:38 cine kernel: input: Logitech Logitech USB Keyboard on
usb-0000:00:03.0-1
Feb 25 20:29:38 cine kernel: drivers/usb/core/usb.c: registered new driver usbkbd
Feb 25 20:29:38 cine kernel: drivers/usb/input/usbkbd.c: :USB HID Boot Protocol
keyboard driver
Feb 25 20:29:38 cine kernel: drivers/usb/core/usb.c: registered new driver usbmouse
Feb 25 20:29:38 cine kernel: drivers/usb/input/usbmouse.c: v1.6:USB HID Boot
Protocol mouse driver
Feb 25 20:29:39 cine input.agent[780]: kernel driver evdev already loaded
Feb 25 20:29:39 cine input.agent[780]: kernel driver mousedev already loaded


Steps to reproduce:
Comment 1 Alexander Rensmann 2004-05-04 09:50:24 UTC
Distribution: Self-build 2.6.5 (with gcc 3.3.2)
Hardware Environment: Logitech Internet Navigator Keyboard (USB)


I had the same problem with 2.6.5. Most times the Kernel didn't bind the
hid-driver to the keyboard. I have tracked down the Problem to this this function:

linux/drivers/usb/input/hid-core.c
> static int hid_get_class_descriptor(struct usb_device *dev, int ifnum,
>                 unsigned char type, void *buf, int size)
> {
>         return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
>                 USB_REQ_GET_DESCRIPTOR, USB_RECIP_INTERFACE | USB_DIR_IN,
>                 (type << 8), ifnum, buf, size, HZ * USB_CTRL_GET_TIMEOUT);
> }

In some cases this function returns without any byte read. The debug-output
shows: "report descriptor (size xyz, read 0)" and tries to interpret the data.
I think usb_control_msg times out too fast.

I for myself solved the problem by looping until an error occured or enough data
has been read. I know its *dirty*, but it works fine for me. 
Comment 2 Dennis 2004-09-19 23:19:07 UTC
I get the same randomly-found problems with my Logitech Internet Navigator
Keyboard - most of the time, either the keyboard or the aditional keys are not
detected. (ie. usbhid: probe of 1-1.3:1.0 failed with error -5)

Within linux/drivers/usb/input/hid-core.c for linux-2.6.8-rc4, I tried doing the
following to "fix" the problem:

static int hid_get_class_descriptor(struct usb_device *dev, int ifnum,
                unsigned char type, void *buf, int size)
{
        usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
                USB_REQ_GET_DESCRIPTOR, USB_RECIP_INTERFACE | USB_DIR_IN,
                (type << 8), ifnum, buf, size, HZ * USB_CTRL_GET_TIMEOUT);
        return 0;
}

Basically, it only works when I return 0. Any non-zero return value (i think)
results in the -5 probe error, and the device not being detected.
Comment 3 Dennis 2004-09-21 08:38:56 UTC
Nevermind .. my last suggestion to force the function to not return an error did
not work today .. although, honestly, it did appear to work for a few days =)

I will try to loop for data, as Alex suggested.
Comment 4 Vojtech Pavlik 2004-09-21 09:00:55 UTC
Created attachment 3688 [details]
Get descriptor retry patch
Comment 5 Dennis 2004-09-22 14:42:15 UTC
ie.

static int hid_get_class_descriptor(struct usb_device *dev, int ifnum,
                unsigned char type, void *buf, int size)
{
        int retv = 0;
        while ( retv < 2 ) {
                retv = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
                        USB_REQ_GET_DESCRIPTOR, USB_RECIP_INTERFACE | USB_DIR_IN,
                        (type << 8), ifnum, buf, size, HZ * USB_CTRL_GET_TIMEOUT);
        }
        return retv;
}
Comment 6 Dennis 2005-01-09 09:45:33 UTC
has the patch actually been applied? ... i'm using kernel v2.6.10 (gentoo-r2),
and it was not patched =(
Comment 7 Dennis 2005-02-11 08:01:47 UTC
the patch isn't working properly, for me (linux-2.6.10-gentoo-r2, Logitech USB
Keyboard) - my keyboard (or the 'mouse' on the keyboard) is still frequently not
detected. i think result=0 is also an error, and instead, we should loop until
result > 0. i did this, and so far, it seems to work.

also, any ideas why hid_get_class_descriptor would fail?
Comment 8 Alexander Rensmann 2005-02-14 09:06:03 UTC
You should loop while result==0. Result<0 means there was an error.
Comment 9 Greg Kroah-Hartman 2005-08-18 16:24:10 UTC
Is this still a problem on 2.6.13-rc6 or greater?  If so, please reopen with 
the new information.

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