Skip to content

Commit 5c9fefb

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Port HCI Command buffer allocation
Refer to commit zephyrproject-rtos/zephyr@d382fca Signed-off-by: Vinayak Kariappa Chettimada <[email protected]> (cherry picked from commit beadde7)
1 parent ea7d8a1 commit 5c9fefb

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Kconfig.nrf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ config MCUMGR_TRANSPORT_NETBUF_SIZE
8484
default 2475 if MCUMGR_TRANSPORT_BT_REASSEMBLY
8585
default 1024 if UPDATEABLE_IMAGE_NUMBER > 1
8686

87-
# When using HCI on the nRF5340 we need a larger command buffer.
88-
config BT_BUF_CMD_TX_COUNT
89-
default 10 if SOC_COMPATIBLE_NRF5340_CPUAPP || SOC_COMPATIBLE_NRF5340_CPUNET
90-
9187
config INIT_ARCH_HW_AT_BOOT
9288
default y
9389
help

subsys/bluetooth/controller/hci_internal_wrappers.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
* to avoid deadlocks due to missing CMD buffers, if the host is only allocating the next command
3737
* once the previous is completed.
3838
*/
39-
BUILD_ASSERT(BT_BUF_ACL_RX_COUNT < CONFIG_BT_BUF_CMD_TX_COUNT,
39+
#define BT_BUF_CMD_TX_COUNT CONFIG_BT_BUF_CMD_TX_COUNT
40+
41+
BUILD_ASSERT(BT_BUF_ACL_RX_COUNT < BT_BUF_CMD_TX_COUNT,
4042
"Too low HCI command buffers compared to ACL Rx buffers.");
4143
#else /* controller-only build */
4244
/*
@@ -46,7 +48,9 @@ BUILD_ASSERT(BT_BUF_ACL_RX_COUNT < CONFIG_BT_BUF_CMD_TX_COUNT,
4648
* do flow control, at least one more buffer is needed.
4749
*
4850
*/
49-
BUILD_ASSERT((CONFIG_BT_BUF_CMD_TX_COUNT - 1) > 0,
51+
#define BT_BUF_CMD_TX_COUNT (BT_BUF_RX_COUNT + 1)
52+
53+
BUILD_ASSERT((BT_BUF_CMD_TX_COUNT - 1) > 0,
5054
"We need at least two HCI command buffers to avoid deadlocks.");
5155
#endif /* CONFIG_BT_CONN && CONFIG_BT_HCI_HOST */
5256

@@ -71,7 +75,7 @@ int sdc_hci_cmd_cb_host_buffer_size_wrapper(const sdc_hci_cmd_cb_host_buffer_siz
7175
sdc_hci_cmd_cb_host_buffer_size_t ctrl_cmd_params = *cmd_params;
7276

7377
ctrl_cmd_params.host_total_num_acl_data_packets = MIN(
74-
ctrl_cmd_params.host_total_num_acl_data_packets, (CONFIG_BT_BUF_CMD_TX_COUNT - 1));
78+
ctrl_cmd_params.host_total_num_acl_data_packets, (BT_BUF_CMD_TX_COUNT - 1));
7579

7680
return sdc_hci_cmd_cb_host_buffer_size(&ctrl_cmd_params);
7781
}

0 commit comments

Comments
 (0)