summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-04-27 15:08:25 -0600
committerCommit Bot <commit-bot@chromium.org>2020-04-29 05:07:04 +0000
commit0c5fd0da1766dc968e3d23e76b0592f086f140d6 (patch)
tree3e066825097b02df1eff4912b84af4c688d65b21
parent2d5c4544f118037a7eb2cfcc42a9919fe756f445 (diff)
downloadchrome-ec-0c5fd0da1766dc968e3d23e76b0592f086f140d6.tar.gz
TCPMv2: Set AMS start for messages in pe_attempt_port_discovery
Discovery steps (discovering identity, SVIDs, mode, etc.) represent the beginning of AMS's, as does initiating data and vconn swaps. This change sets the local AMS flag so ready exit will let the PRL know we're beginning an AMS, and ensure that any PD 3.0 partners know to not interrupt us. BRANCH=None BUG=b:155087579 TEST=on kindred with TCPMv2, PD 3.0 port partner doesn't send messages in the middle of discovery Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I0763ae71551ac0d2c19e3108fed264ec23a9ecd3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2168578 Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--common/usbc/usb_pe_drp_sm.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index b13cad2eab..54c311e1ed 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -1126,6 +1126,10 @@ static void pe_prl_execute_hard_reset(int port)
* Run discovery at our leisure from PE_SNK_Ready or PE_SRC_Ready, after
* attempting to get into the desired default policy of DFP/Vconn source
*
+ * When this function sets a new state, it should set
+ * PE_FLAGS_LOCALLY_INITIATED_AMS first, so the ready exit functions can notify
+ * the PRL that an AMS has been initiated.
+ *
* Return indicates whether set_state was called, in which case the calling
* function should return as well.
*/
@@ -1146,6 +1150,7 @@ static bool pe_attempt_port_discovery(int port)
PE_CLR_FLAG(port, PE_FLAGS_DR_SWAP_TO_DFP);
if (pe[port].data_role == PD_ROLE_UFP) {
+ PE_SET_FLAG(port, PE_FLAGS_LOCALLY_INITIATED_AMS);
set_state_pe(port, PE_DRS_SEND_SWAP);
return true;
}
@@ -1155,6 +1160,7 @@ static bool pe_attempt_port_discovery(int port)
PE_CLR_FLAG(port, PE_FLAGS_VCONN_SWAP_TO_ON);
if (!tc_is_vconn_src(port)) {
+ PE_SET_FLAG(port, PE_FLAGS_LOCALLY_INITIATED_AMS);
set_state_pe(port, PE_VCS_SEND_SWAP);
return true;
}
@@ -1174,11 +1180,13 @@ static bool pe_attempt_port_discovery(int port)
if (get_time().val > pe[port].discover_port_identity_timer) {
if (pe[port].cable.discovery == PD_DISC_NEEDED &&
pe_can_send_sop_prime(port)) {
+ PE_SET_FLAG(port, PE_FLAGS_LOCALLY_INITIATED_AMS);
set_state_pe(port, PE_VDM_IDENTITY_REQUEST_CBL);
return true;
} else if (pd_get_identity_discovery(port, TCPC_TX_SOP) ==
PD_DISC_NEEDED &&
pe_can_send_sop_vdm(port, CMD_DISCOVER_IDENT)) {
+ PE_SET_FLAG(port, PE_FLAGS_LOCALLY_INITIATED_AMS);
set_state_pe(port,
PE_INIT_PORT_VDM_IDENTITY_REQUEST);
return true;
@@ -1188,6 +1196,7 @@ static bool pe_attempt_port_discovery(int port)
* Remove once do_port_discovery can be removed.
*/
} else if (pe_can_send_sop_vdm(port, pe[port].vdm_cmd + 1)) {
+ PE_SET_FLAG(port, PE_FLAGS_LOCALLY_INITIATED_AMS);
set_state_pe(port, PE_DO_PORT_DISCOVERY);
return true;
}