Usb loopback through device fails with timeout

Enable options in kernel menuconfig

Device Drivers->USB support->USB Gadget support->USB Gadget Drivers (USB functions configurable through configfs)

enable all options below that (Function filesystem (FunctionFS) , Loopback and sourcesink function (for testing)) etc

build and flash the kernel

do following as root on device

mount -t configfs none /config
mkdir /config/usb_gadget/g1
echo 0x00aa> /config/usb_gadget/g1/idVendor
echo 0x00bb > /config/usb_gadget/g1/idProduct
echo 0x0200 > /config/usb_gadget/g1/bcdUSB
mkdir /config/usb_gadget/g1/strings/0x409
echo NVIDIAA > /config/usb_gadget/g1/strings/0x409/manufacturer
echo “Loopback” > /config/usb_gadget/g1/strings/0x409/product
echo 012345678ABCDEF > /config/usb_gadget/g1/strings/0x409/serialnumber
mkdir /config/usb_gadget/g1/configs/b.1
mkdir /config/usb_gadget/g1/functions/Loopback.name
cat /config/usb_gadget/g1/functions/Loopback.name/qlen

echo 1382400 > /config/usb_gadget/g1/functions/Loopback.name/bulk_buflen

ln -s /config/usb_gadget/g1/functions/Loopback.name /config/usb_gadget/g1/configs/b.1/f1
echo 3550000.xudc > /config/usb_gadget/g1/UDC

connect otg cable to host

build the following test app and run from host. App would stuck after 60 frames and the above dmesg logs would be obtained. One more observation is, when i increased XUDC_TRANSFER_RING_SIZE in tegra_xudc.c to 128 app while loop pause at 120 instead of 60. Is it like ring buffer not getting cleared. How to do that properly

g++ libusbbulk_gfs.cpp -o libusbbulk_gfs -lusb-1.0