Skip to content

Commit a5e1f59

Browse files
cvinayakcfriedt
authored andcommitted
Bluetooth: Controller: Revert relaxed radio packet assignment deadline
Reverts relaxed radio packet assignment deadline as it is too risky and can cause invalid bits be transmitted and/or cause MIC failures. Reverts commit 4dbfb22 ("Bluetooth: Controller: Relax radio packet pointer assignment deadline"), and commit 230df77 ("Bluetooth: Controller: Relax radio packet pointer assignment deadline"). Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 1fe79a6 commit a5e1f59

File tree

9 files changed

+166
-33
lines changed

9 files changed

+166
-33
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,12 @@ static void isr_tx(void *param)
11821182
radio_pkt_rx_set(node_rx->pdu);
11831183

11841184
/* assert if radio packet ptr is not set and radio started rx */
1185-
LL_ASSERT(!radio_is_ready());
1185+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
1186+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
1187+
lll_prof_latency_get());
1188+
} else {
1189+
LL_ASSERT(!radio_is_ready());
1190+
}
11861191

11871192
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
11881193
lll_prof_cputime_capture();
@@ -1571,7 +1576,12 @@ static inline int isr_rx_pdu(struct lll_adv *lll,
15711576
radio_pkt_tx_set(lll_adv_scan_rsp_curr_get(lll));
15721577

15731578
/* assert if radio packet ptr is not set and radio started tx */
1574-
LL_ASSERT(!radio_is_ready());
1579+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
1580+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
1581+
lll_prof_latency_get());
1582+
} else {
1583+
LL_ASSERT(!radio_is_ready());
1584+
}
15751585

15761586
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
15771587
lll_prof_cputime_capture();
@@ -1642,7 +1652,12 @@ static inline int isr_rx_pdu(struct lll_adv *lll,
16421652
radio_disable();
16431653

16441654
/* assert if radio started tx */
1645-
LL_ASSERT(!radio_is_ready());
1655+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
1656+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
1657+
lll_prof_latency_get());
1658+
} else {
1659+
LL_ASSERT(!radio_is_ready());
1660+
}
16461661

16471662
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
16481663
lll_prof_cputime_capture();

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_aux.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,12 @@ static void isr_tx_chain(void *param)
488488
radio_pkt_tx_set(pdu);
489489

490490
/* assert if radio packet ptr is not set and radio started rx */
491-
LL_ASSERT(!radio_is_ready());
491+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
492+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
493+
lll_prof_latency_get());
494+
} else {
495+
LL_ASSERT(!radio_is_ready());
496+
}
492497

493498
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
494499
lll_prof_cputime_capture();
@@ -602,7 +607,12 @@ static void isr_tx_rx(void *param)
602607
radio_pkt_rx_set(node_rx->pdu);
603608

604609
/* assert if radio packet ptr is not set and radio started rx */
605-
LL_ASSERT(!radio_is_ready());
610+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
611+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
612+
lll_prof_latency_get());
613+
} else {
614+
LL_ASSERT(!radio_is_ready());
615+
}
606616

607617
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
608618
lll_prof_cputime_capture();
@@ -809,7 +819,12 @@ static inline int isr_rx_pdu(struct lll_adv_aux *lll_aux, uint8_t phy_flags_rx,
809819
radio_pkt_tx_set(sr_pdu);
810820

811821
/* assert if radio packet ptr is not set and radio started tx */
812-
LL_ASSERT(!radio_is_ready());
822+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
823+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
824+
lll_prof_latency_get());
825+
} else {
826+
LL_ASSERT(!radio_is_ready());
827+
}
813828

814829
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
815830
lll_prof_cputime_capture();
@@ -881,7 +896,12 @@ static inline int isr_rx_pdu(struct lll_adv_aux *lll_aux, uint8_t phy_flags_rx,
881896
radio_pkt_tx_set(pdu_tx);
882897

883898
/* assert if radio packet ptr is not set and radio started tx */
884-
LL_ASSERT(!radio_is_ready());
899+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
900+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
901+
lll_prof_latency_get());
902+
} else {
903+
LL_ASSERT(!radio_is_ready());
904+
}
885905

886906
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
887907
lll_prof_cputime_capture();

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_iso.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,12 @@ static void isr_tx_common(void *param,
869869
}
870870

871871
/* assert if radio packet ptr is not set and radio started tx */
872-
LL_ASSERT(!radio_is_ready());
872+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
873+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
874+
lll_prof_latency_get());
875+
} else {
876+
LL_ASSERT(!radio_is_ready());
877+
}
873878

874879
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
875880
lll_prof_cputime_capture();

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_sync.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,12 @@ static void isr_tx(void *param)
401401
radio_pkt_tx_set(pdu);
402402

