Commit eae30b2a authored by Siarhei Siamashka's avatar Siarhei Siamashka
Browse files

fel: Fix USB timeout on large transfers



Trying to use oversized initrd files (20 MB or more) can fail
with the "libusb usb_bulk_send error -1" error message.

To address this problem, we can split the transfer into smaller
chunks and the problem disappears. Effectively, this is a revert
of the older "fel: Increase timeout to 60 seconds instead of
splitting bulk transfers" commmit.
Signed-off-by: default avatarSiarhei Siamashka <siarhei.siamashka@gmail.com>
Acked-by: default avatarHans de Goede <hdegoede@redhat.com>
parent e4b3da2b
...@@ -73,11 +73,14 @@ static void pr_info(const char *fmt, ...) ...@@ -73,11 +73,14 @@ static void pr_info(const char *fmt, ...)
} }
} }
static const int AW_USB_MAX_BULK_SEND = 4 * 1024 * 1024; // 4 MiB per bulk request
void usb_bulk_send(libusb_device_handle *usb, int ep, const void *data, int length) void usb_bulk_send(libusb_device_handle *usb, int ep, const void *data, int length)
{ {
int rc, sent; int rc, sent;
while (length > 0) { while (length > 0) {
rc = libusb_bulk_transfer(usb, ep, (void *)data, length, &sent, timeout); int len = length < AW_USB_MAX_BULK_SEND ? length : AW_USB_MAX_BULK_SEND;
rc = libusb_bulk_transfer(usb, ep, (void *)data, len, &sent, timeout);
if (rc != 0) { if (rc != 0) {
fprintf(stderr, "libusb usb_bulk_send error %d\n", rc); fprintf(stderr, "libusb usb_bulk_send error %d\n", rc);
exit(2); exit(2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment