From 18f5fb99c1fed77889bff43dcc26b5fb2a1151c2 Mon Sep 17 00:00:00 2001 From: Wolfgang Puffitsch Date: Tue, 2 Mar 2021 17:50:50 +0100 Subject: [PATCH] Bluetooth: controller: Remove use of lll_stop Remove use of lll_stop and lll_is_stop and rely on "initiated" flag in lll_conn struct instead. Signed-off-by: Wolfgang Puffitsch --- subsys/bluetooth/controller/ll_sw/lll.h | 12 ------------ .../controller/ll_sw/nordic/lll/lll_adv.c | 8 +++----- .../controller/ll_sw/nordic/lll/lll_adv_aux.c | 4 ---- .../controller/ll_sw/nordic/lll/lll_internal.h | 6 ------ .../controller/ll_sw/nordic/lll/lll_scan.c | 17 +++++++++++------ .../controller/ll_sw/openisa/lll/lll_adv.c | 8 +++----- .../controller/ll_sw/openisa/lll/lll_internal.h | 7 ------- .../controller/ll_sw/openisa/lll/lll_scan.c | 8 +++----- 8 files changed, 20 insertions(+), 50 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/lll.h b/subsys/bluetooth/controller/ll_sw/lll.h index 6952179b733..9f46c235f17 100644 --- a/subsys/bluetooth/controller/ll_sw/lll.h +++ b/subsys/bluetooth/controller/ll_sw/lll.h @@ -154,7 +154,6 @@ struct ull_hdr { struct lll_hdr { void *parent; - uint8_t is_stop:1; }; struct lll_prepare_param { @@ -370,17 +369,6 @@ static inline void lll_hdr_init(void *lll, void *parent) struct lll_hdr *hdr = lll; hdr->parent = parent; - hdr->is_stop = 0U; -} - -static inline int lll_stop(void *lll) -{ - struct lll_hdr *hdr = lll; - int ret = !!hdr->is_stop; - - hdr->is_stop = 1U; - - return ret; } int lll_init(void); 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 1c173b6bddb..885d88e437a 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c @@ -740,10 +740,11 @@ static int prepare_cb(struct lll_prepare_param *p) lll = p->param; +#if defined(CONFIG_BT_PERIPHERAL) /* Check if stopped (on connection establishment race between LLL and * ULL. */ - if (unlikely(lll_is_stop(lll))) { + if (unlikely(lll->conn && lll->conn->initiated)) { int err; err = lll_hfclock_off(); @@ -754,6 +755,7 @@ static int prepare_cb(struct lll_prepare_param *p) DEBUG_RADIO_CLOSE_A(0); return 0; } +#endif /* CONFIG_BT_PERIPHERAL */ radio_reset(); @@ -1335,7 +1337,6 @@ static inline int isr_rx_pdu(struct lll_adv *lll, !lll->conn->initiated) { struct node_rx_ftr *ftr; struct node_rx_pdu *rx; - int ret; if (IS_ENABLED(CONFIG_BT_CTLR_CHAN_SEL_2)) { rx = ull_pdu_rx_alloc_peek(4); @@ -1364,9 +1365,6 @@ static inline int isr_rx_pdu(struct lll_adv *lll, #endif /* CONFIG_BT_CTLR_CONN_RSSI */ /* Stop further LLL radio events */ - ret = lll_stop(lll); - LL_ASSERT(!ret); - lll->conn->initiated = 1; rx = ull_pdu_rx_alloc(); 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 821de43c285..99f0e44a1b2 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 @@ -659,7 +659,6 @@ static void isr_tx_connect_rsp(void *param) struct node_rx_pdu *rx; struct lll_adv *lll; bool is_done; - int ret; rx = param; ftr = &(rx->hdr.rx_ftr); @@ -687,9 +686,6 @@ static void isr_tx_connect_rsp(void *param) if (is_done) { /* Stop further LLL radio events */ - ret = lll_stop(lll); - LL_ASSERT(!ret); - lll->conn->initiated = 1; } diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_internal.h b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_internal.h index b10c5b2f969..496eb17e84b 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_internal.h +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_internal.h @@ -14,12 +14,6 @@ int lll_is_abort_cb(void *next, int prio, void *curr, lll_prepare_cb_t *resume_cb, int *resume_prio); void lll_abort_cb(struct lll_prepare_param *prepare_param, void *param); -static inline int lll_is_stop(void *lll) -{ - struct lll_hdr *hdr = lll; - - return !!hdr->is_stop; -} uint32_t lll_evt_offset_get(struct evt_hdr *evt); uint32_t lll_preempt_calc(struct evt_hdr *evt, uint8_t ticker_id, uint32_t ticks_at_event); diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c index f9cb53356b3..b73dc29f585 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c @@ -134,10 +134,11 @@ static int prepare_cb(struct lll_prepare_param *p) lll = p->param; +#if defined(CONFIG_BT_CENTRAL) /* Check if stopped (on connection establishment race between LLL and * ULL. */ - if (unlikely(lll_is_stop(lll))) { + if (unlikely(lll->conn && lll->conn->initiated)) { int err; err = lll_hfclock_off(); @@ -148,6 +149,7 @@ static int prepare_cb(struct lll_prepare_param *p) DEBUG_RADIO_CLOSE_O(0); return 0; } +#endif /* CONFIG_BT_CENTRAL */ /* Initialize scanning state */ lll->state = 0U; @@ -355,6 +357,9 @@ static int is_abort_cb(void *next, int prio, void *curr, static void abort_cb(struct lll_prepare_param *prepare_param, void *param) { +#if defined(CONFIG_BT_CENTRAL) + struct lll_scan *lll = param; +#endif /* CONFIG_BT_CENTRAL */ int err; /* NOTE: This is not a prepare being cancelled */ @@ -363,10 +368,14 @@ static void abort_cb(struct lll_prepare_param *prepare_param, void *param) * After event has been cleanly aborted, clean up resources * and dispatch event done. */ - if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT) && lll_is_stop(param)) { + if (0) { +#if defined(CONFIG_BT_CENTRAL) + } else if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT) && + lll->conn && lll->conn->initiated) { while (!radio_has_disabled()) { cpu_sleep(); } +#endif /* CONFIG_BT_CENTRAL */ } else { radio_isr_set(isr_abort, param); radio_disable(); @@ -782,7 +791,6 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx, #if defined(CONFIG_BT_CTLR_PRIVACY) bt_addr_t *lrpa; #endif /* CONFIG_BT_CTLR_PRIVACY */ - int ret; if (IS_ENABLED(CONFIG_BT_CTLR_CHAN_SEL_2)) { rx = ull_pdu_rx_alloc_peek(4); @@ -922,9 +930,6 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx, */ /* Stop further LLL radio events */ - ret = lll_stop(lll); - LL_ASSERT(!ret); - lll->conn->initiated = 1; rx = ull_pdu_rx_alloc(); diff --git a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_adv.c b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_adv.c index cc45b4e1dd5..4a76d93d726 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_adv.c +++ b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_adv.c @@ -326,10 +326,11 @@ static int prepare_cb(struct lll_prepare_param *prepare_param) DEBUG_RADIO_START_A(1); +#if defined(CONFIG_BT_PERIPHERAL) /* Check if stopped (on connection establishment race between LLL and * ULL. */ - if (lll_is_stop(lll)) { + if (lll->conn && lll->conn->initiated) { int err; err = lll_clk_off(); @@ -340,6 +341,7 @@ static int prepare_cb(struct lll_prepare_param *prepare_param) DEBUG_RADIO_START_A(0); return 0; } +#endif /* CONFIG_BT_PERIPHERAL */ radio_reset(); /* TODO: other Tx Power settings */ @@ -900,7 +902,6 @@ static inline int isr_rx_pdu(struct lll_adv *lll, !lll->conn->initiated) { struct node_rx_ftr *ftr; struct node_rx_pdu *rx; - int ret; if (IS_ENABLED(CONFIG_BT_CTLR_CHAN_SEL_2)) { rx = ull_pdu_rx_alloc_peek(4); @@ -928,9 +929,6 @@ static inline int isr_rx_pdu(struct lll_adv *lll, } #endif /* CONFIG_BT_CTLR_CONN_RSSI */ /* Stop further LLL radio events */ - ret = lll_stop(lll); - LL_ASSERT(!ret); - lll->conn->initiated = 1; rx = ull_pdu_rx_alloc(); diff --git a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_internal.h b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_internal.h index f676bacd53e..39d1379709c 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_internal.h +++ b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_internal.h @@ -14,13 +14,6 @@ int lll_is_abort_cb(void *next, int prio, void *curr, lll_prepare_cb_t *resume_cb, int *resume_prio); void lll_abort_cb(struct lll_prepare_param *prepare_param, void *param); -static inline int lll_is_stop(void *lll) -{ - struct lll_hdr *hdr = lll; - - return !!hdr->is_stop; -} - int lll_clk_on(void); int lll_clk_on_wait(void); int lll_clk_off(void); diff --git a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_scan.c b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_scan.c index 652d709d0e2..30e8cbb5f2b 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_scan.c +++ b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll_scan.c @@ -128,10 +128,11 @@ static int prepare_cb(struct lll_prepare_param *prepare_param) DEBUG_RADIO_START_O(1); +#if defined(CONFIG_BT_CENTRAL) /* Check if stopped (on connection establishment race between LLL and * ULL. */ - if (lll_is_stop(lll)) { + if (lll->conn && lll->conn->initiated) { int err; err = lll_clk_off(); @@ -142,6 +143,7 @@ static int prepare_cb(struct lll_prepare_param *prepare_param) DEBUG_RADIO_START_O(0); return 0; } +#endif /* CONFIG_BT_CENTRAL */ radio_reset(); /* TODO: other Tx Power settings */ @@ -686,7 +688,6 @@ static inline uint32_t isr_rx_pdu(struct lll_scan *lll, uint8_t devmatch_ok, #if defined(CONFIG_BT_CTLR_PRIVACY) bt_addr_t *lrpa; #endif /* CONFIG_BT_CTLR_PRIVACY */ - int ret; if (IS_ENABLED(CONFIG_BT_CTLR_CHAN_SEL_2)) { rx = ull_pdu_rx_alloc_peek(4); @@ -826,9 +827,6 @@ static inline uint32_t isr_rx_pdu(struct lll_scan *lll, uint8_t devmatch_ok, */ /* Stop further LLL radio events */ - ret = lll_stop(lll); - LL_ASSERT(!ret); - lll->conn->initiated = 1; rx = ull_pdu_rx_alloc();