Retry stalled USB bulk transfers during a modem switch operation.

This CL modifies UsbModemSwitchOperation to handle USB halt conditions
better:
- Instead of clearing the halt condition on the bulk endpoint before
  every transfer, clear the halt condition on the output bulk endpoint
  (and also the input bulk endpoint if we expect a response after each
  outgoing message) at the beginning of the switch operation.
- If a bulk transfer stalls, clear the halt condition on the endpoint
  and retry the transfer.
- Clear any halt condition at the end of the switch operation.

BUG=chromium:304960
TEST=Tested the following:
1. Build and run unit tests.
2. Verify on daisy and peppy that mist successfully switches the ZTE
   MF190 dongle from mass storage mode to the modem mode. On peppy,
   USB bulk transfers may stall, but mist should clear the halt
   condition on the endpoint and retry the transfer.

Change-Id: I229ea2b062c7da50a7f40ac42d6bdef1934dc8f0
Reviewed-on: https://chromium-review.googlesource.com/172161
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
2 files changed
tree: 0a044a7da5dc8341d91e68bf3f315f5646fcc3e1
  1. proto/
  2. 51-mist.rules
  3. common.mk
  4. config_loader.cc
  5. config_loader.h
  6. config_loader_unittest.cc
  7. context.cc
  8. context.h
  9. default.conf
  10. event_dispatcher.cc
  11. event_dispatcher.h
  12. event_dispatcher_unittest.cc
  13. LICENSE
  14. main.cc
  15. Makefile
  16. metrics.cc
  17. metrics.h
  18. mist.cc
  19. mist.gyp
  20. mist.h
  21. mock_config_loader.cc
  22. mock_config_loader.h
  23. mock_context.cc
  24. mock_context.h
  25. mock_udev.cc
  26. mock_udev.h
  27. mock_udev_device.cc
  28. mock_udev_device.h
  29. mock_udev_enumerate.cc
  30. mock_udev_enumerate.h
  31. mock_udev_list_entry.cc
  32. mock_udev_list_entry.h
  33. mock_udev_monitor.cc
  34. mock_udev_monitor.h
  35. mock_usb_device_event_observer.cc
  36. mock_usb_device_event_observer.h
  37. OWNERS
  38. README
  39. testrunner.cc
  40. udev.cc
  41. udev.h
  42. udev_device.cc
  43. udev_device.h
  44. udev_enumerate.cc
  45. udev_enumerate.h
  46. udev_list_entry.cc
  47. udev_list_entry.h
  48. udev_monitor.cc
  49. udev_monitor.h
  50. usb_bulk_transfer.cc
  51. usb_bulk_transfer.h
  52. usb_config_descriptor.cc
  53. usb_config_descriptor.h
  54. usb_config_descriptor_unittest.cc
  55. usb_constants.cc
  56. usb_constants.h
  57. usb_constants_unittest.cc
  58. usb_device.cc
  59. usb_device.h
  60. usb_device_descriptor.cc
  61. usb_device_descriptor.h
  62. usb_device_descriptor_unittest.cc
  63. usb_device_event_notifier.cc
  64. usb_device_event_notifier.h
  65. usb_device_event_notifier_unittest.cc
  66. usb_device_event_observer.h
  67. usb_endpoint_descriptor.cc
  68. usb_endpoint_descriptor.h
  69. usb_endpoint_descriptor_unittest.cc
  70. usb_error.cc
  71. usb_error.h
  72. usb_error_unittest.cc
  73. usb_interface.cc
  74. usb_interface.h
  75. usb_interface_descriptor.cc
  76. usb_interface_descriptor.h
  77. usb_interface_descriptor_unittest.cc
  78. usb_manager.cc
  79. usb_manager.h
  80. usb_modem_one_shot_switcher.cc
  81. usb_modem_one_shot_switcher.h
  82. usb_modem_switch_context.cc
  83. usb_modem_switch_context.h
  84. usb_modem_switch_context_unittest.cc
  85. usb_modem_switch_operation.cc
  86. usb_modem_switch_operation.h
  87. usb_modem_switcher.cc
  88. usb_modem_switcher.h
  89. usb_transfer.cc
  90. usb_transfer.h
  91. usb_transfer_unittest.cc