Skip to content

Commit

Permalink
Bluetooth: controller: split: Add internal ull_update_mark func
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cvinayak authored and aescolar committed Jun 11, 2019
1 parent abbd952 commit b11a0d3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 12 deletions.
63 changes: 51 additions & 12 deletions subsys/bluetooth/controller/ll_sw/ull.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
*/
Expand Down
3 changes: 3 additions & 0 deletions subsys/bluetooth/controller/ll_sw/ull_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.