system/core
Révision | 32e78e649e7ac330db4cd3b057a18f94c645a583 (tree) |
---|---|
l'heure | 2019-05-21 12:00:30 |
Auteur | android-build-team Robot <android-build-team-robot@goog...> |
Commiter | android-build-team Robot |
Snap for 5587054 from b28857eee628de9ee6bbae63d745727c5bc81988 to qt-qpr1-release
Change-Id: I6cd23141447ccbcb16663ef921842ce89e79801b
@@ -58,10 +58,12 @@ using android::base::StringPrintf; | ||
58 | 58 | static std::optional<bool> gFfsAioSupported; |
59 | 59 | |
60 | 60 | // Not all USB controllers support operations larger than 16k, so don't go above that. |
61 | -static constexpr size_t kUsbReadQueueDepth = 32; | |
61 | +// Also, each submitted operation does an allocation in the kernel of that size, so we want to | |
62 | +// minimize our queue depth while still maintaining a deep enough queue to keep the USB stack fed. | |
63 | +static constexpr size_t kUsbReadQueueDepth = 8; | |
62 | 64 | static constexpr size_t kUsbReadSize = 4 * PAGE_SIZE; |
63 | 65 | |
64 | -static constexpr size_t kUsbWriteQueueDepth = 32; | |
66 | +static constexpr size_t kUsbWriteQueueDepth = 8; | |
65 | 67 | static constexpr size_t kUsbWriteSize = 4 * PAGE_SIZE; |
66 | 68 | |
67 | 69 | static const char* to_string(enum usb_functionfs_event_type type) { |
@@ -314,11 +316,13 @@ struct UsbFfsConnection : public Connection { | ||
314 | 316 | if (bound) { |
315 | 317 | LOG(WARNING) << "received FUNCTIONFS_BIND while already bound?"; |
316 | 318 | running = false; |
319 | + break; | |
317 | 320 | } |
318 | 321 | |
319 | 322 | if (enabled) { |
320 | 323 | LOG(WARNING) << "received FUNCTIONFS_BIND while already enabled?"; |
321 | 324 | running = false; |
325 | + break; | |
322 | 326 | } |
323 | 327 | |
324 | 328 | bound = true; |
@@ -328,11 +332,13 @@ struct UsbFfsConnection : public Connection { | ||
328 | 332 | if (!bound) { |
329 | 333 | LOG(WARNING) << "received FUNCTIONFS_ENABLE while not bound?"; |
330 | 334 | running = false; |
335 | + break; | |
331 | 336 | } |
332 | 337 | |
333 | 338 | if (enabled) { |
334 | 339 | LOG(WARNING) << "received FUNCTIONFS_ENABLE while already enabled?"; |
335 | 340 | running = false; |
341 | + break; | |
336 | 342 | } |
337 | 343 | |
338 | 344 | enabled = true; |
@@ -364,6 +370,33 @@ struct UsbFfsConnection : public Connection { | ||
364 | 370 | bound = false; |
365 | 371 | running = false; |
366 | 372 | break; |
373 | + | |
374 | + case FUNCTIONFS_SETUP: { | |
375 | + LOG(INFO) << "received FUNCTIONFS_SETUP control transfer: bRequestType = " | |
376 | + << static_cast<int>(event.u.setup.bRequestType) | |
377 | + << ", bRequest = " << static_cast<int>(event.u.setup.bRequest) | |
378 | + << ", wValue = " << static_cast<int>(event.u.setup.wValue) | |
379 | + << ", wIndex = " << static_cast<int>(event.u.setup.wIndex) | |
380 | + << ", wLength = " << static_cast<int>(event.u.setup.wLength); | |
381 | + | |
382 | + if ((event.u.setup.bRequestType & USB_DIR_IN)) { | |
383 | + LOG(WARNING) << "received a device-to-host control transfer, ignoring"; | |
384 | + } else { | |
385 | + std::string buf; | |
386 | + buf.resize(event.u.setup.wLength + 1); | |
387 | + | |
388 | + ssize_t rc = adb_read(control_fd_.get(), buf.data(), buf.size()); | |
389 | + if (rc != event.u.setup.wLength) { | |
390 | + LOG(ERROR) | |
391 | + << "read " << rc | |
392 | + << " bytes when trying to read control request, expected " | |
393 | + << event.u.setup.wLength; | |
394 | + } | |
395 | + | |
396 | + LOG(INFO) << "control request contents: " << buf; | |
397 | + break; | |
398 | + } | |
399 | + } | |
367 | 400 | } |
368 | 401 | } |
369 | 402 |