diff options
author | Denis Brockus <dbrockus@google.com> | 2021-02-18 13:34:27 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-02 00:13:52 +0000 |
commit | e990787dc3e95f77ee89e6d470c38787ef829e23 (patch) | |
tree | 78ccef3e1cbea57f3eb61581be44769e9a70e83b /common | |
parent | 237649020cf4974150f805c0a5d90de4ab593696 (diff) | |
download | chrome-ec-e990787dc3e95f77ee89e6d470c38787ef829e23.tar.gz |
TCPMv2: PD Timers - Add PE SinkRequest to framework
BUG=b:178029034
BRANCH=none
TEST=make runtests
Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: I437efe7b10a7de09a483bfaea3c53ca29f73a771
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2707906
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Tested-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 920f0e1cc7..bcc29a8359 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -612,13 +612,6 @@ static struct policy_engine { uint64_t discover_identity_timer; /* - * This timer is used to ensure that the time before the next Sink - * Request Message, after a Wait Message has been received from the - * Source in response to a Sink Request Message. - */ - uint64_t sink_request_timer; - - /* * This timer tracks the time after receiving a Wait message in response * to a PR_Swap message. */ @@ -3332,18 +3325,21 @@ static void pe_snk_ready_entry(int port) pe[port].dpm_curr_request = 0; /* + * TODO(b:181343741) The PE_TIMER_SINK_REQUEST should not be disabled + * and re-enabled on transition to/from SNK_READY unless this is the + * initial time in. Leaving for a message or other normal handling + * should not reset the timer + */ + /* * On entry to the PE_SNK_Ready state as the result of a wait, * then do the following: * 1) Initialize and run the SinkRequestTimer */ if (PE_CHK_FLAG(port, PE_FLAGS_WAIT)) { PE_CLR_FLAG(port, PE_FLAGS_WAIT); - pe[port].sink_request_timer = - get_time().val + PD_T_SINK_REQUEST; - } else { - pe[port].sink_request_timer = TIMER_DISABLED; + pd_timer_enable(port, PE_TIMER_SINK_REQUEST, + PD_T_SINK_REQUEST); } - /* * Wait and add jitter if we are operating in PD2.0 mode and no messages * have been sent since enter this state. @@ -3488,7 +3484,7 @@ static void pe_snk_ready_run(int port) PE_CLR_FLAG(port, PE_FLAGS_FIRST_MSG); pd_timer_disable(port, PE_TIMER_WAIT_AND_ADD_JITTER); - if (get_time().val > pe[port].sink_request_timer) { + if (pd_timer_is_expired(port, PE_TIMER_SINK_REQUEST)) { set_state_pe(port, PE_SNK_SELECT_CAPABILITY); return; } @@ -3514,6 +3510,7 @@ static void pe_snk_ready_run(int port) static void pe_snk_ready_exit(int port) { + pd_timer_disable(port, PE_TIMER_SINK_REQUEST); pd_timer_disable(port, PE_TIMER_WAIT_AND_ADD_JITTER); } |