summaryrefslogtreecommitdiff
path: root/common/usb_pd_tcpc.c
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@google.com>2016-12-08 10:25:27 +0800
committerchrome-bot <chrome-bot@chromium.org>2016-12-08 22:47:00 -0800
commit0d5562fa73d59d00c1ebf3bfc6a0640f7c3f8f03 (patch)
tree5cd49884212feb6a7a51522a2ae17e46f1523b6c /common/usb_pd_tcpc.c
parentc7559d4d23b461f21a63e4507b5b0cc403d1b096 (diff)
downloadchrome-ec-0d5562fa73d59d00c1ebf3bfc6a0640f7c3f8f03.tar.gz
tcpci_tcpm_get_message: TCPC_REG_RX_BYTE_CNT includes header
From TCPC spec: """ RECEIVE_BYTE_COUNT: Indicates number of bytes in this register that are not stale. The TCPM should read the first RECEIVE_BYTE_COUNT bytes in this register. This is the number of bytes in the RX_BUFFER_DATA_OBJECTS plus three (for the RX_BUF_FRAME_TYPE and RX_BUF_HEADER). """ We were always reading 3 bytes too many. This is an issue if we receive a packet followed by a hard reset, as the register value will be set back to 0, but TCPC_REG_RX_HDR may contain a valid header, leading to corrupted packets being passed down the stack. Also update usb_pd_tcpc to match the specification. BRANCH=none BUG=chrome-os-partner:60575 TEST=elm FW as of 65fb80d (later version include a fix that would hide this issue), cherry-pick this patch, connect j5create adapter, then HDMI, then power => no crash Change-Id: I9ed8f3b500d5733ec7563e31246505e0b8bd48bb Reviewed-on: https://chromium-review.googlesource.com/417442 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/usb_pd_tcpc.c')
-rw-r--r--common/usb_pd_tcpc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c
index a9ce499dbc..18e90c583a 100644
--- a/common/usb_pd_tcpc.c
+++ b/common/usb_pd_tcpc.c
@@ -1235,7 +1235,7 @@ static int tcpc_i2c_read(int port, int reg, uint8_t *payload)
payload[1] = (pd[port].alert_mask >> 8) & 0xff;
return 2;
case TCPC_REG_RX_BYTE_CNT:
- payload[0] = 4 *
+ payload[0] = 3 + 4 *
PD_HEADER_CNT(pd[port].rx_head[pd[port].rx_buf_tail]);
return 1;
case TCPC_REG_RX_HDR: