kernel: sychronize irq_offload() access
Entering irq_offload() on multiple CPUs can cause difficult to debug/reproduce crashes. Demote irq_offload() to non-inline (it never needed to be inline anyway) and wrap the arch call in a semaphore. Some tests which were unnecessarily killing threads have been fixed; these threads exit by themselves anyway and we won't leave the semaphore dangling. The definition of z_arch_irq_offload() moved to arch_interface.h as it only gets called by kernel C code. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
38216b100c
commit
e09a0255da
|
@ -15,9 +15,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <arch/cpu.h>
|
||||
|
||||
#ifdef CONFIG_IRQ_OFFLOAD
|
||||
typedef void (*irq_offload_routine_t)(void *parameter);
|
||||
|
||||
/**
|
||||
* @brief Run a function in interrupt context
|
||||
*
|
||||
|
@ -30,10 +30,7 @@ extern "C" {
|
|||
* @param parameter Argument to pass to the function when it is run as an
|
||||
* interrupt
|
||||
*/
|
||||
static inline void irq_offload(irq_offload_routine_t routine, void *parameter)
|
||||
{
|
||||
arch_irq_offload(routine, parameter);
|
||||
}
|
||||
void irq_offload(irq_offload_routine_t routine, void *parameter);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <stddef.h>
|
||||
#include <zephyr/types.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <irq_offload.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <debug/tracing.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <irq_offload.h>
|
||||
|
||||
static struct k_spinlock lock;
|
||||
|
||||
|
@ -903,3 +904,14 @@ static inline void z_vrfy_k_thread_abort(k_tid_t thread)
|
|||
#include <syscalls/k_thread_abort_mrsh.c>
|
||||
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
#ifdef CONFIG_IRQ_OFFLOAD
|
||||
static K_SEM_DEFINE(offload_sem, 1, 1);
|
||||
|
||||
void irq_offload(irq_offload_routine_t routine, void *parameter)
|
||||
{
|
||||
k_sem_take(&offload_sem, K_FOREVER);
|
||||
arch_irq_offload(routine, parameter);
|
||||
k_sem_give(&offload_sem);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -283,8 +283,6 @@ void test_sem_take_timeout(void)
|
|||
ret_value = sys_sem_take(&simple_sem, SEM_TIMEOUT);
|
||||
zassert_true(ret_value == 0,
|
||||
"sys_sem_take failed when its shouldn't have");
|
||||
|
||||
k_thread_abort(&sem_tid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -309,8 +307,6 @@ void test_sem_take_timeout_forever(void)
|
|||
ret_value = sys_sem_take(&simple_sem, K_FOREVER);
|
||||
zassert_true(ret_value == 0,
|
||||
"sys_sem_take failed when its shouldn't have");
|
||||
|
||||
k_thread_abort(&sem_tid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -329,8 +325,6 @@ void test_sem_take_timeout_isr(void)
|
|||
ret_value = sys_sem_take(&simple_sem, SEM_TIMEOUT);
|
||||
zassert_true(ret_value == 0,
|
||||
"sys_sem_take failed when its shouldn't have");
|
||||
|
||||
k_thread_abort(&sem_tid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -326,8 +326,6 @@ void test_sem_take_timeout_isr(void)
|
|||
ret_value = k_sem_take(&simple_sem, SEM_TIMEOUT);
|
||||
zassert_true(ret_value == 0,
|
||||
"k_sem_take failed when its shouldn't have");
|
||||
k_thread_abort(&sem_tid);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue