Skip to content

Commit

Permalink
Bluetooth: Controller: Add LL_ASSERT_OVERHEAD define
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
cvinayak committed Jun 28, 2023
1 parent 41a4866 commit a6b6862
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 29 deletions.
7 changes: 7 additions & 0 deletions subsys/bluetooth/controller/Kconfig.ll_sw_split
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,13 @@ config BT_CTLR_SCHED_ADVANCED
Disabling this feature will lead to overlapping role in timespace
leading to skipped events amongst active roles.

config BT_CTLR_ASSERT_OVERHEAD_START
bool "Assert on Prepare Latency"
default y
help
Assert on increased Radio Event Prepare callback latencies due to
CPU usage overheads in the Controller implementation.

config BT_CTLR_CENTRAL_SPACING
int "Central Connection Spacing"
depends on BT_CTLR_SCHED_ADVANCED
Expand Down
8 changes: 8 additions & 0 deletions subsys/bluetooth/controller/hal/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ void bt_ctlr_assert_handle(char *file, uint32_t line);
BT_ASSERT_MSG(cond, fmt, ##__VA_ARGS__)
#endif

#if defined(CONFIG_BT_CTLR_ASSERT_OVERHEAD_START)
#define LL_ASSERT_OVERHEAD(overhead) \
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u", \
__func__, HAL_TICKER_TICKS_TO_US(overhead));
#else /* !CONFIG_BT_CTLR_ASSERT_OVERHEAD_START */
#define LL_ASSERT_OVERHEAD(overhead) ARG_UNUSED(overhead)
#endif /* !CONFIG_BT_CTLR_ASSERT_OVERHEAD_START */

#include "hal/debug_vendor_hal.h"
14 changes: 9 additions & 5 deletions subsys/bluetooth/controller/ll_sw/lll_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ int lll_prepare(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb,
lll_prepare_cb_t prepare_cb, int8_t event_prio,
struct lll_prepare_param *prepare_param)
{
int err;

#if defined(CONFIG_BT_CTLR_JIT_SCHEDULING)
int prio = event_prio;
struct lll_hdr *hdr = prepare_param->param;
Expand All @@ -60,20 +62,22 @@ int lll_prepare(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb,
prepare_param->prio = prio;
#endif /* CONFIG_BT_CTLR_JIT_SCHEDULING */

return lll_prepare_resolve(is_abort_cb, abort_cb, prepare_cb,
prepare_param, 0, 0);
err = lll_prepare_resolve(is_abort_cb, abort_cb, prepare_cb,
prepare_param, 0, 0);

return err;
}

void lll_resume(void *param)
{
struct lll_event *next;
int ret;
int err;

next = param;
ret = lll_prepare_resolve(next->is_abort_cb, next->abort_cb,
err = lll_prepare_resolve(next->is_abort_cb, next->abort_cb,
next->prepare_cb, &next->prepare_param,
next->is_resume, 1);
LL_ASSERT(!ret || ret == -EINPROGRESS);
LL_ASSERT(!err || err == -EINPROGRESS);
}

#if defined(CONFIG_BT_CTLR_JIT_SCHEDULING)
Expand Down
5 changes: 5 additions & 0 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,11 @@ int lll_prepare_resolve(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb,

err = prepare_cb(prepare_param);

if (!IS_ENABLED(CONFIG_BT_CTLR_ASSERT_OVERHEAD_START) &&
(err == -ECANCELED)) {
err = 0;
}

#if !defined(CONFIG_BT_CTLR_LOW_LAT)
uint32_t ret;

Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,8 +1042,8 @@ static int prepare_cb(struct lll_prepare_param *p)
ticks_at_event);
/* check if preempt to start has changed */
if (overhead) {
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
__func__, HAL_TICKER_TICKS_TO_US(overhead));
LL_ASSERT_OVERHEAD(overhead);

radio_isr_set(isr_abort, lll);
radio_disable();

Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ static int prepare_cb(struct lll_prepare_param *p)
ticks_at_event);
/* check if preempt to start has changed */
if (overhead) {
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
__func__, HAL_TICKER_TICKS_TO_US(overhead));
LL_ASSERT_OVERHEAD(overhead);

radio_isr_set(lll_isr_abort, lll);
radio_disable();

Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ static int prepare_cb_common(struct lll_prepare_param *p)
ticks_at_event);
/* check if preempt to start has changed */
if (overhead) {
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
__func__, HAL_TICKER_TICKS_TO_US(overhead));
LL_ASSERT_OVERHEAD(overhead);

radio_isr_set(lll_isr_abort, lll);
radio_disable();

Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ static int prepare_cb(struct lll_prepare_param *p)
ticks_at_event);
/* check if preempt to start has changed */
if (overhead) {
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
__func__, HAL_TICKER_TICKS_TO_US(overhead));
LL_ASSERT_OVERHEAD(overhead);

