diff options
author | Jett Rink <jettrink@chromium.org> | 2018-08-17 13:33:02 -0600 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-09-07 18:36:36 -0700 |
commit | e8070b44b088e99e38ec741ed8091c7e4a033bef (patch) | |
tree | dedc7bce6201fba05b92f4e48ec4405366fbc76b /driver/tcpm/fusb302.c | |
parent | e6a13850e9b5a6b2889549c03caddf2944e7fc63 (diff) | |
download | chrome-ec-e8070b44b088e99e38ec741ed8091c7e4a033bef.tar.gz |
tcpm: add TCPC RX circular buffer in EC
The alert line for TCPC will stay asserted as long as there are RX
messages for the TCPM (i.e. EC) to pull from the TCPC. We should clear
all of the RX messages we know about during a single alert handling
session.
This CL can stand on its own, but it is a part of a CL stack that will
tighten the critical section of time between received messages from the
TCPC and sending follow up message out through the TCPC.
See go/usb-pd-slow-response-time for more details.
BRANCH=none
BUG=b:112088135,b:112344286,b:111909282,b:112848644,b:113124761
BUG=b:113057273,b:112825261
TEST=Reduces reset issue in most cases for phaser, bobba. Does not seem to
adversely affect state machine negotiation. Full CL stack consistently
sends a REQUEST at 18ms after a SRC_CAP GoodCRC, which is well below the
24 ms threshold we need to be under for USB PD spec compliance.
Also testing pd_suspend scenario manually and EC was responsive after
port 1 suspend because of "bad behavior"
Change-Id: I1654b46400e9881f2927a5f6d6ace589edd182de
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1185727
Diffstat (limited to 'driver/tcpm/fusb302.c')
-rw-r--r-- | driver/tcpm/fusb302.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/driver/tcpm/fusb302.c b/driver/tcpm/fusb302.c index da5d32e206..68cf14774d 100644 --- a/driver/tcpm/fusb302.c +++ b/driver/tcpm/fusb302.c @@ -699,7 +699,7 @@ static int fusb302_rx_fifo_is_empty(int port) (reg & TCPC_REG_STATUS1_RX_EMPTY); } -static int fusb302_tcpm_get_message(int port, uint32_t *payload, int *head) +static int fusb302_tcpm_get_message_raw(int port, uint32_t *payload, int *head) { /* * This is the buffer that will get the burst-read data @@ -712,10 +712,6 @@ static int fusb302_tcpm_get_message(int port, uint32_t *payload, int *head) uint8_t buf[32]; int rv, len; - /* If our FIFO is empty then we have no packet */ - if (fusb302_rx_fifo_is_empty(port)) - return EC_ERROR_UNKNOWN; - /* Read until we have a non-GoodCRC packet or an empty FIFO */ do { buf[0] = TCPC_REG_FIFOS; @@ -762,13 +758,6 @@ static int fusb302_tcpm_get_message(int port, uint32_t *payload, int *head) memcpy(payload, buf, len); } - /* - * If our FIFO is non-empty then we may have a packet, we may get - * fewer interrupts than packets due to interrupt latency. - */ - if (!fusb302_rx_fifo_is_empty(port)) - task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_RX, 0); - return rv; } @@ -933,8 +922,9 @@ void fusb302_tcpc_alert(int port) /* Packet received and GoodCRC sent */ /* (this interrupt fires after the GoodCRC finishes) */ if (state[port].rx_enable) { - task_set_event(PD_PORT_TO_TASK_ID(port), - PD_EVENT_RX, 0); + /* Pull all RX messages from TCPC into EC memory */ + while (!fusb302_rx_fifo_is_empty(port)) + tcpm_enqueue_message(port); } else { /* flush rx fifo if rx isn't enabled */ fusb302_flush_rx_fifo(port); @@ -971,7 +961,7 @@ const struct tcpm_drv fusb302_tcpm_drv = { .set_vconn = &fusb302_tcpm_set_vconn, .set_msg_header = &fusb302_tcpm_set_msg_header, .set_rx_enable = &fusb302_tcpm_set_rx_enable, - .get_message = &fusb302_tcpm_get_message, + .get_message_raw = &fusb302_tcpm_get_message_raw, .transmit = &fusb302_tcpm_transmit, .tcpc_alert = &fusb302_tcpc_alert, }; |