summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@google.com>2020-05-28 10:16:26 -0600
committerCommit Bot <commit-bot@chromium.org>2020-05-29 06:02:46 +0000
commit929d464ed1dfef532f6e9d5fcd4366def92de862 (patch)
tree518755adfec1c69ac244d68a364287f6b16e7e9e
parent14ab37132cd0571bcad4432347356c80f6854d48 (diff)
downloadchrome-ec-929d464ed1dfef532f6e9d5fcd4366def92de862.tar.gz
TCPMv2:PRL: PD3 messages should transfer as the correct message
Accept and BIST have the same message code but Accept is a control message and should indicate this by the num_objs field of the message header being 0. This was not happening when a message was being received when we attempted to transmit. BUG=b:157650576 BRANCH=none TEST=ThinkPad Dock attach should not show BIST message Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I766e6a5e5fb786f5b6c503a76d1721c303044047 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2220285 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Sam Hurst <shurst@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
-rw-r--r--common/usbc/usb_prl_sm.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c
index c54acfed1d..a3cf347ea8 100644
--- a/common/usbc/usb_prl_sm.c
+++ b/common/usbc/usb_prl_sm.c
@@ -553,6 +553,7 @@ void prl_send_ctrl_msg(int port,
{
pdmsg[port].xmit_type = type;
pdmsg[port].msg_type = msg;
+ pdmsg[port].data_objs = 0;
#ifdef CONFIG_USB_PD_REV30
pdmsg[port].ext = 0;
@@ -560,7 +561,6 @@ void prl_send_ctrl_msg(int port,
TCH_SET_FLAG(port, PRL_FLAGS_MSG_XMIT);
#else
- pdmsg[port].data_objs = 0;
PRL_TX_SET_FLAG(port, PRL_FLAGS_MSG_XMIT);
#endif /* CONFIG_USB_PD_REV30 */
@@ -669,6 +669,16 @@ enum pd_rev_type prl_get_rev(int port, enum tcpm_transmit_type type)
static void prl_copy_msg_to_buffer(int port)
{
/*
+ * Control Messages will have a length of 0 and
+ * no need to spend time with the tx_chk_buf
+ * for this path
+ */
+ if (tx_emsg[port].len == 0) {
+ pdmsg[port].data_objs = 0;
+ return;
+ }
+
+ /*
* Make sure the Policy Engine isn't sending
* more than CHK_BUF_SIZE_BYTES. If so,
* truncate len. This will surely send a
@@ -1818,6 +1828,10 @@ static void tch_message_received_entry(const int port)
/* Pass message to chunked Rx */
RCH_SET_FLAG(port, PRL_FLAGS_MSG_RECEIVED);
+
+ /* Clear extended message objects */
+ TCH_CLR_FLAG(port, PRL_FLAGS_MSG_XMIT);
+ pdmsg[port].data_objs = 0;
}
static void tch_message_received_run(const int port)
@@ -1953,11 +1967,16 @@ static void prl_rx_wait_for_phy_message(const int port, int evt)
/*
* Message (not Ping) Received from
* Protocol Layer & Doing Tx Chunks
+ *
+ * Also, handle the case where a message has been
+ * queued for sending but a message is received before
+ * tch_wait_for_message_request_from_pe has been run
*/
- else if (tch_get_state(port) !=
+ else if ((tch_get_state(port) !=
TCH_WAIT_FOR_MESSAGE_REQUEST_FROM_PE &&
- tch_get_state(port) !=
- TCH_WAIT_FOR_TRANSMISSION_COMPLETE) {
+ tch_get_state(port) !=
+ TCH_WAIT_FOR_TRANSMISSION_COMPLETE) ||
+ TCH_CHK_FLAG(port, PRL_FLAGS_MSG_XMIT)) {
/* NOTE: RTR_TX_CHUNKS State embedded here. */
/*
* Send Message to Tx Chunk