diff options
author | Ting Shen <phoenixshen@google.com> | 2021-08-20 15:29:13 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-08-24 11:30:14 +0000 |
commit | 59fe6576b797d44c8d57c4e28945a4ec137fdf16 (patch) | |
tree | de401c7d567cad6cbdb7ec46ed767d525df49a2c | |
parent | ffc3742a73c7124c62890210f9136908e7b669c1 (diff) | |
download | chrome-ec-59fe6576b797d44c8d57c4e28945a4ec137fdf16.tar.gz |
usb_prl_sm: reduce i2c transactions in FRS path
The get_cc function call is slow (2 i2c transactions in tcpci
implementation) and redundant in FRS path.
Use short-circuiting to remove the function call.
This saves ~2ms on Cherry.
BUG=b:190348051
TEST=Combined with other CLs in the chain, verify FRS workable on Tomato
BRANCH=none
Signed-off-by: Ting Shen <phoenixshen@google.com>
Change-Id: I4161bc3a5ba17eb4983d85dd78465c2e623f46dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3109707
Reviewed-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Eric Yilun Lin <yllin@google.com>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r-- | common/usbc/usb_prl_sm.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index f36248e8ac..0fcc9ba663 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -1229,7 +1229,7 @@ static void prl_tx_snk_pending_entry(const int port) static void prl_tx_snk_pending_run(const int port) { - enum tcpc_cc_voltage_status cc1, cc2; + bool start_tx = false; /* * Wait unit the SRC applies SINK_TX_OK so we can transmit. In FRS mode, @@ -1237,9 +1237,17 @@ static void prl_tx_snk_pending_run(const int port) * gone or the TCPC CC_STATUS update time could be too long to meet * tFRSwapInit. */ - tcpm_get_cc(port, &cc1, &cc2); - if (cc1 == TYPEC_CC_VOLT_RP_3_0 || cc2 == TYPEC_CC_VOLT_RP_3_0 || - pe_in_frs_mode(port)) { + if (pe_in_frs_mode(port)) { + /* shortcut to save some i2c_xfer calls on the FRS path. */ + start_tx = true; + } else { + enum tcpc_cc_voltage_status cc1, cc2; + + tcpm_get_cc(port, &cc1, &cc2); + start_tx = (cc1 == TYPEC_CC_VOLT_RP_3_0 || + cc2 == TYPEC_CC_VOLT_RP_3_0); + } + if (start_tx) { /* * We clear the pending XMIT flag here right before we send so * we can detect if we discarded this message or not |