summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-08-02 16:09:32 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-16 18:15:37 +0000
commitafad18bf59d78ef236cf16d180e8f141cfbb41d7 (patch)
treead069add189dc5649b21ef6c5eb5afb6c60fcc7b
parent5fc7d71623fe7da1faa78844f366888c926b877f (diff)
downloadchrome-ec-afad18bf59d78ef236cf16d180e8f141cfbb41d7.tar.gz
USB MUX: Gate ACK event send on ACK waiting
Currently, the EC doesn't always wait for an ACK from the virtual mux but it will still always send the AP ACK onto the PD task. This means we have some risk of a previous ACK being present in the task events already when we begin a new wait. Remove this risk by only sending the event to the task when there is a task waiting. BRANCH=None BUG=b:186777984 TEST=tast typec.Mode*.manual tests on voxel Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I1e4cf96af838c0cbe4ef549337b304679b59d641 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3078414 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--driver/usb_mux/usb_mux.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c
index c8904134fd..6bf2b2ef23 100644
--- a/driver/usb_mux/usb_mux.c
+++ b/driver/usb_mux/usb_mux.c
@@ -42,6 +42,10 @@ static uint32_t flags[CONFIG_USB_PD_PORT_MAX_COUNT];
/* Coordinate mux accesses by-port among the tasks */
static mutex_t mux_lock[CONFIG_USB_PD_PORT_MAX_COUNT];
+/* Coordinate which task requires an ACK event */
+static task_id_t ack_task[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+ [0 ... CONFIG_USB_PD_PORT_MAX_COUNT - 1] = TASK_ID_INVALID };
+
enum mux_config_type {
USB_MUX_INIT,
USB_MUX_LOW_POWER,
@@ -135,6 +139,9 @@ static int configure_mux(int port,
break;
}
+ if (ack_required)
+ ack_task[port] = task_get_current();
+
/* Apply board specific setting */
if (mux_ptr->board_set)
rv = mux_ptr->board_set(mux_ptr, lcl_state);
@@ -177,6 +184,8 @@ static int configure_mux(int port,
* purposes.
*/
task_wait_event_mask(PD_EVENT_AP_MUX_DONE, 100*MSEC);
+ ack_task[port] = TASK_ID_INVALID;
+
usleep(12.5 * MSEC);
}
}
@@ -512,7 +521,8 @@ static enum ec_status hc_usb_pd_mux_ack(struct host_cmd_handler_args *args)
if (!IS_ENABLED(CONFIG_USB_MUX_AP_ACK_REQUEST))
return EC_RES_INVALID_COMMAND;
- task_set_event(PD_PORT_TO_TASK_ID(p->port), PD_EVENT_AP_MUX_DONE);
+ if (ack_task[p->port] != TASK_ID_INVALID)
+ task_set_event(ack_task[p->port], PD_EVENT_AP_MUX_DONE);
return EC_RES_SUCCESS;
}