-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Bluetooth: Controller: Fix LLCP event_counter value used during prepare #92726
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: Controller: Fix LLCP event_counter value used during prepare #92726
Conversation
c47bfa7
to
5a1f863
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.
Pull Request Overview
This PR fixes the LLCP instant comparison to use the event counter value captured during the prepare phase, preventing stale counter usage when radio events overlap.
- Introduce
ull_conn_event_counter_at_prepare()
and replace direct calls toull_conn_event_counter()
in all LLCP instant checks. - Adjust channel map update instant to include slave latency.
- Add declaration and implementation of the prepare-phase event counter helper.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
subsys/bluetooth/controller/ll_sw/ull_llcp_phy.c | Replaced instant checks to use the new prepare-phase counter helper. |
subsys/bluetooth/controller/ll_sw/ull_llcp_conn_upd.c | Swapped out raw event counter calls for prepare-phase variant in connection update. |
subsys/bluetooth/controller/ll_sw/ull_llcp_chmu.c | Added slave latency to channel map instant; switched runtime checks to use prepare-phase counter. |
subsys/bluetooth/controller/ll_sw/ull_llcp_cc.c | Updated CIS create instant checks to utilize the prepare-phase counter. |
subsys/bluetooth/controller/ll_sw/ull_conn_internal.h | Declared ull_conn_event_counter_at_prepare() . |
subsys/bluetooth/controller/ll_sw/ull_conn.c | Implemented ull_conn_event_counter_at_prepare() and replaced a counter usage in parameter update. |
Comments suppressed due to low confidence (2)
subsys/bluetooth/controller/ll_sw/ull_conn_internal.h:87
- Add a brief comment describing that this returns the event counter value as captured during the prepare phase (event_counter + latency_prepare + lazy).
uint16_t ull_conn_event_counter_at_prepare(struct ll_conn *conn);
subsys/bluetooth/controller/ll_sw/ull_conn.c:2180
- No unit tests appear to cover
ull_conn_event_counter_at_prepare
. Adding tests for variouslatency_prepare
andllcp.prep.lazy
scenarios will help validate its behavior.
uint16_t ull_conn_event_counter_at_prepare(struct ll_conn *conn)
ctx->data.chmu.instant = ull_conn_event_counter(conn) + conn->lll.latency + | ||
CHMU_INSTANT_DELTA; |
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.
This manual calculation may not match the helper's logic (which adds latency_prepare and lazy). Consider using ull_conn_event_counter_at_prepare(conn) + CHMU_INSTANT_DELTA
to keep consistency across instant calculations.
ctx->data.chmu.instant = ull_conn_event_counter(conn) + conn->lll.latency + | |
CHMU_INSTANT_DELTA; | |
ctx->data.chmu.instant = ull_conn_event_counter_at_prepare(conn) + CHMU_INSTANT_DELTA; |
Copilot uses AI. Check for mistakes.
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.
Minor suggestion, but otherwise LGTM
5a1f863
to
25d1ea7
Compare
25d1ea7
to
c85adc3
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.
Need time to look at this.
The issue was discovered running the |
This PR removes fixes that were made as part of #52822 to stabilize CIS therefore I'm not really fond of it.
I'm also a bit curious to why the LLCP unit-tests are passing with this change, either they aren't being run or they don't catch this |
Above is the added fixes/improvement comment, but which can execute anyway inside a connection event anywhere upto 150 us before the next connection event. During the overlap of preemption timeout duration, the
I do not think there is a test to cover the fixes/improvements added in #52822 where the call to |
The original commit has a bit more explaining: 4f5b711 It's to handle the case where the CIS begins in the next event. |
Fix LLCP to use event_counter value used during prepare to compare instant to be the value as when in prepare and not incorrectly use a stale value (when two radio events overlap). Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
c85adc3
to
3cad4b1
Compare
Correction, i.e it is an improvement to handle cases where CIS begins in the current ACL event (and before next ACL event) where the CIS_IND was received. Without the improvement, the CIS will still be established in the next ACL event after calculating any instant latency and appropriately compensating for elapsed CIS intervals and CIS offsets (hence no CI tests failed with/without this improvement) I have added back the improvement with renamed function names to bring clarity to when the instant is checked, state machine run at prepare versus on reception of CIS_IND PDU. |
|
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.
Is there any way to test this fix? CI passes both before and after
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'm wondering if the usefulness of ull_conn_event_counter()
is gone, now we know that the ull_ref_get()
logic is flawed...
None the less, I'll approve these changes.
That said, current use of |
Testable in unit test (otherwise flakky to test with a modified tester Controller implementation under bsim). This PR is not fixing anything fatal, I can get back to adding unit test after some quiet period! |
Fix LLCP to use event_counter value used during prepare to compare instant to be the value as when in prepare and not incorrectly use a stale value (when two radio events overlap).