Skip to content

Commit 85922c0

Browse files
cvinayakAnas Nashif
authored andcommitted
Bluetooth: Controller: mayfly enable to supercede over disable
If mayfly enable is called before mayfly could be disabled, then enable shall supercede disabling, the mayfly will remain enabled. Any new mayfly enqueued by the caller that tried to disable mayfly will be chain for deferred executon under this condition. The BLE Controller's connection update procedure broke when mayfly implementation was updated to defer disabling until all queued mayfly where completed. Mayfly is disabled between ticker_stop and ticker_start calls to chain them so that ticker does not power off counter h/w if the ticker being stopped is last one. This commit fixes the connection update procedure which used the mayfly enable before mayfly disable could complete. Jira: ZEP-1839 Change-id: I07d34c90d193b5eca9762acd8b7272e8d7a78474 Signed-off-by: Vinayak Chettimada <[email protected]>
1 parent 1408ade commit 85922c0

File tree

1 file changed

+23
-10
lines changed
  • subsys/bluetooth/controller/util

1 file changed

+23
-10
lines changed

subsys/bluetooth/controller/util/mayfly.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414
static struct {
1515
void *head;
1616
void *tail;
17-
union {
18-
uint32_t flags;
19-
struct {
20-
uint32_t disable_req : 1;
21-
uint32_t disable_ack : 1;
22-
};
23-
};
17+
uint8_t enable_req;
18+
uint8_t enable_ack;
19+
uint8_t disable_req;
20+
uint8_t disable_ack;
2421
} mft[MAYFLY_CALLEE_COUNT][MAYFLY_CALLER_COUNT];
2522

2623
static void *mfl[MAYFLY_CALLEE_COUNT][MAYFLY_CALLER_COUNT][2];
@@ -45,6 +42,11 @@ void mayfly_init(void)
4542
void mayfly_enable(uint8_t caller_id, uint8_t callee_id, uint8_t enable)
4643
{
4744
if (enable) {
45+
if (mft[callee_id][caller_id].enable_req ==
46+
mft[callee_id][caller_id].enable_ack) {
47+
mft[callee_id][caller_id].enable_req++;
48+
}
49+
4850
mayfly_enable_cb(caller_id, callee_id, enable);
4951
} else {
5052
if (mft[callee_id][caller_id].disable_req ==
@@ -63,7 +65,9 @@ uint32_t mayfly_enqueue(uint8_t caller_id, uint8_t callee_id, uint8_t chain,
6365
uint8_t ack;
6466

6567
chain = chain || !mayfly_prio_is_equal(caller_id, callee_id) ||
66-
!mayfly_is_enabled(caller_id, callee_id);
68+
!mayfly_is_enabled(caller_id, callee_id) ||
69+
(mft[callee_id][caller_id].disable_req !=
70+
mft[callee_id][caller_id].disable_ack);
6771

6872
/* shadow the ack */
6973
ack = m->_ack;
@@ -110,8 +114,9 @@ uint32_t mayfly_enqueue(uint8_t caller_id, uint8_t callee_id, uint8_t chain,
110114

111115
void mayfly_run(uint8_t callee_id)
112116
{
113-
uint8_t caller_id;
114117
uint8_t disable = 0;
118+
uint8_t enable = 0;
119+
uint8_t caller_id;
115120

116121
/* iterate through each caller queue to this callee_id */
117122
caller_id = MAYFLY_CALLER_COUNT;
@@ -180,9 +185,17 @@ void mayfly_run(uint8_t callee_id)
180185
mft[callee_id][caller_id].disable_ack =
181186
mft[callee_id][caller_id].disable_req;
182187
}
188+
189+
if (mft[callee_id][caller_id].enable_req !=
190+
mft[callee_id][caller_id].enable_ack) {
191+
enable = 1;
192+
193+
mft[callee_id][caller_id].enable_ack =
194+
mft[callee_id][caller_id].enable_req;
195+
}
183196
}
184197

185-
if (disable) {
198+
if (disable && !enable) {
186199
mayfly_enable_cb(callee_id, callee_id, 0);
187200
}
188201
}

0 commit comments

Comments
 (0)