From 34b95feb54aa037fe1c1ec5dfc46b61603d420ea Mon Sep 17 00:00:00 2001 From: Wolfgang Puffitsch Date: Thu, 10 Oct 2019 11:18:30 +0200 Subject: [PATCH] Bluetooth: controller: split: Call LLL reset functions from ll_reset Call LLL reset functions when calling ll_reset to avoid carrying LLL state across HCI resets. Respective functions already exist in LLL but had not been called from anywhere. Signed-off-by: Wolfgang Puffitsch --- subsys/bluetooth/controller/ll_sw/lll.h | 1 + subsys/bluetooth/controller/ll_sw/ull.c | 41 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/subsys/bluetooth/controller/ll_sw/lll.h b/subsys/bluetooth/controller/ll_sw/lll.h index b052f69aa36..5cf663867e4 100644 --- a/subsys/bluetooth/controller/ll_sw/lll.h +++ b/subsys/bluetooth/controller/ll_sw/lll.h @@ -292,6 +292,7 @@ static inline int lll_is_stop(void *lll) } int lll_init(void); +int lll_reset(void); int lll_prepare(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb, lll_prepare_cb_t prepare_cb, int prio, struct lll_prepare_param *prepare_param); diff --git a/subsys/bluetooth/controller/ll_sw/ull.c b/subsys/bluetooth/controller/ll_sw/ull.c index e58f6d8c9a2..0f81c863476 100644 --- a/subsys/bluetooth/controller/ll_sw/ull.c +++ b/subsys/bluetooth/controller/ll_sw/ull.c @@ -223,6 +223,7 @@ static void *mark_update; static void *mark_disable; static inline int init_reset(void); +static void perform_lll_reset(void *param); 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); @@ -402,6 +403,19 @@ void ll_reset(void) MFIFO_INIT(ll_pdu_rx_free); #endif /* CONFIG_BT_CONN */ + /* Reset LLL via mayfly */ + { + u32_t retval; + static memq_link_t link; + static struct mayfly mfy = {0, 0, &link, NULL, + perform_lll_reset}; + + mfy.param = NULL; + retval = mayfly_enqueue(TICKER_USER_ID_THREAD, + TICKER_USER_ID_LLL, 0, &mfy); + LL_ASSERT(!retval); + } + /* Common to init and reset */ err = init_reset(); LL_ASSERT(!err); @@ -1163,6 +1177,33 @@ static inline int init_reset(void) return 0; } +static void perform_lll_reset(void *param) +{ + int err; + + /* Reset LLL */ + err = lll_reset(); + LL_ASSERT(!err); + +#if defined(CONFIG_BT_BROADCASTER) + /* Reset adv state */ + err = lll_adv_reset(); + LL_ASSERT(!err); +#endif /* CONFIG_BT_BROADCASTER */ + +#if defined(CONFIG_BT_OBSERVER) + /* Reset scan state */ + err = lll_scan_reset(); + LL_ASSERT(!err); +#endif /* CONFIG_BT_OBSERVER */ + +#if defined(CONFIG_BT_CONN) + /* Reset conn role */ + err = lll_conn_reset(); + LL_ASSERT(!err); +#endif /* CONFIG_BT_CONN */ +} + static inline void *mark_set(void **m, void *param) { if (!*m) {