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 <mtpr@oticon.com>
This commit is contained in:
Morten Priess 2019-11-11 10:11:32 +01:00 committed by Carles Cufí
commit 087706498e

View file

@ -406,14 +406,20 @@ void ll_reset(void)
/* Reset LLL via mayfly */
{
u32_t retval;
struct k_sem sem;
static memq_link_t link;
static struct mayfly mfy = {0, 0, &link, NULL,
perform_lll_reset};
mfy.param = NULL;
k_sem_init(&sem, 0, 1);
mfy.param = &sem;
retval = mayfly_enqueue(TICKER_USER_ID_THREAD,
TICKER_USER_ID_LLL, 0, &mfy);
LL_ASSERT(!retval);
/* LLL reset must complete before returning - wait for
* reset completion in LLL mayfly thread
*/
k_sem_take(&sem, K_FOREVER);
}
/* Common to init and reset */
@ -1202,6 +1208,8 @@ static void perform_lll_reset(void *param)
err = lll_conn_reset();
LL_ASSERT(!err);
#endif /* CONFIG_BT_CONN */
k_sem_give(param);
}
static inline void *mark_set(void **m, void *param)