diff --git a/subsys/bluetooth/controller/ll_sw/ll_addr.c b/subsys/bluetooth/controller/ll_sw/ll_addr.c index 431ecfedfc1..b47db49efa7 100644 --- a/subsys/bluetooth/controller/ll_sw/ll_addr.c +++ b/subsys/bluetooth/controller/ll_sw/ll_addr.c @@ -7,13 +7,16 @@ #include #include -#include +#include +#include #include #include #include "util/util.h" #include "util/memq.h" +#include "hal/cpu.h" + #include "pdu.h" #include "ll.h" #include "lll.h" diff --git a/subsys/bluetooth/controller/ll_sw/ll_tx_pwr.c b/subsys/bluetooth/controller/ll_sw/ll_tx_pwr.c index 09abadea2e7..59264104cc2 100644 --- a/subsys/bluetooth/controller/ll_sw/ll_tx_pwr.c +++ b/subsys/bluetooth/controller/ll_sw/ll_tx_pwr.c @@ -5,12 +5,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include -#include +#include #include #include #include +#include "hal/cpu.h" #include "hal/ccm.h" #include "hal/radio.h" diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c index ec108f7c9ee..44e5870aa79 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c @@ -7,12 +7,12 @@ #include #include -#include +#include +#include +#include #include -#include -#include - +#include "hal/cpu.h" #include "hal/ccm.h" #include "hal/radio.h" #include "hal/ticker.h" @@ -41,7 +41,6 @@ #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) #define LOG_MODULE_NAME bt_ctlr_lll_adv #include "common/log.h" -#include #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.h b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.h index 0840af7c25a..63376242a5d 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.h @@ -108,15 +108,27 @@ void lll_adv_prepare(void *param); static inline struct pdu_adv *lll_adv_pdu_alloc(struct lll_adv_pdu *pdu, uint8_t *idx) { - uint8_t last; + uint8_t first, last; - if (pdu->first == pdu->last) { - last = pdu->last + 1; + first = pdu->first; + last = pdu->last; + if (first == last) { + last++; if (last == DOUBLE_BUFFER_SIZE) { last = 0U; } } else { - last = pdu->last; + uint8_t first_latest; + + pdu->last = first; + cpu_dsb(); + first_latest = pdu->first; + if (first_latest != first) { + last++; + if (last == DOUBLE_BUFFER_SIZE) { + last = 0U; + } + } } *idx = last; diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c index f3cf692743e..1dede367895 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c @@ -6,10 +6,11 @@ #include -#include -#include +#include +#include #include +#include "hal/cpu.h" #include "hal/ccm.h" #include "hal/radio.h" #include "hal/ticker.h" @@ -32,7 +33,6 @@ #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) #define LOG_MODULE_NAME bt_ctlr_lll_adv_aux #include "common/log.h" -#include #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_sync.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_sync.c index 5a5e9845af8..6d7025f9c5a 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_sync.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_sync.c @@ -6,10 +6,10 @@ #include -#include -#include -#include +#include +#include +#include "hal/cpu.h" #include "hal/ccm.h" #include "hal/radio.h" #include "hal/ticker.h" @@ -33,7 +33,6 @@ #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) #define LOG_MODULE_NAME bt_ctlr_lll_adv_sync #include "common/log.h" -#include #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/ull.c b/subsys/bluetooth/controller/ll_sw/ull.c index e0d309896ed..0c61090c8d9 100644 --- a/subsys/bluetooth/controller/ll_sw/ull.c +++ b/subsys/bluetooth/controller/ll_sw/ull.c @@ -8,13 +8,15 @@ #include #include -#include +#include +#include #include #include #include -#include "hal/cntr.h" +#include "hal/cpu.h" #include "hal/ccm.h" +#include "hal/cntr.h" #include "hal/ticker.h" #include "util/util.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv.c b/subsys/bluetooth/controller/ll_sw/ull_adv.c index 9d719a541e5..0f4ef24ff15 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv.c @@ -8,8 +8,10 @@ #include #include +#include #include +#include "hal/cpu.h" #include "hal/ccm.h" #include "hal/radio.h" #include "hal/ticker.h" @@ -47,7 +49,6 @@ #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) #define LOG_MODULE_NAME bt_ctlr_ull_adv #include "common/log.h" -#include #include "hal/debug.h" inline struct ll_adv_set *ull_adv_set_get(uint8_t handle); diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c index f290f534ed5..8cb73468431 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c @@ -4,10 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include -#include +#include +#include #include +#include +#include "hal/cpu.h" #include "hal/ticker.h" #include "util/util.h" @@ -33,7 +35,6 @@ #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) #define LOG_MODULE_NAME bt_ctlr_ull_adv_aux #include "common/log.h" -#include #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c b/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c index b4aff3bbad0..ad1512352c2 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_sync.c @@ -4,10 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include -#include +#include +#include #include +#include +#include "hal/cpu.h" #include "hal/ticker.h" #include "util/util.h" @@ -34,7 +36,6 @@ #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) #define LOG_MODULE_NAME bt_ctlr_ull_adv_sync #include "common/log.h" -#include #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/ull_filter.c b/subsys/bluetooth/controller/ll_sw/ull_filter.c index 69b0a6a0281..480abde0a54 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_filter.c +++ b/subsys/bluetooth/controller/ll_sw/ull_filter.c @@ -7,9 +7,11 @@ #include #include -#include +#include #include +#include +#include "hal/cpu.h" #include "hal/ccm.h" #include "util/util.h" diff --git a/subsys/bluetooth/controller/ll_sw/ull_master.c b/subsys/bluetooth/controller/ll_sw/ull_master.c index af1edb8555a..38a487da5e2 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_master.c +++ b/subsys/bluetooth/controller/ll_sw/ull_master.c @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -12,6 +13,7 @@ #include "util/memq.h" #include "util/mayfly.h" +#include "hal/cpu.h" #include "hal/ccm.h" #include "hal/radio.h" #include "hal/ticker.h" @@ -47,7 +49,6 @@ #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) #define LOG_MODULE_NAME bt_ctlr_ull_master #include "common/log.h" -#include #include "hal/debug.h" static void ticker_op_stop_scan_cb(uint32_t status, void *params); diff --git a/subsys/bluetooth/controller/ll_sw/ull_scan.c b/subsys/bluetooth/controller/ll_sw/ull_scan.c index 44f1690ad77..b374cd7164e 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_scan.c +++ b/subsys/bluetooth/controller/ll_sw/ull_scan.c @@ -6,8 +6,10 @@ */ #include +#include #include +#include "hal/cpu.h" #include "hal/ccm.h" #include "hal/radio.h" #include "hal/ticker.h" @@ -41,7 +43,6 @@ #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) #define LOG_MODULE_NAME bt_ctlr_ull_scan #include "common/log.h" -#include #include "hal/debug.h" static int init_reset(void); diff --git a/subsys/bluetooth/controller/ll_sw/ull_slave.c b/subsys/bluetooth/controller/ll_sw/ull_slave.c index f965dde8f53..44de2f05bb0 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_slave.c +++ b/subsys/bluetooth/controller/ll_sw/ull_slave.c @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -12,6 +13,7 @@ #include "util/memq.h" #include "util/mayfly.h" +#include "hal/cpu.h" #include "hal/ccm.h" #include "hal/radio.h" #include "hal/ticker.h" @@ -41,7 +43,6 @@ #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER) #define LOG_MODULE_NAME bt_ctlr_ull_slave #include "common/log.h" -#include #include "hal/debug.h" static void ticker_op_stop_adv_cb(uint32_t status, void *param);