-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Bluetooth: H4: Cannot receive data anymore after the command bt scan on
executed
#89879
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
Labels
area: Bluetooth HCI
Bluetooth HCI Driver
area: Bluetooth
bug
The issue is a bug, or the PR is fixing a bug
priority: low
Low impact/importance bug
Comments
lylezhu2012
added a commit
to nxp-upstream/zephyr
that referenced
this issue
May 14, 2025
There is an issue that the buffer cannot be allocated by the function `read_payload()` in UART ISR context. Then the UART RX will be disabled. The H4 driver hopes to get the receive buffer in the HCI RX thread and then open the UART RX again. However, there is a situation where the HCI RX thread is blocked in getting the received data buffer. However, since the UARt RX has been disabled, the HCI RX thread cannot get the received data buffer. Therefore, the RX thread is always blocked here, causing the Bluetooth host to not work properly. Add a semaphore `active_sem` to notify new received data buffer has been added to H4 RX queue. Wait for the semaphore `active_sem` instead of H4 RX queue in HCI RX thread. Wake up the HCi RX thread when failing to allocate the RX buffer. Fixes zephyrproject-rtos#89879. Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
lylezhu2012
added a commit
to nxp-upstream/zephyr
that referenced
this issue
May 14, 2025
There is an issue that the buffer cannot be allocated by the function `read_payload()` in UART ISR context. Then the UART RX will be disabled. The H4 driver hopes to get the receive buffer in the HCI RX thread and then open the UART RX again. However, there is a situation where the HCI RX thread is blocked in getting the received data buffer. However, since the UARt RX has been disabled, the HCI RX thread cannot get the received data buffer. Therefore, the RX thread is always blocked here, causing the Bluetooth host to not work properly. Add a semaphore `rx.ready` to notify new received data buffer has been added to H4 RX queue. Wait for the semaphore `rx.ready` instead of H4 RX queue in HCI RX thread. Wake up the HCI RX thread when failing to allocate the RX buffer. Fixes zephyrproject-rtos#89879. Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
lylezhu2012
added a commit
to nxp-upstream/zephyr
that referenced
this issue
May 14, 2025
There is an issue that the buffer cannot be allocated by the function `read_payload()` in UART ISR context. Then the UART RX will be disabled. The H4 driver hopes to get the receive buffer in the HCI RX thread and then open the UART RX again. However, there is a situation where the HCI RX thread is blocked in getting the received data buffer. However, since the UARt RX has been disabled, the HCI RX thread cannot get the received data buffer. Therefore, the RX thread is always blocked here, causing the Bluetooth host to not work properly. Add a semaphore `rx.ready` to notify new received data buffer has been added to H4 RX queue. Wait for the semaphore `rx.ready` instead of H4 RX queue in HCI RX thread. Wake up the HCI RX thread when failing to allocate the RX buffer. Fixes zephyrproject-rtos#89879. Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
kartben
pushed a commit
that referenced
this issue
May 26, 2025
There is an issue that the buffer cannot be allocated by the function `read_payload()` in UART ISR context. Then the UART RX will be disabled. The H4 driver hopes to get the receive buffer in the HCI RX thread and then open the UART RX again. However, there is a situation where the HCI RX thread is blocked in getting the received data buffer. However, since the UARt RX has been disabled, the HCI RX thread cannot get the received data buffer. Therefore, the RX thread is always blocked here, causing the Bluetooth host to not work properly. Add a semaphore `rx.ready` to notify new received data buffer has been added to H4 RX queue. Wait for the semaphore `rx.ready` instead of H4 RX queue in HCI RX thread. Wake up the HCI RX thread when failing to allocate the RX buffer. Fixes #89879. Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area: Bluetooth HCI
Bluetooth HCI Driver
area: Bluetooth
bug
The issue is a bug, or the PR is fixing a bug
priority: low
Low impact/importance bug
Describe the bug
The H4 cannot received data anymore after the command
bt scan on
executed if the log<wrn> bt_driver: Failed to allocate, deferring to rx_thread
printed.To Reproduce
Steps to reproduce the behavior:
bt init
andbt scan on
<wrn> bt_driver: Failed to allocate, deferring to rx_thread
printed, no more adv data printed.bt scan off
, the zephyr os will be halt.Expected behavior
The command
bt scan on
should work normally.Impact
Logs and console output
Environment (please complete the following information):
Additional context
I think rx_thread should be blocked at "buf = k_fifo_get(&h4->rx.fifo, K_FOREVER);" after/when printing ' bt_driver: Failed to allocate, deferring to rx_thread'. This results in it not having a chance to execute the code
zephyr/drivers/bluetooth/hci/h4.c
Lines 245 to 258 in 2a20787
The text was updated successfully, but these errors were encountered: