Skip to content

Commit 22822f2

Browse files
committed
Bluetooth: controller: Fix soft latencies in periodic ticker
Fix, add the missing code for the removal of any accumulated soft latencies or negative drift ticks when scheduling next interval expiry with added laziness. Typically a first interval would accumulate soft latencies and this has to be removed if the interval is rescheduled with any added laziness (scheduled to the next soft real time interval). Example, scan windows block any new scheduling until the end of the window, adding latencies to any soft real time ticker expiry which should try to execute as early as possible after the scan window. Fixes: zephyrproject-rtos#6083 Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent de83152 commit 22822f2

File tree

1 file changed

+14
-0
lines changed
  • subsys/bluetooth/controller/ticker

1 file changed

+14
-0
lines changed

subsys/bluetooth/controller/ticker/ticker.c

+14
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,20 @@ static inline u32_t ticker_job_insert(struct ticker_instance *instance,
833833
ticker->ticks_to_expire += ticker->ticks_periodic +
834834
ticker_remainder_inc(ticker);
835835
ticker->lazy_current++;
836+
837+
/* Remove any accumulated drift (possibly added due to
838+
* ticker job execution latencies).
839+
*/
840+
if (ticker->ticks_to_expire >
841+
ticker->ticks_to_expire_minus) {
842+
ticker->ticks_to_expire -=
843+
ticker->ticks_to_expire_minus;
844+
ticker->ticks_to_expire_minus = 0;
845+
} else {
846+
ticker->ticks_to_expire_minus -=
847+
ticker->ticks_to_expire;
848+
ticker->ticks_to_expire = 0;
849+
}
836850
} else {
837851
return TICKER_STATUS_FAILURE;
838852
}

0 commit comments

Comments
 (0)