@@ -552,6 +552,14 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx)
552
552
553
553
/* Switching to ULL scheduling to receive auxiliary PDUs */
554
554
if (!IS_ENABLED (CONFIG_BT_CTLR_SYNC_PERIODIC ) || lll ) {
555
+ /* Do not ULL schedule if scan disable requested */
556
+ if (unlikely (scan -> is_stop )) {
557
+ goto ull_scan_aux_rx_flush ;
558
+ }
559
+
560
+ /* Remove auxiliary context association with scan context so
561
+ * that LLL can differentiate it to being ULL scheduling.
562
+ */
555
563
lll -> lll_aux = NULL ;
556
564
} else {
557
565
struct ll_sync_set * sync ;
@@ -747,13 +755,36 @@ void ull_scan_aux_done(struct node_rx_event_done *done)
747
755
748
756
aux = HDR_LLL2ULL (sync -> lll .lll_aux );
749
757
} else {
758
+ struct ll_scan_set * scan ;
759
+
760
+ scan = HDR_LLL2ULL (aux -> parent );
761
+ LL_ASSERT (ull_scan_is_valid_get (scan ));
762
+
763
+ /* Auxiliary context will be flushed by ull_scan_aux_stop() */
764
+ if (unlikely (scan -> is_stop )) {
765
+ return ;
766
+ }
767
+
750
768
/* Setup the disabled callback to flush the auxiliary PDUs */
751
769
hdr = & aux -> ull ;
752
770
}
753
771
754
- LL_ASSERT (!hdr -> disabled_cb );
755
- hdr -> disabled_param = aux ;
756
- hdr -> disabled_cb = done_disabled_cb ;
772
+ if (ull_ref_get (hdr ) == 0U ) {
773
+ flush (aux );
774
+ } else {
775
+ LL_ASSERT (!hdr -> disabled_cb );
776
+ hdr -> disabled_param = aux ;
777
+ hdr -> disabled_cb = done_disabled_cb ;
778
+ }
779
+ }
780
+
781
+ struct ll_scan_aux_set * ull_scan_aux_set_get (uint8_t handle )
782
+ {
783
+ if (handle >= CONFIG_BT_CTLR_SCAN_AUX_SET ) {
784
+ return NULL ;
785
+ }
786
+
787
+ return & ll_scan_aux_pool [handle ];
757
788
}
758
789
759
790
uint8_t ull_scan_aux_lll_handle_get (struct lll_scan_aux * lll )
@@ -856,7 +887,7 @@ void ull_scan_aux_release(memq_link_t *link, struct node_rx_hdr *rx)
856
887
scan = HDR_LLL2ULL (lll );
857
888
scan = ull_scan_is_valid_get (scan );
858
889
if (scan ) {
859
- is_stop = 0U ;
890
+ is_stop = scan -> is_stop ;
860
891
} else {
861
892
struct lll_sync * sync_lll ;
862
893
struct ll_sync_set * sync ;
@@ -926,15 +957,37 @@ int ull_scan_aux_stop(struct ll_scan_aux_set *aux)
926
957
927
958
/* Abort LLL event if ULL scheduling not used or already in prepare */
928
959
if (err == - EALREADY ) {
929
- ret = ull_disable (& aux -> lll );
930
- if (ret ) {
931
- return - EBUSY ;
960
+ err = ull_disable (& aux -> lll );
961
+ if (err ) {
962
+ return err ;
932
963
}
933
964
934
965
mfy .fp = flush ;
966
+
967
+ } else if (!IS_ENABLED (CONFIG_BT_CTLR_SYNC_PERIODIC )) {
968
+ /* ULL scan auxiliary PDU reception scheduling stopped
969
+ * before prepare.
970
+ */
971
+ mfy .fp = flush ;
972
+
935
973
} else {
936
- /* ULL scheduling stopped before prepare */
937
- mfy .fp = aux_sync_incomplete ;
974
+ struct ll_scan_set * scan ;
975
+ struct lll_scan * lll ;
976
+
977
+ lll = aux -> parent ;
978
+ scan = HDR_LLL2ULL (lll );
979
+ scan = ull_scan_is_valid_get (scan );
980
+ if (scan ) {
981
+ /* ULL scan auxiliary PDU reception scheduling stopped
982
+ * before prepare.
983
+ */
984
+ mfy .fp = flush ;
985
+ } else {
986
+ /* ULL sync chain reception scheduling stopped before
987
+ * prepare.
988
+ */
989
+ mfy .fp = aux_sync_incomplete ;
990
+ }
938
991
}
939
992
940
993
/* Release auxiliary context in ULL execution context */
@@ -963,6 +1016,16 @@ static inline struct ll_scan_aux_set *aux_acquire(void)
963
1016
964
1017
static inline void aux_release (struct ll_scan_aux_set * aux )
965
1018
{
1019
+ /* Debug check that parent was assigned when allocated for reception of
1020
+ * auxiliary channel PDUs.
1021
+ */
1022
+ LL_ASSERT (aux -> parent );
1023
+
1024
+ /* Clear the parent so that when scan is being disabled then this
1025
+ * auxiliary context shall not associate itself from being disable.
1026
+ */
1027
+ aux -> parent = NULL ;
1028
+
966
1029
mem_release (aux , & scan_aux_free );
967
1030
}
968
1031
0 commit comments