summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2020-06-09 17:03:10 -0600
committerJett Rink <jettrink@chromium.org>2020-06-10 20:56:44 +0000
commit98459644434b60fc2adf21b19c8819ebad4a46cd (patch)
tree06e33067d76dc79cb9292788a88a375bfb8aea3d
parent99c3604670a6db488a126ef35076e810c859ef42 (diff)
downloadchrome-ec-98459644434b60fc2adf21b19c8819ebad4a46cd.tar.gz
tcpmv2: process TCH before and after prl_tx
We need to process the TX chunking state machine both before and after the prl_tx state machine. Processing before allows us to send outgoing chunked messages on this iteration. Processing after allows us to send the TX_COMPLETE status to the PE layer on the same iteration the PRL gets its notification. Without this change, if the TCPC fires its alert saying we finished the TX and we also receive a message (in response to that TX), then we would get a RX message/event before the TX_COMPLETE notification was sent in the PE layer. BRANCH=none BUG=b:158248741 TEST=Verify the RX and TX messages are happening in the same statemachine cycle instead of getting the RX event first. Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I6fd2ece2326f8dc3cee85c94baae09466d673e87 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2239035 Tested-by: Diana Z <dzigterman@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
-rw-r--r--common/usbc/usb_prl_sm.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c
index 955fb0a978..9ddca79416 100644
--- a/common/usbc/usb_prl_sm.c
+++ b/common/usbc/usb_prl_sm.c
@@ -626,16 +626,31 @@ void prl_run(int port, int evt, int en)
prl_rx_wait_for_phy_message(port, evt);
#ifdef CONFIG_USB_PD_REV30
- /* Run RX Chunked state machine */
+ /*
+ * Run RX Chunked state machine after prl_rx. This is what
+ * informs the PE of incoming message. Its input is prl_rx
+ */
run_state(port, &rch[port].ctx);
- /* Run TX Chunked state machine */
+ /*
+ * Run TX Chunked state machine before prl_tx in case we need
+ * to split an extended message and prl_tx can send it for us
+ */
run_state(port, &tch[port].ctx);
#endif /* CONFIG_USB_PD_REV30 */
/* Run Protocol Layer Message Transmission state machine */
run_state(port, &prl_tx[port].ctx);
+#ifdef CONFIG_USB_PD_REV30
+ /*
+ * Run TX Chunked state machine again after prl_tx so we can
+ * handle passing TX_COMPLETE (or failure) up to PE in a single
+ * iteration.
+ */
+ run_state(port, &tch[port].ctx);
+#endif /* CONFIG_USB_PD_REV30 */
+
/* Run Protocol Layer Hard Reset state machine */
run_state(port, &prl_hr[port].ctx);
break;