kernel: fix arch_mem_coherent() call in spinlock
The call to arch_mem_coherent() inside spinlock.h when spinlock validation and memory coherence enabled is causing build error as spinlock.h does not include kernel_arch_func.h directly. However, simply including that file does not work either as this creates the chicken-or-egg in the chain of include files. In order to make spin validation work with kernel coherence enabled, a separate function is created to break the circular dependencies of include files. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
079bc64c16
commit
d1495e98e2
2 changed files with 14 additions and 1 deletions
|
@ -66,6 +66,11 @@ bool z_spin_lock_valid(struct k_spinlock *l);
|
|||
bool z_spin_unlock_valid(struct k_spinlock *l);
|
||||
void z_spin_lock_set_owner(struct k_spinlock *l);
|
||||
BUILD_ASSERT(CONFIG_MP_NUM_CPUS <= 4, "Too many CPUs for mask");
|
||||
|
||||
# ifdef CONFIG_KERNEL_COHERENCE
|
||||
bool z_spin_lock_mem_coherent(struct k_spinlock *l);
|
||||
# endif /* CONFIG_KERNEL_COHERENCE */
|
||||
|
||||
#endif /* CONFIG_SPIN_VALIDATE */
|
||||
|
||||
/**
|
||||
|
@ -123,7 +128,7 @@ static ALWAYS_INLINE k_spinlock_key_t k_spin_lock(struct k_spinlock *l)
|
|||
#ifdef CONFIG_SPIN_VALIDATE
|
||||
__ASSERT(z_spin_lock_valid(l), "Recursive spinlock %p", l);
|
||||
# ifdef KERNEL_COHERENCE
|
||||
__ASSERT_NO_MSG(arch_mem_coherent(l));
|
||||
__ASSERT_NO_MSG(z_spin_lock_mem_coherent(l));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -883,6 +883,14 @@ void z_spin_lock_set_owner(struct k_spinlock *l)
|
|||
{
|
||||
l->thread_cpu = _current_cpu->id | (uintptr_t)_current;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KERNEL_COHERENCE
|
||||
bool z_spin_lock_mem_coherent(struct k_spinlock *l)
|
||||
{
|
||||
return arch_mem_coherent((void *)l);
|
||||
}
|
||||
#endif /* CONFIG_KERNEL_COHERENCE */
|
||||
|
||||
#endif /* CONFIG_SPIN_VALIDATE */
|
||||
|
||||
int z_impl_k_float_disable(struct k_thread *thread)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue