Bug 103451

Summary: Cambridge Silicon Radio, Ltd Bluetooth Dongle unusable (HCI_OP_READ_STORED_LINK_KEY)
Product: Drivers Reporter: Rhobison Alves Pereira (rhobison)
Component: BluetoothAssignee: linux-bluetooth (linux-bluetooth)
Status: RESOLVED CODE_FIX    
Severity: blocking CC: asterix52, johan.hedberg, karfreitag58
Priority: P1    
Hardware: ARM   
OS: Linux   
Kernel Version: 4.1 Subsystem:
Regression: Yes Bisected commit-id:
Attachments: Patch proposal
Sources modified
Sources modified (btusb)
Patch proposal 2

Description Rhobison Alves Pereira 2015-08-25 11:56:00 UTC
CSR Bluetooth always fails with command "hciconfig hci0 up".
btmon shows that command "Read Stored Link Key" always returns status 0x11 (tested on Raspberry Pi2 with OSMC).
My radio is an old bluetooth 2.0 device. It works great on Windows.
Comment 1 Johan Hedberg 2015-08-25 12:26:25 UTC
This kind of issue was fixed over a year ago by commits 81cac64ba258a and f9f462faa0277. The behavior exhibited by the controllers those commits target is exactly the same as you describe (even the specific error value). Your controller must be somehow different that the quirk doesn't get applied for it. To understand exactly how it's different please provide an HCI trace (btmon or hcidump output) of the failed "hciconfig hci0 up" as well as usb-devices output for your adapter.
Comment 2 Rhobison Alves Pereira 2015-08-25 13:01:05 UTC
Hi! Thanks for ready reply!
I will take the trace and the infos requested soon as possible (I am not in home now).

But, how/where can I see the commits 81cac64ba258a and f9f462faa0277 (see what have changed)? I am new to linux/kernel development.
Comment 3 Johan Hedberg 2015-08-25 13:09:24 UTC
You could do a git clone of the kernel tree and then "git show <commit id>" would work. Alternatively you can see these commits through the web interface:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=81cac64ba258a
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=f9f462faa0277
Comment 4 Rhobison Alves Pereira 2015-08-25 13:51:29 UTC
These changes are for HCI_OP_DELETE_STORED_LINK_KEY, if I understand correctly.
My problem is for HCI_OP_READ_STORED_LINK_KEY. I think this is a different issue.
By the way, the dongle works on CentOS 7 (x86_64) 3.10.0-229.7.2

Later I will provide the btmon/usb-devices infos.

Thank you!
Comment 5 Johan Hedberg 2015-08-25 15:22:55 UTC
Sorry, I indeed mixed up these two commands. Sounds like we need a new quirk or need to extend the existing one to cover this second HCI command (the quirk is called HCI_QUIRK_BROKEN_STORED_LINK_KEY so at least the name would cover both commands). FWIW, the kernel code does check whether the controller claims to support this command or not and only issues it if it is claimed to be supported, so in that sense this adapter is quite broken.
Comment 6 Rhobison Alves Pereira 2015-08-25 23:10:58 UTC
Here are the infos:

//--------------------------------------------------------------------------
#uname -a

Linux osmc 4.1.3-2-osmc #1 SMP PREEMPT Tue Aug 4 11:44:21 UTC 2015 armv7l GNU/Linux


//--------------------------------------------------------------------------
#btmon

Bluetooth monitor ver 5.23
= New Index: 00:15:83:16:C0:BF (BR/EDR,USB,hci0)                [hci0] 0.259661
< HCI Command: Reset (0x03|0x0003) plen 0                       [hci0] 6.698975
> HCI Event: Command Complete (0x0e) plen 4                     [hci0] 6.756229
      Reset (0x03|0x0003) ncmd 1
        Status: Success (0x00)
< HCI Command: Read Local Supported Fea.. (0x04|0x0003) plen 0  [hci0] 6.756337
> HCI Event: Command Complete (0x0e) plen 12                    [hci0] 6.758222
      Read Local Supported Features (0x04|0x0003) ncmd 1
        Status: Success (0x00)
        Features: 0xff 0x3e 0x85 0x38 0x18 0x18 0x00 0x00
          3 slot packets
          5 slot packets
          Encryption
          Slot offset
          Timing accuracy
          Role switch
          Hold mode
          Sniff mode
          Power control requests
          Channel quality driven data rate (CQDDR)
          SCO link
          HV2 packets
          HV3 packets
          CVSD synchronous data
          Power control
          Broadcast Encryption
          Enhanced inquiry scan
          Interlaced inquiry scan
          Interlaced page scan
          AFH capable slave
          AFH classification slave
          AFH capable master
          AFH classification master
< HCI Command: Read Local Version Infor.. (0x04|0x0001) plen 0  [hci0] 6.758287
> HCI Event: Command Complete (0x0e) plen 12                    [hci0] 6.760234
      Read Local Version Information (0x04|0x0001) ncmd 1
        Status: Success (0x00)
        HCI version: Bluetooth 2.0 (0x03) - Revision 3164 (0x0c5c)
        LMP version: Bluetooth 2.0 (0x03) - Subversion 3164 (0x0c5c)
        Manufacturer: Cambridge Silicon Radio (10)
< HCI Command: Read BD ADDR (0x04|0x0009) plen 0                [hci0] 6.760293
> HCI Event: Command Complete (0x0e) plen 10                    [hci0] 6.762227
      Read BD ADDR (0x04|0x0009) ncmd 1
        Status: Success (0x00)
        Address: 00:15:83:16:C0:BF (IVT corporation)
< HCI Command: Read Buffer Size (0x04|0x0005) plen 0            [hci0] 6.762377
> HCI Event: Command Complete (0x0e) plen 11                    [hci0] 6.764240
      Read Buffer Size (0x04|0x0005) ncmd 1
        Status: Success (0x00)
        ACL MTU: 672  ACL max packet: 4
        SCO MTU: 48   SCO max packet: 1
< HCI Command: Read Class of Device (0x03|0x0023) plen 0        [hci0] 6.764334
> HCI Event: Command Complete (0x0e) plen 7                     [hci0] 6.766223
      Read Class of Device (0x03|0x0023) ncmd 1
        Status: Success (0x00)
        Class: 0x000104
          Major class: Computer (desktop, notebook, PDA, organizers)
          Minor class: Desktop workstation
< HCI Command: Read Local Name (0x03|0x0014) plen 0             [hci0] 6.766301
> HCI Event: Command Complete (0x0e) plen 252                   [hci0] 6.785235
      Read Local Name (0x03|0x0014) ncmd 1
        Status: Success (0x00)
        Name: 
< HCI Command: Read Voice Setting (0x03|0x0025) plen 0          [hci0] 6.785310
> HCI Event: Command Complete (0x0e) plen 6                     [hci0] 6.787225
      Read Voice Setting (0x03|0x0025) ncmd 1
        Status: Success (0x00)
        Setting: 0x0060
          Input Coding: Linear
          Input Data Format: 2's complement
          Input Sample Size: 16-bit
          # of bits padding at MSB: 0
          Air Coding Format: CVSD
< HCI Command: Read Number of Supported.. (0x03|0x0038) plen 0  [hci0] 6.787290
> HCI Event: Command Complete (0x0e) plen 5                     [hci0] 6.789222
      Read Number of Supported IAC (0x03|0x0038) ncmd 1
        Status: Success (0x00)
        Number of IAC: 2
< HCI Command: Read Current IAC LAP (0x03|0x0039) plen 0        [hci0] 6.789288
> HCI Event: Command Complete (0x0e) plen 8                     [hci0] 6.791221
      Read Current IAC LAP (0x03|0x0039) ncmd 1
        Status: Success (0x00)
        Number of IAC: 1
        Access code: 0x9e8b33 (General Inquiry)
< HCI Command: Set Event Filter (0x03|0x0005) plen 1            [hci0] 6.791284
        Type: Clear All Filters (0x00)
> HCI Event: Command Complete (0x0e) plen 4                     [hci0] 6.793228
      Set Event Filter (0x03|0x0005) ncmd 1
        Status: Success (0x00)
< HCI Command: Write Connection Accept... (0x03|0x0016) plen 2  [hci0] 6.793302
        Timeout: 20000.000 msec (0x7d00)
> HCI Event: Command Complete (0x0e) plen 4                     [hci0] 6.795241
      Write Connection Accept Timeout (0x03|0x0016) ncmd 1
        Status: Success (0x00)
< HCI Command: Read Local Supported Com.. (0x04|0x0002) plen 0  [hci0] 6.795305
> HCI Event: Command Complete (0x0e) plen 68                    [hci0] 6.801219
      Read Local Supported Commands (0x04|0x0002) ncmd 1
        Status: Success (0x00)
        Commands: 114 entries
          Inquiry (Octet 0 - Bit 0)
          Inquiry Cancel (Octet 0 - Bit 1)
          Periodic Inquiry Mode (Octet 0 - Bit 2)
          Exit Periodic Inquiry Mode (Octet 0 - Bit 3)
          Create Connection (Octet 0 - Bit 4)
          Disconnect (Octet 0 - Bit 5)
          Add SCO Connection (Octet 0 - Bit 6)
          Create Connection Cancel (Octet 0 - Bit 7)
          Accept Connection Request (Octet 1 - Bit 0)
          Reject Connection Request (Octet 1 - Bit 1)
          Link Key Request Reply (Octet 1 - Bit 2)
          Link Key Request Negative Reply (Octet 1 - Bit 3)
          PIN Code Request Reply (Octet 1 - Bit 4)
          PIN Code Request Negative Reply (Octet 1 - Bit 5)
          Change Connection Packet Type (Octet 1 - Bit 6)
          Authentication Requested (Octet 1 - Bit 7)
          Set Connection Encryption (Octet 2 - Bit 0)
          Change Connection Link Key (Octet 2 - Bit 1)
          Master Link Key (Octet 2 - Bit 2)
          Remote Name Request (Octet 2 - Bit 3)
          Remote Name Request Cancel (Octet 2 - Bit 4)
          Read Remote Supported Features (Octet 2 - Bit 5)
          Read Remote Extended Features (Octet 2 - Bit 6)
          Read Remote Version Information (Octet 2 - Bit 7)
          Read Clock Offset (Octet 3 - Bit 0)
          Read LMP Handle (Octet 3 - Bit 1)
          Holde Mode (Octet 4 - Bit 1)
          Sniff Mode (Octet 4 - Bit 2)
          Exit Sniff Mode (Octet 4 - Bit 3)
          QoS Setup (Octet 4 - Bit 6)
          Role Discovery (Octet 4 - Bit 7)
          Switch Role (Octet 5 - Bit 0)
          Read Link Policy Settings (Octet 5 - Bit 1)
          Write Link Policy Settings (Octet 5 - Bit 2)
          Read Default Link Policy Settings (Octet 5 - Bit 3)
          Write Default Link Policy Settings (Octet 5 - Bit 4)
          Set Event Mask (Octet 5 - Bit 6)
          Reset (Octet 5 - Bit 7)
          Set Event Filter (Octet 6 - Bit 0)
          Flush (Octet 6 - Bit 1)
          Read PIN Type (Octet 6 - Bit 2)
          Write PIN Type (Octet 6 - Bit 3)
          Create New Unit Key (Octet 6 - Bit 4)
          Read Stored Link Key (Octet 6 - Bit 5)
          Write Stored Link Key (Octet 6 - Bit 6)
          Delete Stored Link Key (Octet 6 - Bit 7)
          Write Local Name (Octet 7 - Bit 0)
          Read Local Name (Octet 7 - Bit 1)
          Read Connection Accept Timeout (Octet 7 - Bit 2)
          Write Connection Accept Timeout (Octet 7 - Bit 3)
          Read Page Timeout (Octet 7 - Bit 4)
          Write Page Timeout (Octet 7 - Bit 5)
          Read Scan Enable (Octet 7 - Bit 6)
          Write Scan Enable (Octet 7 - Bit 7)
          Read Page Scan Activity (Octet 8 - Bit 0)
          Write Page Scan Activity (Octet 8 - Bit 1)
          Read Inquiry Scan Activity (Octet 8 - Bit 2)
          Write Inquiry Scan Activity (Octet 8 - Bit 3)
          Read Authentication Enable (Octet 8 - Bit 4)
          Write Authentication Enable (Octet 8 - Bit 5)
          Read Encryption Mode (Octet 8 - Bit 6)
          Write Encryption Mode (Octet 8 - Bit 7)
          Read Class of Device (Octet 9 - Bit 0)
          Write Class of Device (Octet 9 - Bit 1)
          Read Voice Setting (Octet 9 - Bit 2)
          Write Voice Setting (Octet 9 - Bit 3)
          Read Automatic Flush Timeout (Octet 9 - Bit 4)
          Write Automatic Flush Timeout (Octet 9 - Bit 5)
          Read Num Broadcast Retransmissions (Octet 9 - Bit 6)
          Write Num Broadcast Retransmissions (Octet 9 - Bit 7)
          Read Hold Mode Activity (Octet 10 - Bit 0)
          Write Hold Mode Activity (Octet 10 - Bit 1)
          Read Transmit Power Level (Octet 10 - Bit 2)
          Read Sync Flow Control Enable (Octet 10 - Bit 3)
          Write Sync Flow Control Enable (Octet 10 - Bit 4)
          Set Controller To Host Flow Control (Octet 10 - Bit 5)
          Host Buffer Size (Octet 10 - Bit 6)
          Host Number of Completed Packets (Octet 10 - Bit 7)
          Read Link Supervision Timeout (Octet 11 - Bit 0)
          Write Link Supervision Timeout (Octet 11 - Bit 1)
          Read Number of Supported IAC (Octet 11 - Bit 2)
          Read Current IAC LAP (Octet 11 - Bit 3)
          Write Current IAC LAP (Octet 11 - Bit 4)
          Read Page Scan Period Mode (Octet 11 - Bit 5)
          Write Page Scan Period Mode (Octet 11 - Bit 6)
          Read Page Scan Mode (Octet 11 - Bit 7)
          Write Page Scan Mode (Octet 12 - Bit 0)
          Set AFH Host Channel Classification (Octet 12 - Bit 1)
          Read Inquiry Scan Type (Octet 12 - Bit 4)
          Write Inquiry Scan Type (Octet 12 - Bit 5)
          Read Inquiry Mode (Octet 12 - Bit 6)
          Write Inquiry Mode (Octet 12 - Bit 7)
          Read Page Scan Type (Octet 13 - Bit 0)
          Write Page Scan Type (Octet 13 - Bit 1)
          Read AFH Channel Assessment Mode (Octet 13 - Bit 2)
          Write AFH Channel Assessment Mode (Octet 13 - Bit 3)
          Read Local Version Information (Octet 14 - Bit 3)
          Read Local Supported Features (Octet 14 - Bit 5)
          Read Local Extended Features (Octet 14 - Bit 6)
          Read Buffer Size (Octet 14 - Bit 7)
          Read Country Code (Octet 15 - Bit 0)
          Read BD ADDR (Octet 15 - Bit 1)
          Read Failed Contact Counter (Octet 15 - Bit 2)
          Reset Failed Contact Counter (Octet 15 - Bit 3)
          Read Link Quality (Octet 15 - Bit 4)
          Read RSSI (Octet 15 - Bit 5)
          Read AFH Channel Map (Octet 15 - Bit 6)
          Read Clock (Octet 15 - Bit 7)
          Read Loopback Mode (Octet 16 - Bit 0)
          Write Loopback Mode (Octet 16 - Bit 1)
          Enable Device Under Test Mode (Octet 16 - Bit 2)
          Setup Synchronous Connection (Octet 16 - Bit 3)
          Accept Synchronous Connection Request (Octet 16 - Bit 4)
          Reject Synchronous Connection Request (Octet 16 - Bit 5)
< HCI Command: Set Event Mask (0x03|0x0001) plen 8              [hci0] 6.801367
        Mask: 0x00001807fffbffff
          Inquiry Complete
          Inquiry Result
          Connection Complete
          Connection Request
          Disconnection Complete
          Authentication Complete
          Remote Name Request Complete
          Encryption Change
          Change Connection Link Key Complete
          Master Link Key Complete
          Read Remote Supported Features Complete
          Read Remote Version Information Complete
          QoS Setup Complete
          Command Complete
          Command Status
          Hardware Error
          Flush Occurred
          Role Change
          Mode Change
          Return Link Keys
          PIN Code Request
          Link Key Request
          Link Key Notification
          Loopback Command
          Data Buffer Overflow
          Max Slots Change
          Read Clock Offset Complete
          Connection Packet Type Changed
          QoS Violation
          Page Scan Mode Change
          Page Scan Repetition Mode Change
          Flow Specification Complete
          Inquiry Result with RSSI
          Read Remote Extended Features Complete
          Synchronous Connection Complete
          Synchronous Connection Changed
> HCI Event: Command Complete (0x0e) plen 4                     [hci0] 6.803226
      Set Event Mask (0x03|0x0001) ncmd 1
        Status: Success (0x00)
< HCI Command: Read Stored Link Key (0x03|0x000d) plen 7        [hci0] 6.803291
        Address: 00:00:00:00:00:00 (OUI 00-00-00)
        Read all: 0x01
> HCI Event: Command Complete (0x0e) plen 8                     [hci0] 6.805241
      Read Stored Link Key (0x03|0x000d) ncmd 1
        Status: Unsupported Feature or Parameter Value (0x11)
        Max num keys: 0
        Num keys: 0


//--------------------------------------------------------------------------
#usb-devices

T:  Bus=01 Lev=02 Prnt=02 Port=03 Cnt=03 Dev#=  6 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=16 #Cfgs=  1
P:  Vendor=0a12 ProdID=0001 Rev=01.34
C:  #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb

//--------------------------------------------------------------------------
# cat /sys/kernel/debug/usb/devices

T:  Bus=01 Lev=02 Prnt=02 Port=03 Cnt=03 Dev#=  6 Spd=12   MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=16 #Cfgs=  1
P:  Vendor=0a12 ProdID=0001 Rev= 1.34
C:* #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms


//--------------------------------------------------------------------------
#lsusb -v

Bus 001 Device 006: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass          224 Wireless
  bDeviceSubClass         1 Radio Frequency
  bDeviceProtocol         1 Bluetooth
  bMaxPacketSize0        16
  idVendor           0x0a12 Cambridge Silicon Radio, Ltd
  idProduct          0x0001 Bluetooth Dongle (HCI mode)
  bcdDevice            1.34
  iManufacturer           0 
  iProduct                0 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          108
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0000  1x 0 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0000  1x 0 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           2
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0009  1x 9 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0009  1x 9 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       2
      bNumEndpoints           2
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0011  1x 17 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0011  1x 17 bytes
        bInterval               1
Device Status:     0x0000
  (Bus Powered)


//--------------------------------------------------------------------------


I hope this can help.
Comment 7 Johan Hedberg 2015-08-26 07:38:29 UTC
It looks like this might be counterfeit CSR dongle since there's a mismatch between the USB bcdDevice value (1.34 == 0x0122) and the LMP subversion reported over HCI (3164 = 0x0c5c). On real CSR controllers these two values should be the same.
Comment 8 Rhobison Alves Pereira 2015-08-26 10:57:07 UTC
Ok, but what now? What can I do?
I found someone that have the same problem:
http://permalink.gmane.org/gmane.linux.bluez.kernel/63817

I think this problem come since the version 4.0 of the kernel, where the command HCI_OP_READ_STORED_LINK_KEY was added.
Comment 9 Johan Hedberg 2015-08-26 11:11:34 UTC
We'll need to come up with patches to set the HCI_QUIRK_BROKEN_STORED_LINK_KEY quirk for this controller and then extend the usage of the quirk to this second HCI command.

The main question is whether to apply the quirk against controllers with this specific bcdDevice value or to apply it to any CSR controller where bcdDevice doesn't match the LMP subversion. Either way we'll try to come up with a fix.
Comment 10 Rhobison Alves Pereira 2015-08-26 11:31:48 UTC
Ok, thank you!
Comment 11 Johan Hedberg 2015-08-27 07:10:02 UTC
Created attachment 185961 [details]
Patch proposal

Could you please try to see if the attached patch fixes the problem. It only targets the specific LMP version of your adapter.
Comment 12 Rhobison Alves Pereira 2015-08-27 10:22:58 UTC
Of course! But this will take some time. I will need to learn how to apply this patch and compile the kernel (and if can I do it straight on Raspberry Pi 2). 
Thank you!
Comment 13 Rhobison Alves Pereira 2015-08-29 04:05:18 UTC
Created attachment 186141 [details]
Sources modified

hci_core.c with patch applied.
Comment 14 Rhobison Alves Pereira 2015-08-29 04:06:56 UTC
Created attachment 186151 [details]
Sources modified (btusb)

The patch for this file failed. I had to do manually.
Comment 15 Rhobison Alves Pereira 2015-08-29 04:20:10 UTC
The patch does not work. The issue was the same (I do not know why. Apparently the patch would have to work). 
Above are the files modified. The patch failed for the file btusb.c. I had to make the corrections manually.

There are some way to know that I have applied the patchs and compiled the sources correctly? Add some log or print to console when the code was executed?


//--------------------------------------------------------------------------
#uname -a
Linux osmc 4.1.3-osmc-bluetooth-patch-v7 #1 SMP PREEMPT Fri Aug 28 22:20:51 BRT 2015 armv7l GNU/Linux

//--------------------------------------------------------------------------
#btmon
Bluetooth monitor ver 5.23
= New Index: 00:15:83:16:C0:BF (BR/EDR,USB,hci0)                [hci0] 0.024564
< HCI Command: Reset (0x03|0x0003) plen 0                       [hci0] 8.177020
> HCI Event: Command Complete (0x0e) plen 4                     [hci0] 8.740693
      Reset (0x03|0x0003) ncmd 1
        Status: Success (0x00)
