summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2021-06-11 11:38:55 -0600
committerCommit Bot <commit-bot@chromium.org>2021-06-11 22:37:33 +0000
commit3ba97e28cf05c1cca689e28ed57245f1335b79dd (patch)
tree5ae8af7c2ccc199d4510256eb0a847b0f944e22e
parent963cf28040860313986d5a0a842ba03d1b6ab215 (diff)
downloadchrome-ec-3ba97e28cf05c1cca689e28ed57245f1335b79dd.tar.gz
zephyr: Fix the hook task priority check
On Zephyr, hook calls are run on two threads: HOOKS_TICK and HOOKS_SECOND run in the HOOKS shimmed task, deferred calls run in the system work queue. Both threads must be lower priority (indicated by a larger numeric value) than all the other shimmed tasks. Verify these threads have a priority value of at least (TASK_ID_COUNT - 1). BUG=b:190413210 BRANCH=none TEST=zmake testall TEST=On lazor, verify false error about hooks task priority is gone Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Icb09b866ba8ac6f1ec4c17de79ea281db4954d0e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2956828 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
-rw-r--r--zephyr/shim/src/hooks.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/zephyr/shim/src/hooks.c b/zephyr/shim/src/hooks.c
index e60a12a602..e11b28e88a 100644
--- a/zephyr/shim/src/hooks.c
+++ b/zephyr/shim/src/hooks.c
@@ -68,11 +68,15 @@ void hook_notify(enum hook_type type)
static void check_hook_task_priority(k_tid_t thread)
{
- if (k_thread_priority_get(thread) != LOWEST_THREAD_PRIORITY)
+ /*
+ * Numerically lower priorities take precedence, so verify the hook
+ * related threads cannot preempt any of the shimmed tasks.
+ */
+ if (k_thread_priority_get(thread) < (TASK_ID_COUNT - 1))
cprintf(CC_HOOK,
- "ERROR: %s has priority %d but must be priority %d\n",
+ "ERROR: %s has priority %d but must be >= %d\n",
k_thread_name_get(thread),
- k_thread_priority_get(thread), LOWEST_THREAD_PRIORITY);
+ k_thread_priority_get(thread), (TASK_ID_COUNT - 1));
}
void hook_task(void *u)