arch, boards, drivers, include, sched, wireless: Change spinlock APIs.

Summary:
- This commit changes spinlock APIs (spin_lock_irqsave/spin_unlock_irqrestore)
- In the previous implementation, the global spinlock (i.e. g_irq_spin) was used.
- This commit allows to use caller specific spinlock but also supports to use
  g_irq_spin for backword compatibility (In this case, NULL must be specified)

Impact:
- None

Testing:
- Tested with the following configurations
- spresnse:wifi, spresense:wifi_smp
- esp32-devkitc:smp (QEMU), sabre6-quad:smp (QEMU)
- maxi-bit:smp (QEMU), sim:smp
- stm32f4discovery:wifi

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa
2021-02-08 09:21:26 +09:00
committed by Xiang Xiao
parent f63c189a17
commit d87f350831
70 changed files with 452 additions and 406 deletions
+12 -12
View File
@@ -52,10 +52,10 @@ bt_atomic_t bt_atomic_incr(FAR bt_atomic_t *ptr)
irqstate_t flags;
bt_atomic_t value;
flags = spin_lock_irqsave();
flags = spin_lock_irqsave(NULL);
value = *ptr;
*ptr = value + 1;
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
return value;
}
@@ -65,10 +65,10 @@ bt_atomic_t bt_atomic_decr(FAR bt_atomic_t *ptr)
irqstate_t flags;
bt_atomic_t value;
flags = spin_lock_irqsave();
flags = spin_lock_irqsave(NULL);
value = *ptr;
*ptr = value - 1;
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
return value;
}
@@ -78,10 +78,10 @@ bt_atomic_t bt_atomic_setbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno)
irqstate_t flags;
bt_atomic_t value;
flags = spin_lock_irqsave();
flags = spin_lock_irqsave(NULL);
value = *ptr;
*ptr = value | (1 << bitno);
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
return value;
}
@@ -91,10 +91,10 @@ bt_atomic_t bt_atomic_clrbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno)
irqstate_t flags;
bt_atomic_t value;
flags = spin_lock_irqsave();
flags = spin_lock_irqsave(NULL);
value = *ptr;
*ptr = value & ~(1 << bitno);
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
return value;
}
@@ -104,10 +104,10 @@ bool bt_atomic_testsetbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno)
irqstate_t flags;
bt_atomic_t value;
flags = spin_lock_irqsave();
flags = spin_lock_irqsave(NULL);
value = *ptr;
*ptr = value | (1 << bitno);
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
return (value & (1 << bitno)) != 0;
}
@@ -117,10 +117,10 @@ bool bt_atomic_testclrbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno)
irqstate_t flags;
bt_atomic_t value;
flags = spin_lock_irqsave();
flags = spin_lock_irqsave(NULL);
value = *ptr;
*ptr = value & ~(1 << bitno);
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
return (value & (1 << bitno)) != 0;
}
+10 -10
View File
@@ -243,7 +243,7 @@ FAR struct bt_buf_s *bt_buf_alloc(enum bt_buf_type_e type,
* then try the list of messages reserved for interrupt handlers
*/
flags = spin_lock_irqsave(); /* Always necessary in SMP mode */
flags = spin_lock_irqsave(NULL); /* Always necessary in SMP mode */
if (up_interrupt_context())
{
#if CONFIG_BLUETOOTH_BUFFER_PREALLOC > CONFIG_BLUETOOTH_BUFFER_IRQRESERVE
@@ -254,7 +254,7 @@ FAR struct bt_buf_s *bt_buf_alloc(enum bt_buf_type_e type,
buf = g_buf_free;
g_buf_free = buf->flink;
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
pool = POOL_BUFFER_GENERAL;
}
else
@@ -267,13 +267,13 @@ FAR struct bt_buf_s *bt_buf_alloc(enum bt_buf_type_e type,
buf = g_buf_free_irq;
g_buf_free_irq = buf->flink;
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
pool = POOL_BUFFER_IRQ;
}
else
#endif
{
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
return NULL;
}
}
@@ -290,7 +290,7 @@ FAR struct bt_buf_s *bt_buf_alloc(enum bt_buf_type_e type,
buf = g_buf_free;
g_buf_free = buf->flink;
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
pool = POOL_BUFFER_GENERAL;
}
else
@@ -300,7 +300,7 @@ FAR struct bt_buf_s *bt_buf_alloc(enum bt_buf_type_e type,
* will have to allocate one from the kernel memory pool.
*/
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
buf = (FAR struct bt_buf_s *)
kmm_malloc((sizeof (struct bt_buf_s)));
@@ -430,10 +430,10 @@ void bt_buf_release(FAR struct bt_buf_s *buf)
* list from interrupt handlers.
*/
flags = spin_lock_irqsave();
flags = spin_lock_irqsave(NULL);
buf->flink = g_buf_free;
g_buf_free = buf;
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
}
else
#endif
@@ -449,10 +449,10 @@ void bt_buf_release(FAR struct bt_buf_s *buf)
* list from interrupt handlers.
*/
flags = spin_lock_irqsave();
flags = spin_lock_irqsave(NULL);
buf->flink = g_buf_free_irq;
g_buf_free_irq = buf;
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
}
else
#endif
+4 -4
View File
@@ -143,7 +143,7 @@ static void bt_enqueue_bufwork(FAR struct bt_bufferlist_s *list,
{
irqstate_t flags;
flags = spin_lock_irqsave();
flags = spin_lock_irqsave(NULL);
buf->flink = list->head;
if (list->head == NULL)
{
@@ -151,7 +151,7 @@ static void bt_enqueue_bufwork(FAR struct bt_bufferlist_s *list,
}
list->head = buf;
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
}
/****************************************************************************
@@ -176,7 +176,7 @@ static FAR struct bt_buf_s *
FAR struct bt_buf_s *buf;
irqstate_t flags;
flags = spin_lock_irqsave();
flags = spin_lock_irqsave(NULL);
buf = list->tail;
if (buf != NULL)
{
@@ -205,7 +205,7 @@ static FAR struct bt_buf_s *
buf->flink = NULL;
}
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
return buf;
}
+2 -2
View File
@@ -808,7 +808,7 @@ static int btnet_ifdown(FAR struct net_driver_s *netdev)
/* Disable interruption */
flags = spin_lock_irqsave();
flags = spin_lock_irqsave(NULL);
/* Cancel the TX poll timer and TX timeout timers */
@@ -822,7 +822,7 @@ static int btnet_ifdown(FAR struct net_driver_s *netdev)
/* Mark the device "down" */
priv->bd_bifup = false;
spin_unlock_irqrestore(flags);
spin_unlock_irqrestore(NULL, flags);
return OK;
}