diff --git a/fastboot/usb_linux.cpp b/fastboot/usb_linux.cpp index 9078c8f2d..7b879073d 100644 --- a/fastboot/usb_linux.cpp +++ b/fastboot/usb_linux.cpp @@ -26,29 +26,22 @@ * SUCH DAMAGE. */ +#include +#include +#include +#include +#include #include #include -#include #include - #include #include #include -#include -#include -#include -#include -#include +#include -#include #include #include -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20) #include -#else -#include -#endif -#include #include "fastboot.h" #include "usb.h" @@ -69,9 +62,19 @@ #define DBG1(x...) #endif -/* The max bulk size for linux is 16384 which is defined - * in drivers/usb/core/devio.c. - */ +// Kernels before 3.3 have a 16KiB transfer limit. That limit was replaced +// with a 16MiB global limit in 3.3, but each URB submitted required a +// contiguous kernel allocation, so you would get ENOMEM if you tried to +// send something larger than the biggest available contiguous kernel +// memory region. 256KiB contiguous allocations are generally not reliable +// on a device kernel that has been running for a while fragmenting its +// memory, but that shouldn't be a problem for fastboot on the host. +// In 3.6, the contiguous buffer limit was removed by allocating multiple +// 16KiB chunks and having the USB driver stitch them back together while +// transmitting using a scatter-gather list, so 256KiB bulk transfers should +// be reliable. +// 256KiB seems to work, but 1MiB bulk transfers lock up my z620 with a 3.13 +// kernel. #define MAX_USBFS_BULK_SIZE (16 * 1024) struct usb_handle