< HCI Command: Read Local Supported Fea.. (0x04|0x0003) plen 0  [hci0] 8.740779
> HCI Event: Command Complete (0x0e) plen 12                    [hci0] 8.742685
      Read Local Supported Features (0x04|0x0003) ncmd 1
        Status: Success (0x00)
        Features: 0xff 0x3e 0x85 0x38 0x18 0x18 0x00 0x00
          3 slot packets
          5 slot packets
          Encryption
          Slot offset
          Timing accuracy
          Role switch
          Hold mode
          Sniff mode
          Power control requests
          Channel quality driven data rate (CQDDR)
          SCO link
          HV2 packets
          HV3 packets
          CVSD synchronous data
          Power control
          Broadcast Encryption
          Enhanced inquiry scan
          Interlaced inquiry scan
          Interlaced page scan
          AFH capable slave
          AFH classification slave
          AFH capable master
          AFH classification master
< HCI Command: Read Local Version Infor.. (0x04|0x0001) plen 0  [hci0] 8.742750
> HCI Event: Command Complete (0x0e) plen 12                    [hci0] 8.744688
      Read Local Version Information (0x04|0x0001) ncmd 1
        Status: Success (0x00)
        HCI version: Bluetooth 2.0 (0x03) - Revision 3164 (0x0c5c)
        LMP version: Bluetooth 2.0 (0x03) - Subversion 3164 (0x0c5c)
        Manufacturer: Cambridge Silicon Radio (10)
< HCI Command: Read BD ADDR (0x04|0x0009) plen 0                [hci0] 8.744739
> HCI Event: Command Complete (0x0e) plen 10                    [hci0] 8.746684
      Read BD ADDR (0x04|0x0009) ncmd 1
        Status: Success (0x00)
        Address: 00:15:83:16:C0:BF (IVT corporation)
< HCI Command: Read Buffer Size (0x04|0x0005) plen 0            [hci0] 8.746798
> HCI Event: Command Complete (0x0e) plen 11                    [hci0] 8.748691
      Read Buffer Size (0x04|0x0005) ncmd 1
        Status: Success (0x00)
        ACL MTU: 672  ACL max packet: 4
        SCO MTU: 48   SCO max packet: 1
< HCI Command: Read Class of Device (0x03|0x0023) plen 0        [hci0] 8.748754
> HCI Event: Command Complete (0x0e) plen 7                     [hci0] 8.750685
      Read Class of Device (0x03|0x0023) ncmd 1
        Status: Success (0x00)
        Class: 0x000104
          Major class: Computer (desktop, notebook, PDA, organizers)
          Minor class: Desktop workstation
< HCI Command: Read Local Name (0x03|0x0014) plen 0             [hci0] 8.750730
> HCI Event: Command Complete (0x0e) plen 252                   [hci0] 8.769690
      Read Local Name (0x03|0x0014) ncmd 1
        Status: Success (0x00)
        Name: 
< HCI Command: Read Voice Setting (0x03|0x0025) plen 0          [hci0] 8.769784
> HCI Event: Command Complete (0x0e) plen 6                     [hci0] 8.771697
      Read Voice Setting (0x03|0x0025) ncmd 1
        Status: Success (0x00)
        Setting: 0x0060
          Input Coding: Linear
          Input Data Format: 2's complement
          Input Sample Size: 16-bit
          # of bits padding at MSB: 0
          Air Coding Format: CVSD
< HCI Command: Read Number of Supported.. (0x03|0x0038) plen 0  [hci0] 8.771758
> HCI Event: Command Complete (0x0e) plen 5                     [hci0] 8.773706
      Read Number of Supported IAC (0x03|0x0038) ncmd 1
        Status: Success (0x00)
        Number of IAC: 2
< HCI Command: Read Current IAC LAP (0x03|0x0039) plen 0        [hci0] 8.773804
> HCI Event: Command Complete (0x0e) plen 8                     [hci0] 8.775705
      Read Current IAC LAP (0x03|0x0039) ncmd 1
        Status: Success (0x00)
        Number of IAC: 1
        Access code: 0x9e8b33 (General Inquiry)
< HCI Command: Set Event Filter (0x03|0x0005) plen 1            [hci0] 8.775792
        Type: Clear All Filters (0x00)
> HCI Event: Command Complete (0x0e) plen 4                     [hci0] 8.777715
      Set Event Filter (0x03|0x0005) ncmd 1
        Status: Success (0x00)
< HCI Command: Write Connection Accept... (0x03|0x0016) plen 2  [hci0] 8.777812
        Timeout: 20000.000 msec (0x7d00)
> HCI Event: Command Complete (0x0e) plen 4                     [hci0] 8.779744
      Write Connection Accept Timeout (0x03|0x0016) ncmd 1
        Status: Success (0x00)
