From 7b1a0dc7959e83d202fefb1a4c3079ec2edd35e5 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Wed, 20 Aug 2014 18:27:59 -0700 Subject: [PATCH] pd: fix bug in pd transmit retry mechanism This fixes a bug in the PD transmit retry mechanism. In the retry mechanism, we were assuming that only a pd rx interrupt will wake up this event. But, there are other events that could potentially wake us up, so we need to check to make sure that pd rx started when we first wake up. BUG=chrome-os-partner:30135 BRANCH=none TEST=load onto samus and zinger. run "pd 0 flash rw_hash" a bunch of times manually from the console. Observe that we nearly always fail the first receive, but succeed on next try, which prevents us from dropping the negotiation. Change-Id: I5f7261176c151c3185d76aa374b9b83ac9df9a7d Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/213369 Reviewed-by: Todd Broch Tested-by: Todd Broch --- common/usb_pd_protocol.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index bf77755941..91575052fe 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -371,6 +371,14 @@ static int send_validate_message(int port, uint16_t header, if (task_wait_event(USB_PD_RX_TMOUT_US) == TASK_EVENT_TIMER) continue; + /* + * Make sure we woke up due to rx recd, otherwise + * we need to manually start + */ + if (!pd_rx_started(port)) { + pd_rx_disable_monitoring(port); + pd_rx_start(port); + } } else { /* starting waiting for GoodCrc */ pd_rx_start(port);