diff options
author | Patryk Duda <pdk@semihalf.com> | 2020-06-15 12:46:55 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-06-23 09:19:44 +0000 |
commit | 6ac3fe8e804516b12c5747e0aae728fcc3f79153 (patch) | |
tree | 62bb37ed7fd1c8baf5700b5d8c2fbf52085bdbdc | |
parent | ee588d44e253154dce00d03d74aa568dcadef90f (diff) | |
download | chrome-ec-6ac3fe8e804516b12c5747e0aae728fcc3f79153.tar.gz |
TCPMv2: Do not reset negotiated PD revision level during soft reset
PD3.0 6.2.1.1.5 Specification Revision clearly states that negotiated
Specification Revision level should be used until Detach, Hard Reset
or Error Recovery happens.
Current implementation of soft reset performs full reinitialization of
PRL state machines, flags, counters including negotiated Specification
Revision level. As a result when sending PD_CTRL_SOFT_RESET DUT was
waiting for SinkTxOk, but it was never observed because ServoV4 was
running PD2.0 stack.
This issue was fixed by separating parts of SM_INIT state which
shouldn't be reset during soft reset.
BUG=b:158996004
BRANCH=none
TEST=Flash nocturne with firmware which contains fix.
Make sure ServoV4 runs PD2.0 revision.
Run firmware_PDResetSoft test, make sure that hard reset doesn't occur.
Signed-off-by: Patryk Duda <pdk@semihalf.com>
Change-Id: I852817a63772dbc8baab74ff6b0c425228b2f49b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2246020
Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 4 | ||||
-rw-r--r-- | common/usbc/usb_prl_sm.c | 31 | ||||
-rw-r--r-- | include/usb_prl_sm.h | 7 | ||||
-rw-r--r-- | test/fake_prl.c | 3 |
4 files changed, 33 insertions, 12 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 16a8dc48b7..3133a09864 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -2958,8 +2958,8 @@ static void pe_send_soft_reset_entry(int port) { print_current_state(port); - /* Reset Protocol Layer */ - prl_reset(port); + /* Reset Protocol Layer (softly) */ + prl_reset_soft(port); pe[port].sender_response_timer = TIMER_DISABLED; } diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index f9102ca80c..4fd0a79970 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -498,16 +498,6 @@ static void prl_init(int port) rch[port].flags = 0; #endif /* CONFIG_USB_PD_REV30 */ - /* - * Initialize to highest revision supported. If the port or cable - * partner doesn't support this revision, the Protocol Engine will - * lower this value to the revision supported by the partner. - */ - pdmsg[port].rev[TCPC_TX_SOP] = PD_REVISION; - pdmsg[port].rev[TCPC_TX_SOP_PRIME] = PD_REVISION; - pdmsg[port].rev[TCPC_TX_SOP_PRIME_PRIME] = PD_REVISION; - pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME] = PD_REVISION; - pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME_PRIME] = PD_REVISION; pdmsg[port].flags = 0; prl_hr[port].flags = 0; @@ -599,8 +589,28 @@ void prl_send_ext_data_msg(int port, } #endif /* CONFIG_USB_PD_REV30 */ +static void prl_set_default_pd_revision(int port) { + /* + * Initialize to highest revision supported. If the port or cable + * partner doesn't support this revision, the Protocol Engine will + * lower this value to the revision supported by the partner. + */ + pdmsg[port].rev[TCPC_TX_SOP] = PD_REVISION; + pdmsg[port].rev[TCPC_TX_SOP_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPC_TX_SOP_PRIME_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME_PRIME] = PD_REVISION; +} + +void prl_reset_soft(int port) +{ + /* Do not change negotiated PD Revision Specification level */ + local_state[port] = SM_INIT; +} + void prl_reset(int port) { + prl_set_default_pd_revision(port); local_state[port] = SM_INIT; } @@ -610,6 +620,7 @@ void prl_run(int port, int evt, int en) case SM_PAUSED: if (!en) break; + prl_set_default_pd_revision(port); /* fall through */ case SM_INIT: prl_init(port); diff --git a/include/usb_prl_sm.h b/include/usb_prl_sm.h index ee357ccba2..6b35bd67e8 100644 --- a/include/usb_prl_sm.h +++ b/include/usb_prl_sm.h @@ -41,6 +41,13 @@ void prl_set_debug_level(enum debug_level level); void prl_reset(int port); /** + * Resets the Protocol Layer State Machine (softly) + * + * @param port USB-C port number + */ +void prl_reset_soft(int port); + +/** * Runs the Protocol Layer State Machine * * @param port USB-C port number diff --git a/test/fake_prl.c b/test/fake_prl.c index b4e2aaa11a..f174274318 100644 --- a/test/fake_prl.c +++ b/test/fake_prl.c @@ -33,6 +33,9 @@ int prl_is_running(int port) void prl_reset(int port) {} +void prl_reset_soft(int port) +{} + static enum pd_ctrl_msg_type last_ctrl_msg[CONFIG_USB_PD_PORT_MAX_COUNT]; void prl_send_ctrl_msg(int port, enum tcpm_transmit_type type, enum pd_ctrl_msg_type msg) |