diff options
author | Diana Z <dzigterman@chromium.org> | 2018-11-16 12:59:47 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-11-20 14:15:22 -0800 |
commit | 2c0d1c2555e1e7400ca470d32c11007086fe1dc5 (patch) | |
tree | 02b0f6f2560bafc2905c56d3621ddfeb74e4097e | |
parent | 590a45db85507787af77cf6bfc8ae63499cbf1cc (diff) | |
download | chrome-ec-2c0d1c2555e1e7400ca470d32c11007086fe1dc5.tar.gz |
PD: Respect tTypeCSendSourceCap timing
Currently, the pd_task will send source capability messages every time
the task wakes while in PD_STATE_SRC_DISCOVERY. This can cause the task
to violate the required 100-200 ms gap between sending source
capabilities during source advertisement, and in a worst case it will
give up sending source cabilities well before it should.
With this change, the task should send a source capability message
almost exactly every 100ms while in PD_STATE_SRC_DISCOVERY.
BRANCH=None
BUG=b:117788783
TEST=plugged hoho into bobba360 and phaser repeatedly with no hard
resets during initial connection
Change-Id: Id968921e0b0ea874bf7361849c22354804b5b9ca
Signed-off-by: Diana Z <dzigterman@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1340546
Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 20d713f628..ccfeb944e6 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -2539,6 +2539,7 @@ void pd_task(void *u) enum pd_states this_state; enum pd_cc_states new_cc_state; timestamp_t now; + uint64_t next_src_cap = 0; int caps_count = 0, hard_reset_sent = 0; int snk_cap_count = 0; int evt; @@ -3023,8 +3024,10 @@ void pd_task(void *u) } break; case PD_STATE_SRC_DISCOVERY: + now = get_time(); if (pd[port].last_state != pd[port].task_state) { caps_count = 0; + next_src_cap = now.val; /* * If we have had PD connection with this port * partner, then start NoResponseTimer. @@ -3040,7 +3043,8 @@ void pd_task(void *u) } /* Send source cap some minimum number of times */ - if (caps_count < PD_CAPS_COUNT) { + if (caps_count < PD_CAPS_COUNT && + next_src_cap <= now.val) { /* Query capabilities of the other side */ res = send_source_cap(port); /* packet was acked => PD capable device) */ @@ -3055,8 +3059,12 @@ void pd_task(void *u) PD_FLAGS_PREVIOUS_PD_CONN; } else { /* failed, retry later */ timeout = PD_T_SEND_SOURCE_CAP; + next_src_cap = now.val + + PD_T_SEND_SOURCE_CAP; caps_count++; } + } else if (caps_count < PD_CAPS_COUNT) { + timeout = next_src_cap - now.val; } break; case PD_STATE_SRC_NEGOCIATE: |