-
Notifications
You must be signed in to change notification settings - Fork 712
[nrf noup] bluetooth: att: Fix CONFIG_BT_ATT_SENT_CB_AFTER_TX
#3323
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
Open
MarekPieta
wants to merge
4
commits into
nrfconnect:main
Choose a base branch
from
MarekPieta:fix_att_sent_cb_after_tx
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+29
−10
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d82ab7a
Revert "[nrf noup] bluetooth: conn: Skip buffer ref count check in se…
MarekPieta 65b8128
Revert "[nrf noup] bluetooth: conn: Allow for an extra ref in bt_l2ca…
MarekPieta e5a694b
Revert "[nrf noup] bluetooth: att: Allow ATT sent callback after data…
MarekPieta 5d62bf5
[nrf noup] bluetooth: att: Allow ATT sent callback after data TX is done
MarekPieta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Detecting ATT PDUs by checking buf->ref == 2 is fragile because future changes might introduce other scenarios with extra references for different reasons. I'm not even sure that it's not the case today. Instead of using the ref count as a proxy, I suggest comparing the cb:
But I realized it's a bug that we don't invoke the callbacks here. We should be invoking all the callbacks here just like in
process_unack_tx()
. I made a PR upstream to fix this just now:zephyrproject-rtos/zephyr#97056
I suggest we cherry pick that general fix instead. Can you test that it works for you when it passes the upstream CI?
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
bt_l2cap_send_pdu
andbt_l2cap_dyn_chan_send
both seem to demand thatref
counter is1
for buffers placed on the TX queue. Also it seems that thenet_buf_unref
here is expected to remove the last reference (please correct me if I overlooked something).Using the
closure_cb
as in the code snippet above would require to pass thechan_sent_cb
function (through header or usingextern
keyword). The function would no longer be static for theatt.c
file. I tried to avoid that as it might not be a clean solution.Invoking the sent callback here might help. I will test your commit locally and let you know if it works.
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.
That's just to protect against user error. We did not foresee that a stack-internal user would keep an extra reference and wait for the callback. We just saw no use for the extra reference and it is indicative of a leaked reference. The stack does not rely on this fact AFAIK. We can remove all these checks. Maybe we should.
I prefer that. We are referring to ATT anyway (to explain the code), so including the header is just being explicit about the dependency.
Thanks! It passed CI checks. Invoking the sent callback is a generalization of my code snippet here, so I'm sure it will work. Let's just look out for unintentional breakage elsewhere.
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 confirmed your fix from the upstream PR. As soon as the upstream PR is merged, I will update this PR.