After hotplug ging USB mass storage device system hang.

Hello,
I am using a Beaglebone black board wuth ubuntu 12.04 (3.8.13-kernel). My board is working very good with eMMC as well as with with SD card. Problem is when I hotplug a USB mass storage device(pendrive) whole system getting hang. Then if I powered off and again powered ON with pendrive then its working properly and pendrive is also detecting. Problem is only during hotplug.
Also I tried to debug through the serial debug port but I am newbie so I didn’t get the issue. Serial debug port output is as follows.

ubuntu-armhf login: tilcdc 4830e000.fb: timeout waiting for framedone
usb 1-1.4: new high-speed USB device number 5 using musb-hdrc
usb 1-1.4: New USB device found, idVendor=0781, idProduct=5567
usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.4: Product: Firebird USB Flash Drive
usb 1-1.4: Manufacturer: SanDisk
usb 1-1.4: SerialNumber: 4C532000060711111374
scsi0 : usb-storage 1-1.4:1.0
scsi 0:0:0:0: Direct-Access SanDisk Cruzer Blade 1.26 PQ: 0 ANSI: 5
sd 0:0:0:0: [sda] 7821312 512-byte logical blocks: (4.00 GB/3.72 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn’t support DPO or FUA
BUG: spinlock bad magic on CPU#0, kworker/u:2/62
lock: 0xdf4cfee8, .magic: 00000000, .owner: /-1, .owner_cpu: 0
[] (unwind_backtrace+0x0/0xe0) from [] (do_raw_spin_lock+0x20/0x164)
[] (do_raw_spin_lock+0x20/0x164) from [] (get_device_parent+0x84/0x18c)
[] (get_device_parent+0x84/0x18c) from [] (device_add+0xcc/0x580)
[] (device_add+0xcc/0x580) from [] (add_disk+0x1a8/0x40c)
[] (add_disk+0x1a8/0x40c) from [] (sd_probe_async+0xec/0x1a8)
[] (sd_probe_async+0xec/0x1a8) from [] (async_run_entry_fn+0xe8/0x204)
[] (async_run_entry_fn+0xe8/0x204) from [] (process_one_work+0x240/0x3fc)
[] (process_one_work+0x240/0x3fc) from [] (worker_thread+0x258/0x370)
[] (worker_thread+0x258/0x370) from [] (kthread+0xa0/0xb0)
[] (kthread+0xa0/0xb0) from [] (ret_from_fork+0x14/0x3c)
Unable to handle kernel NULL pointer dereference at virtual address 00000008
pgd = c0004000
[00000008] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
Modules linked in: binfmt_misc unix
CPU: 0 Tainted: G W (3.8.13-bone26 #272)
PC is at get_device_parent+0x94/0x18c
LR is at spin_bug+0x10/0x28
pc : [] lr : [] psr: 00000013
sp : df3d3df8 ip : c000d918 fp : c08122dc
r10: ddca98c8 r9 : c07d2408 r8 : df3d40b0
r7 : df51080c r6 : ddca98d0 r5 : df510868 r4 : df510868
r3 : df4cfee0 r2 : 00000000 r1 : 00000000 r0 : fffffffc
Flags: nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: 10c5387d Table: 9f5f4019 DAC: 00000015
Process kworker/u:2 (pid: 62, stack limit = 0xdf3d2240)
Stack: (0xdf3d3df8 to 0xdf3d4000)
3de0: ddc526c0 df510868
3e00: 00000000 df510870 df51080c c02c1904 df510870 00000000 00000000 c02358ac
3e20: ddca98c8 df510800 dd8e0e40 df510800 dd8e0e40 df510868 df51080c df3d40b0
3e40: c07d2408 ddb04600 c08122dc c0226358 c0225360 df510800 df000000 00800000
3e60: 00000000 00000004 c0c76e80 df4e1c00 df510800 df4e1c00 df510800 ddca9800
3e80: 00000000 ddb04608 ddb04600 c02efaf8 df4e1c00 c02efa0c 00000002 df39dbc0
3ea0: ddb04608 c0812200 df03f800 c005f87c c07d0da8 c07d0da8 c0812200 df3a9600
3ec0: c0812318 00000001 df39dbc0 ddb04608 c0812200 df03f800 c0812318 00000000
3ee0: 00000000 c0054b70 df061e8c 00000001 00000000 00000003 00000001 df39dbc0
3f00: c0812318 df3d2000 c07ec6b8 c0812200 c0812318 df39dbd4 00000089 c005514c
3f20: df39dbc0 df3d3f54 df3d3f38 df061e74 00000000 df39dbc0 c0054ef4 00000000
3f40: 00000000 00000000 00000000 c0058d70 942dff37 00000000 f93fdf65 df39dbc0
3f60: 00000000 00000000 dead4ead ffffffff ffffffff df3d3f74 df3d3f74 00000000
3f80: 00000000 dead4ead ffffffff ffffffff df3d3f90 df3d3f90 df3d3fac df061e74
3fa0: c0058cd0 00000000 00000000 c000d918 00000000 00000000 00000000 00000000
3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 90fc7cef 3cd6dee1
[] (get_device_parent+0x94/0x18c) from [] (device_add+0xcc/0x580)
[] (device_add+0xcc/0x580) from [] (add_disk+0x1a8/0x40c)
[] (add_disk+0x1a8/0x40c) from [] (sd_probe_async+0xec/0x1a8)
[] (sd_probe_async+0xec/0x1a8) from [] (async_run_entry_fn+0xe8/0x204)
[] (async_run_entry_fn+0xe8/0x204) from [] (process_one_work+0x240/0x3fc)
[] (process_one_work+0x240/0x3fc) from [] (worker_thread+0x258/0x370)
[] (worker_thread+0x258/0x370) from [] (kthread+0xa0/0xb0)
[] (kthread+0xa0/0xb0) from [] (ret_from_fork+0x14/0x3c)
Code: e5953198 e593303c e5b300e0 ea000006 (e590200c)
—[ end trace 6528e0e98df06b3f ]—
Unable to handle kernel paging request at virtual address ffffffe0
pgd = c0004000
[ffffffe0] *pgd=9fefe821, *pte=00000000, *ppte=00000000
Internal error: Oops: 17 [#2] SMP ARM
Modules linked in: binfmt_misc unix
CPU: 0 Tainted: G D W (3.8.13-bone26 #272)
PC is at kthread_data+0x4/0xc
LR is at wq_worker_sleeping+0xc/0x9c
pc : [] lr : [] psr: 00000093
sp : df3d3b20 ip : 00000000 fp : df3d3bcc
r10: df1777a4 r9 : 00000000 r8 : df177820
r7 : c077ae80 r6 : 00000000 r5 : c0c76e80 r4 : df177580
r3 : 00000000 r2 : 00000007 r1 : 00000000 r0 : df177580
Flags: nzcv IRQs off FIQs on Mode SVC_32 ISA ARM Segment user
Control: 10c5387d Table: 9f754019 DAC: 00000015
Process kworker/u:2 (pid: 62, stack limit = 0xdf3d2240)
Stack: (0xdf3d3b20 to 0xdf3d4000)
3b20: df177580 c0c76e80 df3d2000 c0484ab4 00000000 c07ceb44 c07ceb30 00000004
3b40: df3d3b7c 60000093 df3b9fc4 c029f8f8 c0040508 c077ae80 00000000 0e230e22
3b60: df049cc0 60000093 c077e100 047e047d 800000c2 60000093 00000000 df049cc0
3b80: df3b9fc4 00050004 df177580 00000000 00000000 60000013 df3b48bc 00020001
3ba0: 00000000 60000013 df3b48bc df177580 00000001 df3d39ac 00000000 00000001
3bc0: df177578 df1777a4 df1777a4 c0040508 c05e69f3 df1777ec 000e000e df3d3bd8
3be0: 8df06b3f 0000000b df3d3c52 c02c1288 00000000 00000001 c05e69fb 00000000
3c00: c05e69f3 c0011dfc df3d2240 0000000b c02c1288 00000000 00000008 60000113
3c20: 65fe6f02 33353935 20383931 33393565 63333033 62356520 65303033 61652030
3c40: 30303030 28203630 30393565 63303032 c0002029 c047fdd4 c0625dbc 00000008
3c60: 00000005 00000000 df3d3db0 00000000 00000028 00000005 c08122dc c047f60c
3c80: df177580 c0487964 df009310 df3d2000 00000000 00000053 00000000 00000000
3ca0: 00000053 c07ef1f4 00000000 c00429e0 00000053 c000e7c0 00000043 fa200000
3cc0: df3d3ce0 c0008760 c003d084 c003d0a0 60000013 ffffffff df3d3d14 c04861c0
3ce0: c07b6d14 60000013 c07b6d0c 00000005 c0788f84 00000008 df3d3db0 df3d40b0
3d00: c07d2408 ddca98c8 c08122dc c0008530 000008d0 df3d3d28 c003d084 c003d0a0
3d20: 60000013 ffffffff 00000000 00000000 c06a6f78 c000d918 df3d3db8 c00142b0
3d40: 60000013 df39dbc0 60000013 00000000 ddc526c0 c0058d70 df3d3fac ddca98d0
3d60: df51080c df4cfee8 c07d2408 ddca98c8 00000000 c047fdd4 df3d3fb0 c000d918
3d80: 00000000 df3d3d94 c0058d70 c0011a3c c05e69b2 c000d918 df510868 c02c1288
3da0: 00000013 ffffffff df3d3de4 c0486158 fffffffc 00000000 00000000 df4cfee0
3dc0: df510868 df510868 ddca98d0 df51080c df3d40b0 c07d2408 ddca98c8 c08122dc
3de0: c000d918 df3d3df8 c04821a8 c02c1288 00000013 ffffffff ddc526c0 df510868
3e00: 00000000 df510870 df51080c c02c1904 df510870 00000000 00000000 c02358ac
3e20: ddca98c8 df510800 dd8e0e40 df510800 dd8e0e40 df510868 df51080c df3d40b0
3e40: c07d2408 ddb04600 c08122dc c0226358 c0225360 df510800 df000000 00800000
3e60: 00000000 00000004 c0c76e80 df4e1c00 df510800 df4e1c00 df510800 ddca9800
3e80: 00000000 ddb04608 ddb04600 c02efaf8 df4e1c00 c02efa0c 00000002 df39dbc0
3ea0: ddb04608 c0812200 df03f800 c005f87c c07d0da8 c07d0da8 c0812200 df3a9600
3ec0: c0812318 00000001 df39dbc0 ddb04608 c0812200 df03f800 c0812318 00000000
3ee0: 00000000 c0054b70 df061e8c 00000001 00000000 00000003 00000001 df39dbc0
3f00: c0812318 df3d2000 c07ec6b8 c0812200 c0812318 df39dbd4 00000089 c005514c
3f20: df39dbc0 df3d3f54 df3d3f38 df061e74 00000000 df39dbc0 c0054ef4 00000000
3f40: 00000000 00000000 00000000 c0058d70 942dff37 00000000 f93fdf65 df39dbc0
3f60: 00000000 00000000 dead4ead ffffffff ffffffff df3d3f74 df3d3f74 00000001
3f80: 00010001 dead4ead ffffffff ffffffff df3d3f90 df3d3f90 df3d3fac df061e74
3fa0: c0058cd0 00000000 00000000 c000d918 00000000 00000000 00000000 00000000
3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 90fc7cef 3cd6dee1
[] (kthread_data+0x4/0xc) from [] (wq_worker_sleeping+0xc/0x9c)
[] (wq_worker_sleeping+0xc/0x9c) from [] (__schedule+0x104/0x6fc)
[] (__schedule+0x104/0x6fc) from [] (do_exit+0x820/0x874)
[] (do_exit+0x820/0x874) from [] (die+0x35c/0x3d4)
[] (die+0x35c/0x3d4) from [] (__do_kernel_fault.part.8+0x54/0x74)
[] (__do_kernel_fault.part.8+0x54/0x74) from [] (do_page_fault+0x34c/0x39c)
[] (do_page_fault+0x34c/0x39c) from [] (do_DataAbort+0x34/0x98)
[] (do_DataAbort+0x34/0x98) from [] (__dabt_svc+0x38/0x60)
Exception stack(0xdf3d3db0 to 0xdf3d3df8)
3da0: fffffffc 00000000 00000000 df4cfee0
3dc0: df510868 df510868 ddca98d0 df51080c df3d40b0 c07d2408 ddca98c8 c08122dc
3de0: c000d918 df3d3df8 c04821a8 c02c1288 00000013 ffffffff
[] (__dabt_svc+0x38/0x60) from [] (get_device_parent+0x94/0x18c)
[] (get_device_parent+0x94/0x18c) from [] (device_add+0xcc/0x580)
[] (device_add+0xcc/0x580) from [] (add_disk+0x1a8/0x40c)
[] (add_disk+0x1a8/0x40c) from [] (sd_probe_async+0xec/0x1a8)
[] (sd_probe_async+0xec/0x1a8) from [] (async_run_entry_fn+0xe8/0x204)
[] (async_run_entry_fn+0xe8/0x204) from [] (process_one_work+0x240/0x3fc)
[] (process_one_work+0x240/0x3fc) from [] (worker_thread+0x258/0x370)
[] (worker_thread+0x258/0x370) from [] (kthread+0xa0/0xb0)
[] (kthread+0xa0/0xb0) from [] (ret_from_fork+0x14/0x3c)
Code: e5130028 e7e00150 e12fff1e e5903274 (e5130020)
—[ end trace 6528e0e98df06b40 ]—
Fixing recursive fault but reboot is needed!
BUG: spinlock lockup suspected on CPU#0, kworker/u:2/62
lock: 0xc0c76e80, .magic: dead4ead, .owner: kworker/u:2/62, .owner_cpu: 0
[] (unwind_backtrace+0x0/0xe0) from [] (do_raw_spin_lock+0xb4/0x164)
[] (do_raw_spin_lock+0xb4/0x164) from [] (__schedule+0xac/0x6fc)
[] (__schedule+0xac/0x6fc) from [] (do_exit+0xec/0x874)
[] (do_exit+0xec/0x874) from [] (die+0x35c/0x3d4)
[] (die+0x35c/0x3d4) from [] (__do_kernel_fault.part.8+0x54/0x74)
[] (__do_kernel_fault.part.8+0x54/0x74) from [] (do_page_fault+0x34c/0x39c)
[] (do_page_fault+0x34c/0x39c) from [] (do_DataAbort+0x34/0x98)
[] (do_DataAbort+0x34/0x98) from [] (__dabt_svc+0x38/0x60)
Exception stack(0xdf3d3ad8 to 0xdf3d3b20)
3ac0: df177580 00000000
3ae0: 00000007 00000000 df177580 c0c76e80 00000000 c077ae80 df177820 00000000
3b00: df1777a4 df3d3bcc 00000000 df3d3b20 c00552ec c005918c 00000093 ffffffff
[] (__dabt_svc+0x38/0x60) from [] (kthread_data+0x4/0xc)
[] (kthread_data+0x4/0xc) from [] (wq_worker_sleeping+0xc/0x9c)
[] (wq_worker_sleeping+0xc/0x9c) from [] (__schedule+0x104/0x6fc)
[] (__schedule+0x104/0x6fc) from [] (do_exit+0x820/0x874)
[] (do_exit+0x820/0x874) from [] (die+0x35c/0x3d4)
[] (die+0x35c/0x3d4) from [] (__do_kernel_fault.part.8+0x54/0x74)
[] (__do_kernel_fault.part.8+0x54/0x74) from [] (do_page_fault+0x34c/0x39c)
[] (do_page_fault+0x34c/0x39c) from [] (do_DataAbort+0x34/0x98)
[] (do_DataAbort+0x34/0x98) from [] (__dabt_svc+0x38/0x60)
Exception stack(0xdf3d3db0 to 0xdf3d3df8)
3da0: fffffffc 00000000 00000000 df4cfee0
3dc0: df510868 df510868 ddca98d0 df51080c df3d40b0 c07d2408 ddca98c8 c08122dc
3de0: c000d918 df3d3df8 c04821a8 c02c1288 00000013 ffffffff
[] (__dabt_svc+0x38/0x60) from [] (get_device_parent+0x94/0x18c)
[] (get_device_parent+0x94/0x18c) from [] (device_add+0xcc/0x580)
[] (device_add+0xcc/0x580) from [] (add_disk+0x1a8/0x40c)
[] (add_disk+0x1a8/0x40c) from [] (sd_probe_async+0xec/0x1a8)
[] (sd_probe_async+0xec/0x1a8) from [] (async_run_entry_fn+0xe8/0x204)
[] (async_run_entry_fn+0xe8/0x204) from [] (process_one_work+0x240/0x3fc)
[] (process_one_work+0x240/0x3fc) from [] (worker_thread+0x258/0x370)
[] (worker_thread+0x258/0x370) from [] (kthread+0xa0/0xb0)
[] (kthread+0xa0/0xb0) from [] (ret_from_fork+0x14/0x3c)

Please help to solve this problem.
Thanking you.

Regards,
Kishor

You could file a bug report with ubuntu folks; it looks like something isn’t right in the kernel code.
Can you try it with Debian Linux installed instead of Ubuntu?

Tis is a known issue with the 3.8.x kernel. You could have found information on the groups here simply by searching.

You have two options.

  1. use 3.8.x and do not hotplug any USB device.

  2. Move to a newer kernel such as 3.12.x

Hello,
Thank you for reply guys. I found the problem. It was silly mistake from me in kernel code. Same function called twice with different name in same code thats why this bug generated. Sorry for wasting your time. Thank you for responding to my question.

Regards,
Kishor.