Skip to content

Commit 9e3c7b9

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: controller: Fix flash driver sync regression
Fix flash driver sync regression introduced due to changed default ULL_HIGH in the commit 3063433 ("Bluetooth: controller: Fix ULL_HIGH priority to be lower than LLL"). Fixes #33862. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent f642feb commit 9e3c7b9

File tree

3 files changed

+90
-66
lines changed

3 files changed

+90
-66
lines changed

drivers/flash/soc_flash_nrf_ticker.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ static void time_slot_delay(uint32_t ticks_at_expire, uint32_t ticks_delay,
9292
* Radio h/w.
9393
*/
9494
err = ticker_start(instance_index, /* Radio instance ticker */
95-
0, /* user_id */
95+
1, /* user id for link layer ULL_HIGH */
96+
/* (MAYFLY_CALL_ID_WORKER) */
9697
(ticker_id + 1), /* ticker_id */
9798
ticks_at_expire, /* current tick */
9899
ticks_delay, /* one-shot delayed timeout */

subsys/bluetooth/controller/include/ll.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ void ll_rx_dequeue(void);
292292
void ll_rx_mem_release(void **node_rx);
293293

294294
/* External co-operation */
295-
void ll_timeslice_ticker_id_get(uint8_t * const instance_index, uint8_t * const user_id);
295+
void ll_timeslice_ticker_id_get(uint8_t * const instance_index,
296+
uint8_t * const ticker_id);
296297
void ll_radio_state_abort(void);
297298
uint32_t ll_radio_state_is_idle(void);
298299

subsys/bluetooth/controller/ll_sw/ull.c

Lines changed: 86 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -63,53 +63,6 @@
6363
#include "common/log.h"
6464
#include "hal/debug.h"
6565

66-
/* When both central and peripheral are supported, one each Rx node will be
67-
* needed by connectable advertising and the initiator to generate connection
68-
* complete event, hence conditionally set the count.
69-
*/
70-
#if defined(CONFIG_BT_MAX_CONN)
71-
#if defined(CONFIG_BT_CENTRAL) && defined(CONFIG_BT_PERIPHERAL)
72-
#define BT_CTLR_MAX_CONNECTABLE 2
73-
#else
74-
#define BT_CTLR_MAX_CONNECTABLE 1
75-
#endif
76-
#define BT_CTLR_MAX_CONN CONFIG_BT_MAX_CONN
77-
#else
78-
#define BT_CTLR_MAX_CONNECTABLE 0
79-
#define BT_CTLR_MAX_CONN 0
80-
#endif
81-
82-
#if !defined(TICKER_USER_LLL_VENDOR_OPS)
83-
#define TICKER_USER_LLL_VENDOR_OPS 0
84-
#endif /* TICKER_USER_LLL_VENDOR_OPS */
85-
86-
#if !defined(TICKER_USER_ULL_HIGH_VENDOR_OPS)
87-
#define TICKER_USER_ULL_HIGH_VENDOR_OPS 0
88-
#endif /* TICKER_USER_ULL_HIGH_VENDOR_OPS */
89-
90-
#if !defined(TICKER_USER_THREAD_VENDOR_OPS)
91-
#define TICKER_USER_THREAD_VENDOR_OPS 0
92-
#endif /* TICKER_USER_THREAD_VENDOR_OPS */
93-
94-
/* Define ticker nodes and user operations */
95-
#if defined(CONFIG_BT_CTLR_LOW_LAT) && \
96-
(CONFIG_BT_CTLR_LLL_PRIO == CONFIG_BT_CTLR_ULL_LOW_PRIO)
97-
#define TICKER_USER_LLL_OPS (3 + TICKER_USER_LLL_VENDOR_OPS + 1)
98-
/* NOTE: When ticker job is disabled inside radio events then all advertising,
99-
* scanning, and slave latency cancel ticker operations will be deferred,
100-
* requiring increased ticker thread context operation queue count.
101-
*/
102-
#define TICKER_USER_THREAD_OPS (BT_CTLR_ADV_SET + BT_CTLR_SCAN_SET + \
103-
BT_CTLR_CONN_MAX + \
104-
TICKER_USER_THREAD_VENDOR_OPS + 1)
105-
#else /* !CONFIG_BT_CTLR_LOW_LAT */
106-
#define TICKER_USER_LLL_OPS (2 + TICKER_USER_LLL_VENDOR_OPS + 1)
107-
#define TICKER_USER_THREAD_OPS (1 + TICKER_USER_THREAD_VENDOR_OPS + 1)
108-
#endif /* !CONFIG_BT_CTLR_LOW_LAT */
109-
110-
#define TICKER_USER_ULL_HIGH_OPS (3 + TICKER_USER_ULL_HIGH_VENDOR_OPS + 1)
111-
#define TICKER_USER_ULL_LOW_OPS (1 + 1)
112-
11366
#if defined(CONFIG_BT_BROADCASTER)
11467
#define BT_ADV_TICKER_NODES ((TICKER_ID_ADV_LAST) - (TICKER_ID_ADV_STOP) + 1)
11568
#if defined(CONFIG_BT_CTLR_ADV_EXT) && (CONFIG_BT_CTLR_ADV_AUX_SET > 0)
@@ -158,20 +111,33 @@
158111
#define BT_CONN_TICKER_NODES 0
159112
#endif
160113

161-
#if defined(CONFIG_SOC_FLASH_NRF_RADIO_SYNC_TICKER)
162-
#define FLASH_TICKER_NODES 2 /* No. of tickers reserved for flashing */
163-
#define FLASH_TICKER_USER_APP_OPS 1 /* No. of additional ticker operations */
164-
#else
165-
#define FLASH_TICKER_NODES 0
166-
#define FLASH_TICKER_USER_APP_OPS 0
167-
#endif
168-
169114
#if defined(CONFIG_BT_CTLR_USER_EXT)
170115
#define USER_TICKER_NODES CONFIG_BT_CTLR_USER_TICKER_ID_RANGE
171116
#else
172117
#define USER_TICKER_NODES 0
173118
#endif
174119

120+
#if defined(CONFIG_SOC_FLASH_NRF_RADIO_SYNC_TICKER)
121+
#define FLASH_TICKER_NODES 2 /* No. of tickers reserved for flash
122+
* driver
123+
*/
124+
#define TICKER_USER_ULL_HIGH_FLASH_OPS 1 /* No. of additional ticker ULL_HIGH
125+
* context operations
126+
*/
127+
#define TICKER_USER_THREAD_FLASH_OPS 1 /* No. of additional ticker thread
128+
* context operations
129+
*/
130+
#else
131+
#define FLASH_TICKER_NODES 0
132+
#define TICKER_USER_ULL_HIGH_FLASH_OPS 0
133+
#define TICKER_USER_THREAD_FLASH_OPS 0
134+
#endif
135+
136+
/* Define ticker nodes */
137+
/* NOTE: FLASH_TICKER_NODES shall be after Link Layer's list of ticker id
138+
* allocations, refer to ll_timeslice_ticker_id_get on how ticker id
139+
* used by flash driver is returned.
140+
*/
175141
#define TICKER_NODES (TICKER_ID_ULL_BASE + \
176142
BT_ADV_TICKER_NODES + \
177143
BT_ADV_AUX_TICKER_NODES + \
@@ -180,15 +146,71 @@
180146
BT_SCAN_AUX_TICKER_NODES + \
181147
BT_SCAN_SYNC_TICKER_NODES + \
182148
BT_CONN_TICKER_NODES + \
183-
FLASH_TICKER_NODES + \
184-
USER_TICKER_NODES)
185-
#define TICKER_USER_APP_OPS (TICKER_USER_THREAD_OPS + \
186-
FLASH_TICKER_USER_APP_OPS)
149+
USER_TICKER_NODES + \
150+
FLASH_TICKER_NODES)
151+
152+
/* When both central and peripheral are supported, one each Rx node will be
153+
* needed by connectable advertising and the initiator to generate connection
154+
* complete event, hence conditionally set the count.
155+
*/
156+
#if defined(CONFIG_BT_MAX_CONN)
157+
#if defined(CONFIG_BT_CENTRAL) && defined(CONFIG_BT_PERIPHERAL)
158+
#define BT_CTLR_MAX_CONNECTABLE 2
159+
#else
160+
#define BT_CTLR_MAX_CONNECTABLE 1
161+
#endif
162+
#define BT_CTLR_MAX_CONN CONFIG_BT_MAX_CONN
163+
#else
164+
#define BT_CTLR_MAX_CONNECTABLE 0
165+
#define BT_CTLR_MAX_CONN 0
166+
#endif
167+
168+
#if !defined(TICKER_USER_LLL_VENDOR_OPS)
169+
#define TICKER_USER_LLL_VENDOR_OPS 0
170+
#endif /* TICKER_USER_LLL_VENDOR_OPS */
171+
172+
#if !defined(TICKER_USER_ULL_HIGH_VENDOR_OPS)
173+
#define TICKER_USER_ULL_HIGH_VENDOR_OPS 0
174+
#endif /* TICKER_USER_ULL_HIGH_VENDOR_OPS */
175+
176+
#if !defined(TICKER_USER_THREAD_VENDOR_OPS)
177+
#define TICKER_USER_THREAD_VENDOR_OPS 0
178+
#endif /* TICKER_USER_THREAD_VENDOR_OPS */
179+
180+
/* Define ticker user operations */
181+
#if defined(CONFIG_BT_CTLR_LOW_LAT) && \
182+
(CONFIG_BT_CTLR_LLL_PRIO == CONFIG_BT_CTLR_ULL_LOW_PRIO)
183+
#define TICKER_USER_LLL_OPS (3 + TICKER_USER_LLL_VENDOR_OPS + 1)
184+
/* NOTE: When ticker job is disabled inside radio events then all advertising,
185+
* scanning, and slave latency cancel ticker operations will be deferred,
186+
* requiring increased ticker thread context operation queue count.
187+
*/
188+
#define TICKER_USER_THREAD_OPS (BT_CTLR_ADV_SET + BT_CTLR_SCAN_SET + \
189+
BT_CTLR_MAX_CONN + \
190+
TICKER_USER_THREAD_VENDOR_OPS + \
191+
TICKER_USER_THREAD_FLASH_OPS + \
192+
1)
193+
#else /* !CONFIG_BT_CTLR_LOW_LAT */
194+
#define TICKER_USER_LLL_OPS (2 + TICKER_USER_LLL_VENDOR_OPS + 1)
195+
/* NOTE: As ticker job is not disabled inside radio events, no need for extra
196+
* thread operations queue element for flash driver.
197+
*/
198+
#define TICKER_USER_THREAD_OPS (1 + TICKER_USER_THREAD_VENDOR_OPS + 1)
199+
#endif /* !CONFIG_BT_CTLR_LOW_LAT */
200+
201+
/* NOTE: When ULL_LOW priority is configured to lower than ULL_HIGH, then extra
202+
* ULL_HIGH operations queue elements are required to buffer the
203+
* requested ticker operations.
204+
*/
205+
#define TICKER_USER_ULL_HIGH_OPS (3 + TICKER_USER_ULL_HIGH_VENDOR_OPS + \
206+
TICKER_USER_ULL_HIGH_FLASH_OPS + 1)
207+
208+
#define TICKER_USER_ULL_LOW_OPS (1 + 1)
209+
187210
#define TICKER_USER_OPS (TICKER_USER_LLL_OPS + \
188211
TICKER_USER_ULL_HIGH_OPS + \
189212
TICKER_USER_ULL_LOW_OPS + \
190-
TICKER_USER_THREAD_OPS + \
191-
FLASH_TICKER_USER_APP_OPS)
213+
TICKER_USER_THREAD_OPS)
192214

