diff options
author | Badhri Jagan Sridharan <badhri@google.com> | 2021-04-30 16:19:45 -0700 |
---|---|---|
committer | Badhri Jagan Sridharan <badhri@google.com> | 2021-04-30 16:24:57 -0700 |
commit | 8a02cb1253d13a6aff6e32f0c719c1341e0d525c (patch) | |
tree | c35b5a7471da9c7b6820d7eb9c6ef06c80328043 /usb | |
parent | 49c6d47acc5c133eb41a4b3689964407c6c3f548 (diff) |
Usb Gadget HAL: Partial revert due to power regression
9cf018372ba8527af4bc54d453f1e2a5d0a9749f introduced a
power regression where adbd would keep spinning the CPU
waiting for FUNCTIONFS_BIND.
adbd : timed out while waiting for FUNCTIONFS_BIND, trying again
Partially reverting the CL. Complete revert would have
to revert CLs across multiple devices.
Bug: 186824331
Test: adb while have usb booted. adb on unplug. adbd does not spin.
Change-Id: Ie666eb5318914a0b5b4e7edc14e0cda50f896f96
Diffstat (limited to 'usb')
-rw-r--r-- | usb/MonitorFfs.cpp | 29 | ||||
-rw-r--r-- | usb/include/pixelusb/UsbGadgetCommon.h | 2 |
2 files changed, 4 insertions, 27 deletions
diff --git a/usb/MonitorFfs.cpp b/usb/MonitorFfs.cpp index dc25aba..a52eda1 100644 --- a/usb/MonitorFfs.cpp +++ b/usb/MonitorFfs.cpp @@ -26,7 +26,8 @@ namespace usb { static volatile bool gadgetPullup; -MonitorFfs::MonitorFfs(const char *const gadget, const char *const extconUsbState) +MonitorFfs::MonitorFfs(const char *const gadget, + __attribute__((unused)) const char *const extconUsbState) : mWatchFd(), mEndpointList(), mLock(), @@ -37,7 +38,6 @@ MonitorFfs::MonitorFfs(const char *const gadget, const char *const extconUsbStat mCallback(NULL), mPayload(NULL), mGadgetName(gadget), - mExtconUsbState(extconUsbState), mMonitorRunning(false) { unique_fd eventFd(eventfd(0, 0)); if (eventFd == -1) { @@ -119,7 +119,6 @@ void *MonitorFfs::startMonitorFd(void *param) { bool writeUdc = true, stopMonitor = false; struct epoll_event events[kEpollEvents]; steady_clock::time_point disconnect; - std::string usb_state; bool descriptorWritten = true; for (int i = 0; i < static_cast<int>(monitorFfs->mEndpointList.size()); i++) { @@ -129,17 +128,7 @@ void *MonitorFfs::startMonitorFd(void *param) { } } - if (ReadFileToString(monitorFfs->mExtconUsbState, &usb_state)) - usb_state = Trim(usb_state); - else - usb_state = TYPEC_GADGET_MODE_ENABLE; - - // notify here if the endpoints are already present. - if (usb_state == TYPEC_GADGET_MODE_DISABLE) { - gadgetPullup = false; - writeUdc = false; - ALOGI("pending GADGET pulled up due to USB disconnected"); - } else if (descriptorWritten) { + if (descriptorWritten) { usleep(kPullUpDelay); if (!!WriteStringToFile(monitorFfs->mGadgetName, PULLUP_PATH)) { lock_guard<mutex> lock(monitorFfs->mLock); @@ -183,17 +172,7 @@ void *MonitorFfs::startMonitorFd(void *param) { } } - if (ReadFileToString(monitorFfs->mExtconUsbState, &usb_state)) - usb_state = Trim(usb_state); - else - usb_state = TYPEC_GADGET_MODE_ENABLE; - - if (usb_state == TYPEC_GADGET_MODE_DISABLE) { - if (kDebug) - ALOGI("pending GADGET pulled up due to USB disconnected"); - gadgetPullup = false; - writeUdc = false; - } else if (!descriptorPresent && !writeUdc) { + if (!descriptorPresent && !writeUdc) { if (kDebug) ALOGI("endpoints not up"); writeUdc = true; diff --git a/usb/include/pixelusb/UsbGadgetCommon.h b/usb/include/pixelusb/UsbGadgetCommon.h index fde80b3..197aaf2 100644 --- a/usb/include/pixelusb/UsbGadgetCommon.h +++ b/usb/include/pixelusb/UsbGadgetCommon.h @@ -131,8 +131,6 @@ class MonitorFfs { void *mPayload; // Name of the USB gadget. Used for pullup. const char *const mGadgetName; - // Extcon USB state from Type-C notification. - const char *const mExtconUsbState; // Monitor State bool mMonitorRunning; |