From 24c5daa48c94cdf6160ee111d346690817238413 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Fri, 22 Jan 2021 08:04:56 -0700 Subject: tcpmv2: ensure the USB mux state is only changed in the PD task The USB mux code does not provide any mutex protection. In addition the virtual USB mux code must be run from the PD task to handle synchronization of the EC_CMD_USB_PD_MUX_ACK host command. Move the USB mux updates into the common power state handler for the type-C state machine. BUG=b:178186846 BRANCH=volteer TEST=make buildall TEST=Connect Gatkex to Voxel, execute EC reboot and verify assertion is fixed. Signed-off-by: Keith Short Change-Id: I0a18d0f5c51eedb4ecb0c275ea1235f7838246a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2644843 Reviewed-by: Abe Levkoy Tested-by: Chiranjeevi Rapolu --- common/usbc/usb_tc_drp_acc_trysrc_sm.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'common/usbc/usb_tc_drp_acc_trysrc_sm.c') diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index f63fd5075f..293f5bf1fa 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -1734,14 +1734,13 @@ __maybe_unused static void handle_new_power_state(int port) * boots up */ dpm_set_mode_exit_request(port); - - /* - * The following function will disconnect both USB and - * DP mux, as the chipset is transitioning to OFF. - */ - set_usb_mux_with_current_data_role(port); } } + /* + * Set the USB mux according to the new power state. If the chipset + * is transitioning to OFF, this disconnects USB and DP mux. + */ + set_usb_mux_with_current_data_role(port); } #if defined(CONFIG_USB_PD_ALT_MODE) && !defined(CONFIG_USB_PD_ALT_MODE_DFP) @@ -3604,7 +3603,6 @@ static void pd_chipset_startup(void) int i; for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - set_usb_mux_with_current_data_role(i); pd_set_dual_role_and_event(i, pd_get_drp_state_in_suspend(), PD_EVENT_UPDATE_DUAL_ROLE -- cgit v1.2.1