summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2021-02-22 23:20:43 -0800
committerCommit Bot <commit-bot@chromium.org>2021-03-17 19:13:34 +0000
commit8984434913efaafda4c172c15b98ddd3cb636dd8 (patch)
tree7e8163ee00920c91c4250f7e7a797ef682a5c7c7
parentcd5b766a5508ea96e145b9741b6cb058848bbff9 (diff)
downloadchrome-ec-8984434913efaafda4c172c15b98ddd3cb636dd8.tar.gz
TCPMv2: Fix check for svdm response w/ Attention
Attention messages do not require a response message. A previous CL had a check for this message in a helper function. That method was not correct because the the vdm message buffer in the PE object does not get cleared and so this buffer should only be checked in a state where the vdm buffer contents are known to be current. BUG=b:175660576,b:173027965 BRANCH=None TEST=Verified on quiche that can enter ALT-DP mode as a UFP-D and that display is extended properly via display port or hdmi connector. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: Id9908fd4bd3db574fb6f769ab0d2e1db0be5aecd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2718270 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--common/usbc/usb_pe_drp_sm.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 14f59cf624..8a62427006 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -5068,27 +5068,6 @@ static enum vdm_response_result parse_vdm_response_common(int port)
uint8_t type;
uint8_t cnt;
uint8_t ext;
- uint32_t vdm_hdr;
-
- /*
- * USB-PD 3.0 Rev 1.1 - 6.4.4.2.5
- * Structured VDM command consists of a command request and a command
- * response (ACK, NAK, or BUSY). An exception is made for the Attention
- * command which shall have no response.
- *
- * This function is a helper function for PE states which are sending
- * VDM commands and are waiting for VDM responses from the port partner.
- * Since Attention commands do not have an expected reply, the SVDM
- * command is complete once the Attention command transmit is complete.
- */
- vdm_hdr = pe[port].vdm_data[0];
- if(PD_VDO_SVDM(vdm_hdr) &&
- (PD_VDO_CMD(vdm_hdr) == CMD_ATTENTION)) {
- if (PE_CHK_FLAG(port, PE_FLAGS_TX_COMPLETE)) {
- PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE);
- return VDM_RESULT_NO_ACTION;
- }
- }
if (!PE_CHK_REPLY(port))
return VDM_RESULT_WAITING;
@@ -5753,9 +5732,33 @@ static void pe_vdm_request_dpm_entry(int port)
static void pe_vdm_request_dpm_run(int port)
{
+ uint32_t vdm_hdr;
+
switch (parse_vdm_response_common(port)) {
case VDM_RESULT_WAITING:
- /* If common code didn't parse a message, continue waiting. */
+ /*
+ * USB-PD 3.0 Rev 1.1 - 6.4.4.2.5
+ * Structured VDM command consists of a command request and a
+ * command response (ACK, NAK, or BUSY). An exception is made
+ * for the Attention command which shall have no response.
+ *
+ * Since Attention commands do not have an expected reply,
+ * the SVDM command is complete once the Attention command
+ * transmit is complete.
+ */
+ vdm_hdr = pe[port].vdm_data[0];
+ if(PD_VDO_SVDM(vdm_hdr) &&
+ (PD_VDO_CMD(vdm_hdr) == CMD_ATTENTION)) {
+ if (PE_CHK_FLAG(port, PE_FLAGS_TX_COMPLETE)) {
+ PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE);
+ break;
+ }
+ }
+ /*
+ * If common code didn't parse a message, and the VDM
+ * just sent was not an Attention message, then continue
+ * waiting.
+ */
return;
case VDM_RESULT_NO_ACTION:
/*