You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bluetooth: Host: Don't call user callback from TX thread
ATT is invoking user callbacks in its net_buf destroy function. It is
common practice that these callbacks can block on bt_hci_cmd_alloc(), so
we must consider these callbacks as blocking. This is a deadlock when
the net_buf_unref() happens inside the HCI driver, driver invoked from
tx_processor. Blocking callbacks like this appear in our own samples.
See further down about how this problem was detected.
Currently, tx_processor not protect against blocking callbacks so it is
de-facto forbidden. The Host should not equip net_bufs with dangerous
destroy callbacks.
This commit makes ATT defer its net_buf destruction and user callback
invocation to the system workqueue, so that net_buf_unref is safe to
call from non-blocking threads. Unsafe code is banished to the system
workqueue wild west. Future improvement may be to allow the user to
provide their own workqueue for ATT callbacks.
This deadlock was detected because the following test was failing while
tx_processor to the bt_taskq:
tests/bsim/bluetooth/ll/throughput/tests_scripts/gatt_write.sh
The above test has an ATT callback `write_cmd_cb` invokes
`bt_conn_le_param_update` can block waiting for `tx_processor`.
Signed-off-by: Aleksander Wasaznik <[email protected]>
0 commit comments