Skip to content

Commit 35a737b

Browse files
Bluetooth: Controller: Fix aux scanning with mixed ULL/LLL sched
We should decide on flush immediately vs. from disabled_cb based on ull_hdr reference count instead of last rxd node - if ull_hdr has non-zero ref, then done event is still pending and we should flush from there. Signed-off-by: Andrzej Kaczmarek <[email protected]>
1 parent 5d40986 commit 35a737b

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,23 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx)
477477
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */
478478

479479
if (aux) {
480-
if (is_lll_aux) {
480+
struct ull_hdr *hdr;
481+
482+
hdr = &aux->ull;
483+
484+
/* ref == 0
485+
* All PDUs were scheduled from LLL and there is no pending done
486+
* event, we can flush here.
487+
*
488+
* ref == 1
489+
* There is pending done event so we need to flush from disabled
490+
* callback. Flushing here would release aux context and thus
491+
* ull_hdr before done event was processed.
492+
*/
493+
LL_ASSERT(ull_ref_get(hdr) < 2);
494+
if (ull_ref_get(hdr) == 0) {
481495
flush(aux, rx);
482496
} else {
483-
struct ull_hdr *hdr;
484-
485-
/* Setup the disabled callback to flush the
486-
* auxiliary PDUs
487-
*/
488-
hdr = &aux->ull;
489497
LL_ASSERT(!hdr->disabled_cb);
490498

491499
hdr->disabled_param = rx;
@@ -593,7 +601,17 @@ static void last_disabled_cb(void *param)
593601
struct node_rx_hdr *rx;
594602

595603
rx = param;
596-
aux = HDR_LLL2ULL(rx->rx_ftr.param);
604+
605+
if (ull_scan_is_valid_get(HDR_LLL2ULL(rx->rx_ftr.param))) {
606+
struct lll_scan *lll;
607+
608+
lll = rx->rx_ftr.param;
609+
LL_ASSERT(lll->lll_aux);
610+
aux = HDR_LLL2ULL(lll->lll_aux);
611+
} else {
612+
aux = HDR_LLL2ULL(rx->rx_ftr.param);
613+
LL_ASSERT(ull_scan_aux_is_valid_get(aux));
614+
}
597615

598616
flush(aux, rx);
599617
}

0 commit comments

Comments
 (0)