summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatryk Duda <pdk@semihalf.com>2020-06-17 12:00:09 +0200
committerCommit Bot <commit-bot@chromium.org>2020-06-22 13:08:24 +0000
commit23f039077e86e6da42705f8e7305c2627bac54db (patch)
treec1d8ac8191128ec267a8fe644bca244e57c2ee62
parentbf8b2dd9996bc633cec2942ebcdd1118313af654 (diff)
downloadchrome-ec-23f039077e86e6da42705f8e7305c2627bac54db.tar.gz
Avoid deadlock when calling pd_set_suspend()
Calling pd_set_suspend() from PD task we are going to suspend results in deadlock, because pd_set_suspend() waits until it reaches Disabled state. This fix adds early return after setting appropriate flags when task we are going to disable is running task BUG=none BRANCH=none TEST=make buildall -j Change-Id: I295677908db8a24215b010e47dbb56e586bbb041 Signed-off-by: Patryk Duda <pdk@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250679 Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index c3554b475d..9c3e732634 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -813,6 +813,14 @@ void pd_set_suspend(int port, int suspend)
int wait = 0;
TC_SET_FLAG(port, TC_FLAGS_SUSPEND);
+
+ /*
+ * Avoid deadlock when running from task
+ * which we are going to suspend
+ */
+ if (PD_PORT_TO_TASK_ID(port) == task_get_current())
+ return;
+
task_wake(PD_PORT_TO_TASK_ID(port));
/* Sleep this task if we are not suspended */