From dec4d9ddfd30a978b0ddb2fe95d68f00b61e31ee Mon Sep 17 00:00:00 2001 From: Scott Collyer Date: Wed, 31 Mar 2021 11:33:43 -0700 Subject: TCPMv2: PE: Clear PRS request following accept This CL adds logic to clear any pending DPM_REQUEST_PR_SWAP once we accept a PRS request from the port partner. This prevents a possible back to back swap if we want to PRS, but the port partner sends the request before PRS swap request is generated. BUG=b:182441965 BRANCH=quiche TEST=tested quiche with kohaku where quiche attaches in sink role. This case causes quiche to want to power role swap and causes the port partner to request a power role swap. Verified that only 1 power role swap occurs. Signed-off-by: Scott Collyer Change-Id: I05ee27897d5900e71257d268acd3bd37c8abb787 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2799450 Tested-by: Scott Collyer Reviewed-by: Diana Z Commit-Queue: Scott Collyer --- common/usbc/usb_pe_drp_sm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 2dc4649fe3..75e78039a8 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -4314,6 +4314,12 @@ static void pe_prs_src_snk_evaluate_swap_run(int port) if (PE_CHK_FLAG(port, PE_FLAGS_ACCEPT)) { PE_CLR_FLAG(port, PE_FLAGS_ACCEPT); + /* + * Clear any pending DPM power role swap request so we + * don't trigger a power role swap request back to src + * power role. + */ + PE_CLR_DPM_REQUEST(port, DPM_REQUEST_PR_SWAP); /* * Power Role Swap OK, transition to * PE_PRS_SRC_SNK_Transition_to_off @@ -4557,6 +4563,12 @@ static void pe_prs_snk_src_evaluate_swap_run(int port) if (PE_CHK_FLAG(port, PE_FLAGS_ACCEPT)) { PE_CLR_FLAG(port, PE_FLAGS_ACCEPT); + /* + * Clear any pending DPM power role swap request so we + * don't trigger a power role swap request back to sink + * power role. + */ + PE_CLR_DPM_REQUEST(port, DPM_REQUEST_PR_SWAP); /* * Accept message sent, transition to * PE_PRS_SNK_SRC_Transition_to_off -- cgit v1.2.1