Skip to content

Commit f3cffe8

Browse files
committed
Bluetooth: Controller: Tune aux offset calculation overhead assertion
Tune the aux offset calculation overhead assertion to use EVENT_OVERHEAD_START_US; this is the correct maximum overhead causing ISR latency for start of a radio event that occurs thereafter. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 62b7bbb commit f3cffe8

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_vendor.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@
1616
/* Measurement based on drifting roles that can overlap leading to collision
1717
* resolutions that consume CPU time between radio events.
1818
* Value include max end, start and scheduling CPU usage times.
19-
* Measurements based on central_gatt_write and peripheral_gatt_write sample on
20-
* nRF52833 SoC.
19+
* Measurements based on central_gatt_write, peripheral_gatt_write, observer and
20+
* broadcaster_multiple samples on nRF52833 SoC.
2121
*/
2222
#if defined(CONFIG_BT_CTLR_ADV_EXT)
2323
#if defined(CONFIG_BT_OBSERVER)
2424
#if defined(CONFIG_BT_CTLR_PHY_CODED)
25-
/* Active connection in peripheral role with extended scanning on 1M and Coded
26-
* PHY, scheduling and receiving auxiliary PDUs.
25+
/* Simultaneous 3 extended advertising sets with extended scanning on 1M and Coded PHY, scheduling
26+
* and receiving auxiliary PDUs.
2727
*/
2828
#define EVENT_OVERHEAD_START_US 733 /* 24 RTC ticks */
2929
#else /* !CONFIG_BT_CTLR_PHY_CODED */
30-
/* Active connection in peripheral role with extended scanning on 1M only,
31-
* scheduling and receiving auxiliary PDUs.
30+
/* Active connection in peripheral role with extended scanning on 1M only, scheduling and receiving
31+
* auxiliary PDUs.
3232
*/
3333
#define EVENT_OVERHEAD_START_US 428 /* 14 RTC ticks */
3434
#endif /* !CONFIG_BT_CTLR_PHY_CODED */
3535
#else /* !CONFIG_BT_OBSERVER */
36-
/* Active connection in peripheral role with legacy scanning on 1M.
36+
/* Simultaneous 3 extended advertising sets calculating aux offsets.
3737
*/
38-
#define EVENT_OVERHEAD_START_US 275 /* 9 RTC ticks */
38+
#define EVENT_OVERHEAD_START_US 367 /* 12 RTC ticks */
3939
#endif /* !CONFIG_BT_OBSERVER */
4040
#else /* !CONFIG_BT_CTLR_ADV_EXT */
4141
/* Active connection in peripheral role with additional advertising state.

subsys/bluetooth/controller/ll_sw/ull_adv_aux.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,15 +3184,12 @@ static void mfy_aux_offset_get(void *param)
31843184
struct lll_adv_aux *lll_aux;
31853185
struct ll_adv_aux_set *aux;
31863186
uint32_t ticks_to_expire;
3187-
uint32_t ticks_to_start;
31883187
uint8_t data_chan_count;
31893188
uint8_t *data_chan_map;
31903189
uint32_t ticks_current;
3191-
uint32_t ticks_elapsed;
31923190
struct ll_adv_set *adv;
31933191
uint16_t chan_counter;
31943192
struct pdu_adv *pdu;
3195-
uint32_t ticks_now;
31963193
uint32_t remainder = 0U;
31973194
uint32_t offset_us;
31983195
uint8_t ticker_id;
@@ -3208,7 +3205,7 @@ static void mfy_aux_offset_get(void *param)
32083205
id = TICKER_NULL;
32093206
ticks_to_expire = 0U;
32103207
ticks_current = adv->ticks_at_expire;
3211-
retry = 1U; /* Assert on first ticks_current change */
3208+
retry = 4U; /* Assert on 2 other adv set ticks_current change, and 2 scanners expiring */
32123209
do {
32133210
uint32_t volatile ret_cb;
32143211
uint32_t ticks_previous;
@@ -3322,11 +3319,16 @@ static void mfy_aux_offset_get(void *param)
33223319
data_chan_map, data_chan_count);
33233320

33243321
/* Assertion check for delayed aux_offset calculations */
3322+
uint32_t ticks_to_start;
3323+
uint32_t ticks_elapsed;
3324+
uint32_t ticks_now;
3325+
33253326
ticks_now = ticker_ticks_now_get();
3326-
ticks_elapsed = ticker_ticks_diff_get(ticks_now, ticks_current);
3327-
ticks_to_start = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US) -
3328-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
3329-
LL_ASSERT(ticks_elapsed < ticks_to_start);
3327+
ticks_elapsed = ticker_ticks_diff_get(ticks_now, adv->ticks_at_expire);
3328+
ticks_to_start = HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_START_US);
3329+
LL_ASSERT_MSG((ticks_elapsed <= ticks_to_start), "%s overhead = %u (%u) us.",
3330+
__func__, HAL_TICKER_TICKS_TO_US(ticks_elapsed),
3331+
HAL_TICKER_TICKS_TO_US(ticks_to_start));
33303332
}
33313333

33323334
static void ticker_op_cb(uint32_t status, void *param)

0 commit comments

Comments
 (0)