diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-05-21 14:08:41 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-05-21 14:08:41 -0700 |
commit | f6e83f7eb8cab99b416c5be299f70adc4722a8bf (patch) | |
tree | 8b31ea2f976807324caea3b9cf91c0cf7a9dc5b7 /fastboot | |
parent | 0bc248f9830901a047161fb9cedc9c6213cf70e0 (diff) | |
parent | dc5942840e1d1501a7ac4d633e8c5311e90c903b (diff) | |
download | system_core-f6e83f7eb8cab99b416c5be299f70adc4722a8bf.zip system_core-f6e83f7eb8cab99b416c5be299f70adc4722a8bf.tar.gz system_core-f6e83f7eb8cab99b416c5be299f70adc4722a8bf.tar.bz2 |
am dc594284: Merge "Fix kernel panics in fastboot on OS X." into kraken
Diffstat (limited to 'fastboot')
-rw-r--r-- | fastboot/usb_osx.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/fastboot/usb_osx.c b/fastboot/usb_osx.c index 0b0512d..9488687 100644 --- a/fastboot/usb_osx.c +++ b/fastboot/usb_osx.c @@ -64,7 +64,7 @@ struct usb_handle /** Try out all the interfaces and see if there's a match. Returns 0 on * success, -1 on failure. */ -static int try_interfaces(IOUSBDeviceInterface **dev, usb_handle *handle) { +static int try_interfaces(IOUSBDeviceInterface182 **dev, usb_handle *handle) { IOReturn kr; IOUSBFindInterfaceRequest request; io_iterator_t iterator; @@ -515,8 +515,29 @@ int usb_write(usb_handle *h, const void *data, int len) { return -1; } +#if 0 result = (*h->interface)->WritePipe( h->interface, h->bulkOut, (void *)data, len); +#else + /* Attempt to work around crashes in the USB driver that may be caused + * by trying to write too much data at once. The kernel IOCopyMapper + * panics if a single iovmAlloc needs more than half of its mapper pages. + */ + const int maxLenToSend = 1048576; // 1 MiB + int lenRemaining = len; + result = 0; + while (lenRemaining > 0) { + int lenToSend = lenRemaining > maxLenToSend + ? maxLenToSend : lenRemaining; + + result = (*h->interface)->WritePipe( + h->interface, h->bulkOut, (void *)data, lenToSend); + if (result != 0) break; + + lenRemaining -= lenToSend; + data = (const char*)data + lenToSend; + } +#endif #if 0 if ((result == 0) && (h->zero_mask)) { |