Skip to content
Commit bbfa3bc1 authored by Lyle Zhu's avatar Lyle Zhu Committed by Anas Nashif
Browse files

Bluetooth: HFP_AG: Optimize lock/unlock of the SCO creating

When testing https://github.com/zephyrproject-rtos/zephyr/pull/72090/

,
there is an issue found.

The change in the previous commit is to put all data sending
operations into the work queue context, and lock the current
AG before sending data.

And in change of #72090, the HCI TX thread is removed. All
sending sequence are happened in work queue context.

There is a possible problem when AG creates a SCO connection
by calling the function bt_conn_create_sco. Before the
function bt_conn_create_sco is called, AG will be locked to
avoid creating repeated SCO connection.
And the execution of the function bt_conn_create_sco
depends on the work queue. Because the HCI command of
function bt_conn_create_sco is sent in work queue context.

In the normal case, there is not any issue.
But there is a case that when the function
bt_conn_create_sco is being executed, there is a pending AG
TX waiting to be executed.

Once the work queue starts executing the handler, the AG TX
handler is executed first. Since the lock has been acquired
by other threads, the AG TX handler cannot acquire the lock.
As a result, the SCO connection creation fails.

Remove the AG lock from SCO creating. Instead, use a flag
to mark whether a SCO connection is be created.

Signed-off-by: default avatarLyle Zhu <lyle.zhu@nxp.com>
parent 6939c8c0
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment