Bug 26182

Summary: btusb hangs after resetting USB device
Product: Drivers Reporter: denk
Component: USBAssignee: Greg Kroah-Hartman (greg)
Status: CLOSED CODE_FIX    
Severity: normal CC: akpm, brian, florian, gustavo, jfaulkne, maciej.rutecki, meako, mjg59-kernel, rjw, stern
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.37 Subsystem:
Regression: Yes Bisected commit-id:
Bug Depends on:    
Bug Blocks: 21782    

Description denk 2011-01-05 23:55:09 UTC
Since I updated to 2.6.37 I can't use my bluetooth input devices anymore. After booting up, they work until I don't touch them for some seconds. When I want to use them again they don't work and in dmesg I can read the following:

btusb 5-1:1.0: no reset_resume for driver btusb?
[ 1250.747352] btusb 5-1:1.1: no reset_resume for driver btusb? 

Only once I got the following trace:

    [ 4421.829246] ------------[ cut here ]------------
    [ 4421.829262] WARNING: at /tmp/buildd/linux-aptosid-2.6-2.6.37/debian/build/source_i386_none/fs/sysfs/dir.c:451 sysfs_add_one+0x96/0xc0()
    [ 4421.829268] Hardware name: 200763G
    [ 4421.829272] sysfs: cannot create duplicate filename '/class/bluetooth/hci0:11'
    [ 4421.829276] Modules linked in: btrfs zlib_deflate crc32c libcrc32c qnx4 hfsplus hfs minix ntfs vfat msdos fat jfs xfs ext4 jbd2 ext3 jbd ext2 mbcache dm_mod hidp hid vboxnetadp vboxnetflt vboxdrv af_packet acpi_cpufreq mperf cpufreq_powersave cpufreq_stats cpufreq_performance cpufreq_ondemand cpufreq_conservative freq_table ppdev lp parport sco bnep rfcomm l2cap crc16 nfsd lockd nfs_acl auth_rpcgss binfmt_misc sunrpc exportfs microcode uinput fuse coretemp arc4 ecb iwl3945 snd_hda_codec_analog radeon iwlcore snd_hda_intel pcmcia btusb ttm bluetooth snd_hda_codec snd_hwdep joydev drm_kms_helper yenta_socket snd_pcm drm mac80211 tpm_tis rtc_cmos snd_seq tpm ac pcmcia_rsrc pcmcia_core rtc_core video cfg80211 i2c_algo_bit rtc_lib i2c_i801 thinkpad_acpi i2c_core battery serio_raw snd_timer output tpm_bios rfkill nvram psmouse snd_seq_device intel_agp evdev intel_gtt snd button processor soundcore rng_core snd_page_alloc reiserfs sg sr_mod sd_mod cdrom pata_acpi crc_t10dif ata_generic ahci uhci_hcd ata_piix ehci_hcd libahci usbcore e1000e libata scsi_mod thermal nls_base [last unloaded: parport_pc]
    [ 4421.829469] Pid: 21822, comm: kworker/u:1 Tainted: G        W   2.6.37-0.slh.1-aptosid-686 #1
    [ 4421.829474] Call Trace:
    [ 4421.829484]  [<c013a938>] ? warn_slowpath_common+0x78/0xb0
    [ 4421.829492]  [<c022ae86>] ? sysfs_add_one+0x96/0xc0
    [ 4421.829499]  [<c022ae86>] ? sysfs_add_one+0x96/0xc0
    [ 4421.829505]  [<c013aa03>] ? warn_slowpath_fmt+0x33/0x40
    [ 4421.829512]  [<c022ae86>] ? sysfs_add_one+0x96/0xc0
    [ 4421.829520]  [<c022bd61>] ? sysfs_do_create_link+0xf1/0x1c0
    [ 4421.829527]  [<c022a705>] ? sysfs_add_file_mode+0x55/0x90
    [ 4421.829534]  [<c022be5f>] ? sysfs_create_link+0xf/0x20
    [ 4421.829544]  [<c0314de6>] ? device_add+0x326/0x570
    [ 4421.829553]  [<c01cfa49>] ? kmem_cache_alloc+0x79/0x90
    [ 4421.829561]  [<c0282b15>] ? kvasprintf+0x45/0x60
    [ 4421.829568]  [<c0314747>] ? device_private_init+0x37/0x50
    [ 4421.829589]  [<f8d5fcdd>] ? add_conn+0x4d/0xd0 [bluetooth]
    [ 4421.829599]  [<c014f233>] ? process_one_work+0x103/0x350
    [ 4421.829609]  [<f8d5fc90>] ? add_conn+0x0/0xd0 [bluetooth]
    [ 4421.829617]  [<c014f7d2>] ? worker_thread+0x122/0x3c0
    [ 4421.829624]  [<c014f6b0>] ? worker_thread+0x0/0x3c0
    [ 4421.829631]  [<c01529f4>] ? kthread+0x74/0x80
    [ 4421.829638]  [<c0152980>] ? kthread+0x0/0x80
    [ 4421.829645]  [<c0103df6>] ? kernel_thread_helper+0x6/0x10
    [ 4421.829651] ---[ end trace aa100ba423364fa5 ]---
    [ 4421.829691] add_conn: Failed to register connection device
    [ 4421.914415] BUG: unable to handle kernel NULL pointer dereference at 00000021
    [ 4421.914546] IP: [<c022b8d1>] sysfs_create_dir+0x21/0xb0
    [ 4421.914634] *pde = 00000000
    [ 4421.914687] Oops: 0000 [#1] PREEMPT SMP
    [ 4421.914775] last sysfs file: /sys/devices/system/cpu/cpu1/cache/index2/shared_cpu_map
    [ 4421.914880] Modules linked in: btrfs zlib_deflate crc32c libcrc32c qnx4 hfsplus hfs minix ntfs vfat msdos fat jfs xfs ext4 jbd2 ext3 jbd ext2 mbcache dm_mod hidp hid vboxnetadp vboxnetflt vboxdrv af_packet acpi_cpufreq mperf cpufreq_powersave cpufreq_stats cpufreq_performance cpufreq_ondemand cpufreq_conservative freq_table ppdev lp parport sco bnep rfcomm l2cap crc16 nfsd lockd nfs_acl auth_rpcgss binfmt_misc sunrpc exportfs microcode uinput fuse coretemp arc4 ecb iwl3945 snd_hda_codec_analog radeon iwlcore snd_hda_intel pcmcia btusb ttm bluetooth snd_hda_codec snd_hwdep joydev drm_kms_helper yenta_socket snd_pcm drm mac80211 tpm_tis rtc_cmos snd_seq tpm ac pcmcia_rsrc pcmcia_core rtc_core video cfg80211 i2c_algo_bit rtc_lib i2c_i801 thinkpad_acpi i2c_core battery serio_raw snd_timer output tpm_bios rfkill nvram psmouse snd_seq_device intel_agp evdev intel_gtt snd button processor soundcore rng_core snd_page_alloc reiserfs sg sr_mod sd_mod cdrom pata_acpi crc_t10dif ata_generic ahci uhci_hcd ata_piix ehci_hcd libahci usbcore e1000e libata scsi_mod thermal nls_base [last unloaded: parport_pc]
    [ 4421.915008]
    [ 4421.915008] Pid: 16419, comm: bluetoothd Tainted: G        W   2.6.37-0.slh.1-aptosid-686 #1 200763G/200763G
    [ 4421.915008] EIP: 0060:[<c022b8d1>] EFLAGS: 00010246 CPU: 0
    [ 4421.915008] EIP is at sysfs_create_dir+0x21/0xb0
    [ 4421.915008] EAX: f3eaaeb4 EBX: f0056c5c ECX: f0056c60 EDX: f3ec6414
    [ 4421.915008] ESI: 00000000 EDI: 00000000 EBP: f3eaaeb4 ESP: f2ed7cac
    [ 4421.915008]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
    [ 4421.915008] Process bluetoothd (pid: 16419, ti=f2ed6000 task=ef460c60 task.ti=f2ed6000)
    [ 4421.915008] Stack:
    [ 4421.915008]  00000286 000000d0 00000286 f5006d54 f0056c5c ffffffea f3eaaeac c0279728
    [ 4421.915008]  ed50a778 ed7d6bd0 f0056c5c f3eaaeb4 c027994e f0056c5c ffffffea f3eaaeac
    [ 4421.915008]  f0056c5c c02799ed f2ed7d14 ffffffea f3eaaeac f0056c54 c0314b48 f0056c5c
    [ 4421.915008] Call Trace:
    [ 4421.915008]  [<c0279728>] ? kobject_add_internal+0x88/0x1d0
    [ 4421.915008]  [<c027994e>] ? kobject_add_varg+0x1e/0x60
    [ 4421.915008]  [<c02799ed>] ? kobject_add+0x2d/0x60
    [ 4421.915008]  [<c0314b48>] ? device_add+0x88/0x570
    [ 4421.915008]  [<c0230826>] ? debugfs_create_file+0x146/0x220
    [ 4421.915008]  [<f828ee47>] ? hid_add_device+0x87/0x240 [hid]
    [ 4421.915008]  [<f82add89>] ? hidp_add_connection+0x389/0x580 [hidp]
    [ 4421.915008]  [<f82aeac9>] ? hidp_sock_ioctl+0x199/0x260 [hidp]
    [ 4421.915008]  [<c019cfc8>] ? find_get_page+0x58/0xa0
    [ 4421.915008]  [<c019e7a2>] ? filemap_fault+0x82/0x400
    [ 4421.915008]  [<c01d2b5b>] ? __dentry_open+0x1bb/0x280
    [ 4421.915008]  [<c012b065>] ? __kunmap_atomic+0x95/0xd0
    [ 4421.915008]  [<c012b071>] ? __kunmap_atomic+0xa1/0xd0
    [ 4421.915008]  [<c01b3a49>] ? __do_fault+0x399/0x4d0
    [ 4421.915008]  [<c01d02b9>] ? __kmalloc+0xc9/0x120
    [ 4421.915008]  [<c023f65d>] ? security_sk_alloc+0xd/0x10
    [ 4421.915008]  [<c0342063>] ? sock_update_classid+0x53/0x70
    [ 4421.915008]  [<c01cfa49>] ? kmem_cache_alloc+0x79/0x90
    [ 4421.915008]  [<c033e17f>] ? sock_ioctl+0x6f/0x260
    [ 4421.915008]  [<c033e110>] ? sock_ioctl+0x0/0x260
    [ 4421.915008]  [<c01e22cc>] ? do_vfs_ioctl+0x8c/0x5e0
    [ 4421.915008]  [<c033fc76>] ? sock_alloc_file+0xa6/0x120
    [ 4421.915008]  [<c01d261c>] ? fd_install+0x2c/0x60
    [ 4421.915008]  [<c033fd0b>] ? sock_map_fd+0x1b/0x30
    [ 4421.915008]  [<c0340a30>] ? sys_socket+0x60/0x80
    [ 4421.915008]  [<c0340ade>] ? sys_socketcall+0x8e/0x2c0
    [ 4421.915008]  [<c01e2896>] ? sys_ioctl+0x76/0x90
    [ 4421.915008]  [<c0103858>] ? sysenter_do_call+0x12/0x28
    [ 4421.915008]  [<c0410000>] ? ezx_pcap_probe+0x1c4/0x305
    [ 4421.915008] Code: 90 90 90 90 90 90 90 90 90 90 57 56 53 89 c3 83 ec 10 85 c0 0f 84 88 00 00 00 8b 40 0c be 40 0b 51 c0 85 c0 74 03 8b 70 18 31 ff <80> 7e 21 00 75 59 89 d8 e8 52 d8 04 00 85 c0 74 5e 8b 00 85 c0
    [ 4421.915008] EIP: [<c022b8d1>] sysfs_create_dir+0x21/0xb0 SS:ESP 0068:f2ed7cac
    [ 4421.915008] CR2: 0000000000000021
    [ 4421.933152] ---[ end trace aa100ba423364fa6 ]---

Looking at the dmesg error message I thought of the autosuspend feature for usb devices as the culprit and deactivated it completely. This solved the problem and my bluetooth devices work as they should again. But that's only a workaround as I don't want to forgo the suspend functionality.

Any idea where the problem could be?

My System:
- ThinkPad T60
- Broadcom Bluetooth Card BCM2045B
- Debian unstable (aptosid) with kernel 2.6.37 32-bit
 If you need further information, please ask.

Regards
denk
Comment 1 denk 2011-01-10 12:40:45 UTC
I found another problem/regression with suspend/resume. Whereas the 
suspend seems to work as it should the resume of my Thinkpad leads to 
an unusable bt device. The only working solution is to reboot. I hope 
the maintainers of btusb or someone else can investigate that further!

Regards
denk
Comment 2 denk 2011-01-20 21:32:32 UTC
I found another problem regarding btusb: If I connect my USB HP LaserJet 1018, I get the following dmesg output:

[  142.256064] usb 5-1: reset full speed USB device using uhci_hcd and address 2
[  142.390577] btusb 5-1:1.0: no reset_resume for driver btusb?
[  142.390585] btusb 5-1:1.1: no reset_resume for driver btusb?

This also happens if I run XSane. During XSane is searching for devices I get the same dmesg output.

If anyone who can look into this, needs more information, please ask!

As this is really annoying and renders my bluetooth card and bluetooth input devices nearly unusable I hope somebody can solve this!

Regards
denk
Comment 3 denk 2011-01-30 07:30:48 UTC
Still no answer on this! Can somebody at least tell me the maintainer 
(mail adress) of btusb?

I found out that autosuspend for btusb has been enabled by default 
recently: 
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=556ea928f78a390fe16ae584e6433dff304d3014 
Seems to be, that my adapter doesn't work with this enabled.

Regards
denk
Comment 4 denk 2011-02-04 10:04:58 UTC
I did another round of investigation and blacklisted the module 'btusb'. Then everything works as it should: I can use my USB printer, HPLIP oder XSane can search for devices etc. (as for sure my bluetooth devices don't work...)
Is 'btusb' loaded the USB printer doesn't work and HPLIP or XSane scanning for devices lead to the above mentioned dmesg output.

I would like to help with investigating the error but I don't know where to begin! I need someone who can look into this and point me into the right direction where to look for the cause for this.

Regards
denk
Comment 5 Andrew Meakovski 2011-02-09 18:48:33 UTC
Confirming same bug on kernel 2.6.37-ARCH (Arch Linux), it appeared after update to 2.6.37.
I'm using mobile phone as a modem via bluetooth, and BT connection gets lost after random time. It's unable to reconnect. Rfcomm says 'no route to host', different manipulations with hcitool and kernel modules at runtime give no results.
After rebooting the system everything works for some time until next lockup.

Using Dell Inspiron 1525 laptop and Nokia 3720 phone.

Bluetooth device:
Bus 007 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
Bus 007 Device 003: ID 413c:8126 Dell Computer Corp. Wireless 355 Bluetooth
Comment 6 Jim Faulkner 2011-02-20 23:17:23 UTC
I'm seeing the same bug when using my bluetooth remote control.  The problem appeared in 2.6.37, I had no problems before that version.  2.6.37.1 is affected as well.  Here's my device:

Bus 008 Device 002: ID 0a5c:2101 Broadcom Corp. A-Link BlueUsbA2 Bluetooth

and here's the errors I see when it stops working:

[ 4533.361959] btusb 8-1:1.0: no reset_resume for driver btusb?
[ 4533.361964] btusb 8-1:1.1: no reset_resume for driver btusb?
Comment 7 Alan Stern 2011-02-23 16:04:19 UTC
Matthew, it looks like your 556ea928f78a390fe16ae584e6433dff304d3014 commit (Bluetooth: Enable USB autosuspend by default on btusb) needs to be reverted, at least until somebody adds reset-resume support to the btusb driver.

Florian or Rafael, can one of you let the Bluetooth maintainers know about this bug?  There has been at least one other bug report for this same problem on LKML:

   http://marc.info/?l=linux-kernel&m=129845423017429&w=2
Comment 8 Gustavo Padovan 2011-02-23 20:09:29 UTC
Does it still happen with 2.6.38-rc6? I pushed a fix from Oliver Neukum in the btusb driver. I'm really not sure if it fix this, but it worth a try.

commit 8efdd0cdc54f3bb5db464b3baf88f7441f54da47
Author: Oliver Neukum <oneukum@suse.de>
Date:   Fri Feb 11 13:00:06 2011 +0100

    Bluetooth: fix crash with quirky dongles doing sound
    
    Quirky dongles sometimes do not use the iso interface which
    causes a crash with runtime PM
    
    Signed-off-by: Oliver Neukum <oneukum@suse.de>
    Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>

btw, my Bluetooth input devices are working fine with a kernel from linux-next from Monday.
Comment 9 Alan Stern 2011-02-23 20:18:55 UTC
I don't think that patch will affect this problem.  Apparently some Bluetooth devices require a reset when they are resumed, and btusb doesn't currently support this.

It might help to know _why_ the device requires a reset.  A usbmon trace showing a suspend-resume cycle would be good.  Instructions are in the kernel source file Documentation/usb/usbmon.txt.  Can somebody attach a trace to this bug report?
Comment 11 denk 2011-02-25 10:07:57 UTC
Thanks for fixing this! I can use my BT input devices again and they work as they did before.

Regards
denk