-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Bluetooth: ascs: Handle ASE control point operations in separate thread #59775
Bluetooth: ascs: Handle ASE control point operations in separate thread #59775
Conversation
@MariuszSkamra Before I dive too deep into the implementation of this, what is the advantage of using a new thread for this compared to the system workqueue thread? |
subsys/bluetooth/audio/ascs.c
Outdated
@@ -2905,4 +2993,7 @@ void bt_ascs_cleanup(void) | |||
unicast_server_cb = NULL; | |||
} | |||
} | |||
|
|||
K_THREAD_DEFINE(ascs, CONFIG_BT_ASCS_STACK_SIZE, ascs_thread, NULL, NULL, NULL, |
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.
I am wondering if we can get this working without the need for a separate thread (thinking memory constraints)?
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.
I decided to make use of the System Workqueue thread
Being slightly cautious adding to the memory budget, I am wondering if this can be done without a separate thread. Also, do we have some real life tests/observations where this causes a clear issue (sans thread)? |
5a2902e
to
3a47272
Compare
3a47272
to
656221e
Compare
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.
Changes are sound, and none of my comments are blocking
subsys/bluetooth/audio/ascs.c
Outdated
err = k_work_submit(&ase->state_transition_work); | ||
if (err < 0) { | ||
return err; |
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.
Maybe we should log this?
If this indeed fails, then we can't really recover from it, can we?
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.
I'll add a log, but I'm not sure about how to recover if this one fails.
k_work_submit
API defines below errors that might be returned:
* @retval -EBUSY
* * if work submission was rejected because the work item is cancelling; or
* * @p queue is draining; or
* * @p queue is plugged.
* @retval -EINVAL if @p queue is null and the work item has never been run.
* @retval -ENODEV if @p queue has not been started.
I think that in case of System Workqueue, EINVAL
and ENODEV
if returned indicate some failure in the system. Not sure about EBUSY
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.
Indeed. We can't really do much besides logging this as an LOG_ERR
; I don't think we can do anything to recover from it
@MariuszSkamra please rebase |
The `ops` variable is unused, thus can be removed. Signed-off-by: Mariusz Skamra <[email protected]>
This adds handling of ASE control point operations in separate thread so that the notifications of ASE state changes are sent from non-BT thread. This ensures bt_gatt_notify_cb to be blocking waiting for available buffers to send the notifications. Signed-off-by: Mariusz Skamra <[email protected]>
656221e
to
3264836
Compare
This adds handling of ASE control point operations in separate thread
so that the notifications of ASE state changes are sent from non-BTRX
thread. This ensures bt_gatt_notify_cb to be blocking waiting for
available buffers to send the notifications.