< HCI Command: Read Local Supported Com.. (0x04|0x0002) plen 0  [hci0] 8.779919
> HCI Event: Command Complete (0x0e) plen 68                    [hci0] 8.785688
      Read Local Supported Commands (0x04|0x0002) ncmd 1
        Status: Success (0x00)
        Commands: 114 entries
          Inquiry (Octet 0 - Bit 0)
          Inquiry Cancel (Octet 0 - Bit 1)
          Periodic Inquiry Mode (Octet 0 - Bit 2)
          Exit Periodic Inquiry Mode (Octet 0 - Bit 3)
          Create Connection (Octet 0 - Bit 4)
          Disconnect (Octet 0 - Bit 5)
          Add SCO Connection (Octet 0 - Bit 6)
          Create Connection Cancel (Octet 0 - Bit 7)
          Accept Connection Request (Octet 1 - Bit 0)
          Reject Connection Request (Octet 1 - Bit 1)
          Link Key Request Reply (Octet 1 - Bit 2)
          Link Key Request Negative Reply (Octet 1 - Bit 3)
          PIN Code Request Reply (Octet 1 - Bit 4)
          PIN Code Request Negative Reply (Octet 1 - Bit 5)
          Change Connection Packet Type (Octet 1 - Bit 6)
          Authentication Requested (Octet 1 - Bit 7)
          Set Connection Encryption (Octet 2 - Bit 0)
          Change Connection Link Key (Octet 2 - Bit 1)
          Master Link Key (Octet 2 - Bit 2)
          Remote Name Request (Octet 2 - Bit 3)
          Remote Name Request Cancel (Octet 2 - Bit 4)
          Read Remote Supported Features (Octet 2 - Bit 5)
          Read Remote Extended Features (Octet 2 - Bit 6)
          Read Remote Version Information (Octet 2 - Bit 7)
          Read Clock Offset (Octet 3 - Bit 0)
          Read LMP Handle (Octet 3 - Bit 1)
          Holde Mode (Octet 4 - Bit 1)
          Sniff Mode (Octet 4 - Bit 2)
          Exit Sniff Mode (Octet 4 - Bit 3)
          QoS Setup (Octet 4 - Bit 6)
          Role Discovery (Octet 4 - Bit 7)
          Switch Role (Octet 5 - Bit 0)
          Read Link Policy Settings (Octet 5 - Bit 1)
          Write Link Policy Settings (Octet 5 - Bit 2)
          Read Default Link Policy Settings (Octet 5 - Bit 3)
          Write Default Link Policy Settings (Octet 5 - Bit 4)
          Set Event Mask (Octet 5 - Bit 6)
          Reset (Octet 5 - Bit 7)
          Set Event Filter (Octet 6 - Bit 0)
          Flush (Octet 6 - Bit 1)
          Read PIN Type (Octet 6 - Bit 2)
          Write PIN Type (Octet 6 - Bit 3)
          Create New Unit Key (Octet 6 - Bit 4)
          Read Stored Link Key (Octet 6 - Bit 5)
          Write Stored Link Key (Octet 6 - Bit 6)
          Delete Stored Link Key (Octet 6 - Bit 7)
          Write Local Name (Octet 7 - Bit 0)
          Read Local Name (Octet 7 - Bit 1)
          Read Connection Accept Timeout (Octet 7 - Bit 2)
          Write Connection Accept Timeout (Octet 7 - Bit 3)
          Read Page Timeout (Octet 7 - Bit 4)
          Write Page Timeout (Octet 7 - Bit 5)
          Read Scan Enable (Octet 7 - Bit 6)
          Write Scan Enable (Octet 7 - Bit 7)
          Read Page Scan Activity (Octet 8 - Bit 0)
          Write Page Scan Activity (Octet 8 - Bit 1)
          Read Inquiry Scan Activity (Octet 8 - Bit 2)
          Write Inquiry Scan Activity (Octet 8 - Bit 3)
          Read Authentication Enable (Octet 8 - Bit 4)
          Write Authentication Enable (Octet 8 - Bit 5)
          Read Encryption Mode (Octet 8 - Bit 6)
          Write Encryption Mode (Octet 8 - Bit 7)
          Read Class of Device (Octet 9 - Bit 0)
          Write Class of Device (Octet 9 - Bit 1)
          Read Voice Setting (Octet 9 - Bit 2)
          Write Voice Setting (Octet 9 - Bit 3)
          Read Automatic Flush Timeout (Octet 9 - Bit 4)
          Write Automatic Flush Timeout (Octet 9 - Bit 5)
          Read Num Broadcast Retransmissions (Octet 9 - Bit 6)
          Write Num Broadcast Retransmissions (Octet 9 - Bit 7)
          Read Hold Mode Activity (Octet 10 - Bit 0)
          Write Hold Mode Activity (Octet 10 - Bit 1)
          Read Transmit Power Level (Octet 10 - Bit 2)
          Read Sync Flow Control Enable (Octet 10 - Bit 3)
          Write Sync Flow Control Enable (Octet 10 - Bit 4)
          Set Controller To Host Flow Control (Octet 10 - Bit 5)
          Host Buffer Size (Octet 10 - Bit 6)
          Host Number of Completed Packets (Octet 10 - Bit 7)
          Read Link Supervision Timeout (Octet 11 - Bit 0)
          Write Link Supervision Timeout (Octet 11 - Bit 1)
          Read Number of Supported IAC (Octet 11 - Bit 2)
          Read Current IAC LAP (Octet 11 - Bit 3)
          Write Current IAC LAP (Octet 11 - Bit 4)
          Read Page Scan Period Mode (Octet 11 - Bit 5)
          Write Page Scan Period Mode (Octet 11 - Bit 6)
          Read Page Scan Mode (Octet 11 - Bit 7)
          Write Page Scan Mode (Octet 12 - Bit 0)
          Set AFH Host Channel Classification (Octet 12 - Bit 1)
          Read Inquiry Scan Type (Octet 12 - Bit 4)
          Write Inquiry Scan Type (Octet 12 - Bit 5)
          Read Inquiry Mode (Octet 12 - Bit 6)
          Write Inquiry Mode (Octet 12 - Bit 7)
          Read Page Scan Type (Octet 13 - Bit 0)
          Write Page Scan Type (Octet 13 - Bit 1)
          Read AFH Channel Assessment Mode (Octet 13 - Bit 2)
          Write AFH Channel Assessment Mode (Octet 13 - Bit 3)
          Read Local Version Information (Octet 14 - Bit 3)
          Read Local Supported Features (Octet 14 - Bit 5)
          Read Local Extended Features (Octet 14 - Bit 6)
          Read Buffer Size (Octet 14 - Bit 7)
          Read Country Code (Octet 15 - Bit 0)
          Read BD ADDR (Octet 15 - Bit 1)
          Read Failed Contact Counter (Octet 15 - Bit 2)
          Reset Failed Contact Counter (Octet 15 - Bit 3)
          Read Link Quality (Octet 15 - Bit 4)
          Read RSSI (Octet 15 - Bit 5)
          Read AFH Channel Map (Octet 15 - Bit 6)
          Read Clock (Octet 15 - Bit 7)
          Read Loopback Mode (Octet 16 - Bit 0)
          Write Loopback Mode (Octet 16 - Bit 1)
          Enable Device Under Test Mode (Octet 16 - Bit 2)
          Setup Synchronous Connection (Octet 16 - Bit 3)
          Accept Synchronous Connection Request (Octet 16 - Bit 4)
          Reject Synchronous Connection Request (Octet 16 - Bit 5)
< HCI Command: Set Event Mask (0x03|0x0001) plen 8              [hci0] 8.785834
        Mask: 0x00001807fffbffff
          Inquiry Complete
          Inquiry Result
          Connection Complete
          Connection Request
          Disconnection Complete
          Authentication Complete
          Remote Name Request Complete
          Encryption Change
          Change Connection Link Key Complete
          Master Link Key Complete
          Read Remote Supported Features Complete
          Read Remote Version Information Complete
          QoS Setup Complete
          Command Complete
          Command Status
          Hardware Error
          Flush Occurred
          Role Change
          Mode Change
          Return Link Keys
          PIN Code Request
          Link Key Request
          Link Key Notification
          Loopback Command
          Data Buffer Overflow
          Max Slots Change
          Read Clock Offset Complete
          Connection Packet Type Changed
          QoS Violation
          Page Scan Mode Change
          Page Scan Repetition Mode Change
          Flow Specification Complete
          Inquiry Result with RSSI
          Read Remote Extended Features Complete
          Synchronous Connection Complete
          Synchronous Connection Changed
> HCI Event: Command Complete (0x0e) plen 4                     [hci0] 8.787695
      Set Event Mask (0x03|0x0001) ncmd 1
        Status: Success (0x00)
< HCI Command: Read Stored Link Key (0x03|0x000d) plen 7        [hci0] 8.787741
        Address: 00:00:00:00:00:00 (OUI 00-00-00)
        Read all: 0x01
> HCI Event: Command Complete (0x0e) plen 8                     [hci0] 8.789691
      Read Stored Link Key (0x03|0x000d) ncmd 1
        Status: Unsupported Feature or Parameter Value (0x11)
        Max num keys: 0
        Num keys: 0


//--------------------------------------------------------------------------
#usb-devices

T:  Bus=01 Lev=02 Prnt=02 Port=03 Cnt=03 Dev#=  7 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=16 #Cfgs=  1
P:  Vendor=0a12 ProdID=0001 Rev=01.34
C:  #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb

//--------------------------------------------------------------------------
#lsusb -v

Bus 001 Device 007: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass          224 Wireless
  bDeviceSubClass         1 Radio Frequency
  bDeviceProtocol         1 Bluetooth
  bMaxPacketSize0        16
  idVendor           0x0a12 Cambridge Silicon Radio, Ltd
  idProduct          0x0001 Bluetooth Dongle (HCI mode)
  bcdDevice            1.34
  iManufacturer           0 
  iProduct                0 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          108
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0000  1x 0 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0000  1x 0 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           2
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0009  1x 9 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0009  1x 9 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       2
      bNumEndpoints           2
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0011  1x 17 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0011  1x 17 bytes
        bInterval               1
Device Status:     0x0000
  (Bus Powered)
Comment 16 Johan Hedberg 2015-08-29 04:33:09 UTC
I think I know why it's not working, because of this in btusb_probe():

                /* Fake CSR devices with broken commands */                     
                if (bcdDevice <= 0x100)                                         
                        hdev->setup = btusb_setup_csr;                          

Since the bcdDevice value of your adapter doesn't match that condition the btusb_setup_csr() function I modified will never get called. Let me try to create another patch.
Comment 17 Johan Hedberg 2015-08-29 04:42:06 UTC
Created attachment 186161 [details]
Patch proposal 2

Please try with this. It will probably again not apply cleanly since I do these against the bluetooth-next tree which is probably a bit different from yours.
Comment 18 Rhobison Alves Pereira 2015-08-30 17:50:23 UTC
Good news!!

#hciconfig
hci0:	Type: BR/EDR  Bus: USB
	BD Address: 00:15:83:16:C0:BF  ACL MTU: 672:4  SCO MTU: 48:1
	UP RUNNING 
	RX bytes:484 acl:0 sco:0 events:20 errors:0
	TX bytes:324 acl:0 sco:0 commands:20 errors:0


The patch works,  but I had to modify the line (btusb.c):
   if (bcdDevice <= 0x100 || bcdDevice == 0x132)
To:
   if (bcdDevice <= 0x100 || bcdDevice == 0x134)

The bcdDevice field is 1.34 and not 1.32.

Thank you very much!
Comment 19 Johan Hedberg 2015-08-30 18:48:30 UTC
Good to hear that it works. I've sent the patch (split into two separate commits) for upstream inclusion to the linux-bluetooth mailing list.
Comment 20 Rhobison Alves Pereira 2015-08-31 10:53:01 UTC
Do not forget to modify the patch with the correct bcdDevice value (0x134) in the if statement ( if (bcdDevice <= 0x100 || bcdDevice == 0x134 ).

Thanks!

PS: I have to modify the status of the bug (RESOLVED - PATCH_ALREADY_AVAILABLE) or is up to you?
Comment 21 Norbert 2015-08-31 17:07:13 UTC
The patch doesn't work for me. Where can I find the bcdDevice value?
Comment 22 Johan Hedberg 2015-08-31 18:31:25 UTC
(In reply to Norbert from comment #21)
> The patch doesn't work for me. Where can I find the bcdDevice value?

You should be using the patches I sent to linux-bluetooth, the one here had the wrong bcdDevice value. You can see the bcdDevice value e.g. with 'lsusb -v' - if your device is the same one the value should show as 1.34 (i.e. 0x134 in hex).
Comment 23 Norbert 2015-08-31 18:55:59 UTC
OK, I have 1.34 too. Do I need kernel 4.2? I tried it with 4.1 (Ubuntu x64). 



Bus 004 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass          224 Wireless
  bDeviceSubClass         1 Radio Frequency
  bDeviceProtocol         1 Bluetooth
  bMaxPacketSize0        16
  idVendor           0x0a12 Cambridge Silicon Radio, Ltd
  idProduct          0x0001 Bluetooth Dongle (HCI mode)
  bcdDevice            1.34
  iManufacturer           0 
  iProduct                0 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          108
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0000  1x 0 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0000  1x 0 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           2
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0009  1x 9 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0009  1x 9 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       2
      bNumEndpoints           2
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0011  1x 17 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0011  1x 17 bytes
        bInterval               1
Comment 24 Norbert 2015-08-31 19:07:16 UTC
(In reply to Norbert from comment #23)
> OK, I have 1.34 too. Do I need kernel 4.2? I tried it with 4.1 (Ubuntu x64). 
 
Can the patch modified for kernel 4.1? I tried to install 4.2 but it dosen't work.
Comment 25 Norbert 2015-08-31 19:13:47 UTC
This is the reject:

--- btusb.c	
+++ btusb.c	
@@ -1348,7 +1348,9 @@ static int btusb_setup_csr(struct hci_dev *hdev)
 
 	rp = (struct hci_rp_read_local_version *)skb->data;
 
-	if (le16_to_cpu(rp->manufacturer) != 10) {
+	/* Detect controllers which aren't real CSR ones. */
+	if (le16_to_cpu(rp->manufacturer) != 10 ||
+	    le16_to_cpu(rp->lmp_subver) == 0x0c5c) {
 		/* Clear the reset quirk since this is not an actual
 		 * early Bluetooth 1.1 device from CSR.
 		 */
Comment 26 Rhobison Alves Pereira 2015-09-01 10:36:00 UTC
The patch does not worked straight for me too for the file btusb.c. I had to modify this file manually. If your btusb.c is the same as mine, here is what to do:

The original source is like this:

// Line 1356:
	if (!rp->status) {
            if ( (le16_to_cpu(rp->manufacturer) != 10) {

			/* Clear the reset quirk since this is not an actual
			 * early Bluetooth 1.1 device from CSR.
			 */
			clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);


//---------------------------------------------------

Change it to:

// Line 1356:
	if (!rp->status) {
            if ( (le16_to_cpu(rp->manufacturer) != 10) ||
                 ( le16_to_cpu(rp->lmp_subver) == 0x0c5c ) ) {

			/* Clear the reset quirk since this is not an actual
			 * early Bluetooth 1.1 device from CSR.
			 */
			clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
Comment 27 Rhobison Alves Pereira 2015-09-01 10:46:25 UTC
As well the line 3218 must be modified from this (file btusb.c, function
 static int btusb_probe(struct usb_interface *intf, const struct usb_device_id *id) ):

// Line 3218
		/* Fake CSR devices with broken commands */
		if (bcdDevice <= 0x100)
			hdev->setup = btusb_setup_csr;

		set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);


//---------------------------------------------------

To This:

// Line 3218
		/* Fake CSR devices with broken commands */
                if (bcdDevice <= 0x100 || bcdDevice == 0x134)
			hdev->setup = btusb_setup_csr;

		set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
Comment 28 Norbert 2015-09-01 19:08:24 UTC
Thanks for the advice.

The new modules are running and my mouse is working.
Comment 29 Johan Hedberg 2015-09-03 05:52:28 UTC
(In reply to Rhobison Alves Pereira from comment #20)
> PS: I have to modify the status of the bug (RESOLVED -
> PATCH_ALREADY_AVAILABLE) or is up to you?

I don't seem to have the privileges to change the status, so yes could you please resolve this as FIXED.
Comment 30 knott 2016-03-04 08:31:08 UTC
The patch was applied to the kernel but I got the same error with the git kernel.

Device 003: ID 0a12:0002 Cambridge Silicon Radio, Ltd 

#hciconfig -a
hci0:	Type: BR/EDR  Bus: USB
	BD Address: 00:00:00:00:00:00  ACL MTU: 0:0  SCO MTU: 0:0
	DOWN 
	RX bytes:0 acl:0 sco:0 events:0 errors:0
	TX bytes:0 acl:0 sco:0 commands:0 errors:0

#hciconfig hci0 up
Can't init device hci0: Operation not supported (95)

#hcitool dev                                                                          
Devices:

#rfkill list
2: hci0: Bluetooth
	Soft blocked: no
	Hard blocked: no

#hcidump -X
HCI sniffer - Bluetooth packet analyzer ver 5.37
device: hci0 snap_len: 1500 filter: 0xffffffffffffffff

I'm not sure but shouldn't hcidump show a log or something when executing hciconfig hci0 up parallely?

#uname -r    
4.5.0-rc6-gfc77dbd


How can I get the bluetooth working?