diff options
author | Tomasz Michalec <tm@semihalf.com> | 2021-06-11 16:38:44 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-06-30 08:49:31 +0000 |
commit | d92274769d4590fb49fae2c9a478342d56b96834 (patch) | |
tree | 31585cd508793bb5a98e4b68b05886d4ccf3b7f0 /zephyr | |
parent | 8f98839255b6bdccd21610454818b0d75e40414e (diff) | |
download | chrome-ec-d92274769d4590fb49fae2c9a478342d56b96834.tar.gz |
zephyr: tasks: fix task id for deferred calls
In Zephyr deferred calls are run in k_sys_work_queue context instead of
thread running hook_task(). Because of that shimmed task_get_current() is
modfied to return TASK_ID_HOOKS if run from k_sys_work_queue context.
BUG=b:190727776
TEST=make hosttest
BRANCH=none
Signed-off-by: Tomasz Michalec <tm@semihalf.com>
Change-Id: I9e15627df8dce6b0829ad872150cbe2318330f28
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2953225
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr')
-rw-r--r-- | zephyr/shim/src/tasks.c | 8 | ||||
-rw-r--r-- | zephyr/test/tasks/prj.conf | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c index f0805ed09b..340c7415b8 100644 --- a/zephyr/shim/src/tasks.c +++ b/zephyr/shim/src/tasks.c @@ -91,6 +91,14 @@ task_id_t task_get_current(void) return i; } } + +#if defined(HAS_TASK_HOOKS) + /* Hooks ID should be returned for deferred calls */ + if (k_current_get() == &k_sys_work_q.thread) { + return TASK_ID_HOOKS; + } +#endif /* HAS_TASK_HOOKS */ + __ASSERT(false, "Task index out of bound"); return 0; } diff --git a/zephyr/test/tasks/prj.conf b/zephyr/test/tasks/prj.conf index 77e8ab9b0c..f5ddf014a7 100644 --- a/zephyr/test/tasks/prj.conf +++ b/zephyr/test/tasks/prj.conf @@ -6,3 +6,4 @@ CONFIG_ZTEST=y CONFIG_HAS_TEST_TASKS=y CONFIG_PLATFORM_EC=y CONFIG_CROS_EC=y +CONFIG_HAS_TASK_HOOKS=n |