From 673255588bbf585aa3f9b79defe88dd85025eb36 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Tue, 18 Nov 2014 10:52:03 -0800 Subject: [PATCH] pd: implement SenderResponseTimer on request messages Add tSenderResponse timeout to waiting for response from a request message. If timeout triggers, send hard reset. BUG=chrome-os-partner:33687 BRANCH=samus TEST=test with zinger that we can negotiate normally. then modify zinger code to not send any response when it receives a request and see that samus sends hard reset from PD_STATE_SNK_REQUESTED. Signed-off-by: Alec Berg Change-Id: If147d809cfe185ec714e292a4814fbbfb50af04b Reviewed-on: https://chromium-review.googlesource.com/230521 Reviewed-by: Todd Broch Reviewed-by: Vincent Palatin --- common/usb_pd_protocol.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 81f4df1f60..e32ea6ea5c 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1653,7 +1653,11 @@ void pd_task(void) break; case PD_STATE_SRC_NEGOCIATE: /* wait for a "Request" message */ - timeout = 500*MSEC; + if (pd[port].last_state != pd[port].task_state) + set_state_timeout(port, + get_time().val + + PD_T_SENDER_RESPONSE, + PD_STATE_HARD_RESET); break; case PD_STATE_SRC_ACCEPTED: /* Accept sent, wait for enabling the new voltage */ @@ -1903,9 +1907,14 @@ void pd_task(void) } break; case PD_STATE_SNK_REQUESTED: - /* Ensure the power supply actually becomes ready */ - hard_reset_count = 0; - timeout = 10 * MSEC; + /* Wait for ACCEPT or REJECT */ + if (pd[port].last_state != pd[port].task_state) { + hard_reset_count = 0; + set_state_timeout(port, + get_time().val + + PD_T_SENDER_RESPONSE, + PD_STATE_HARD_RESET); + } break; case PD_STATE_SNK_TRANSITION: /* Wait for PS_RDY */