-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Bluetooth: Controller: Fix Extended Scanning for slow CPUs #98267
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 Extended Scanning for slow CPUs #98267
Conversation
|
This pull request introduces a robust handling mechanism for radio ISR latency issues during auxiliary PDU reception setup in the Bluetooth controller. It adds logic to detect and gracefully handle missed hard realtime deadlines, reducing the risk of assertion failures and improving system resilience on slower CPUs. Improvements to radio ISR latency handling:
|
Summary
Possible regression failures and drawbacks
Impact and severity
Notes / suggestions (for consideration)
Overall assessment
|
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 adds graceful handling for high Radio ISR latencies on slower CPUs (e.g., nRF51x with 16 MHz ARM Cortex-M0) during extended Bluetooth scanning. When the radio setup fails to meet hard real-time deadlines due to CPU limitations, the code now implements a retry mechanism with countdown before asserting, rather than immediately failing.
Key Changes:
- Implements a countdown-based retry mechanism (up to 3 attempts) when radio setup timing fails
- Adds graceful radio event cleanup paths for both auxiliary and non-auxiliary scanning contexts
- Enhances assertion diagnostics with ISR latency information when profiling is enabled
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const uint8_t latency_skip_max = 3U; | ||
| static uint8_t latency_skip_countdown = latency_skip_max; |
Copilot
AI
Oct 26, 2025
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 static variable latency_skip_countdown is not thread-safe. In interrupt contexts or concurrent execution scenarios, multiple invocations could race on this shared state, leading to incorrect countdown behavior. Consider using atomic operations or re-architecting to avoid shared mutable state across ISR invocations.
Add implementation to gracefully handle failure due to high Radio ISR latencies due to higher CPU usage in LLL execution context just before the handling of Radio IRQs. Higher CPU time usage in LLL execution context can be due to slow CPUs, example, nRF51x SoC Series with 16 MHz ARM Cortex-M0 CPU. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
0dbd7c4 to
c37debb
Compare
|
This pull request introduces several improvements and bug fixes to the Bluetooth controller's low-latency features, configuration, and radio event handling. The changes focus on making low-latency options more robust, improving error handling for radio event setup, and cleaning up configuration dependencies. Low-latency features and configuration:
Radio event handling and error resilience:
Low-latency ticker synchronization:
|
ba17b0a to
c3f2124
Compare
|
| * Detect the latency and gracefully close the radio event. If there is consecutive | ||
| * failure, then lets catch it in an assertion check. | ||
| */ | ||
| const uint8_t latency_skip_max = 3U; |
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.
Why the magic number 3 here?
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.
Constant value (instead of define far away from locality of reference) to detect and assert consecutively skipped reception.
Should I have a Kconfig for this? value of greater than 0 for nRF51 and 0 for other faster SoCs?
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 more interested in why the value is 3, rather than any other value. It's OK to have constants defined like this instead of #defines etc., but the actual value needs to be documented on why it is that specific value, unless it's obvious (which it isn't in this case IMO)
| latency_skip_countdown--; | ||
|
|
||
| /* Gracefully close the radio event */ | ||
| if (lll_aux) { |
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.
| if (lll_aux) { | |
| if (lll_aux != NULL) { |
| struct node_rx_pdu *node_rx2; | ||
|
|
||
| node_rx2 = ull_pdu_rx_alloc(); | ||
| LL_ASSERT_ERR(node_rx2); |
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.
| LL_ASSERT_ERR(node_rx2); | |
| LL_ASSERT_ERR(node_rx2 != NULL); |



Add implementation to gracefully handle failure due to high Radio ISR latencies due to higher CPU usage in LLL execution context just before the handling of Radio IRQs. Higher CPU time usage in LLL execution context can be due to slow CPUs, example, nRF51x SoC Series with 16 MHz ARM Cortex-M0 CPU.