Reputation: 41
Recently I was developing a custom USB receiver program running on Linux. I chose to use libusb to develop it. Due to the larger bandwidth, I needed a larger total transfer size. At that time, when I submitted more than 15MB (each bulk transfer is 1MB, the 16th submit failed) an error will occur:
[INFO] submit transfer [0]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [1]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [2]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [3]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [4]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [5]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [6]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [7]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [8]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [9]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [10]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [11]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [12]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [13]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
[INFO] submit transfer [14]: [0] LIBUSB_SUCCESS / LIBUSB_TRANSFER_COMPLETED
libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=12
[INFO] submit transfer [15]: [-1] LIBUSB_ERROR_IO
libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=12
This is the test result on ubuntu18.04,
Related system information:
Linux xxx 5.4.0-77-generic #86~18.04.1-Ubuntu SMP Fri Jun 18 01:23:22 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
System RAM: 20GB
I also encountered the same problem when I tested it on Raspberry Pi 4B. I did not find the answer to the related problem through Google (maybe the wrong keyword was used?)
There is a very similar problem here, but he said that the maximum limit is the maximum value that an int can represent, but it does not seem to be the case.
Any suggestions or hints will help me a lot!
Upvotes: 2
Views: 1122
Reputation: 41
It turns out that I use google badly and open source is really great!!
I dug into the code and found the memory limit in the kernel source code: https://github.com/torvalds/linux/blob/3d5895cd351757f69c9a66fb5fc8cf19f454d773/drivers/usb/core/devio.c#L133
Now I can set the memory limit via /sys/module/usbcore/parameters/usbfs_memory_mb
Upvotes: 2