Opened 2 years ago

Closed 2 years ago

#18008 closed bug (fixed)

USB HID driver improperly handle device removing

Reported by: zelenoviy Owned by: nobody
Priority: normal Milestone: R1/beta4
Component: Drivers/Input/HID/USB Version: R1/beta3
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

USB HID driver improperly handle usb device removing events in case of complex device (e.g. multiple hid devices on multiple interfaces on one usb parent device). It remove only first published device.

Attachments (1)

usb_hid_device_remove_fix.patch (1.3 KB ) - added by zelenoviy 2 years ago.
fix patch

Download all attachments as: .zip

Change History (6)

by zelenoviy, 2 years ago

fix patch

comment:1 by korli, 2 years ago

For reference, with which usb hid devices was this tested?

comment:2 by zelenoviy, 2 years ago

Its "MOTORSPEED" - a chinese mechanical keyboard

[Device /dev/bus/usb/2/5]
    Class .................. 0x00 ((Defined at Interface level) ())
    Subclass ............... 0x00(Defined at Interface level) ()
    Protocol ............... 0x00(Defined at Interface level) ()
    Max Endpoint 0 Packet .. 64
    USB Version ............ 2.0
    Vendor ID .............. 0x0c45 (Microdia)
    Product ID ............. 0x8502
    Product Version ........ 0x0106
    Manufacturer String .... "SONiX"
    Product String ......... "USB DEVICE"
    Serial Number .......... ""
    [Configuration 0]
        Configuration String . ""
        [Interface 0]
            [Alternate 0 active]
                Class .............. 0x03 (Human Interface Device (No Subclass, None))
                Subclass ........... 0x01Human Interface Device (Boot Interface Subclass, None)
                Protocol ........... 0x01Human Interface Device (Boot Interface Subclass, Keyboard)
                Interface String ... ""
                [Endpoint 0]
                    MaxPacketSize .... 8
                    Interval ......... 8
                    Type ............. Interrupt
                    Direction ........ Input
                [Descriptor 0]
                    Type ............. 0x21
                    Data ............. 11 01 00 01 22 4f 00 
        [Interface 1]
            [Alternate 0 active]
                Class .............. 0x03 (Human Interface Device (No Subclass, None))
                Subclass ........... 0x01Human Interface Device (Boot Interface Subclass, None)
                Protocol ........... 0x02Human Interface Device (Boot Interface Subclass, Mouse)
                Interface String ... ""
                [Endpoint 0]
                    MaxPacketSize .... 64
                    Interval ......... 1
                    Type ............. Interrupt
                    Direction ........ Input
                [Descriptor 0]
                    Type ............. 0x21
                    Data ............. 11 01 00 01 22 71 00 

I dot understood yet why it register 3(!) HID devices and all the keyboards.

For first device (input/keyboard/usb/0)

usb_hid: root collection holds 1 application collection
usb_hid: collection usage page 1 usage id 6
...
usb_hid: keyboard device with 6 keys and 8 modifiers
usb_hid: input report: 0; output report: 0
usb_hid: collection not a joystick or gamepad
usb_hid: collection not a mouse
usb_hid: collection not a tablet/digitizer
usb_hid: added 1 handlers for hid device

For second two

usb_hid: keyboard device with 120 keys and 0 modifiers
usb_hid: input report: 1; output report: 255
usb_hid: collection not a joystick or gamepad
usb_hid: collection not a mouse
usb_hid: collection not a tablet/digitizer
usb_hid: collection usage page 1 usage id 128
usb_hid: collection not a supported keyboard subset
usb_hid: collection not a joystick or gamepad
usb_hid: collection not a mouse
usb_hid: collection not a tablet/digitizer
usb_hid: collection usage page 12 usage id 1
usb_hid: input report count: 1
usb_hid: keyboard item with usage c0000
usb_hid: keyboard device with 1 keys and 0 modifiers
usb_hid: input report: 3; output report: 255
usb_hid: collection not a joystick or gamepad
usb_hid: collection not a mouse
usb_hid: collection not a tablet/digitizer
usb_hid: collection usage page 65308 usage id 146
usb_hid: collection not a supported keyboard subset
usb_hid: collection not a joystick or gamepad
usb_hid: collection not a mouse
usb_hid: collection not a tablet/digitizer
usb_hid: added 2 handlers for hid device

And yes, its not working properly on Haiku, but its another problem

Version 1, edited 2 years ago by zelenoviy (previous) (next) (diff)

comment:3 by waddlesplash, 2 years ago

korli: Does the patch look logical to you?

comment:4 by korli, 2 years ago

waddlesplash, seeing the DeviceList implementation, it's logical (a linked list accessed by index).

comment:5 by waddlesplash, 2 years ago

Milestone: UnscheduledR1/beta4
Resolution: fixed
Status: newclosed

Merged in hrev56570. Thanks for investigating this and providing a patch!

Note: See TracTickets for help on using tickets.