|
65 | 65 | #define PHY_VALID_MASK (BT_HCI_ISO_PHY_VALID_MASK & ~BIT(2))
|
66 | 66 | #endif
|
67 | 67 |
|
| 68 | +/* CIS Create Procedure uses 3 PDU transmissions, and one connection interval to process the LLCP |
| 69 | + * requested, hence minimum relative instant not be less than 4. I.e. the CIS_REQ PDU will be |
| 70 | + * transmitted in the next ACL interval. |
| 71 | + * The +1 also helps with the fact that currently we do not have Central implementation to handle |
| 72 | + * event latencies at the instant. Refer to `ull_conn_iso_start()` implementation. |
| 73 | + */ |
| 74 | +#define CIS_CREATE_INSTANT_DELTA_MIN 4U |
| 75 | + |
68 | 76 | #if (CONFIG_BT_CTLR_CENTRAL_SPACING == 0)
|
69 | 77 | static void cig_offset_get(struct ll_conn_iso_stream *cis);
|
70 | 78 | static void mfy_cig_offset_get(void *param);
|
@@ -925,10 +933,10 @@ uint8_t ull_central_iso_setup(uint16_t cis_handle,
|
925 | 933 | cis->lll.prepared = 0U;
|
926 | 934 | #endif /* !CONFIG_BT_CTLR_JIT_SCHEDULING */
|
927 | 935 |
|
928 |
| - cis->central.instant = instant; |
929 | 936 | #if defined(CONFIG_BT_CTLR_ISOAL_PSN_IGNORE)
|
930 | 937 | cis->pkt_seq_num = 0U;
|
931 | 938 | #endif /* CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
|
| 939 | + |
932 | 940 | /* It is intentional to initialize to the 39 bit maximum value and rollover to 0 in the
|
933 | 941 | * prepare function, the event counter is pre-incremented in prepare function for the
|
934 | 942 | * current ISO event.
|
@@ -975,19 +983,11 @@ int ull_central_iso_cis_offset_get(uint16_t cis_handle,
|
975 | 983 |
|
976 | 984 | conn = ll_conn_get(cis->lll.acl_handle);
|
977 | 985 |
|
978 |
| - /* NOTE: CIS Create Procedure uses 3 PDU transmissions, hence minimum relative instant not |
979 |
| - * be less than 3. As the CIS_REQ PDU will be transmitted in the next ACL interval, |
980 |
| - * add +1 to the instant. The +1 also helps with the fact that currently we do not |
981 |
| - * have Central implementation to handle event latencies at the instant. Refer to |
982 |
| - * `ull_conn_iso_start()` implementation. |
983 |
| - * |
984 |
| - * `ull_conn_llcp()` is called before `ull_ref_inc()` hence we do not need to use |
985 |
| - * `ull_conn_event_counter()`. |
| 986 | + /* `ull_conn_llcp()` (caller of this function) is called before `ull_ref_inc()` hence we do |
| 987 | + * not need to use `ull_conn_event_counter()`. |
986 | 988 | */
|
987 |
| - cis->central.instant = conn->lll.event_counter + conn->lll.latency_prepare + |
988 |
| - conn->llcp.prep.lazy + 4U; |
989 |
| - |
990 |
| - *conn_event_count = cis->central.instant; |
| 989 | + *conn_event_count = conn->lll.event_counter + conn->lll.latency_prepare + |
| 990 | + conn->llcp.prep.lazy + CIS_CREATE_INSTANT_DELTA_MIN; |
991 | 991 |
|
992 | 992 | /* Provide CIS offset range
|
993 | 993 | * CIS_Offset_Max < (connInterval - (CIG_Sync_Delay + T_MSS))
|
@@ -1090,18 +1090,18 @@ static void cis_offset_get(struct ll_conn_iso_stream *cis)
|
1090 | 1090 | static void mfy_cis_offset_get(void *param)
|
1091 | 1091 | {
|
1092 | 1092 | uint32_t elapsed_acl_us, elapsed_cig_us;
|
1093 |
| - uint16_t latency_acl, latency_cig; |
1094 | 1093 | struct ll_conn_iso_stream *cis;
|
1095 | 1094 | struct ll_conn_iso_group *cig;
|
1096 | 1095 | uint32_t cig_remainder_us;
|
1097 | 1096 | uint32_t acl_remainder_us;
|
1098 | 1097 | uint32_t cig_interval_us;
|
1099 | 1098 | uint32_t offset_limit_us;
|
1100 | 1099 | uint32_t ticks_to_expire;
|
| 1100 | + uint32_t remainder = 0U; |
1101 | 1101 | uint32_t ticks_current;
|
1102 | 1102 | uint32_t offset_min_us;
|
1103 | 1103 | struct ll_conn *conn;
|
1104 |
| - uint32_t remainder = 0U; |
| 1104 | + uint16_t latency_cig; |
1105 | 1105 | uint8_t ticker_id;
|
1106 | 1106 | uint16_t lazy;
|
1107 | 1107 | uint8_t retry;
|
@@ -1188,13 +1188,7 @@ static void mfy_cis_offset_get(void *param)
|
1188 | 1188 | * and latency counts (typically 3) is low enough to avoid 32-bit
|
1189 | 1189 | * overflow. Refer to ull_central_iso_cis_offset_get().
|
1190 | 1190 | */
|
1191 |
| - /* FIXME: Mayfly execution of `mfy_cig_offset_get()` could be before "LLL Prepare" or after |
1192 |
| - * conn->lll.event_counter could have been pre-incremented. |
1193 |
| - * This race condition needs a fix. |
1194 |
| - */ |
1195 |
| - latency_acl = cis->central.instant - conn->lll.event_counter - conn->lll.latency_prepare - |
1196 |
| - conn->llcp.prep.lazy; |
1197 |
| - elapsed_acl_us = latency_acl * conn->lll.interval * CONN_INT_UNIT_US; |
| 1191 | + elapsed_acl_us = CIS_CREATE_INSTANT_DELTA_MIN * conn->lll.interval * CONN_INT_UNIT_US; |
1198 | 1192 |
|
1199 | 1193 | /* Calculate elapsed CIG intervals until the instant */
|
1200 | 1194 | cig_interval_us = cig->iso_interval * ISO_INT_UNIT_US;
|
|
0 commit comments