From c0933f00b15d63a0a50e4faeed43fb3a60d48390 Mon Sep 17 00:00:00 2001 From: Todd Broch Date: Fri, 2 Jan 2015 21:02:33 -0800 Subject: [PATCH] pd: Bugfix for pending VDM in disconnected state. Commit f993fe3c refactored pd_vdm_send_state_machine to allow well timed PD disconnects to be acceptable. This violates specification as VDMs certainly shouldn't proceed without an explicit contract and mode entry. CL reverts the logic to make 'ready' VDM in shadow of disconnect an error. Signed-off-by: Todd Broch BRANCH=samus BUG=chrome-os-partner:33947 TEST=manual, compiles when disconnect occurs 'ready' VDM transistions to vdm_state VDM_STATE_ERR_BUSY instead of staying 'ready' Change-Id: Ic8e96506df365a72053713a806356c4afcfde26d Reviewed-on: https://chromium-review.googlesource.com/238292 Reviewed-by: Alec Berg Tested-by: Todd Broch Commit-Queue: Todd Broch --- common/usb_pd_protocol.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 9d9c9d2178..86ccbeb0ad 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1404,21 +1404,19 @@ static void pd_vdm_send_state_machine(int port, int incoming_packet) switch (pd[port].vdm_state) { case VDM_STATE_READY: - /* - * if there's traffic or we're not in PDO ready state don't send - * a VDM */ - if (incoming_packet || pdo_busy(port)) - break; - - /* - * Only transmit VDM if connected. Should follow busy logic - * (above) as custom VDMs can leave port in disconnected state - */ + /* Only transmit VDM if connected. */ if (!pd_is_connected(port)) { pd[port].vdm_state = VDM_STATE_ERR_BUSY; break; } + /* + * if there's traffic or we're not in PDO ready state don't send + * a VDM. + */ + if (incoming_packet || pdo_busy(port)) + break; + /* Prepare and send VDM */ header = PD_HEADER(PD_DATA_VENDOR_DEF, pd[port].power_role, pd[port].data_role, pd[port].msg_id,