From cf8f65d34af0aff42e66bd395a74adf2874bd200 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Sat, 10 Jan 2015 12:03:17 -0800 Subject: [PATCH] pd: make VDO responses faster Allow VDO responses to be sent faster by taking out the check for incoming packet when a VDO is pending. This check isn't needed because we already check if the PD state machine is busy sending something. With this change, the turn around time for responding to Discover Identity on zinger is ~200us. BUG=chrome-os-partner:35327 BRANCH=samus TEST=loaded onto zinger and used twinkie to verify that discover identity is responded to in ~200us every time. used ectool to perform remote update on zinger, now takes ~18s (compared to ~55s). Also, used following bash loop to constantly sent PD voltage requests: while true; do dut-control "usbpd_uart_cmd:pd 1 dev 5"; sleep 0.3; dut-control "usbpd_uart_cmd:pd 1 dev 20"; sleep 0.3; done Used bash loop while updating zinger via ectool. I programmed zinger ~50 times and verified: - we never missed a PD voltage request - never got any PD protocol or phy layer errors (no collisions) - zinger successfully jumped to RW after each (no packets missed) Note: sending any other PD traffic while programming zinger does obviously slow down zinger update (~30s with my bash loop above). Change-Id: I94d1ac01440d096671972fa9c21c149ea432863f Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/240150 Reviewed-by: Todd Broch Reviewed-by: Vincent Palatin --- common/usb_pd_protocol.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index cedf027094..72094f9912 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1470,7 +1470,7 @@ static uint64_t vdm_get_ready_timeout(uint32_t vdm_hdr) return timeout; } -static void pd_vdm_send_state_machine(int port, int incoming_packet) +static void pd_vdm_send_state_machine(int port) { int res; uint16_t header; @@ -1487,7 +1487,7 @@ static void pd_vdm_send_state_machine(int port, int incoming_packet) * if there's traffic or we're not in PDO ready state don't send * a VDM. */ - if (incoming_packet || pdo_busy(port)) + if (pdo_busy(port)) break; /* Prepare and send VDM */ @@ -1723,7 +1723,7 @@ void pd_task(void) while (1) { /* process VDM messages last */ - pd_vdm_send_state_machine(port, incoming_packet); + pd_vdm_send_state_machine(port); /* monitor for incoming packet if in a connected state */ if (pd_is_connected(port) && pd_comm_enabled)