diff options
author | Elliott Hughes <enh@google.com> | 2015-07-24 14:09:44 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-07-28 14:18:50 -0700 |
commit | 93f65faee85facd14fa58993bbcb98c357217fcb (patch) | |
tree | e2e7307d03e5ee2d60decb354cbdc3536e62e2d0 | |
parent | 9dad4ec4408bf412c265ac9bb27c84bb5098e67c (diff) | |
download | core-93f65faee85facd14fa58993bbcb98c357217fcb.tar.gz core-93f65faee85facd14fa58993bbcb98c357217fcb.tar.bz2 core-93f65faee85facd14fa58993bbcb98c357217fcb.zip |
Document the current MAX_USBFS_BULK_SIZE situation.
Bug: http://b/22688598
Change-Id: I8e5b92996d635f6b939f3add4dda0b9023629a8b
-rw-r--r-- | fastboot/usb_linux.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
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 <ctype.h> +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <pthread.h> #include <stdio.h> #include <stdlib.h> -#include <unistd.h> #include <string.h> - #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/types.h> -#include <dirent.h> -#include <fcntl.h> -#include <errno.h> -#include <pthread.h> -#include <ctype.h> +#include <unistd.h> #include <linux/usbdevice_fs.h> -#include <linux/usbdevice_fs.h> #include <linux/version.h> -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20) #include <linux/usb/ch9.h> -#else -#include <linux/usb_ch9.h> -#endif -#include <asm/byteorder.h> #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 |