Skip to content

Bluetooth: BAP: Sink: Move mod_src_param to RAM #88251

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

Merged

Conversation

Thalley
Copy link
Collaborator

@Thalley Thalley commented Apr 7, 2025

The mod_src_param was several places stored on the stack. However this is a complex paramater struct that has 2 Kconfig options that can significantly increase the size, and the maximum size of the parameter is nearly 8 KiB, and was always place the in the BT RX thread's stack.

For this reason, the param is now stored in a single static variable in RAM instead, so that the BT RX thread's stack does not need to be increased based on the Kconfig options, as that is quite difficult for users to be aware of.

The add_src_param has been left as is, as that stored in the calling thread, and it is easier for an application to determine if the calling thread needs additional stack space.

The mod_src_param was several places stored on the stack.
However this is a complex paramater struct that has
2 Kconfig options that can significantly increase the size,
and the maximum size of the parameter is nearly 8 KiB, and
was always place the in the BT RX thread's stack.

For this reason, the param is now stored in a single
static variable in RAM instead, so that the BT RX thread's stack
does not need to be increased based on the Kconfig options,
as that is quite difficult for users to be aware of.

The add_src_param has been left as is, as that stored in
the calling thread, and it is easier for an application
to determine if the calling thread needs additional stack
space.

Signed-off-by: Emil Gydesen <[email protected]>
@Thalley Thalley requested a review from Copilot April 7, 2025 11:42
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

subsys/bluetooth/audio/bap_broadcast_sink.c:66

  • [nitpick] Consider rephrasing the comment for clarity, e.g., 'The mod_src_param is intended to be used solely by the BT RX thread and is statically allocated due to its configurable size.'
/* The mod_src_param is and shall only be used by the BT RX thread. It is statically defined due to

subsys/bluetooth/audio/bap_broadcast_sink.c:514

  • Since the function no longer accepts a mod_src_param parameter and instead uses the global instance, update its documentation and/or naming to clearly reflect this change.
static int update_recv_state_base_copy_meta(const struct bt_bap_base *base)

@kartben kartben merged commit 11c3ee1 into zephyrproject-rtos:main Apr 22, 2025
29 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Bluetooth LE Audio Apr 22, 2025
@Thalley Thalley deleted the broadcast_sink_mod_src_stack_fix branch April 22, 2025 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants