Bug 60901

Summary: [PATCH]Roper Class 1 Bluetooth Dongle / TRENDnet TBW-102UB not working with all kernel 3.x tested
Product: Drivers Reporter: Christophe PEREZ (chris)
Component: BluetoothAssignee: linux-bluetooth (linux-bluetooth)
Status: RESOLVED CODE_FIX    
Severity: normal CC: alan, gustavo, info, martin, opi, pupykin.s, yury.af
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.10.7 Subsystem:
Regression: No Bisected commit-id:
Attachments: dont send local commnads command to silicon wave devices

Description Christophe PEREZ 2013-09-07 16:50:32 UTC
As already explained (with my bad english) in https://bugs.gentoo.org/show_bug.cgi?id=411407, my trendnet bluetooth usb key doesn't work anymore with kernel 3.x, but it works fine with 2.6.32.
I use Gentoo.

# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 1310:0001 Roper Class 1 Bluetooth Dongle

# dmesg | grep -i bluetooth
[    0.150278] Bluetooth: Core ver 2.16
[    0.150588] Bluetooth: HCI device and connection manager initialized
[    0.150699] Bluetooth: HCI socket layer initialized
[    0.150808] Bluetooth: L2CAP socket layer initialized
[    0.150935] Bluetooth: SCO socket layer initialized
[    6.305338] Bluetooth: Generic Bluetooth USB driver ver 0.6
[   25.333242] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   25.333247] Bluetooth: BNEP filters: protocol multicast

# rc-service bluetooth status
 * status: started

# hciconfig
hci0:   Type: BR/EDR  Bus: USB
        BD Address: 00:0B:0D:06:F3:A3  ACL MTU: 120:20  SCO MTU: 0:0
        DOWN
        RX bytes:724 acl:0 sco:0 events:26 errors:0
        TX bytes:114 acl:0 sco:0 commands:26 errors:0

# lsmod
Module                  Size  Used by
bnep                    9223  2
fujitsu_laptop         10557  0
radeon                643069  2
snd_atiixp             11110  0
snd_atiixp_modem        8101  0
snd_ac97_codec         99647  2 snd_atiixp,snd_atiixp_modem
ttm                    41935  1 radeon
drm_kms_helper         21168  1 radeon
backlight               3624  2 fujitsu_laptop,radeon
cfbcopyarea             2881  1 radeon
cfbimgblt               1873  1 radeon
ac97_bus                1062  1 snd_ac97_codec
firewire_ohci          26212  0
cfbfillrect             2941  1 radeon
btusb                   9013  1
snd_pcm                54804  3 snd_atiixp,snd_atiixp_modem,snd_ac97_codec
i2c_piix4               7664  0
snd_page_alloc          6043  3 snd_atiixp,snd_atiixp_modem,snd_pcm
k8temp                  3067  0

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

# hcitool scan
Device is not available: No such device

# hcitool dev
Devices:

net-wireless/bluez-4.98-r2
dev-libs/openobex-1.5
app-mobilephone/obex-data-server-0.4.5
app-mobilephone/obexd-0.44
net-libs/libbluedevil-1.9.1
net-wireless/bluedevil-1.2.2

My dongle is TRENDnet TBW-102UB which worked fine with sys-kernel/gentoo-sources:2.6.32-r29 but not with 3.x (tried a lot of version before my actual 3.10.7)
Comment 1 Gustavo Padovan 2013-09-10 15:53:17 UTC
Could you provide the output of hcidump or btmon when you try to run:

$ hciconfig hci0 down
$ hciconfig hci0 up
Comment 2 Christophe PEREZ 2013-09-10 18:19:36 UTC
output of hcidump ou btmon ?
I don't understand, I don't have this on my system.

# hciconfig hci0 down
# hciconfig hci0 up  
Can't init device hci0: Invalid request code (56)
#
# which hcidump
which: no hcidump in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin...
# which btmon
which: no btmon in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin...
Comment 3 Christophe PEREZ 2013-09-10 18:29:43 UTC
found hcidump in another package.

"hciconfig hci0 down" doesn't give anything in hcidump
"hciconfig hci0 up" :
< HCI Command: Reset (0x03|0x0003) plen 0
> HCI Event: Command Complete (0x0e) plen 4
    Reset (0x03|0x0003) ncmd 1
    status 0x00
< HCI Command: Read Local Supported Features (0x04|0x0003) plen 0
> HCI Event: Command Complete (0x0e) plen 12
    Read Local Supported Features (0x04|0x0003) ncmd 1
    status 0x00
    Features: 0xff 0xff 0x05 0x38 0x18 0x18 0x00 0x00
< HCI Command: Read Local Version Information (0x04|0x0001) plen 0
> HCI Event: Command Complete (0x0e) plen 12
    Read Local Version Information (0x04|0x0001) ncmd 1
    status 0x00
    HCI Version: 1.2 (0x2) HCI Revision: 0x0
    LMP Version: 1.2 (0x2) LMP Subversion: 0x757
    Manufacturer: Silicon Wave (11)
< HCI Command: Read BD ADDR (0x04|0x0009) plen 0
> HCI Event: Command Complete (0x0e) plen 10
    Read BD ADDR (0x04|0x0009) ncmd 1
    status 0x00 bdaddr 00:0B:0D:06:F3:A3
< HCI Command: Read Buffer Size (0x04|0x0005) plen 0
> HCI Event: Command Complete (0x0e) plen 11
    Read Buffer Size (0x04|0x0005) ncmd 1
    status 0x00
    ACL MTU 120:20 SCO MTU 0:0
< HCI Command: Read Class of Device (0x03|0x0023) plen 0
> HCI Event: Command Complete (0x0e) plen 7
    Read Class of Device (0x03|0x0023) ncmd 1
    status 0x00 class 0x000000
< HCI Command: Read Local Name (0x03|0x0014) plen 0
> HCI Event: Command Complete (0x0e) plen 252
    Read Local Name (0x03|0x0014) ncmd 1
    status 0x00 name ''
< HCI Command: Read Voice Setting (0x03|0x0025) plen 0
> HCI Event: Command Complete (0x0e) plen 6
    Read Voice Setting (0x03|0x0025) ncmd 1
    status 0x00 voice setting 0x0060
< HCI Command: Set Event Filter (0x03|0x0005) plen 1
    type 0 condition 0
    Clear all filters
> HCI Event: Command Complete (0x0e) plen 4
    Set Event Filter (0x03|0x0005) ncmd 1
    status 0x00
< HCI Command: Write Connection Accept Timeout (0x03|0x0016) plen 2
    timeout 32000
> HCI Event: Command Complete (0x0e) plen 4
    Write Connection Accept Timeout (0x03|0x0016) ncmd 1
    status 0x00
< HCI Command: Read Page Scan Activity (0x03|0x001b) plen 0
> HCI Event: Command Complete (0x0e) plen 8
    Read Page Scan Activity (0x03|0x001b) ncmd 1
    status 0x00 interval 2048 window 18
< HCI Command: Read Page Scan Type (0x03|0x0046) plen 0
> HCI Event: Command Complete (0x0e) plen 5
    Read Page Scan Type (0x03|0x0046) ncmd 1
< HCI Command: Set Event Mask (0x03|0x0001) plen 8
    Mask: 0xfffffbff07180000
> HCI Event: Command Complete (0x0e) plen 4
    Set Event Mask (0x03|0x0001) ncmd 1
    status 0x00
< HCI Command: Read Local Supported Commands (0x04|0x0002) plen 0
> HCI Event: Command Status (0x0f) plen 4
    Read Local Supported Commands (0x04|0x0002) status 0x01 ncmd 1
    Error: Unknown HCI Command

I hope I used hcidump correctly, just with : hcidump hci0 > hci0.txt
Comment 4 Gustavo Padovan 2013-09-10 21:01:48 UTC
Created attachment 108071 [details]
dont send local commnads command to silicon wave devices

Could please try this patch? It is just a workaround for now. Please send the hcidump output with this patch in.
Comment 5 Yury Afanasyev 2013-10-16 15:43:41 UTC
Hi, I've got the same issue and the patch provided is not working for me because of different ID.

I did executed same commands as described in comments above and got same results, however my device has ID=31, and not 11:

