This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Kernel panic running FunctionFS on Beaglebone Black

I am trying to run the ffs-test.c program found in the Linux source tree to work with the USB Gadget framework on the Beaglebone Black.  I am getting a kernel panic that has me confused as this program works on other ARM Linux hardware.  I am running the 4.1 kernel. Here is the panic:

[  207.626307] BUG: spinlock bad magic on CPU#0, ffs-test/1379
[  207.632185]  lock: 0xde0273c0, .magic: de0273c0, .owner: <none>/-1, .owner_cpu: -675651324
[  207.640857] CPU: 0 PID: 1379 Comm: ffs-test Not tainted 4.1.0-rc7-bone70 #5
[  207.648155] Hardware name: Generic AM33XX (Flattened Device Tree)
[  207.654570] [<c0012941>] (unwind_backtrace) from [<c00100f3>] (show_stack+0xb/0xc)
[  207.662518] [<c00100f3>] (show_stack) from [<c0540183>] (dump_stack+0x53/0x68)
[  207.670105] [<c0540183>] (dump_stack) from [<c0059bb1>] (do_raw_spin_lock+0x101/0x138)
[  207.678421] [<c0059bb1>] (do_raw_spin_lock) from [<c054424d>] (_raw_spin_lock_irqsave+0xd/0x10)
[  207.687555] [<c054424d>] (_raw_spin_lock_irqsave) from [<c00feac7>] (kiocb_set_cancel_fn+0x13/0x3c)
[  207.697067] [<c00feac7>] (kiocb_set_cancel_fn) from [<bf82312f>] (ffs_epfile_read_iter+0x56/0xd4 [usb_f_fs])
[  207.707391] [<bf82312f>] (ffs_epfile_read_iter [usb_f_fs]) from [<c00d28c1>] (__vfs_read+0x69/0x84)
[  207.716883] [<c00d28c1>] (__vfs_read) from [<c00d3315>] (vfs_read+0x4d/0xec)
[  207.724277] [<c00d3315>] (vfs_read) from [<c00d33e1>] (SyS_read+0x2d/0x64)
[  207.731497] [<c00d33e1>] (SyS_read) from [<c000dbc1>] (ret_fast_syscall+0x1/0x4c)
[  220.689258] BUG: spinlock lockup suspected on CPU#0, ffs-test/1379
[  220.695740]  lock: 0xde0273c0, .magic: de0273c0, .owner: <none>/-1, .owner_cpu: -675651324
[  220.704408] CPU: 0 PID: 1379 Comm: ffs-test Not tainted 4.1.0-rc7-bone70 #5
[  220.711706] Hardware name: Generic AM33XX (Flattened Device Tree)
[  220.718100] [<c0012941>] (unwind_backtrace) from [<c00100f3>] (show_stack+0xb/0xc)
[  220.726042] [<c00100f3>] (show_stack) from [<c0540183>] (dump_stack+0x53/0x68)
[  220.733620] [<c0540183>] (dump_stack) from [<c0059b7f>] (do_raw_spin_lock+0xcf/0x138)
[  220.741837] [<c0059b7f>] (do_raw_spin_lock) from [<c054424d>] (_raw_spin_lock_irqsave+0xd/0x10)
[  220.750964] [<c054424d>] (_raw_spin_lock_irqsave) from [<c00feac7>] (kiocb_set_cancel_fn+0x13/0x3c)
[  220.760461] [<c00feac7>] (kiocb_set_cancel_fn) from [<bf82312f>] (ffs_epfile_read_iter+0x56/0xd4 [usb_f_fs])
[  220.770777] [<bf82312f>] (ffs_epfile_read_iter [usb_f_fs]) from [<c00d28c1>] (__vfs_read+0x69/0x84)
[  220.780267] [<c00d28c1>] (__vfs_read) from [<c00d3315>] (vfs_read+0x4d/0xec)
[  220.787661] [<c00d3315>] (vfs_read) from [<c00d33e1>] (SyS_read+0x2d/0x64)
[  220.794874] [<c00d33e1>] (SyS_read) from [<c000dbc1>] (ret_fast_syscall+0x1/0x4c)

Here is the startup script:

modprobe libcomposite
modprobe usb_f_fs

mkdir /dev/cfg
mount -t configfs configfs /dev/cfg
mkdir /dev/cfg/usb_gadget/g1
echo "0x2341" > /dev/cfg/usb_gadget/g1/idVendor
echo "0x01AA" > /dev/cfg/usb_gadget/g1/idProduct
mkdir /dev/cfg/usb_gadget/g1/functions/ffs.auto
mkdir /dev/cfg/usb_gadget/g1/configs/c.1
ln -s /dev/cfg/usb_gadget/g1/functions/ffs.auto /dev/cfg/usb_gadget/g1/configs/c.1

echo 0xcd > /dev/cfg/usb_gadget/g1/os_desc/b_vendor_code
echo MSFT100 > /dev/cfg/usb_gadget/g1/os_desc/qw_sign
echo 0 > /dev/cfg/usb_gadget/g1/os_desc/use

echo 0x200 > /dev/cfg/usb_gadget/g1/bcdUSB

mkdir  /dev/cfg/usb_gadget/g1/strings/0x409
echo "serialnumber" > /dev/cfg/usb_gadget/g1/strings/0x409/serialnumber
echo "manufacturer" > /dev/cfg/usb_gadget/g1/strings/0x409/manufacturer
echo "Test Device" > /dev/cfg/usb_gadget/g1/strings/0x409/product

mkdir /dev/ffs
mount -t functionfs auto /dev/ffs

And the test program can be found here:

https://github.com/torvalds/linux/blob/master/tools/usb/ffs-test.c