diff options
author | Denis Brockus <dbrockus@google.com> | 2021-02-18 11:57:01 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-02 00:13:12 +0000 |
commit | 3f2639ecc67352151a70ce5ae4c6ae96c0a420bf (patch) | |
tree | 29e451375403240f0d4c5b0d7ca1b776a3931379 | |
parent | bd2f43eb15862e98ad0cb35bf322ea0a92190836 (diff) | |
download | chrome-ec-3f2639ecc67352151a70ce5ae4c6ae96c0a420bf.tar.gz |
TCPMv2: PD Timers - Add PE VDMResponse to framework
BUG=b:178029034
BRANCH=none
TEST=make runtests
Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: I6f7a5c79a79d5938c13514a3cea935491a443c3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2707820
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Tested-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index b3ceda3a6d..3a19a9d57a 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -653,14 +653,6 @@ static struct policy_engine { uint64_t swap_source_start_timer; /* - * This timer is used by the Initiator’s Policy Engine to ensure that - * a Structured VDM Command request needing a response (e.g. Discover - * Identity Command request) is responded to within a bounded time of - * tVDMSenderResponse. - */ - uint64_t vdm_response_timer; - - /* * This timer is used during a VCONN Swap. */ uint64_t vconn_on_timer; @@ -5182,21 +5174,19 @@ static void pe_vdm_send_request_entry(int port) /* All VDM sequences are Interruptible */ PE_SET_FLAG(port, PE_FLAGS_LOCALLY_INITIATED_AMS | PE_FLAGS_INTERRUPTIBLE_AMS); - - pe[port].vdm_response_timer = TIMER_DISABLED; } static void pe_vdm_send_request_run(int port) { - if (pe[port].vdm_response_timer == TIMER_DISABLED && - PE_CHK_FLAG(port, PE_FLAGS_TX_COMPLETE)) { + if (PE_CHK_FLAG(port, PE_FLAGS_TX_COMPLETE) && + pd_timer_is_disabled(port, PE_TIMER_VDM_RESPONSE)) { /* Message was sent */ PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE); /* Start no response timer */ /* TODO(b/155890173): Support DPM-supplied timeout */ - pe[port].vdm_response_timer = - get_time().val + PD_T_VDM_SNDR_RSP; + pd_timer_enable(port, PE_TIMER_VDM_RESPONSE, + PD_T_VDM_SNDR_RSP); } if (PE_CHK_FLAG(port, PE_FLAGS_MSG_DISCARDED)) { @@ -5212,7 +5202,7 @@ static void pe_vdm_send_request_run(int port) * Check the VDM timer, child will be responsible for processing * messages and reacting appropriately to unexpected messages. */ - if (get_time().val > pe[port].vdm_response_timer) { + if (pd_timer_is_expired(port, PE_TIMER_VDM_RESPONSE)) { CPRINTF("VDM %s Response Timeout\n", pe[port].tx_type == TCPC_TX_SOP ? "Port" : "Cable"); @@ -5236,6 +5226,8 @@ static void pe_vdm_send_request_exit(int port) /* Invalidate TX type so it must be set before next call */ pe[port].tx_type = TCPC_TX_INVALID; + + pd_timer_disable(port, PE_TIMER_VDM_RESPONSE); } /** |