Skip to content
Permalink
Browse files

Bluetooth: controller: split: Add internal ull_update_mark func

Added an internal ull_update_mark function to detect race
conditions while stopping ticker instances during slave
drift, disconnection and connection update.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
  • Loading branch information...
cvinayak authored and aescolar committed Jun 5, 2019
1 parent abbd952 commit b11a0d35ee2293b40d6bb38c850d84b38821b7da
Showing with 54 additions and 12 deletions.
  1. +51 −12 subsys/bluetooth/controller/ll_sw/ull.c
  2. +3 −0 subsys/bluetooth/controller/ll_sw/ull_internal.h
@@ -197,11 +197,16 @@ static MEMQ_DECLARE(ll_rx);
#if defined(CONFIG_BT_CONN)
static MFIFO_DEFINE(tx_ack, sizeof(struct lll_tx),
CONFIG_BT_CTLR_TX_BUFFERS);

static void *mark_update;
#endif /* CONFIG_BT_CONN */

static void *mark;
static void *mark_disable;

static inline int init_reset(void);
static inline void *mark_set(void **m, void *param);
static inline void *mark_unset(void **m, void *param);
static inline void *mark_get(void *m);
static inline void done_alloc(void);
static inline void rx_alloc(u8_t max);
static void rx_demux(void *param);
@@ -938,26 +943,35 @@ u32_t ull_ticker_status_take(u32_t ret, u32_t volatile *ret_cb)

void *ull_disable_mark(void *param)
{
if (!mark) {
mark = param;
}

return mark;
return mark_set(&mark_disable, param);
}

void *ull_disable_unmark(void *param)
{
if (mark && mark == param) {
mark = NULL;
}

return param;
return mark_unset(&mark_disable, param);
}

void *ull_disable_mark_get(void)
{
return mark;
return mark_get(mark_disable);
}

#if defined(CONFIG_BT_CONN)
void *ull_update_mark(void *param)
{
return mark_set(&mark_update, param);
}

void *ull_update_unmark(void *param)
{
return mark_unset(&mark_update, param);
}

void *ull_update_mark_get(void)
{
return mark_get(mark_update);
}
#endif /* CONFIG_BT_CONN */

int ull_disable(void *lll)
{
@@ -1160,6 +1174,31 @@ static inline int init_reset(void)
return 0;
}

static inline void *mark_set(void **m, void *param)
{
if (!*m) {
*m = param;
}

return *m;
}

static inline void *mark_unset(void **m, void *param)
{
if (*m && *m == param) {
*m = NULL;

return param;
}

return NULL;
}

static inline void *mark_get(void *m)
{
return m;
}

/**
* @brief Allocate buffers for done events
*/
@@ -33,5 +33,8 @@ u32_t ull_ticker_status_take(u32_t ret, u32_t volatile *ret_cb);
void *ull_disable_mark(void *param);
void *ull_disable_unmark(void *param);
void *ull_disable_mark_get(void);
void *ull_update_mark(void *param);
void *ull_update_unmark(void *param);
void *ull_update_mark_get(void);
int ull_disable(void *param);
u8_t ull_entropy_get(u8_t len, void *rand);

0 comments on commit b11a0d3

Please sign in to comment.
You can’t perform that action at this time.