|
2 | 2 |
|
3 | 3 | /*
|
4 | 4 | * Copyright (c) 2015-2016 Intel Corporation
|
| 5 | + * Copyright (c) 2025 Nordic Semiconductor ASA |
5 | 6 | *
|
6 | 7 | * SPDX-License-Identifier: Apache-2.0
|
7 | 8 | */
|
@@ -3932,12 +3933,25 @@ static void att_chan_mtu_updated(struct bt_att_chan *updated_chan)
|
3932 | 3933 | struct bt_att_req *bt_att_req_alloc(k_timeout_t timeout)
|
3933 | 3934 | {
|
3934 | 3935 | struct bt_att_req *req = NULL;
|
| 3936 | + k_tid_t current_thread = k_current_get(); |
3935 | 3937 |
|
3936 |
| - if (k_current_get() == att_handle_rsp_thread) { |
3937 |
| - /* No req will be fulfilled while blocking on the bt_recv thread. |
3938 |
| - * Blocking would cause deadlock. |
| 3938 | + if (current_thread == att_handle_rsp_thread || |
| 3939 | + current_thread == k_work_queue_thread_get(&k_sys_work_q)) { |
| 3940 | + /* bt_att_req are released by the att_handle_rsp_thread. |
| 3941 | + * A blocking allocation the same thread would cause a |
| 3942 | + * deadlock. |
| 3943 | + * |
| 3944 | + * Likewise, the system work queue is used for |
| 3945 | + * tx_processor(), which is needed to send currently |
| 3946 | + * pending requests. Blocking here in a situation where |
| 3947 | + * all the request holding a bt_att_req have yet to go |
| 3948 | + * through the tx_processor() would cause a deadlock. |
| 3949 | + * |
| 3950 | + * Note the att_handle_rsp_thread might be the system |
| 3951 | + * work queue thread or the dedicated BT RX WQ thread, |
| 3952 | + * depending on kconfig. |
3939 | 3953 | */
|
3940 |
| - LOG_DBG("Timeout discarded. No blocking on bt_recv thread."); |
| 3954 | + LOG_DBG("Timeout discarded. No blocking on BT RX WQ or SYS WQ threads."); |
3941 | 3955 | timeout = K_NO_WAIT;
|
3942 | 3956 | }
|
3943 | 3957 |
|
|
0 commit comments