diff options
author | Diana Z <dzigterman@chromium.org> | 2020-04-27 16:22:34 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-04-29 05:10:03 +0000 |
commit | d0d63e01bbc5843263afa7b2b88213bbd7f97a77 (patch) | |
tree | 2c6019e309bd11abf6d6884b59854b6f21f664f7 | |
parent | 0c5fd0da1766dc968e3d23e76b0592f086f140d6 (diff) | |
download | chrome-ec-d0d63e01bbc5843263afa7b2b88213bbd7f97a77.tar.gz |
TCPMv2: Exit PE_VCS_Send_Ps_Rdy_Swap after Accept received
When a cable sends an Accept to the Vconn swap soft reset, exit the
PE_VCS_Send_Ps_Rdy_Swap state. Previously, the check for TX complete
made it impossible to detect the Accept unless it came in on the same
state machine iteration.
BRANCH=None
BUG=b:155087012
TEST=on kindred with TCPMv2, DUT can continue with discovery when a
cable plug is present and accepts
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I0af72a3dbb44b310d4c9809a8b2f680e9fd1c14a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2168582
Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 54c311e1ed..82337b3bde 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -4972,43 +4972,49 @@ static void pe_vcs_send_ps_rdy_swap_entry(int port) static void pe_vcs_send_ps_rdy_swap_run(int port) { - if (PE_CHK_FLAG(port, PE_FLAGS_TX_COMPLETE)) { - PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE); + /* TODO(b/152058087): TCPMv2: Break up pe_vcs_send_ps_rdy_swap */ + switch (pe[port].sub) { + case PE_SUB0: + /* + * After a VCONN Swap the VCONN Source needs to reset + * the Cable Plug’s Protocol Layer in order to ensure + * MessageID synchronization. + */ + if (PE_CHK_FLAG(port, PE_FLAGS_TX_COMPLETE)) { + PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE); - switch (pe[port].sub) { - case PE_SUB0: - /* - * After a VCONN Swap the VCONN Source needs to reset - * the Cable Plug’s Protocol Layer in order to ensure - * MessageID synchronization. - */ prl_send_ctrl_msg(port, TCPC_TX_SOP_PRIME, - PD_CTRL_SOFT_RESET); + PD_CTRL_SOFT_RESET); pe[port].sub = PE_SUB1; - pe[port].timeout = get_time().val + 100*MSEC; - break; - case PE_SUB1: - /* Got ACCEPT or REJECT from Cable Plug */ - if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED) || - get_time().val > pe[port].timeout) { - PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED); - /* - * A VCONN Swap Shall reset the - * DiscoverIdentityCounter to zero - */ - pe[port].discover_port_identity_counter = 0; - pe[port].dr_swap_attempt_counter = 0; + } + break; + case PE_SUB1: + if (PE_CHK_FLAG(port, PE_FLAGS_TX_COMPLETE)) { + PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE); + pe[port].sender_response_timer = get_time().val + + PD_T_SENDER_RESPONSE; + } - if (pe[port].power_role == PD_ROLE_SOURCE) - set_state_pe(port, PE_SRC_READY); - else - set_state_pe(port, PE_SNK_READY); - } - break; - case PE_SUB2: - /* Do nothing */ - break; + /* Got ACCEPT or REJECT from Cable Plug */ + if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED) || + get_time().val > pe[port].sender_response_timer) { + PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED); + /* + * A VCONN Swap Shall reset the + * DiscoverIdentityCounter to zero + */ + pe[port].discover_port_identity_counter = 0; + pe[port].dr_swap_attempt_counter = 0; + + if (pe[port].power_role == PD_ROLE_SOURCE) + set_state_pe(port, PE_SRC_READY); + else + set_state_pe(port, PE_SNK_READY); } + break; + case PE_SUB2: + /* Do nothing */ + break; } if (PE_CHK_FLAG(port, PE_FLAGS_PROTOCOL_ERROR)) { |