summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/src
diff options
context:
space:
mode:
authorDeepti Deshatty <deepti.deshatty@intel.corp-partner.google.com>2021-09-02 20:05:56 +0530
committerCommit Bot <commit-bot@chromium.org>2021-09-20 16:50:23 +0000
commit438f1748043d9b9869a8986ac06208e0102554a8 (patch)
tree58e8107321656bd22deef4a3c7baaeffa2a4a1cb /zephyr/test/drivers/src
parentc1ef7c696c45632503165cbabb1e37cbabfbe448 (diff)
downloadchrome-ec-438f1748043d9b9869a8986ac06208e0102554a8.tar.gz
usbpd: implement new api to access PD discovery data
API pd_get_am_discovery() sets the lock (task access bit) to keep track of EC tasks accessing the pd port discovery data. If any of the task access bits are set,EC host task typec discovery handler will return EC_RES_BUSY to host, indicating discovery data is modified while copying port discovery data to the host. Hence the lock/task access bit should be set only when the port discovery data is modified by any tasks. Setting of lock/task access is removed from pd_get_am_discovery() and implemented new api pd_get_am_discovery_and_notify_access() for this. pd_get_am_discovery() proto type is changed to return 'constant pointer' which forces developers to use pd_get_am_discovery_and_notify_access() when they intend to access and modify discovery data. summary of changes implemented. - Remove setting of task access bit from pd_get_am_discovery(). - modify pd_get_am_discovery() prototype to return constant pointer. - implement new api pd_get_am_discovery_and_notify_access() - Replace calls to pd_get_am_discovery() with new api wherever discovery data is accessed and modified. BRANCH=none BUG=b:197466819 b:190390784 TEST=Verified 50 cold boot cycling with TBT device attached. Device detected in every cycle. Signed-off-by: Deepti Deshatty <deepti.deshatty@intel.corp-partner.google.com> Change-Id: I5b6f1f2b91d92ddbe58f3bf994f684abee948c02 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3139858 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
Diffstat (limited to 'zephyr/test/drivers/src')
-rw-r--r--zephyr/test/drivers/src/bb_retimer.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/zephyr/test/drivers/src/bb_retimer.c b/zephyr/test/drivers/src/bb_retimer.c
index 38111ce4e5..eb48fb0789 100644
--- a/zephyr/test/drivers/src/bb_retimer.c
+++ b/zephyr/test/drivers/src/bb_retimer.c
@@ -90,7 +90,8 @@ static void test_bb_set_state(void)
exp_conn, conn);
/* Test USB3 gen2 mode */
- disc = pd_get_am_discovery(USBC_PORT_C1, TCPCI_MSG_SOP_PRIME);
+ disc = pd_get_am_discovery_and_notify_access(
+ USBC_PORT_C1, TCPCI_MSG_SOP_PRIME);
disc->identity.product_t1.p_rev20.ss = USB_R20_SS_U31_GEN1_GEN2;
prl_set_rev(USBC_PORT_C1, TCPCI_MSG_SOP_PRIME, PD_REV30);
zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
@@ -210,7 +211,8 @@ static void test_bb_set_dfp_state(void)
exp_conn, conn);
/* Set active cable type */
- disc = pd_get_am_discovery(USBC_PORT_C1, TCPCI_MSG_SOP_PRIME);
+ disc = pd_get_am_discovery_and_notify_access(
+ USBC_PORT_C1, TCPCI_MSG_SOP_PRIME);
disc->identity.idh.product_type = IDH_PTYPE_ACABLE;
disc->identity.product_t2.a2_rev30.active_elem = ACTIVE_RETIMER;
prl_set_rev(USBC_PORT_C1, TCPCI_MSG_SOP_PRIME, PD_REV30);
@@ -230,7 +232,8 @@ static void test_bb_set_dfp_state(void)
disc->svids[0].mode_vdo[0] = cable_resp.raw_value;
/* Set device VDO */
- dev_disc = pd_get_am_discovery(USBC_PORT_C1, TCPCI_MSG_SOP);
+ dev_disc = pd_get_am_discovery_and_notify_access(
+ USBC_PORT_C1, TCPCI_MSG_SOP);
dev_disc->svid_cnt = 1;
dev_disc->svids[0].svid = USB_VID_INTEL;
dev_disc->svids[0].discovery = PD_DISC_COMPLETE;