193215
/* Memory for ticker nodes/instances */
194216
static uint8_t MALIGN(4) ticker_nodes[TICKER_NODES][TICKER_NODE_T_SIZE];
@@ -363,7 +385,7 @@ int ll_init(struct k_sem *sem_rx)
363385
ticker_users[MAYFLY_CALL_ID_0][0] = TICKER_USER_LLL_OPS;
364386
ticker_users[MAYFLY_CALL_ID_1][0] = TICKER_USER_ULL_HIGH_OPS;
365387
ticker_users[MAYFLY_CALL_ID_2][0] = TICKER_USER_ULL_LOW_OPS;
366-
ticker_users[MAYFLY_CALL_ID_PROGRAM][0] = TICKER_USER_APP_OPS;
388+
ticker_users[MAYFLY_CALL_ID_PROGRAM][0] = TICKER_USER_THREAD_OPS;
367389

368390
err = ticker_init(TICKER_INSTANCE_ID_CTLR,
369391
TICKER_NODES, &ticker_nodes[0],
@@ -1282,10 +1304,10 @@ void ll_tx_ack_put(uint16_t handle, struct node_tx *node_tx)
12821304
#endif /* CONFIG_BT_CONN */
12831305

12841306
void ll_timeslice_ticker_id_get(uint8_t * const instance_index,
1285-
uint8_t * const user_id)
1307+
uint8_t * const ticker_id)
12861308
{
12871309
*instance_index = TICKER_INSTANCE_ID_CTLR;
1288-
*user_id = (TICKER_NODES - FLASH_TICKER_NODES);
1310+
*ticker_id = (TICKER_NODES - FLASH_TICKER_NODES);
12891311
}
12901312

12911313
void ll_radio_state_abort(void)

0 commit comments

Comments
 (0)