kernel: Make irq_{un}lock() APIs into a global spinlock in SMP mode

In SMP mode, the idea of a single "IRQ lock" goes away.  Long term,
all usage needs to migrate to spinlocks (which become simple IRQ locks
in the uniprocessor case).  For the near term, we can ease the
migration (at the expense of performance) by providing a compatibility
implementation around a single global lock.

Note that one complication is that the older lock was recursive, while
spinlocks will deadlock if you try to lock them twice.  So we
implement a simple "count" semantic to handle multiple locks.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2018-01-29 09:23:49 -08:00 committed by Anas Nashif
commit 364cbae412
3 changed files with 61 additions and 0 deletions

View file

@ -190,7 +190,12 @@ extern "C" {
*
* @return Lock-out key.
*/
#ifdef CONFIG_SMP
unsigned int _smp_global_lock(void);
#define irq_lock() _smp_global_lock()
#else
#define irq_lock() _arch_irq_lock()
#endif
/**
* @brief Unlock interrupts.
@ -206,7 +211,12 @@ extern "C" {
*
* @return N/A
*/
#ifdef CONFIG_SMP
void _smp_global_unlock(unsigned int key);
#define irq_unlock(key) _smp_global_unlock(key)
#else
#define irq_unlock(key) _arch_irq_unlock(key)
#endif
/**
* @brief Enable an IRQ.