Skip to content

Commit 3a80785

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: controller: Fix connection terminate to happen on event done
Fix conn_cleanup to be performed in the event done. The regression was introduced in commit 5412f61 ("Bluetooth: controller: Introduce separate done memq"). Now that done event is handled asynchronously outside the handling of the terminate node rx type, it is necessary that terminate node rx type is generated after the done event. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 13b4d44 commit 3a80785

File tree

5 files changed

+141
-83
lines changed

5 files changed

+141
-83
lines changed

subsys/bluetooth/controller/ll_sw/ull_adv.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ uint8_t ll_adv_enable(uint8_t enable)
913913
conn->llcp_feature.features_peer = 0;
914914
conn->llcp_version.req = conn->llcp_version.ack = 0;
915915
conn->llcp_version.tx = conn->llcp_version.rx = 0;
916-
conn->llcp_terminate.reason_peer = 0;
916+
conn->llcp_terminate.reason_final = 0;
917917
/* NOTE: use allocated link for generating dedicated
918918
* terminate ind rx node
919919
*/
@@ -1822,7 +1822,6 @@ static void ticker_op_stop_cb(uint32_t status, void *param)
18221822
static struct mayfly mfy = {0, 0, &link, NULL, NULL};
18231823
struct ll_adv_set *adv;
18241824
struct ull_hdr *hdr;
1825-
uint32_t ret;
18261825

18271826
/* Ignore if race between thread and ULL */
18281827
if (status != TICKER_STATUS_SUCCESS) {
@@ -1838,10 +1837,18 @@ static void ticker_op_stop_cb(uint32_t status, void *param)
18381837
}
18391838
#endif /* CONFIG_BT_HCI_MESH_EXT */
18401839

1840+
/* NOTE: We are in ULL_LOW which can be pre-empted by ULL_HIGH.
1841+
* As we are in the callback after successful stop of the
1842+
* ticker, the ULL reference count will not be modified
1843+
* further hence it is safe to check and act on either the need
1844+
* to call lll_disable or not.
1845+
*/
18411846
adv = param;
18421847
hdr = &adv->ull;
18431848
mfy.param = &adv->lll;
18441849
if (ull_ref_get(hdr)) {
1850+
uint32_t ret;
1851+
18451852
LL_ASSERT(!hdr->disabled_cb);
18461853
hdr->disabled_param = mfy.param;
18471854
hdr->disabled_cb = disabled_cb;
@@ -1851,6 +1858,8 @@ static void ticker_op_stop_cb(uint32_t status, void *param)
18511858
TICKER_USER_ID_LLL, 0, &mfy);
18521859
LL_ASSERT(!ret);
18531860
} else {
1861+
uint32_t ret;
1862+
18541863
mfy.fp = disabled_cb;
18551864
ret = mayfly_enqueue(TICKER_USER_ID_ULL_LOW,
18561865
TICKER_USER_ID_ULL_HIGH, 0, &mfy);

0 commit comments

Comments
 (0)