summaryrefslogtreecommitdiff
path: root/common/usbc/usb_pe_drp_sm.c
diff options
context:
space:
mode:
authorudaykiran <udaykiran@google.com>2021-06-18 23:07:05 -0700
committerCommit Bot <commit-bot@chromium.org>2021-06-25 03:33:38 +0000
commit1e6577393086546f983d325be264293dbfc12a76 (patch)
tree9facfe6c7bb34c8545fd75380de6f029315c8f00 /common/usbc/usb_pe_drp_sm.c
parent07578aee1c0c64343ee0de7e186a708984552904 (diff)
downloadchrome-ec-1e6577393086546f983d325be264293dbfc12a76.tar.gz
SenderResponseTimer: offset with TCPC transmit success timestamp
The SenderResponseTimer shall be used by the sender's policy engine to ensure that a message requesting a response is responded to within a bounded time. Which is 24Msec to 30 Msec. However, delays associated TCPC I2C, PE, and PRL layers make hard reset response time greater 30Msec. This CL address the delay associated with TCPC. When TCPC transmit success is reported by TCPC upon receiving the GoodCRC, time stamp is recorded. Another time stamp is recorded just before starting SenderResponseTimer and offsetting PD_T_SENDER_RESPONSE. BUG=b:182439366 BRANCH=none TEST=checked with GRL compliance tester. Noted that total response time is in the middle of the expected time of 24ms to 30ms. This fix achieved response time about 27.675ms Signed-off-by: udaykiran <udaykiran@google.com> Change-Id: Id2ddcdd90eed8b3d66ade3d16877004871a21de8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2971078 Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'common/usbc/usb_pe_drp_sm.c')
-rw-r--r--common/usbc/usb_pe_drp_sm.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 9171b2fb94..e0a364240b 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -2016,6 +2016,8 @@ static void pe_sender_response_msg_entry(const int port)
*/
static enum pe_msg_check pe_sender_response_msg_run(const int port)
{
+ timestamp_t tx_success_ts;
+ uint32_t offset;
if (pd_timer_is_disabled(port, PE_TIMER_SENDER_RESPONSE)) {
/* Check for Discard */
if (PE_CHK_FLAG(port, PE_FLAGS_MSG_DISCARDED)) {
@@ -2034,9 +2036,19 @@ static enum pe_msg_check pe_sender_response_msg_run(const int port)
if (PE_CHK_FLAG(port, PE_FLAGS_TX_COMPLETE)) {
PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE);
- /* Initialize and run the SenderResponseTimer */
+ /* TCPC TX success time stamp */
+ tx_success_ts = prl_get_tcpc_tx_success_ts(port);
+ /* Calculate the delay from TX success to PE */
+ offset = time_since32(tx_success_ts);
+
+ /*
+ * Initialize and run the SenderResponseTimer by
+ * offsetting it with TX transmit success time.
+ * This would remove the effect of the latency from
+ * propagating the TX status.
+ */
pd_timer_enable(port, PE_TIMER_SENDER_RESPONSE,
- PD_T_SENDER_RESPONSE);
+ PD_T_SENDER_RESPONSE - offset);
return PE_MSG_SEND_COMPLETED;
}
return PE_MSG_SEND_PENDING;