Skip to content

Commit 624e003

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: controller: Fix auxiliary scan context release
Fix the auxiliary scan context release to be performed in the disabled_cb callback after the ULL reference count is decremented. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 3a80785 commit 624e003

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

subsys/bluetooth/controller/ll_sw/ull_scan.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ static void ticker_op_ext_stop_cb(uint32_t status, void *param)
855855
uint32_t ret;
856856

857857
LL_ASSERT(!hdr->disabled_cb);
858+
858859
hdr->disabled_param = mfy.param;
859860
hdr->disabled_cb = ext_disabled_cb;
860861

subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ static inline struct ll_scan_aux_set *aux_acquire(void);
4242
static inline void aux_release(struct ll_scan_aux_set *aux);
4343
static inline uint8_t aux_handle_get(struct ll_scan_aux_set *aux);
4444
static inline struct ll_sync_set *sync_create_get(struct ll_scan_set *scan);
45+
static void last_disabled_cb(void *param);
46+
static void done_disabled_cb(void *param);
4547
static void flush(struct ll_scan_aux_set *aux, struct node_rx_hdr *rx);
4648
static void ticker_cb(uint32_t ticks_at_expire, uint32_t remainder,
4749
uint16_t lazy, uint8_t force, void *param);
@@ -338,7 +340,14 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx)
338340
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */
339341

340342
if (aux) {
341-
flush(aux, rx);
343+
struct ull_hdr *hdr;
344+
345+
/* Setup the disabled callback to flush the auxiliary PDUs */
346+
hdr = &aux->ull;
347+
LL_ASSERT(!hdr->disabled_cb);
348+
349+
hdr->disabled_param = rx;
350+
hdr->disabled_cb = last_disabled_cb;
342351

343352
return;
344353
}
@@ -351,8 +360,14 @@ void ull_scan_aux_done(struct node_rx_event_done *done)
351360
{
352361
struct lll_scan_aux *lll = (void *)HDR_ULL2LLL(done->param);
353362
struct ll_scan_aux_set *aux = (void *)HDR_LLL2EVT(lll);
363+
struct ull_hdr *hdr;
354364

355-
flush(aux, NULL);
365+
/* Setup the disabled callback to flush the auxiliary PDUs */
366+
hdr = &aux->ull;
367+
LL_ASSERT(!hdr->disabled_cb);
368+
369+
hdr->disabled_param = aux;
370+
hdr->disabled_cb = done_disabled_cb;
356371
}
357372

358373
uint8_t ull_scan_aux_lll_handle_get(struct lll_scan_aux *lll)
@@ -395,6 +410,22 @@ static inline struct ll_sync_set *sync_create_get(struct ll_scan_set *scan)
395410
#endif /* !CONFIG_BT_CTLR_SYNC_PERIODIC */
396411
}
397412

413+
static void last_disabled_cb(void *param)
414+
{
415+
struct ll_scan_aux_set *aux;
416+
struct node_rx_hdr *rx;
417+
418+
rx = param;
419+
aux = (void *)HDR_LLL2EVT(rx->rx_ftr.param);
420+
421+
flush(aux, rx);
422+
}
423+
424+
static void done_disabled_cb(void *param)
425+
{
426+
flush(param, NULL);
427+
}
428+
398429
static void flush(struct ll_scan_aux_set *aux, struct node_rx_hdr *rx)
399430
{
400431
if (aux->rx_last) {

0 commit comments

Comments
 (0)