Commit cf60dfb7 authored by Rahix's avatar Rahix
Browse files

fix(lifecycle): Fix epic_sleep() calls delaying load of new app

When core 1 repeatedly calls `epic_sleep()`, this could delay an
epic_load() from core 0 because the reset interrupt can only be
delivered after such a call completed.

To work around this, add calls into `do_load()` to notify the dispatcher
task that it should return early from calls like `epic_sleep()`.  This
gets a bit tricky because the dispatcher task also uses
`ulTaskNotifyTake()` to wake up when new API calls arrive.  To make sure
we still break out of `epic_sleep()`, we need to call
`xTaskNotifyGive()` twice in the wait loop.
parent 0f4a515a
Pipeline #5278 passed with stages
in 43 seconds
......@@ -109,6 +109,9 @@ static int do_load(struct load_info *info)
return -EPERM;
}
/* Signal the dispatcher to return early from applicable API calls. */
xTaskNotifyGive(dispatcher_task_id);
mutex_lock(&api_mutex);
if (info->do_reset) {
......@@ -126,9 +129,17 @@ static int do_load(struct load_info *info)
* call.
*/
while (!core1_is_ready()) {
/*
* Wake up the dispatcher task prematurely. This is needed so
* the second xTaskNotifyGive() below can then break out the
* dispatcher from e.g. an epic_sleep() call.
*/
xTaskNotifyGive(dispatcher_task_id);
mutex_unlock(&api_mutex);
/* Sleep so the dispatcher task can take the lock. */
vTaskDelay(8);
/* Signal the dispatcher to return early from applicable API calls. */
xTaskNotifyGive(dispatcher_task_id);
mutex_lock(&api_mutex);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment