summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2018-06-27 10:48:02 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-06-27 22:07:11 -0700
commit7d55645209d726c4140b439a6ea0de3957f694f8 (patch)
tree2803499fa477700a84b9ce0d72cb53d1ed1fb268 /core
parent69153048757481a312c0f9f4747ed45565a30c1e (diff)
downloadchrome-ec-7d55645209d726c4140b439a6ea0de3957f694f8.tar.gz
core/host/task: Fix task_set_event
task_set_event is expected to _add_ the event bit to the current mask, not reset the whole mask. Also, fix all operations to use atomics. BRANCH=none BUG=chromium:854975 TEST=No more timeouts when running usb_pd fuzzing tests. Change-Id: Id17428e15f6fb8b52891bed33281f866fbc2be8f Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1116624 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/host/task.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/host/task.c b/core/host/task.c
index 500e18413d..870f8c3dc3 100644
--- a/core/host/task.c
+++ b/core/host/task.c
@@ -183,7 +183,7 @@ pthread_t task_get_thread(task_id_t tskid)
uint32_t task_set_event(task_id_t tskid, uint32_t event, int wait)
{
- tasks[tskid].event = event;
+ atomic_or(&tasks[tskid].event, event);
if (wait)
return task_wait_event(-1);
return 0;
@@ -202,8 +202,7 @@ uint32_t task_wait_event(int timeout_us)
pthread_cond_wait(&tasks[tid].resume, &run_lock);
/* Resume */
- ret = tasks[tid].event;
- tasks[tid].event = 0;
+ ret = atomic_read_clear(&tasks[tid].event);
pthread_mutex_unlock(&interrupt_lock);
return ret;
}
@@ -231,7 +230,8 @@ uint32_t task_wait_event_mask(uint32_t event_mask, int timeout_us)
/* Re-post any other events collected */
if (events & ~event_mask)
- tasks[task_get_current()].event |= events & ~event_mask;
+ atomic_or(&tasks[task_get_current()].event,
+ events & ~event_mask);
return events & event_mask;
}