summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2019-08-29 14:14:33 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-17 06:14:32 +0000
commit9e271aeb78c7f8bc21cd52b66305217d0770ac46 (patch)
tree8acb27cc928ebe2f72eb72361f5184dd3dbd1aec
parent3db43fe342f4423cb450cb9fb14e69d1bc0a7b56 (diff)
downloadchrome-ec-9e271aeb78c7f8bc21cd52b66305217d0770ac46.tar.gz
pd: Extend READY_HOLD_OFF_US timer value for SRC
The READY_HOLD_OFF_US was set to 200 msec for both SNK and SRC connections. However, in the case of SRC, there can be a race condition with charge through hubs that initiate a power swap request and the SRC port sending the VDM discover idenity message. This CL makes the holdoff timer delay longer for SRC connections and prefixes READY_HOLD_OFF_US with SNK/SRC to differentiate the two timer values. BUG=b:140092163 BRANCH=None TEST=Tested with the AA-AM1N95W charge through hub. Verfied that this can be attached to Kohaku with external power already connected and successfully power role swap into source to charge the kohaku port. Tested 20-25 connections with no failures. Prior to this change the failure rate was 1 out of 3 attempts. Change-Id: I375415fec96baf44ecd4592033e8b44ed4616011 Signed-off-by: Scott Collyer <scollyer@google.com> Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1776844 Tested-by: Scott Collyer <scollyer@chromium.org> Tested-by: Jongpil Jung <jongpil19.jung@samsung.corp-partner.google.com>
-rw-r--r--common/usb_pd_protocol.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 039ef9dc23..e06d424c39 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -102,7 +102,15 @@ static const int debug_level;
* going to, but not so long that a "low power charger connected" notification
* would be shown in the chrome OS UI.
*/
-#define READY_HOLD_OFF_US (200 * MSEC)
+#define SNK_READY_HOLD_OFF_US (200 * MSEC)
+/*
+ * For the same purpose as SNK_READY_HOLD_OFF_US, but this delay can be longer
+ * since the concern over "low power charger" is not relevant when connected as
+ * a source and the additional delay avoids a race condition where the partner
+ * port sends a power role swap request close to when the VDM discover identity
+ * message gets sent.
+ */
+#define SRC_READY_HOLD_OFF_US (400 * MSEC)
enum vdm_states {
VDM_STATE_ERR_BUSY = -3,
@@ -1842,7 +1850,7 @@ static void handle_ctrl_request(int port, uint16_t head,
*/
if (pd[port].task_state == PD_STATE_SNK_TRANSITION)
pd[port].ready_state_holdoff_timer =
- get_time().val + READY_HOLD_OFF_US
+ get_time().val + SNK_READY_HOLD_OFF_US
+ (get_time().le.lo % (100 * MSEC));
set_state(port, PD_STATE_SNK_READY);
@@ -3577,10 +3585,14 @@ void pd_task(void *u)
* before we may send messages of our own. Add
* some jitter of up to 100ms, taken from the
* current system time, to prevent multiple
- * collisions.
+ * collisions. This delay also allows the sink
+ * device to request power role swap and allow
+ * the the accept message to be sent prior to
+ * CMD_DISCOVER_IDENT being sent in the
+ * SRC_READY state.
*/
pd[port].ready_state_holdoff_timer =
- get_time().val + READY_HOLD_OFF_US
+ get_time().val + SRC_READY_HOLD_OFF_US
+ (get_time().le.lo % (100 * MSEC));
/* it'a time to ping regularly the sink */