diff options
author | Fabio Baltieri <fabiobaltieri@google.com> | 2021-04-28 13:40:50 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-28 20:56:13 +0000 |
commit | 3af8cd2203b377cd597b77feb4c07ab7ced2ea6e (patch) | |
tree | d60d5ad9ef5fb3918a0ee1b26627808ae4830330 /zephyr/shim/src | |
parent | ab56320e8afabb76deaab62e60cbe50ecce70858 (diff) | |
download | chrome-ec-3af8cd2203b377cd597b77feb4c07ab7ced2ea6e.tar.gz |
zephyr: shim: use the standard sysworkq for deferred tasks
Zephyr defines a default system wide work queue and allows to add extra
queues, the default queue is only compiled in if used by anything. The
shim queue was the only one originally used until vboot started to use
the sysworkq as well, which added that to the build as well.
The API documentation[1] explicitly discourages custom workqueues if not
strictly necessary. In this case the system one is only used once and
then it's effectively dedicated to the hooks, so there should be
effectively no change is using that one as the only queue, and we get
rid of a custom queue structure, initialization and thread.
Kernel stacks before:
0x200c2928 ec_hooks (real size 704): unused 144 usage 560 / 704 (79 %)
0x200c3488 sysworkq (real size 288): unused 80 usage 208 / 288 (72 %)
Kernel stacks after:
0x200c76f8 sysworkq (real size 704): unused 176 usage 528 / 704 (75 %)
SRAM should go down by about 520 bytes.
[1] https://docs.zephyrproject.org/latest/reference/kernel/threads/workqueue.html#system-workqueue
BUG=b:183748844
BRANCH=none
TEST=build and run on volteer
TEST=kernel stacks on volteer
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change-Id: Ia8ab59bf3e6a5e28fe36ec1e94c65483c4645baa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2854850
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/shim/src')
-rw-r--r-- | zephyr/shim/src/hooks.c | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/zephyr/shim/src/hooks.c b/zephyr/shim/src/hooks.c index b37d1dc750..e0a506c88e 100644 --- a/zephyr/shim/src/hooks.c +++ b/zephyr/shim/src/hooks.c @@ -12,19 +12,6 @@ #include "task.h" #include "timer.h" -/* - * Deferred thread is always the lowest priority, and preemptive if - * available. - */ -#ifdef CONFIG_PREEMPT_ENABLED -#define DEFERRED_THREAD_PRIORITY (CONFIG_NUM_PREEMPT_PRIORITIES - 1) -#else -#define DEFERRED_THREAD_PRIORITY -1 -#endif - -static K_THREAD_STACK_DEFINE(deferred_thread, CONFIG_DEFERRED_STACK_SIZE); -static struct k_work_q deferred_work_queue; - static void deferred_work_queue_handler(struct k_work *work) { struct deferred_data *data = @@ -33,16 +20,6 @@ static void deferred_work_queue_handler(struct k_work *work) data->routine(); } -static int init_deferred_work_queue(const struct device *unused) -{ - ARG_UNUSED(unused); - k_work_q_start(&deferred_work_queue, deferred_thread, - CONFIG_DEFERRED_STACK_SIZE, DEFERRED_THREAD_PRIORITY); - k_thread_name_set(&deferred_work_queue.thread, "ec_hooks"); - return 0; -} -SYS_INIT(init_deferred_work_queue, APPLICATION, 0); - void zephyr_shim_setup_deferred(const struct deferred_data *data) { struct deferred_data *non_const = (struct deferred_data *)data; @@ -59,12 +36,13 @@ int hook_call_deferred(const struct deferred_data *data, int us) if (us == -1) { k_delayed_work_cancel(&non_const->delayed_work); } else if (us >= 0) { - rv = k_delayed_work_submit_to_queue(&deferred_work_queue, - &non_const->delayed_work, - K_USEC(us)); + rv = k_delayed_work_submit(&non_const->delayed_work, + K_USEC(us)); if (rv < 0) - cprints(CC_HOOK, - "Warning: deferred call not submitted."); + cprintf(CC_HOOK, + "Warning: deferred call not submitted, " + "routine=0x%08x, err=%d", + non_const->routine, rv); } else { return EC_ERROR_PARAM2; } |