summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2021-03-08 18:04:39 -0800
committerCommit Bot <commit-bot@chromium.org>2021-03-19 17:40:14 +0000
commit538b3c9eb9200b4c4732e1c2565c96d8e69d6632 (patch)
treea8623e9070584a8d51345b8503a6b224184e5611
parent67c4d4e09a33abbb28c686592617afaa485638a2 (diff)
downloadchrome-ec-538b3c9eb9200b4c4732e1c2565c96d8e69d6632.tar.gz
TCPMv2: PE/DPM: Don't preemptively set modal flag
Currently we are setting the modal flag as a DFP when the ENTER command is being sent, without confirmation of the ACK reply from the UFP. This CL keeps this behavior for TCPMv1, but moves the setting of the modal flag into the alt mode specific state machine. Currently, we only support DP and Thunderbolt alt modes. When the modal flag is set pre-emptively, we will fail the TDA.2.2.3: BMC-PROT-SEQ-DRSWAP compliance test. This is because we trigger a hard reset if the modal flag is set and we receive a data role swap request. BUG=b:180764800,b:159946351,b:181386294 BRANCH=None TEST=Verifed that TDA.2.2.3: BMC-PROT-SEQ-DRSWAP passes on quiche Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I4ae527903859e8ffdb01f355606c5d0f7d177def Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2751329 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2774591 Tested-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--common/usb_pd_alt_mode_dfp.c8
-rw-r--r--common/usbc/dp_alt_mode.c2
-rw-r--r--common/usbc/tbt_alt_mode.c2
3 files changed, 9 insertions, 3 deletions
diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c
index 1c683145f1..c671616da6 100644
--- a/common/usb_pd_alt_mode_dfp.c
+++ b/common/usb_pd_alt_mode_dfp.c
@@ -250,10 +250,12 @@ uint32_t pd_dfp_enter_mode(int port, enum tcpm_transmit_type type,
/*
* Strictly speaking, this should only happen when the request
* has been ACKed.
- * TODO(b/159854667): Redo setting the enter mode flag to incorporate
- * it into the DP state machine.
+ * For TCPMV1, still set modal flag pre-emptively. For TCPMv2, the modal
+ * flag is set when the ENTER command is ACK'd for each alt mode that is
+ * supported.
*/
- pd_set_dfp_enter_mode_flag(port, true);
+ if (IS_ENABLED(CONFIG_USB_PD_TCPMV1))
+ pd_set_dfp_enter_mode_flag(port, true);
/* SVDM to send to UFP for mode entry */
return VDO(modep->fx->svid, 1, CMD_ENTER_MODE | VDO_OPOS(modep->opos));
diff --git a/common/usbc/dp_alt_mode.c b/common/usbc/dp_alt_mode.c
index 8e22c23170..321fe1c884 100644
--- a/common/usbc/dp_alt_mode.c
+++ b/common/usbc/dp_alt_mode.c
@@ -123,6 +123,8 @@ void dp_vdm_acked(int port, enum tcpm_transmit_type type, int vdo_count,
case DP_START:
case DP_ENTER_RETRY:
dp_state[port] = DP_ENTER_ACKED;
+ /* Inform PE layer that alt mode is now active */
+ pd_set_dfp_enter_mode_flag(port, true);
break;
case DP_ENTER_ACKED:
/* DP status response & UFP's DP attention have same payload. */
diff --git a/common/usbc/tbt_alt_mode.c b/common/usbc/tbt_alt_mode.c
index 3ce66f7e5d..de296aa216 100644
--- a/common/usbc/tbt_alt_mode.c
+++ b/common/usbc/tbt_alt_mode.c
@@ -290,6 +290,8 @@ void intel_vdm_acked(int port, enum tcpm_transmit_type type, int vdo_count,
tbt_state[port] = TBT_ACTIVE;
tbt_prints("enter mode SOP", port);
TBT_SET_FLAG(port, TBT_FLAG_RETRY_DONE);
+ /* Indicate to PE layer that alt mode is active */
+ pd_set_dfp_enter_mode_flag(port, true);
break;
case TBT_ACTIVE:
tbt_prints("exit mode SOP", port);