403403
/* assert if radio packet ptr is not set and radio started rx */
404-
LL_ASSERT(!radio_is_ready());
404+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
405+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
406+
lll_prof_latency_get());
407+
} else {
408+
LL_ASSERT(!radio_is_ready());
409+
}
405410

406411
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
407412
lll_prof_cputime_capture();

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include "lll_internal.h"
3636
#include "lll_tim_internal.h"
37+
#include "lll_prof_internal.h"
3738

3839
#include "ll_feat.h"
3940

@@ -466,6 +467,10 @@ static void isr_tx(void *param)
466467
struct node_rx_pdu *node_rx;
467468
uint32_t hcto;
468469

470+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
471+
lll_prof_latency_capture();
472+
}
473+
469474
/* Call to ensure packet/event timer accumulates the elapsed time
470475
* under single timer use.
471476
*/
@@ -538,7 +543,12 @@ static void isr_tx(void *param)
538543
}
539544

540545
/* assert if radio packet ptr is not set and radio started rx */
541-
LL_ASSERT(!radio_is_ready());
546+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
547+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
548+
lll_prof_latency_get());
549+
} else {
550+
LL_ASSERT(!radio_is_ready());
551+
}
542552

543553
/* +/- 2us active clock jitter, +1 us PPI to timer start compensation */
544554
hcto = radio_tmr_tifs_base_get() + cis_lll->tifs_us +
@@ -705,6 +715,10 @@ static void isr_rx(void *param)
705715
uint8_t crc_ok;
706716
uint8_t cie;
707717

718+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
719+
lll_prof_latency_capture();
720+
}
721+
708722
/* Read radio status and events */
709723
trx_done = radio_is_done();
710724
if (trx_done) {
@@ -975,6 +989,10 @@ static void isr_rx(void *param)
975989

976990
isr_prepare_subevent(param);
977991

992+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
993+
lll_prof_send();
994+
}
995+
978996
return;
979997

980998
isr_rx_done:
@@ -1131,6 +1149,13 @@ static void isr_prepare_subevent(void *param)
11311149
radio_tmr_end_capture();
11321150

11331151
#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN)
1152+
/* PA enable is overwriting packet end used in ISR profiling, hence
1153+
* back it up for later use.
1154+
*/
1155+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
1156+
lll_prof_radio_end_backup();
1157+
}
1158+
11341159
radio_gpio_pa_setup();
11351160

11361161
#if defined(CONFIG_BT_CTLR_PHY)
@@ -1148,7 +1173,16 @@ static void isr_prepare_subevent(void *param)
11481173
#endif /* !HAL_RADIO_GPIO_HAVE_PA_PIN */
11491174

11501175
/* assert if radio packet ptr is not set and radio started tx */
1151-
LL_ASSERT(!radio_is_ready());
1176+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
1177+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
1178+
lll_prof_latency_get());
1179+
} else {
1180+
LL_ASSERT(!radio_is_ready());
1181+
}
1182+
1183+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
1184+
lll_prof_cputime_capture();
1185+
}
11521186

11531187
radio_isr_set(isr_tx, param);
11541188

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,6 @@ void lll_conn_isr_rx(void *param)
311311
struct pdu_data *pdu_data_tx;
312312
struct node_rx_pdu *node_rx;
313313
struct node_tx *tx_release;
314-
#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN)
315-
uint32_t pa_lna_enable_us;
316-
#endif /* HAL_RADIO_GPIO_HAVE_PA_PIN */
317314
uint8_t is_rx_enqueue;
318315
struct lll_conn *lll;
319316
uint8_t rssi_ready;
@@ -384,7 +381,12 @@ void lll_conn_isr_rx(void *param)
384381
radio_disable();
385382

386383
/* assert if radio started tx before being disabled */
387-
LL_ASSERT(!radio_is_ready());
384+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
385+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u",
386+
__func__, lll_prof_latency_get());
387+
} else {
388+
LL_ASSERT(!radio_is_ready());
389+
}
388390

389391
goto lll_conn_isr_rx_exit;
390392
}
@@ -468,10 +470,13 @@ void lll_conn_isr_rx(void *param)
468470
} else if (!lll->role) {
469471
radio_disable();
470472

471-
/* assert if radio packet ptr is not set and radio
472-
* started tx.
473-
*/
474-
LL_ASSERT(!radio_is_ready());
473+
/* assert if radio started tx before being disabled */
474+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
475+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u",
476+
__func__, lll_prof_latency_get());
477+
} else {
478+
LL_ASSERT(!radio_is_ready());
479+
}
475480

