fix/update BLE log SPI LBM (IDFGH-17969)#18834
Conversation
|
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 77586fb. Configure here.
|
|
||
| size_t payload_len = len + len_append; | ||
|
|
||
| ble_log_prph_trans_t *trans = ble_log_pool_acquire(payload_len, is_isr); |
There was a problem hiding this comment.
LL task writers can block
High Severity
ble_log_write_hex_ll in task context now goes through ble_log_pool_acquire with backpressure enabled, so the Link Layer or HCI task can block on xSemaphoreTake when the pool is empty. Previously those paths used dedicated non-blocking LBMs and dropped on exhaustion. Blocking the controller task under log pressure can stall BLE scheduling.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 77586fb. Configure here.
| ble_log_prph_trans_t *trans = g_pool.trans[id]; | ||
| while (!ble_log_cas_acquire(&trans->atomic_lock)) { | ||
| /* A writer holds the lock only for a single-frame memcpy. */ | ||
| } |
There was a problem hiding this comment.
Flush lock spin can hang
High Severity
ble_log_flush busy-waits on ble_log_cas_acquire with no yield or delay. If a lower-priority writer holds atomic_lock and flush runs at higher priority, the writer never resumes, the spin never exits, and the system hangs until the watchdog.
Reviewed by Cursor Bugbot for commit 77586fb. Configure here.
| goto failed; | ||
| else if (src_code == BLE_LOG_SRC_LL_HCI) { | ||
| if (len_append > CONFIG_BLE_LOG_LL_HCI_LOG_PAYLOAD_LEN_LIMIT) { | ||
| len_append = CONFIG_BLE_LOG_LL_HCI_LOG_PAYLOAD_LEN_LIMIT; |
There was a problem hiding this comment.
HCI upstream limit skipped
Medium Severity
When BLE_LOG_LL_HCI_LOG_PAYLOAD_LEN_LIMIT_ENABLED is set, truncation only runs for BLE_LOG_SRC_LL_HCI. Upstream HCI logs (BLE_LOG_SRC_HCI / BLE_LOG_LL_FLAG_HCI_UPSTREAM) no longer get the limit, so large len_append values can exceed the intended cap or fail to fit a transport.
Reviewed by Cursor Bugbot for commit 77586fb. Configure here.


Description
Related
Testing
Checklist
Before submitting a Pull Request, please ensure the following:
Note
High Risk
Large concurrency and lifecycle changes in ISR/task logging, flush/deinit, and sdkconfig tuning; mis-tuning or races could cause dropped logs, stalls, or use-after-free if shutdown ordering regresses.
Overview
Replaces the old multi-LBM design (separate atomic/spin/Link Layer managers and per-LBM transport sizing) with a single global pool of transport buffers shared by task, ISR, and Link Layer writers.
Kconfig drops per-LBM options (auto-flush, atomic LBM counts, common/LL total memory) and adds pool tuning:
BLE_LOG_POOL_TRANS_CNT, ISR reserve count, per-buffer size, optional ISR OPEN-scan cap, and task backpressure timeout.Allocation path uses per-buffer
atomic_lock, FREE/OPEN/SENDING lifecycle, and free/open hint bitmaps with round-robin scan. Task writers can block on a counting semaphore (with timeout) when the pool is full; ISR writers use shared buffers first, then a reserved ISR region, and never block. Recycle is centralized inble_log_lbm_recycle_trans()from runtime drain and UART/SPI/dummy tx-done or send-failure paths.Flush/deinit wake blocked tasks, wait on both ref count and
waiting_task_count, seal all OPEN buffers, then wait for pool inflight to drain; per-LBM utilization reporting collapses to one pool record. UART port-0 redirection stays on a separateble_log_redir_t(not pool IDs).ble_log_write_final_stat/ble_log_write_internaland the old LBM acquire/release write path are removed in favor of direct pool acquire +ble_log_pool_write_frame.Reviewed by Cursor Bugbot for commit 77586fb. Bugbot is set up for automated code reviews on this repo. Configure here.