From 32ae59a65217ad7bdb95543a744a46ff23415576 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Tue, 17 Oct 2023 22:11:04 +0200 Subject: [PATCH 1/2] Bluetooth: Controller: Fix periodic advertising sync window Fix periodic advertising sync window calculation to include the scheduling resolution margin, i.e. be double as with the event jitter value. Signed-off-by: Vinayak Kariappa Chettimada (cherry picked from commit 05c85ddbcf8e09cd5cbfdae2adbdbbf6ddcc612b) --- subsys/bluetooth/controller/ll_sw/ull_scan_aux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c b/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c index ecdfdd60d0782b..9a86a473b02de5 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c +++ b/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c @@ -646,8 +646,8 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx) window_widening_us = SCA_DRIFT_500_PPM_US(aux_offset_us); } - lll_aux->window_size_us += (EVENT_TICKER_RES_MARGIN_US + - ((EVENT_JITTER_US + window_widening_us) << 1)); + lll_aux->window_size_us += ((EVENT_TICKER_RES_MARGIN_US + EVENT_JITTER_US + + window_widening_us) << 1); ready_delay_us = lll_radio_rx_ready_delay_get(lll_aux->phy, PHY_FLAGS_S8); From 9ff9be87bac4219b36aee5bd26120b540ad04f3a Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Mon, 23 Oct 2023 19:44:37 +0200 Subject: [PATCH 2/2] Bluetooth: Controller: Fix missing ext adv terminate event Fix missing Extended Advertising terminate event and advertising scheduling not being stopped. Under race conditions, auxiliary event is aborted without the generation of done extra event which is suppose to stop the scheduling when max events count is used. The fix now generates the done extra event. Signed-off-by: Vinayak Kariappa Chettimada (cherry picked from commit f64d123a3d7495632dfb64733c2e22a5c7990517) --- .../controller/ll_sw/nordic/lll/lll_adv_aux.c | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c index 6fa0204fb56e36..6b61c3b559f9cd 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c @@ -49,6 +49,9 @@ static int init_reset(void); static int prepare_cb(struct lll_prepare_param *p); +#if !defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO) +static void isr_early_abort(void *param); +#endif /* !CONFIG_BT_TICKER_EXT_EXPIRE_INFO */ static void isr_done(void *param); #if defined(CONFIG_BT_CTLR_ADV_AUX_PDU_BACK2BACK) static void isr_tx_chain(void *param); @@ -188,7 +191,7 @@ static int prepare_cb(struct lll_prepare_param *p) /* Abort if no aux_ptr filled */ if (unlikely(!pri_hdr->aux_ptr || !PDU_ADV_AUX_PTR_OFFSET_GET(aux_ptr))) { - radio_isr_set(lll_isr_early_abort, lll); + radio_isr_set(isr_early_abort, lll); radio_disable(); return 0; @@ -325,7 +328,7 @@ static int prepare_cb(struct lll_prepare_param *p) if (overhead) { LL_ASSERT_OVERHEAD(overhead); - radio_isr_set(lll_isr_abort, lll); + radio_isr_set(isr_done, lll); radio_disable(); return -ECANCELED; @@ -347,6 +350,33 @@ static int prepare_cb(struct lll_prepare_param *p) return 0; } +#if !defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO) +static void isr_race(void *param) +{ + radio_status_reset(); +} + +static void isr_early_abort(void *param) +{ + struct event_done_extra *extra; + int err; + + /* Generate auxiliary radio event done */ + extra = ull_done_extra_type_set(EVENT_DONE_EXTRA_TYPE_ADV_AUX); + LL_ASSERT(extra); + + radio_isr_set(isr_race, param); + if (!radio_is_idle()) { + radio_disable(); + } + + err = lll_hfclock_off(); + LL_ASSERT(err >= 0); + + lll_done(NULL); +} +#endif /* !CONFIG_BT_TICKER_EXT_EXPIRE_INFO */ + static void isr_done(void *param) { struct event_done_extra *extra;