476481
/* Restore state if last transmitted was empty PDU */
477482
lll->empty = is_empty_pdu_tx_retry;
@@ -507,6 +512,7 @@ void lll_conn_isr_rx(void *param)
507512
lll_conn_tx_pkt_set(lll, pdu_data_tx);
508513

509514
#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN)
515+
uint32_t pa_lna_enable_us;
510516

511517
#if defined(CONFIG_BT_CTLR_PROFILE_ISR)
512518
/* PA enable is overwriting packet end used in ISR profiling, hence
@@ -529,10 +535,10 @@ void lll_conn_isr_rx(void *param)
529535

530536
/* assert if radio packet ptr is not set and radio started tx */
531537
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
532-
LL_ASSERT_MSG(!radio_is_address(), "%s: Radio ISR latency: %u", __func__,
538+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
533539
lll_prof_latency_get());
534540
} else {
535-
LL_ASSERT(!radio_is_address());
541+
LL_ASSERT(!radio_is_ready());
536542
}
537543

538544
#if defined(CONFIG_BT_CTLR_TX_DEFER)
@@ -727,10 +733,10 @@ void lll_conn_isr_tx(void *param)
727733

728734
/* assert if radio packet ptr is not set and radio started rx */
729735
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
730-
LL_ASSERT_MSG(!radio_is_address(), "%s: Radio ISR latency: %u", __func__,
736+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
731737
lll_prof_latency_get());
732738
} else {
733-
LL_ASSERT(!radio_is_address());
739+
LL_ASSERT(!radio_is_ready());
734740
}
735741

736742
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_TX)

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral_iso.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include "lll_internal.h"
3636
#include "lll_tim_internal.h"
37+
#include "lll_prof_internal.h"
3738

3839
#include "ll_feat.h"
3940

@@ -496,6 +497,10 @@ static void isr_rx(void *param)
496497
uint8_t crc_ok;
497498
uint8_t cie;
498499

500+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
501+
lll_prof_latency_capture();
502+
}
503+
499504
/* Read radio status and events */
500505
trx_done = radio_is_done();
501506
if (trx_done) {
@@ -774,6 +779,13 @@ static void isr_rx(void *param)
774779
#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN)
775780
uint32_t pa_lna_enable_us;
776781

782+
/* PA enable is overwriting packet end used in ISR profiling, hence
783+
* back it up for later use.
784+
*/
785+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
786+
lll_prof_radio_end_backup();
787+
}
788+
777789
radio_gpio_pa_setup();
778790

779791
pa_lna_enable_us = radio_tmr_tifs_base_get() + cis_lll->tifs_us -
@@ -788,7 +800,16 @@ static void isr_rx(void *param)
788800
#endif /* HAL_RADIO_GPIO_HAVE_PA_PIN */
789801

790802
/* assert if radio packet ptr is not set and radio started tx */
791-
LL_ASSERT(!radio_is_ready());
803+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
804+
LL_ASSERT_MSG(!radio_is_ready(), "%s: Radio ISR latency: %u", __func__,
805+
lll_prof_latency_get());
806+
} else {
807+
LL_ASSERT(!radio_is_ready());
808+
}
809+
810+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
811+
lll_prof_cputime_capture();
812+
}
792813

793814
/* Schedule next subevent */
794815
if (!cie && (se_curr < cis_lll->nse)) {
@@ -865,6 +886,10 @@ static void isr_rx(void *param)
865886
start_us = radio_tmr_start_us(0U, subevent_us);
866887
LL_ASSERT(start_us == (subevent_us + 1U));
867888
#endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */
889+
890+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
891+
lll_prof_send();
892+
}
868893
}
869894

870895
static void isr_tx(void *param)
@@ -876,6 +901,10 @@ static void isr_tx(void *param)
876901
uint32_t start_us;
877902
uint32_t hcto;
878903

904+
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
905+
lll_prof_latency_capture();
906+
}
907+
879908
/* Call to ensure packet/event timer accumulates the elapsed time
880909
* under single timer use.
881910
*/
@@ -994,6 +1023,10 @@ static void isr_tx(void *param)
9941023

9951024
radio_tmr_hcto_configure_abs(hcto);
9961025

1026+
#if defined(CONFIG_BT_CTLR_PROFILE_ISR) || defined(HAL_RADIO_GPIO_HAVE_PA_PIN)
1027+
radio_tmr_end_capture();
1028+
#endif /* CONFIG_BT_CTLR_PROFILE_ISR || HAL_RADIO_GPIO_HAVE_PA_PIN */
1029+
9971030
#if defined(HAL_RADIO_GPIO_HAVE_LNA_PIN)
9981031
radio_gpio_lna_setup();
9991032

0 commit comments

Comments
 (0)