Skip to content

Commit 0877064

Browse files
mtpr-otcarlescufi
authored andcommitted
bluetooth: controller: Perform synchronized LLL reset via mayfly
Use semaphore to synchronize lll_reset completion with HCI thread for returning (command complete) only when all is done. Signed-off-by: Morten Priess <[email protected]>
1 parent ed61065 commit 0877064

File tree

1 file changed

+9
-1
lines changed
  • subsys/bluetooth/controller/ll_sw

1 file changed

+9
-1
lines changed

subsys/bluetooth/controller/ll_sw/ull.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,20 @@ void ll_reset(void)
406406
/* Reset LLL via mayfly */
407407
{
408408
u32_t retval;
409+
struct k_sem sem;
409410
static memq_link_t link;
410411
static struct mayfly mfy = {0, 0, &link, NULL,
411412
perform_lll_reset};
412413

413-
mfy.param = NULL;
414+
k_sem_init(&sem, 0, 1);
415+
mfy.param = &sem;
414416
retval = mayfly_enqueue(TICKER_USER_ID_THREAD,
415417
TICKER_USER_ID_LLL, 0, &mfy);
416418
LL_ASSERT(!retval);
419+
/* LLL reset must complete before returning - wait for
420+
* reset completion in LLL mayfly thread
421+
*/
422+
k_sem_take(&sem, K_FOREVER);
417423
}
418424

419425
/* Common to init and reset */
@@ -1202,6 +1208,8 @@ static void perform_lll_reset(void *param)
12021208
err = lll_conn_reset();
12031209
LL_ASSERT(!err);
12041210
#endif /* CONFIG_BT_CONN */
1211+
1212+
k_sem_give(param);
12051213
}
12061214

12071215
static inline void *mark_set(void **m, void *param)

0 commit comments

Comments
 (0)