--- hci_core.c  2013-09-03 04:46:10.000000000 +0800
+++ hci_core.c.patched  2013-10-13 16:27:15.559095546 +0800
@@ -516,7 +516,7 @@ static void hci_init2_req(struct hci_req
        /* AVM Berlin (31), aka "BlueFRITZ!", doesn't support the read
         * local supported commands HCI command.
         */
-       if (hdev->manufacturer != 31 && hdev->hci_ver > BLUETOOTH_VER_1_1)
+       if (hdev->manufacturer != 31 && hdev->manufacturer != 11 && hdev->hci_ver > BLUETOOTH_VER_1_1)
                hci_req_add(req, HCI_OP_READ_LOCAL_COMMANDS, 0, NULL);

        if (lmp_ssp_capable(hdev)) {


I've tested my changes and they work fine. Please include this in next kernel release if possible. Many thanks!
Comment 6 Sergej Pupykin 2013-12-19 14:26:16 UTC
"1310:0001 Roper Class 1 Bluetooth Dongle" also fails on "Read Local Supported Commands"
Comment 7 Sergej Pupykin 2013-12-19 14:27:25 UTC
And looks working after patching
Comment 8 Sergej Pupykin 2013-12-19 16:07:55 UTC
PS. I've used

sed -i 's|.*HCI_OP_READ_LOCAL_COMMANDS.*|do{}while(0);|g' net/bluetooth/hci_core.c

command instead of fair patching. My Roper Class 1 Bluetooth Dongle works now.
Comment 9 Christophe PEREZ 2014-01-05 05:45:39 UTC
(In reply to Gustavo Padovan from comment #4)
> Could please try this patch? It is just a workaround for now. Please send
> the hcidump output with this patch in.

Sorry for not responding before.
It works with the patch :
< HCI Command: Reset (0x03|0x0003) plen 0
> HCI Event: Command Complete (0x0e) plen 4
    Reset (0x03|0x0003) ncmd 1
    status 0x00
< HCI Command: Read Local Supported Features (0x04|0x0003) plen 0
> HCI Event: Command Complete (0x0e) plen 12
    Read Local Supported Features (0x04|0x0003) ncmd 1
    status 0x00
    Features: 0xff 0xff 0x05 0x38 0x18 0x18 0x00 0x00
< HCI Command: Read Local Version Information (0x04|0x0001) plen 0
> HCI Event: Command Complete (0x0e) plen 12
    Read Local Version Information (0x04|0x0001) ncmd 1
    status 0x00
    HCI Version: 1.2 (0x2) HCI Revision: 0x0
    LMP Version: 1.2 (0x2) LMP Subversion: 0x757
    Manufacturer: Silicon Wave (11)
< HCI Command: Read BD ADDR (0x04|0x0009) plen 0
> HCI Event: Command Complete (0x0e) plen 10
    Read BD ADDR (0x04|0x0009) ncmd 1
    status 0x00 bdaddr 00:0B:0D:06:F3:A3
< HCI Command: Read Buffer Size (0x04|0x0005) plen 0
> HCI Event: Command Complete (0x0e) plen 11
    Read Buffer Size (0x04|0x0005) ncmd 1
    status 0x00
    ACL MTU 120:20 SCO MTU 0:0
< HCI Command: Read Class of Device (0x03|0x0023) plen 0
> HCI Event: Command Complete (0x0e) plen 7
    Read Class of Device (0x03|0x0023) ncmd 1
    status 0x00 class 0x000000
< HCI Command: Read Local Name (0x03|0x0014) plen 0
> HCI Event: Command Complete (0x0e) plen 252
    Read Local Name (0x03|0x0014) ncmd 1
    status 0x00 name ''
< HCI Command: Read Voice Setting (0x03|0x0025) plen 0
> HCI Event: Command Complete (0x0e) plen 6
    Read Voice Setting (0x03|0x0025) ncmd 1
    status 0x00 voice setting 0x0060
< HCI Command: Set Event Filter (0x03|0x0005) plen 1
    type 0 condition 0
    Clear all filters
> HCI Event: Command Complete (0x0e) plen 4
    Set Event Filter (0x03|0x0005) ncmd 1
    status 0x00
< HCI Command: Write Connection Accept Timeout (0x03|0x0016) plen 2
    timeout 32000
> HCI Event: Command Complete (0x0e) plen 4
    Write Connection Accept Timeout (0x03|0x0016) ncmd 1
    status 0x00
< HCI Command: Read Page Scan Activity (0x03|0x001b) plen 0
> HCI Event: Command Complete (0x0e) plen 8
    Read Page Scan Activity (0x03|0x001b) ncmd 1
    status 0x00 interval 2048 window 18
< HCI Command: Read Page Scan Type (0x03|0x0046) plen 0
> HCI Event: Command Complete (0x0e) plen 5
    Read Page Scan Type (0x03|0x0046) ncmd 1
< HCI Command: Set Event Mask (0x03|0x0001) plen 8
    Mask: 0xfffffbff07180000
> HCI Event: Command Complete (0x0e) plen 4
    Set Event Mask (0x03|0x0001) ncmd 1
    status 0x00
< HCI Command: Write Scan Enable (0x03|0x001a) plen 1
    enable 3
> HCI Event: Command Complete (0x0e) plen 4
    Write Scan Enable (0x03|0x001a) ncmd 1
    status 0x00
< HCI Command: Write Class of Device (0x03|0x0024) plen 3
    class 0x620100
> HCI Event: Command Complete (0x0e) plen 4
    Write Class of Device (0x03|0x0024) ncmd 1
    status 0x00
< HCI Command: Write Local Name (0x03|0x0013) plen 248
    name 'fuji'
> HCI Event: Command Complete (0x0e) plen 4
    Write Local Name (0x03|0x0013) ncmd 1
    status 0x00
Comment 10 mastervolkov 2014-03-13 07:31:17 UTC
*** Bug 51831 has been marked as a duplicate of this bug. ***
Comment 11 mastervolkov 2014-03-13 08:05:05 UTC
After

sed -i 's|.*HCI_OP_READ_LOCAL_COMMANDS.*|do{}while(0);|g' net/bluetooth/hci_core.c

my dongle "ID 1310:0001 Roper Class 1 Bluetooth Dongle" works now too.

And after

-       if (hdev->manufacturer != 31 && hdev->hci_ver > BLUETOOTH_VER_1_1)
+       if (hdev->manufacturer != 31 && hdev->manufacturer != 11 && hdev->hci_ver > BLUETOOTH_VER_1_1)

my dongle "ID 1310:0001 Roper Class 1 Bluetooth Dongle" works too.
Comment 12 Alexander Opitz 2014-09-22 21:21:36 UTC
I've another (unnamed) device with same issue:

$> cat /var/log/syslog

kernel: [ 7425.384652] usb 9-2: new full-speed USB device number 6 using ohci-pci
kernel: [ 7425.553469] usb 9-2: New USB device found, idVendor=0c10, idProduct=0000
kernel: [ 7425.553481] usb 9-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
kernel: [ 7425.553488] usb 9-2: Product: SiW
kernel: [ 7425.553494] usb 9-2: Manufacturer: SiW
kernel: [ 7425.553499] usb 9-2: SerialNumber: 48E707F61100


$> lsusb

Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 009 Device 006: ID 0c10:0000  
Bus 009 Device 002: ID 1130:6604 Tenx Technology, Inc. MCE IR-Receiver
Bus 009 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 002: ID 192f:0916 Avago Technologies, Pte. 
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

$> hcitool dev
Devices:

$> hcitool scan
Device is not available: No such device

$> hciconfig hci0
hci0:   Type: BR/EDR  Bus: USB
        BD Address: 00:11:F6:07:E7:48  ACL MTU: 120:20  SCO MTU: 0:0
        DOWN 
        RX bytes:388 acl:0 sco:0 events:16 errors:0
        TX bytes:59 acl:0 sco:0 commands:16 errors:0

$> hciconfig hci0 up
Can't init device hci0: Invalid request code (56)

$> uname -a
Linux zimmer 3.16.0-16-generic #22-Ubuntu SMP Wed Sep 17 18:47:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Kubuntu 14.10
Comment 13 Christophe PEREZ 2015-01-01 23:19:24 UTC
not yet definitively corrected ?
I always have to patch new kernel the same way to use my dongle (actually 3.17.7 on gentoo)
Comment 14 Sergej Pupykin 2015-02-02 14:26:03 UTC
linux-next.git already has more proper fix instead of this hack.

See
http://permalink.gmane.org/gmane.linux.bluez.kernel/57722

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/bluetooth/btusb.c

/* Roper Class 1 Bluetooth Dongle (Silicon Wave based) */
{ USB_DEVICE(0x1300, 0x0001), .driver_info = BTUSB_SWAVE },

And then HCI_QUIRK_BROKEN_LOCAL_COMMANDS is set.
Comment 15 Christophe PEREZ 2015-02-02 14:41:54 UTC
(In reply to Sergej Pupykin from comment #14)
> linux-next.git already has more proper fix instead of this hack.

Thanks.
I don't know what "linux-next" is. Which kernel version will I find this fix in pls ?
Comment 16 Sergej Pupykin 2015-02-02 14:49:30 UTC
(In reply to Christophe PEREZ from comment #15)
> I don't know what "linux-next" is. Which kernel version will I find this fix
> in pls ?

See last line in table on https://www.kernel.org/. It should be linux-3.20.
Comment 17 mastervolkov 2015-03-19 19:50:08 UTC
driver_info = BTUSB_SWAVE
and
HCI_QUIRK_BROKEN_LOCAL_COMMANDS

present in 4.0-rc1
Comment 18 mastervolkov 2015-05-01 09:13:49 UTC
That bug fixed since 4.0-r1, but not for all device.

Please, add my "1310:0001 Roper Class 1 Bluetooth Dongle" too


--- drivers/bluetooth/btusb.c_ORIG      2015-05-01 12:06:59.000000000 +0300
+++ drivers/bluetooth/btusb.c   2015-05-01 12:02:00.000000000 +0300
@@ -254,6 +254,7 @@
 
        /* Roper Class 1 Bluetooth Dongle (Silicon Wave based) */
        { USB_DEVICE(0x1300, 0x0001), .driver_info = BTUSB_SWAVE },
+       { USB_DEVICE(0x1310, 0x0001), .driver_info = BTUSB_SWAVE },
 
        /* Digianswer devices */
        { USB_DEVICE(0x08fd, 0x0001), .driver_info = BTUSB_DIGIANSWER },
Comment 19 Alan 2015-05-01 12:26:41 UTC
Add a Signed-off-by: line and send the patch to linux-bluetooth@vger.kernel.org with a note saying you've tested that it fixes your Roper Class 1 dongle and it should get picked up and merged by the maintainer (See Documentation/SubmittingPatches). You don't need to be subscribed to linux-bluetooth to send a patch there.
Comment 20 mastervolkov 2015-05-12 09:57:23 UTC
On compliance http://permalink.gmane.org/gmane.linux.bluez.kernel/61883

that 0x1300 instead of 0x1310 is a typo.

Can be simply used as:

--- drivers/bluetooth/btusb.c_ORIG      2015-05-01 12:06:59.000000000 +0300
+++ drivers/bluetooth/btusb.c   2015-05-01 12:02:00.000000000 +0300
@@ -254,6 +254,6 @@
 
        /* Roper Class 1 Bluetooth Dongle (Silicon Wave based) */
-       { USB_DEVICE(0x1300, 0x0001), .driver_info = BTUSB_SWAVE },
+       { USB_DEVICE(0x1310, 0x0001), .driver_info = BTUSB_SWAVE },
 
        /* Digianswer devices */
        { USB_DEVICE(0x08fd, 0x0001), .driver_info = BTUSB_DIGIANSWER },
Comment 21 mastervolkov 2015-07-07 13:50:43 UTC
That typo fixed in commit 2eeac871697ac24a77b6d7953bd711b490e83ac7 of kernel 4.2-rc1

Since that kernel on "1310:0001 Roper Class 1 Bluetooth Dongle" applied 
HCI_QUIRK_BROKEN_LOCAL_COMMANDS

and Dongle initialize and work.

In my case all work and bug fixed.
Comment 22 Christophe PEREZ 2015-08-08 23:11:09 UTC
Kernel 4.0.5 doesn't workd for me.
I always need to patch with :
--- net/bluetooth/hci_core.c.orig       2015-08-08 18:22:36.000000000 -0400
+++ net/bluetooth/hci_core.c    2015-08-08 18:25:15.000000000 -0400
@@ -594,7 +594,7 @@
         * the driver can quirk the behavior and skip reading the local
         * supported commands.
         */
-       if (hdev->hci_ver > BLUETOOTH_VER_1_1 &&
+       if (hdev->manufacturer != 11 && hdev->manufacturer != 31 && hdev->hci_ver > BLUETOOTH_VER_1_1 &&
            !test_bit(HCI_QUIRK_BROKEN_LOCAL_COMMANDS, &hdev->quirks))
                hci_req_add(req, HCI_OP_READ_LOCAL_COMMANDS, 0, NULL);

to make it work :(
Comment 23 mastervolkov 2015-08-09 16:18:11 UTC
For Christophe PEREZ:
That bug FIXED in kernel AFTER 4.2-rc1

in 4.0.5 that patch adsent and patch hci_core.c steel need.
Comment 24 Christophe PEREZ 2015-08-16 06:51:47 UTC
Oh ! sorry ...
Comment 25 mastervolkov 2015-08-19 12:35:34 UTC
For information:

that bug fixed in kernel:

>= 4.1.4
>= 4.2-rc1