Skip to content

Commit 96c076b

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Add LL_ASSERT_OVERHEAD define
Add LL_ASSERT_OVERHEAD define to reuse the assertion check related to increase in actual EVENT_OVERHEAD_START_US value. Introduce Kconfig option to permit radio event be skipped when increased prepare callback latencies are measured, instead of assertion. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 5aae5d2 commit 96c076b

16 files changed

+57
-31
lines changed

subsys/bluetooth/controller/Kconfig.ll_sw_split

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,19 @@ config BT_CTLR_SCHED_ADVANCED
458458
Disabling this feature will lead to overlapping role in timespace
459459
leading to skipped events amongst active roles.
460460

461+
config BT_CTLR_ASSERT_OVERHEAD_START
462+
bool "Assert on Prepare Latency"
463+
default y
464+
help
465+
Assert on increased Radio Event Prepare callback latencies due to
466+
CPU usage overheads in the Controller implementation.
467+
468+
Disabling this option permits the Controller to gracefully skip radio
469+
events that are delayed due to CPU usage latencies; as long as the
470+
radio event skips are not for every consecutive radio event interval,
471+
otherwise leading to remote supervision timeout and possible missing
472+
local disconnect events.
473+
461474
config BT_CTLR_CENTRAL_SPACING
462475
int "Central Connection Spacing"
463476
depends on BT_CTLR_SCHED_ADVANCED

subsys/bluetooth/controller/hal/debug.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,12 @@ void bt_ctlr_assert_handle(char *file, uint32_t line);
2727
BT_ASSERT_MSG(cond, fmt, ##__VA_ARGS__)
2828
#endif
2929

30+
#if defined(CONFIG_BT_CTLR_ASSERT_OVERHEAD_START)
31+
#define LL_ASSERT_OVERHEAD(overhead) \
32+
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u", \
33+
__func__, HAL_TICKER_TICKS_TO_US(overhead));
34+
#else /* !CONFIG_BT_CTLR_ASSERT_OVERHEAD_START */
35+
#define LL_ASSERT_OVERHEAD(overhead) ARG_UNUSED(overhead)
36+
#endif /* !CONFIG_BT_CTLR_ASSERT_OVERHEAD_START */
37+
3038
#include "hal/debug_vendor_hal.h"

subsys/bluetooth/controller/ll_sw/lll_common.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ int lll_prepare(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb,
3838
lll_prepare_cb_t prepare_cb, int8_t event_prio,
3939
struct lll_prepare_param *prepare_param)
4040
{
41+
int err;
42+
4143
#if defined(CONFIG_BT_CTLR_JIT_SCHEDULING)
4244
int prio = event_prio;
4345
struct lll_hdr *hdr = prepare_param->param;
@@ -60,20 +62,20 @@ int lll_prepare(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb,
6062
prepare_param->prio = prio;
6163
#endif /* CONFIG_BT_CTLR_JIT_SCHEDULING */
6264

63-
return lll_prepare_resolve(is_abort_cb, abort_cb, prepare_cb,
64-
prepare_param, 0, 0);
65+
err = lll_prepare_resolve(is_abort_cb, abort_cb, prepare_cb, prepare_param, 0U, 0U);
66+
67+
return err;
6568
}
6669

6770
void lll_resume(void *param)
6871
{
6972
struct lll_event *next;
70-
int ret;
73+
int err;
7174

7275
next = param;
73-
ret = lll_prepare_resolve(next->is_abort_cb, next->abort_cb,
74-
next->prepare_cb, &next->prepare_param,
75-
next->is_resume, 1);
76-
LL_ASSERT(!ret || ret == -EINPROGRESS);
76+
err = lll_prepare_resolve(next->is_abort_cb, next->abort_cb, next->prepare_cb,
77+
&next->prepare_param, next->is_resume, 1U);
78+
LL_ASSERT(!err || err == -EINPROGRESS);
7779
}
7880

7981
#if defined(CONFIG_BT_CTLR_JIT_SCHEDULING)

subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,11 @@ int lll_prepare_resolve(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb,
755755

756756
err = prepare_cb(prepare_param);
757757

758+
if (!IS_ENABLED(CONFIG_BT_CTLR_ASSERT_OVERHEAD_START) &&
759+
(err == -ECANCELED)) {
760+
err = 0;
761+
}
762+
758763
#if !defined(CONFIG_BT_CTLR_LOW_LAT)
759764
uint32_t ret;
760765

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,8 @@ static int prepare_cb(struct lll_prepare_param *p)
10411041
ticks_at_event);
10421042
/* check if preempt to start has changed */
10431043
if (overhead) {
1044-
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
1045-
__func__, HAL_TICKER_TICKS_TO_US(overhead));
1044+
LL_ASSERT_OVERHEAD(overhead);
1045+
10461046
radio_isr_set(isr_abort, lll);
10471047
radio_disable();
10481048

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ static int prepare_cb(struct lll_prepare_param *p)
323323
ticks_at_event);
324324
/* check if preempt to start has changed */
325325
if (overhead) {
326-
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
327-
__func__, HAL_TICKER_TICKS_TO_US(overhead));
326+
LL_ASSERT_OVERHEAD(overhead);
327+
328328
radio_isr_set(lll_isr_abort, lll);
329329
radio_disable();
330330

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ static int prepare_cb_common(struct lll_prepare_param *p)
425425
overhead = lll_preempt_calc(ull, (TICKER_ID_ADV_ISO_BASE + lll->handle), ticks_at_event);
426426
/* check if preempt to start has changed */
427427
if (overhead) {
428-
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
429-
__func__, HAL_TICKER_TICKS_TO_US(overhead));
428+
LL_ASSERT_OVERHEAD(overhead);
429+
430430
radio_isr_set(lll_isr_abort, lll);
431431
radio_disable();
432432

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_sync.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ static int prepare_cb(struct lll_prepare_param *p)
244244
ull_adv_sync_lll_handle_get(lll)), ticks_at_event);
245245
/* check if preempt to start has changed */
246246
if (overhead) {
247-
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
248-
__func__, HAL_TICKER_TICKS_TO_US(overhead));
247+
LL_ASSERT_OVERHEAD(overhead);
248+
249249
radio_isr_set(lll_isr_abort, lll);
250250
radio_disable();
251251

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ static int prepare_cb(struct lll_prepare_param *p)
246246
overhead = lll_preempt_calc(ull, (TICKER_ID_CONN_BASE + lll->handle), ticks_at_event);
247247
/* check if preempt to start has changed */
248248
if (overhead) {
249-
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
250-
__func__, HAL_TICKER_TICKS_TO_US(overhead));
249+
LL_ASSERT_OVERHEAD(overhead);
250+
251251
radio_isr_set(lll_isr_abort, lll);
252252
radio_disable();
253253

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,7 @@ static int prepare_cb(struct lll_prepare_param *p)
384384
ticks_at_event);
385385
/* check if preempt to start has changed */
386386
if (overhead) {
387-
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
388-
__func__, HAL_TICKER_TICKS_TO_US(overhead));
387+
LL_ASSERT_OVERHEAD(overhead);
389388

390389
radio_isr_set(isr_done, cis_lll);
391390
radio_disable();

0 commit comments

Comments
 (0)