Skip to content

Commit da738f8

Browse files
committed
Bluetooth: Controller: Add code comments related to short prepare
Add code comments explaining the handling of short prepare that can be enqueued out of order and present in use of FIFO for prepare pipeline. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 2cfd924 commit da738f8

File tree

1 file changed

+25
-0
lines changed
  • subsys/bluetooth/controller/ll_sw/nordic/lll

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,16 +852,41 @@ int lll_prepare_resolve(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb,
852852
ticks_at_preempt_next = ready->prepare_param.ticks_at_expire;
853853
diff = ticker_ticks_diff_get(ticks_at_preempt_min,
854854
ticks_at_preempt_next);
855+
/* If the enqueued prepare is a resume or current ready prepare is shorter, then we
856+
* should pick current ready prepare for setting up the prepare timeout.
857+
*/
855858
if (is_resume || ((diff & BIT(HAL_TICKER_CNTR_MSBIT)) == 0U)) {
856859
ticks_at_preempt_min = ticks_at_preempt_next;
857860
if (&ready->prepare_param != prepare_param) {
861+
/* There is a shorter prepare in the pipeline */
858862
ready_short = ready;
863+
} else {
864+
/* It is the same prepare in the pipeline being enqueued.
865+
* This can happen executing `lll_done()`.
866+
* Hence, we should ignore it being the `first` that setup the
867+
* preempt timeout and also it has already setup the preempt
868+
* timeout, refer to `preempt_ticker_start()` for details.
869+
*
870+
* We also set the `ready` to NULL as it is the same ready, the one
871+
* being enqueued. This help short circuit a related assertion check
872+
* later in this function.
873+
*/
874+
ready = NULL;
859875
}
860876
} else {
861877
ready = NULL;
862878
idx_backup = UINT8_MAX;
863879
}
864880

881+
/* Loop and find any short prepare present out-of-order in the prepare pipeline.
882+
*
883+
* NOTE: This loop is O(n), where n is number of items in prepare pipeline present
884+
* before a short prepare was enqueued in to the FIFO.
885+
* Use of ordered linked list implementation has show improved lower latencies
886+
* and less CPU use.
887+
* TODO: Replace use of FIFO for prepare pipeline with ordered linked list
888+
* implementation.
889+
*/
865890
do {
866891
struct lll_event *ready_next;
867892

0 commit comments

Comments
 (0)