diff options
author | Diana Z <dzigterman@chromium.org> | 2021-11-05 13:27:41 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-08 23:36:06 +0000 |
commit | ff45017216f37d00a9588abef0a2609635f0a042 (patch) | |
tree | 8bf171a86235ae7b0aa3b4f9aa7e51038cbb4999 | |
parent | 90667a78ac83443043b255a5e9f28f578b41016b (diff) | |
download | chrome-ec-ff45017216f37d00a9588abef0a2609635f0a042.tar.gz |
Zephyr: Create sysworkq entry in task shim
At the moment, the sysworkq is sharing a task ID with the HOOKS task.
However, it needs its own entry in the dynamic task information in order
to receive events from other tasks. This entry doesn't need a thread
created, but does need an accurate thread ID and a polling entry.
BRANCH=None
BUG=b:195137794
TEST=on gubrush, verify sysworkq can now be notified of TCPC wakes and
charging works
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I89458be79e95f5f3c03ca67609b457c68e249b17
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3263321
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r-- | zephyr/shim/src/tasks.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c index 95fe952976..95322d598c 100644 --- a/zephyr/shim/src/tasks.c +++ b/zephyr/shim/src/tasks.c @@ -83,6 +83,7 @@ struct task_ctx_dyn { #endif /* CONFIG_THREAD_NAME */ #define TASK_TEST(_name, _entry, _parameter, _size) \ CROS_EC_TASK(_name, _entry, _parameter, _size) +/* Note: no static entry is required for sysworkq, as it isn't started here */ const static struct task_ctx_static shimmed_tasks_static[TASK_ID_COUNT] = { CROS_EC_TASK_LIST #ifdef TEST_BUILD @@ -90,7 +91,8 @@ const static struct task_ctx_static shimmed_tasks_static[TASK_ID_COUNT] = { #endif }; -static struct task_ctx_dyn shimmed_tasks_dyn[TASK_ID_COUNT]; +/* In dynamic tasks, allocate one extra spot for the sysworkq */ +static struct task_ctx_dyn shimmed_tasks_dyn[TASK_ID_COUNT + 1]; static int tasks_started; #undef CROS_EC_TASK @@ -98,18 +100,12 @@ static int tasks_started; task_id_t task_get_current(void) { - for (size_t i = 0; i < TASK_ID_COUNT; ++i) { + /* Include sysworkq entry in search for the task ID */ + for (size_t i = 0; i < TASK_ID_COUNT + 1; ++i) { if (shimmed_tasks_dyn[i].zephyr_tid == k_current_get()) 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; } @@ -287,6 +283,7 @@ void set_test_runner_tid(void) void start_ec_tasks(void) { + /* Initialize all EC tasks, which does not include the sysworkq entry */ for (size_t i = 0; i < TASK_ID_COUNT; ++i) { struct task_ctx_dyn *const ctx_dyn = &shimmed_tasks_dyn[i]; const struct task_ctx_static *const ctx_static = @@ -318,6 +315,10 @@ void start_ec_tasks(void) 0, K_NO_WAIT); } + + /* Create an entry for sysworkq we can send events to */ + shimmed_tasks_dyn[TASK_ID_COUNT].zephyr_tid = &k_sys_work_q.thread; + tasks_started = 1; } @@ -330,10 +331,10 @@ int init_signals(const struct device *unused) { ARG_UNUSED(unused); - for (size_t i = 0; i < TASK_ID_COUNT; ++i) { + /* Initialize event structures for all entries, including sysworkq */ + for (size_t i = 0; i < TASK_ID_COUNT + 1; ++i) { struct task_ctx_dyn *const ctx = &shimmed_tasks_dyn[i]; - /* Initialize the new_event structure */ k_poll_signal_init(&ctx->new_event); } |