Skip to content

Commit af13d6d

Browse files
cvinayakjhedberg
authored andcommitted
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 57e49b1 commit af13d6d

File tree

1 file changed

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

1 file changed

+14
-0
lines changed

Diff for: subsys/bluetooth/controller/ticker/ticker.c

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

0 commit comments

Comments
 (0)