From d534492bf91a08dabbe77abebd44c5c185adfc10 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Tue, 8 Oct 2019 15:55:37 +0530 Subject: [PATCH] Bluetooth: controller: Fix ticker previous slot value Fix ticker previous slot value with elapsed ticks value from the time stopped ticker has expired. When a ticker is stopped, if it was in its reserved time space, then the currently occupied slot (was set to 0) should be the amount of time that has elapsed in the expired and stopped ticker's reserved time space and beyond until the stop. This is required to ensure that any other new ticker does not get scheduled over the stopped ticker's reserved time space. Fixes #19515. Signed-off-by: Vinayak Kariappa Chettimada --- subsys/bluetooth/controller/ticker/ticker.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/controller/ticker/ticker.c b/subsys/bluetooth/controller/ticker/ticker.c index 895970319d1..b9ebf6fc29a 100644 --- a/subsys/bluetooth/controller/ticker/ticker.c +++ b/subsys/bluetooth/controller/ticker/ticker.c @@ -1112,8 +1112,15 @@ static inline void ticker_job_node_manage(struct ticker_instance *instance, ticker->req = ticker->ack; if (instance->ticker_id_slot_previous == user_op->id) { + u32_t ticks_now = cntr_cnt_get(); + u32_t ticks_used; + instance->ticker_id_slot_previous = TICKER_NULL; - instance->ticks_slot_previous = 0U; + ticks_used = ticks_elapsed + + ticker_ticks_diff_get(ticks_now, + instance->ticks_current); + instance->ticks_slot_previous = MIN(ticker->ticks_slot, + ticks_used); } }