mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 17:41:54 +00:00
7771c52368e03bb63fd49eb303b3152b557b897b
looks like we had a bit of a race condition: set_state() was effectively just an assignment opration to pd[port].task_state. it's called asynchronously from pd_set_suspend() in response to a PD_SUSPEND message from the AP as well as from pd_task() before it enters its main event loop. this can take a long time because tcpci_tcpm_init() has a 300ms timeout. last one wins. similarly, when pd_task() is running its main loop, pd_set_suspend() really needs to wait for pd_task() to actually enter the PD_STATE_SUSPENDED state before the caller can assume that the pd_task() has stopped accessing the TCPC. the particular failure case was when depthcharge would decide to do a TCPC firmware update. it starts by sending a PD_SUSPEND to the EC, then accessing the TCPC. unfortunately, the pd_task() hadn't gotten out of the way yet, thus causing TCPC access chaos. so, i'm adding a req_suspend_state flag to the pd_protocol struct so we can tell pd_task() to suspend itself in a controlled manner. when pd_task() is ready to do a state change - basically at the top of the main event loop - it'll change to PD_STATE_SUSPENDED and clear the req_suspend_state flag. in any case, pd_set_suspend() still needs to wait around for pd_task() to enter the suspended state as we don't have a fancy handshake mechanism between these tasks. TEST=in combination with some follow-on CLs, ps8751 firmware update works properly where previously it needed a ~2 second delay for the EC pd_task() to settle. the way to trigger the failure was to insert or remove the power brick. BRANCH=none BUG=b:62356808 Change-Id: I363803ff60db31ccf84d592f8c9d1610fbe0f9ce Signed-off-by: Caveh Jalali <caveh@google.com> Reviewed-on: https://chromium-review.googlesource.com/544659 Reviewed-by: Shawn N <shawnn@chromium.org>
For an overview of the Embedded Controller firmware, refer to http://www.chromium.org/chromium-os/2014-firmware-summit For instructions on building from source, refer to http://www.chromium.org/chromium-os/ec-development/getting-started-building-ec-images-quickly
Description
Languages
C
64.7%
Lasso
20.7%
ASL
3.6%
JavaScript
3.2%
C#
2.9%
Other
4.6%