radio_isr_set(lll_isr_abort, lll);
radio_disable();

Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ static int prepare_cb(struct lll_prepare_param *p)
ticks_at_event);
/* check if preempt to start has changed */
if (overhead) {
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
__func__, HAL_TICKER_TICKS_TO_US(overhead));
LL_ASSERT_OVERHEAD(overhead);

radio_isr_set(lll_isr_abort, lll);
radio_disable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,7 @@ static int prepare_cb(struct lll_prepare_param *p)
overhead = lll_preempt_calc(ull, (TICKER_ID_CONN_ISO_BASE +
cig_lll->handle), ticks_at_event);
if (overhead) {
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
__func__, HAL_TICKER_TICKS_TO_US(overhead));
LL_ASSERT_OVERHEAD(overhead);

radio_isr_set(isr_done, cis_lll);
radio_disable();
Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ static int prepare_cb(struct lll_prepare_param *p)
ticks_at_event);
/* check if preempt to start has changed */
if (overhead) {
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
__func__, HAL_TICKER_TICKS_TO_US(overhead));
LL_ASSERT_OVERHEAD(overhead);

radio_isr_set(lll_isr_abort, lll);
radio_disable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,7 @@ static int prepare_cb(struct lll_prepare_param *p)
ticks_at_event);
/* check if preempt to start has changed */
if (overhead) {
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
__func__, HAL_TICKER_TICKS_TO_US(overhead));
LL_ASSERT_OVERHEAD(overhead);

radio_isr_set(isr_done, cis_lll);
radio_disable();
Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ static int common_prepare_cb(struct lll_prepare_param *p, bool is_resume)
ull_scan_lll_handle_get(lll)),
ticks_at_event);
if (overhead) {
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
__func__, HAL_TICKER_TICKS_TO_US(overhead));
LL_ASSERT_OVERHEAD(overhead);

radio_isr_set(isr_abort, lll);
radio_disable();

Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,8 @@ static int prepare_cb(struct lll_prepare_param *p)
ull_scan_aux_lll_handle_get(lll_aux)),
ticks_at_event);
if (overhead) {
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
__func__, HAL_TICKER_TICKS_TO_US(overhead));
LL_ASSERT_OVERHEAD(overhead);

radio_isr_set(isr_done, lll_aux);
radio_disable();

Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ static int prepare_cb_common(struct lll_prepare_param *p, uint8_t chan_idx)
ticks_at_event);
/* check if preempt to start has changed */
if (overhead) {
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
__func__, HAL_TICKER_TICKS_TO_US(overhead));
LL_ASSERT_OVERHEAD(overhead);

radio_isr_set(isr_done, lll);
radio_disable();

Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ static int prepare_cb_common(struct lll_prepare_param *p)
ticks_at_event);
/* check if preempt to start has changed */
if (overhead) {
LL_ASSERT_MSG(false, "%s: Actual EVENT_OVERHEAD_START_US = %u",
__func__, HAL_TICKER_TICKS_TO_US(overhead));
LL_ASSERT_OVERHEAD(overhead);

radio_isr_set(lll_isr_abort, lll);
radio_disable();

Expand Down

0 comments on commit a6b6862

Please sign in to comment.