Skip to content

Commit 31c6a9c

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Fix Periodic Sync lost implementation
Fix Periodic Advertising Synchronization lost implementation to avoid processing done event twice in cases of overlapping events or race between sync terminate being requested. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 27afc77 commit 31c6a9c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

subsys/bluetooth/controller/ll_sw/ull_sync.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@ uint8_t ll_sync_terminate(uint16_t handle)
370370
link_sync_lost = sync->node_rx_lost.hdr.link;
371371
ll_rx_link_release(link_sync_lost);
372372

373+
/* Mark sync context not sync established */
374+
sync->timeout_reload = 0U;
375+
373376
ull_sync_release(sync);
374377

375378
return 0;
@@ -488,9 +491,6 @@ void ull_sync_release(struct ll_sync_set *sync)
488491
sync->timeout = 0U;
489492
}
490493

491-
/* Mark sync context not sync established */
492-
sync->timeout_reload = 0U;
493-
494494
/* reset accumulated data len */
495495
sync->data_len = 0U;
496496

@@ -853,8 +853,8 @@ void ull_sync_done(struct node_rx_event_done *done)
853853
/* Get reference to ULL context */
854854
sync = CONTAINER_OF(done->param, struct ll_sync_set, ull);
855855

856-
/* Do nothing if local terminate requested */
857-
if (unlikely(sync->is_stop)) {
856+
/* Do nothing if local terminate requested or sync lost */
857+
if (unlikely(sync->is_stop || !sync->timeout_reload)) {
858858
return;
859859
}
860860

@@ -1115,6 +1115,9 @@ static void sync_ticker_cleanup(struct ll_sync_set *sync, ticker_op_func stop_op
11151115
TICKER_ID_SCAN_SYNC_BASE + sync_handle, stop_op_cb, (void *)sync);
11161116
LL_ASSERT((ret == TICKER_STATUS_SUCCESS) ||
11171117
(ret == TICKER_STATUS_BUSY));
1118+
1119+
/* Mark sync context not sync established */
1120+
sync->timeout_reload = 0U;
11181121
}
11191122

11201123
static void ticker_cb(uint32_t ticks_at_expire, uint32_t ticks_drift,

0 commit comments

Comments
 (0)