summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-09-28 10:16:33 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-15 22:42:56 +0000
commite9e7b70c98b0a61faf7dc56839b2a62874b12814 (patch)
tree6755c49a835b830354774b02567b37b96b6b2d85
parentbaceb4eb56d65f038ebe44b634fb4b7e858be379 (diff)
downloadchrome-ec-e9e7b70c98b0a61faf7dc56839b2a62874b12814.tar.gz
TCPMv2: Handle timing corner case in TCPC PRL discard
If a message is received by the PD_INT task between the PRL_RX run and PRL_TX run, we may end up sending a message to the TCPC even though the PRL_RX will be forcing a discard next PRL cycle. This will get the PE out of sync, as it will assume the message was discarded when it was in fact sent. Peek into our receive queue right before sending a message to the TCPC, in order to reduce the liklihood of a mix-up like this happening. BRANCH=None BUG=None TEST=on voxel, run tast typec.Mode*.manual and observe we can successfully exit DP mode even when a VDM:Attention command comes in mid-PRL cycle Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I6979bf53972e40794dfae83f631b865a00d73302 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3192236 Reviewed-by: Scott Collyer <scollyer@chromium.org>
-rw-r--r--driver/tcpm/tcpci.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 8a6aea2dbb..359cb04d30 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -1020,6 +1020,18 @@ int tcpci_tcpm_transmit(int port, enum tcpci_msg_type type,
}
/*
+ * The PRL_RX state machine should force a discard of PRL_TX any time a
+ * new message comes in. However, since most of the PRL_RX runs on
+ * the TCPC, we may receive a RX interrupt between the EC PRL_RX and
+ * PRL_TX state machines running. In this case, mark the message
+ * discarded and don't tell the TCPC to transmit.
+ */
+ if (tcpm_has_pending_message(port)) {
+ pd_transmit_complete(port, TCPC_TX_COMPLETE_DISCARDED);
+ return EC_ERROR_BUSY;
+ }
+
+ /*
* We always retry in TCPC hardware since the TCPM is too slow to
* respond within tRetry (~195 usec).
*