summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2023-01-31 10:14:18 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-02-15 19:19:15 +0000
commitb05c46a23916b727ef2c357ffe4a28c7b2bb34c4 (patch)
tree782a9852ffd42c52091b9221e11470343aac3148
parent8636762aff20e11da8a99b010550ea3952d5bbc0 (diff)
downloadchrome-ec-b05c46a23916b727ef2c357ffe4a28c7b2bb34c4.tar.gz
TCPMv2: Trigger ErrorRecovery for FRS corner cases
Currently, if the port partner sends a Hard Reset during the FRS sequence, we attempt to handle the Hard Reset. However, this leaves us in an inconsistent power state which can lead to the DUT sourcing itself while neither partner presents Rp. Instead, go to ErrorRecovery which is the general method of recovering from anything unexpected during the FRS sequence. Additionally, correct the state machine to go to ErrorRecovery on discard as well and when we receive a SoftReset in the middle of the FRS sequence. BRANCH=None BUG=b:266035645 TEST=on frostflow, trigger FRS with problematic dock and observe Chrome does not show charging LOW_COVERAGE_REASON=FRS support in the partner emulator needs expanded, filed b/269473786 to track this Change-Id: Icd3a9da52534ecbb9012b740b082938f66052c22 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4209978 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--common/usbc/usb_pe_drp_sm.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 5eb983a89c..3037ed1fca 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -911,6 +911,15 @@ void pe_got_hard_reset(int port)
assert(port == TASK_ID_TO_PD_PORT(task_get_current()));
/*
+ * If we're in the middle of an FRS, any error should cause us to follow
+ * the ErrorRecovery path
+ */
+ if (pe_in_frs_mode(port)) {
+ set_state_pe(port, PE_WAIT_FOR_ERROR_RECOVERY);
+ return;
+ }
+
+ /*
* Transition from any state to the PE_SRC_Hard_Reset_Received or
* PE_SNK_Transition_to_default state when:
* 1) Hard Reset Signaling is detected.
@@ -1263,8 +1272,12 @@ void pe_got_soft_reset(int port)
/*
* The PE_SRC_Soft_Reset state Shall be entered from any state when a
* Soft_Reset Message is received from the Protocol Layer.
+ *
+ * However, if we're in the middle of an FRS sequence, we need to go to
+ * ErrorRecovery instead.
*/
- set_state_pe(port, PE_SOFT_RESET);
+ set_state_pe(port, pe_in_frs_mode(port) ? PE_WAIT_FOR_ERROR_RECOVERY :
+ PE_SOFT_RESET);
}
__overridable bool pd_can_charge_from_device(int port, const int pdo_cnt,
@@ -5151,10 +5164,9 @@ static void pe_prs_snk_src_send_swap_run(int port)
* Handle discarded message
*/
if (msg_check & PE_MSG_DISCARDED) {
- if (pe_in_frs_mode(port))
- pe_set_hard_reset(port);
- else
- set_state_pe(port, PE_SNK_READY);
+ set_state_pe(port, pe_in_frs_mode(port) ?
+ PE_WAIT_FOR_ERROR_RECOVERY :
+ PE_SNK_READY);
return;
}