diff options
author | Diana Z <dzigterman@chromium.org> | 2022-04-22 15:46:31 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-04 19:06:24 +0000 |
commit | 45bd906e541574a0af60757fcf5e6d8ccfec544e (patch) | |
tree | 56e237a20602b37dfbf3625a3bcd36ea4ef6e8cd | |
parent | ca53b80ed7585e4febeeaa2edc6cc36be9719865 (diff) | |
download | chrome-ec-45bd906e541574a0af60757fcf5e6d8ccfec544e.tar.gz |
TCPMv2: Verify data role in incoming messages
We're required to exeute Error Recovery when we see a partner set the
data role bit we believe ourselves to have. The spec gives no specific
state this should be performed from, so centralize it to the PRL RX.
BRANCH=None
BUG=b:155418161,b:228478468
TEST=with a normal charger, verify connection completes successfully.
With bad apple charger connection, verify error recovery is performed
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I82071d01ece105dbfc483446995e7f423bd9804e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3602225
Reviewed-by: Aaron Massey <aaronmassey@google.com>
Reviewed-by: Michał Barnaś <barnas@google.com>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r-- | common/usbc/usb_prl_sm.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index d9c3849f58..5460edf1d4 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -2195,6 +2195,29 @@ static void prl_rx_wait_for_phy_message(const int port, int evt) PD_HEADER_PROLE(header) == PD_PLUG_FROM_DFP_UFP) return; + /* + * From 6.2.1.1.6 Port Data Role in USB PD Rev 3.1, Ver 1.3 + * "If a USB Type-C Port receives a Message with the Port Data Role + * field set to the same Data Role as its current Data Role, except + * for the GoodCRC Message, USB Type-C Error Recovery actions as + * defined in [USB Type-C 2.0] Shall be performed." + * + * The spec lists no required state for this check, so centralize it by + * processing this requirement in the PRL RX. + */ + if (PD_HEADER_GET_SOP(header) == TCPCI_MSG_SOP && + PD_HEADER_DROLE(header) == pd_get_data_role(port)) { + CPRINTS("C%d Error: Data role mismatch (0x%08x)", port, header); + /* + * TODO(b/230656752): Ensure emulated test partners send + * correct data roles + */ + if (!IS_ENABLED(CONFIG_ZTEST)) { + tc_start_error_recovery(port); + return; + } + } + /* Handle incoming soft reset as special case */ if (cnt == 0 && type == PD_CTRL_SOFT_RESET) { /* Clear MessageIdCounter */ |