summaryrefslogtreecommitdiff
path: root/common/usbc/tbt_alt_mode.c
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 /common/usbc/tbt_alt_mode.c
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 'common/usbc/tbt_alt_mode.c')
-rw-r--r--common/usbc/tbt_alt_mode.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/common/usbc/tbt_alt_mode.c b/common/usbc/tbt_alt_mode.c
index 0509add1f8..73e2796345 100644
--- a/common/usbc/tbt_alt_mode.c
+++ b/common/usbc/tbt_alt_mode.c
@@ -218,7 +218,7 @@ static void tbt_retry_enter_mode(int port)
/* Send Exit Mode to SOP''(if supported), or SOP' */
static void tbt_active_cable_exit_mode(int port)
{
- struct pd_discovery *disc;
+ const struct pd_discovery *disc;
disc = pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME);
@@ -230,7 +230,7 @@ static void tbt_active_cable_exit_mode(int port)
bool tbt_cable_entry_required_for_usb4(int port)
{
- struct pd_discovery *disc_sop_prime;
+ const struct pd_discovery *disc_sop_prime;
union tbt_mode_resp_cable cable_mode_resp;
/* Request to enter Thunderbolt mode for the cable prior to entering
@@ -262,7 +262,7 @@ bool tbt_cable_entry_required_for_usb4(int port)
void intel_vdm_acked(int port, enum tcpci_msg_type type, int vdo_count,
uint32_t *vdm)
{
- struct pd_discovery *disc;
+ const struct pd_discovery *disc;
const uint8_t vdm_cmd = PD_VDO_CMD(vdm[0]);
int opos_sop, opos_sop_prime;
union tbt_mode_resp_cable cable_mode_resp;