From e21ff7067d37a4af9a8164595c7fcaabbd92bfd8 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Mon, 15 Jul 2024 18:03:27 +0200 Subject: [PATCH] Bluetooth: Controller: Fix BT_CTLR_SCAN_AUX_SYNC_RESERVE_MIN Fix BT_CTLR_SCAN_AUX_SYNC_RESERVE_MIN such that event is not aborted when near supervision timeout conditions. Relates to commit ddf04997a5ba ("Bluetooth: Controller: Add abort fairness in overlapping Periodic Sync"). Signed-off-by: Vinayak Kariappa Chettimada --- subsys/bluetooth/controller/ll_sw/lll_sync.h | 1 + .../bluetooth/controller/ll_sw/nordic/lll/lll_sync.c | 7 +++++++ subsys/bluetooth/controller/ll_sw/ull_sync.c | 11 ++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/controller/ll_sw/lll_sync.h b/subsys/bluetooth/controller/ll_sw/lll_sync.h index 03c1d4e2eda..568c71fe8a8 100644 --- a/subsys/bluetooth/controller/ll_sw/lll_sync.h +++ b/subsys/bluetooth/controller/ll_sw/lll_sync.h @@ -27,6 +27,7 @@ struct lll_sync { uint8_t filter_policy:1; uint8_t is_rx_enabled:1; uint8_t is_aux_sched:1; + uint8_t forced:1; #if defined(CONFIG_BT_CTLR_SYNC_ISO) uint8_t sca:3; diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c index f74b5fa145d..36949e334f0 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c @@ -562,6 +562,13 @@ static int is_abort_cb(void *next, void *curr, lll_prepare_cb_t *resume_cb) lll_sync_next = ull_sync_lll_is_valid_get(next); if (!lll_sync_next) { + lll_sync_curr = curr; + + /* Do not abort if near supervision timeout */ + if (lll_sync_curr->forced) { + return 0; + } + /* Abort current event as next event is not a * scan and not a scan aux event. */ diff --git a/subsys/bluetooth/controller/ll_sw/ull_sync.c b/subsys/bluetooth/controller/ll_sw/ull_sync.c index c557260c22a..bc7b673b97e 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_sync.c +++ b/subsys/bluetooth/controller/ll_sw/ull_sync.c @@ -722,6 +722,7 @@ void ull_sync_setup(struct ll_scan_set *scan, struct ll_scan_aux_set *aux, memcpy(lll->crc_init, si->crc_init, sizeof(lll->crc_init)); lll->event_counter = sys_le16_to_cpu(si->evt_cntr); lll->phy = aux->lll.phy; + lll->forced = 0U; interval = sys_le16_to_cpu(si->interval); interval_us = interval * PERIODIC_INT_UNIT_US; @@ -1020,6 +1021,7 @@ void ull_sync_done(struct node_rx_event_done *done) struct ll_sync_set *sync; uint16_t elapsed_event; uint16_t skip_event; + uint8_t force_lll; uint16_t lazy; uint8_t force; @@ -1100,6 +1102,7 @@ void ull_sync_done(struct node_rx_event_done *done) /* check timeout */ force = 0U; + force_lll = 0U; if (sync->timeout_expire) { if (sync->timeout_expire > elapsed_event) { sync->timeout_expire -= elapsed_event; @@ -1107,7 +1110,11 @@ void ull_sync_done(struct node_rx_event_done *done) /* break skip */ lll->skip_event = 0U; - if (skip_event) { + if (sync->timeout_expire <= 6U) { + force_lll = 1U; + + force = 1U; + } else if (skip_event) { force = 1U; } } else { @@ -1117,6 +1124,8 @@ void ull_sync_done(struct node_rx_event_done *done) } } + lll->forced = force_lll; + /* Check if skip needs update */ lazy = 0U; if ((force) || (skip_event != lll->skip_event)) {