summaryrefslogtreecommitdiff
path: root/include
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 /include
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 'include')
-rw-r--r--include/usb_pd.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/include/usb_pd.h b/include/usb_pd.h
index e57f4a4d2a..42771c8de5 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -372,7 +372,7 @@ struct svdm_amode_data {
/* VDM object position */
int opos;
/* mode capabilities specific to SVID amode. */
- struct svid_mode_data *data;
+ const struct svid_mode_data *data;
};
enum hpd_event {
@@ -1987,7 +1987,8 @@ int pd_get_mode_vdo_for_svid(int port, enum tcpci_msg_type type,
* mode, if any exist and no modes succeeded in discovery;
* NULL, otherwise
*/
-struct svid_mode_data *pd_get_next_mode(int port, enum tcpci_msg_type type);
+const struct svid_mode_data *pd_get_next_mode(int port,
+ enum tcpci_msg_type type);
/**
* Return a pointer to the discover identity response structure for this SOP*
@@ -2053,7 +2054,7 @@ uint16_t pd_get_svid(int port, uint16_t svid_idx, enum tcpci_msg_type type);
* @param type SOP* type to retrieve
* @return Pointer to modes of VDO
*/
-uint32_t *pd_get_mode_vdo(int port, uint16_t svid_idx,
+const uint32_t *pd_get_mode_vdo(int port, uint16_t svid_idx,
enum tcpci_msg_type type);
/*
@@ -2144,7 +2145,18 @@ bool pd_discovery_access_validate(int port, enum tcpci_msg_type type);
* @param type Transmit type (SOP, SOP') for discovered information
* @return pointer to PD alternate mode discovery results
*/
-struct pd_discovery *pd_get_am_discovery(int port,
+struct pd_discovery *pd_get_am_discovery_and_notify_access(int port,
+ enum tcpci_msg_type type);
+
+/*
+ * Returns the constant pointer to PD alternate mode discovery results
+ * Note: Caller function is expected to only read the discovery results.
+ *
+ * @param port USB-C port number
+ * @param type Transmit type (SOP, SOP') for discovered information
+ * @return pointer to PD alternate mode discovery results
+ */
+const struct pd_discovery *pd_get_am_discovery(int port,
enum tcpci_msg_type type);
/*