-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Bluetooth: ISO: Cleanup BIG before stopped callback #93324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Bluetooth: ISO: Cleanup BIG before stopped callback #93324
Conversation
BIS termination as broadcaster is handled different than ACL and CIS, and in rare chances the tx_complete for BIS may not have been completed in the system workqueue before iso_new was called for the same bt_conn struct (e.g. via bt_iso_cig_create), which would perform k_work_init(&conn->tx_complete_work, tx_complete_work); but where conn->tx_complete_work still existed in the system workqueue, which would cause the list of pending items on the system workqueue to be removed as the `next` pointer would be NULL. This also adds an assert in bt_conn_new to prevent this issue from appearing again. Signed-off-by: Emil Gydesen <[email protected]>
Modify the big_disconnect function to do cleanup_big before calling the `stopped` callback. This will allow the ISO channels, as well as the BIG itself, to be reused for other purposes directly in the stopped callback, without having to offload such actions to a separate thread. Signed-off-by: Emil Gydesen <[email protected]>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modifies the BIG (Broadcast Isochronous Group) disconnection sequence to perform cleanup before invoking the stopped callback, allowing callers to immediately reuse BIG and ISO channel resources. The key changes include:
- Moved
cleanup_big()
call insidebig_disconnect()
to occur before the stopped callback - Added special handling for BIS (Broadcast Isochronous Stream) TX completion cleanup
- Added assertion to prevent workqueue corruption during connection initialization
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
subsys/bluetooth/host/iso.c |
Core change: moves cleanup_big() into big_disconnect() and adds BIS TX completion handling |
subsys/bluetooth/host/conn.c |
Adds assertion to prevent workqueue corruption during connection initialization |
tests/bluetooth/host/conn/mocks/kernel.h |
Adds mock declaration for k_work_busy_get function |
tests/bluetooth/host/conn/mocks/kernel.c |
Adds mock implementation for k_work_busy_get function |
@@ -372,6 +372,8 @@ struct bt_conn *bt_conn_new(struct bt_conn *conns, size_t size) | |||
k_work_init_delayable(&conn->deferred_work, deferred_work); | |||
#endif /* CONFIG_BT_CONN */ | |||
#if defined(CONFIG_BT_CONN_TX) | |||
__ASSERT(!k_work_is_pending(&conn->tx_complete_work), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion uses k_work_is_pending() but the mock system only provides k_work_busy_get(). The k_work_is_pending() function may not be available in the test environment, potentially causing build failures in tests.
__ASSERT(!k_work_is_pending(&conn->tx_complete_work), | |
__ASSERT(!(k_work_busy_get(&conn->tx_complete_work) & K_WORK_BUSY_PENDING), |
Copilot uses AI. Check for mistakes.
Modify the big_disconnect function to do cleanup_big before
calling the
stopped
callback. This will allow the ISO channels,as well as the BIG itself, to be reused for other purposes directly
in the stopped callback, without having to offload such actions
to a separate thread.