Skip to content

Commit 92f0b54

Browse files
cvinayakaescolar
authored andcommitted
Bluetooth: Controller: Fix uninitialized ticks_slot in CIS create
Fix use of uninitialized ticks_slot value in calculation of cis_offset_min when creating CIS. Calculate the ticks_slot value earlier when committing the CIG parameters. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 9c95dce commit 92f0b54

File tree

2 files changed

+40
-16
lines changed

2 files changed

+40
-16
lines changed

subsys/bluetooth/controller/ll_sw/ull_central_iso.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,26 @@ uint8_t ll_cig_parameters_commit(uint8_t cig_id)
443443
cig->c_latency = c_max_latency;
444444
cig->p_latency = p_max_latency;
445445

446+
#if !defined(CONFIG_BT_CTLR_JIT_SCHEDULING)
447+
uint32_t slot_us;
448+
449+
/* CIG sync_delay has been calculated considering the configured
450+
* packing.
451+
*/
452+
slot_us = cig->sync_delay;
453+
454+
slot_us += EVENT_OVERHEAD_START_US + EVENT_OVERHEAD_END_US;
455+
456+
/* Populate the ULL hdr with event timings overheads */
457+
cig->ull.ticks_active_to_start = 0U;
458+
cig->ull.ticks_prepare_to_start =
459+
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
460+
cig->ull.ticks_preempt_to_start =
461+
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
462+
cig->ull.ticks_slot = HAL_TICKER_US_TO_TICKS(slot_us);
463+
#endif /* !CONFIG_BT_CTLR_JIT_SCHEDULING */
464+
465+
/* Reset params cache */
446466
ll_iso_setup.cis_idx = 0U;
447467

448468
return BT_HCI_ERR_SUCCESS;

subsys/bluetooth/controller/ll_sw/ull_conn_iso.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -915,30 +915,34 @@ void ull_conn_iso_start(struct ll_conn *conn, uint16_t cis_handle,
915915
#else /* !CONFIG_BT_CTLR_JIT_SCHEDULING */
916916
uint32_t ticks_slot_overhead;
917917
uint32_t ticks_slot_offset;
918-
uint32_t slot_us;
919918

920919
/* Calculate time reservations for sequential and interleaved packing as
921920
* configured.
922921
*/
923-
if (IS_CENTRAL(cig)) {
924-
/* CIG sync_delay has been calculated considering the configured
925-
* packing.
926-
*/
927-
slot_us = cig->sync_delay;
928-
} else {
922+
if (IS_PERIPHERAL(cig)) {
923+
uint32_t slot_us;
924+
929925
/* FIXME: Time reservation for interleaved packing */
930926
/* Below is time reservation for sequential packing */
931927
slot_us = cis->lll.sub_interval * cis->lll.nse;
928+
929+
slot_us += EVENT_OVERHEAD_START_US + EVENT_OVERHEAD_END_US;
930+
931+
/* FIXME: How to use ready_delay_us in the time reservation?
932+
* i.e. when CISes use different PHYs? Is that even
933+
* allowed?
934+
*
935+
* Missing code here, i.e. slot_us += ready_delay_us;
936+
*/
937+
938+
/* Populate the ULL hdr with event timings overheads */
939+
cig->ull.ticks_active_to_start = 0U;
940+
cig->ull.ticks_prepare_to_start =
941+
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
942+
cig->ull.ticks_preempt_to_start =
943+
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
944+
cig->ull.ticks_slot = HAL_TICKER_US_TO_TICKS(slot_us);
932945
}
933-
slot_us += EVENT_OVERHEAD_START_US + EVENT_OVERHEAD_END_US;
934-
935-
/* Populate the ULL hdr with event timings overheads */
936-
cig->ull.ticks_active_to_start = 0U;
937-
cig->ull.ticks_prepare_to_start =
938-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_XTAL_US);
939-
cig->ull.ticks_preempt_to_start =
940-
HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_PREEMPT_MIN_US);
941-
cig->ull.ticks_slot = HAL_TICKER_US_TO_TICKS(slot_us);
942946

943947
ticks_slot_offset = MAX(cig->ull.ticks_active_to_start,
944948
cig->ull.ticks_prepare_to_start);

0 commit comments

Comments
 (0)