diff options
author | Keith Short <keithshort@chromium.org> | 2021-01-06 13:08:08 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-09 00:44:43 +0000 |
commit | 6be1ff9b14b3593cfc6b657a41334cc8a7f5811d (patch) | |
tree | 31b6b8214f38d24c2e58b787563b2b4cf71e19c7 /common/usbc | |
parent | af3d7e6e6c65b993ca2b0830eb70e2c6cbf405cd (diff) | |
download | chrome-ec-6be1ff9b14b3593cfc6b657a41334cc8a7f5811d.tar.gz |
tcpmv2: correct MessageId handling during soft reset
Change the soft reset handling in the PRL to reset the MessageId counter
only for the matching message type.
From section 6.3.13 Soft Reset Message in the USB PD 3.0 v2.0 spec,
Soft_Reset Message Shall be targeted at a specific entity depending on
the type of SOP* Packet used.
BUG=b:172364575
BRANCH=none
TEST=make buildall
TEST=Connect USB dock, verify MessageId sequences of SOP and SOP' are
handled correctly.
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: I3d4b69e8d08e3691aeac024064a68599f76010a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2613730
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'common/usbc')
-rw-r--r-- | common/usbc/usb_prl_sm.c | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index 834d2d6f2b..dabc6a269d 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -999,13 +999,27 @@ static void prl_tx_snk_start_ams_run(const int port) */ static void prl_tx_layer_reset_for_transmit_entry(const int port) { - int i; - print_current_prl_tx_state(port); - /* Reset MessageIdCounters */ - for (i = 0; i < NUM_SOP_STAR_TYPES; i++) - prl_tx[port].msg_id_counter[i] = 0; + if (pdmsg[port].xmit_type < NUM_SOP_STAR_TYPES) { + /* + * This state is only used during soft resets. Reset only the + * matching message type. + * + * From section 6.3.13 Soft Reset Message in the USB PD 3.0 + * v2.0 spec, Soft_Reset Message Shall be targeted at a + * specific entity depending on the type of SOP* Packet used. + */ + prl_tx[port].msg_id_counter[pdmsg[port].xmit_type] = 0; + + /* + * From section 6.11.2.3.2, the MessageID should be cleared + * from the PRL_Rx_Layer_Reset_for_Receive state. However, we + * don't implement a full state machine for PRL RX states so + * clear the MessageID here. + */ + prl_rx[port].msg_id[pdmsg[port].xmit_type] = -1; + } } static void prl_tx_layer_reset_for_transmit_run(const int port) @@ -1244,15 +1258,6 @@ static void prl_hr_reset_layer_entry(const int port) print_current_prl_hr_state(port); - /* reset messageIDCounters */ - for (i = 0; i < NUM_SOP_STAR_TYPES; i++) - prl_tx[port].msg_id_counter[i] = 0; - /* - * Protocol Layer message transmission transitions to - * PRL_Tx_Wait_For_Message_Request state. - */ - set_state_prl_tx(port, PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - if (IS_ENABLED(CONFIG_USB_PD_EXTENDED_MESSAGES)) { tch[port].flags = 0; rch[port].flags = 0; @@ -1260,7 +1265,7 @@ static void prl_hr_reset_layer_entry(const int port) pdmsg[port].flags = 0; - /* Reset message ids */ + /* Hard reset resets messageIDCounters for all TX types */ for (i = 0; i < NUM_SOP_STAR_TYPES; i++) { prl_rx[port].msg_id[i] = -1; prl_tx[port].msg_id_counter[i] = 0; @@ -1273,6 +1278,12 @@ static void prl_hr_reset_layer_entry(const int port) else tcpm_set_rx_enable(port, 0); + /* + * Protocol Layer message transmission transitions to + * PRL_Tx_Wait_For_Message_Request state. + */ + set_state_prl_tx(port, PRL_TX_WAIT_FOR_MESSAGE_REQUEST); + return; } @@ -2071,14 +2082,10 @@ static void prl_rx_wait_for_phy_message(const int port, int evt) /* Handle incoming soft reset as special case */ if (cnt == 0 && type == PD_CTRL_SOFT_RESET) { - int i; - - for (i = 0; i < NUM_SOP_STAR_TYPES; i++) { - /* Clear MessageIdCounter */ - prl_tx[port].msg_id_counter[i] = 0; - /* Clear stored MessageID value */ - prl_rx[port].msg_id[i] = -1; - } + /* Clear MessageIdCounter */ + prl_tx[port].msg_id_counter[prl_rx[port].sop] = 0; + /* Clear stored MessageID value */ + prl_rx[port].msg_id[prl_rx[port].sop] = -1; /* Soft Reset occurred */ set_state_prl_tx(port, PRL_TX_PHY_LAYER_RESET); |