Skip to content

Commit a0ddd88

Browse files
committed
Revert "[nrf fromtree] Bluetooth: Controller: Fix HCI command buffer allocation failure"
This reverts commit eabfcff.
1 parent af6b4bb commit a0ddd88

File tree

30 files changed

+98
-281
lines changed

30 files changed

+98
-281
lines changed

include/zephyr/bluetooth/buf.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ struct bt_buf_data {
100100
* available for the HCI driver to allocate from.
101101
*
102102
* TODO: When CONFIG_BT_BUF_ACL_RX_COUNT is removed,
103-
* remove the MAX and only keep the 1.
103+
* remove the MAX and only keep (CONFIG_BT_MAX_CONN + 1)
104104
*/
105-
#define BT_BUF_ACL_RX_COUNT_EXTRA CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA
106-
#define BT_BUF_ACL_RX_COUNT (MAX(CONFIG_BT_BUF_ACL_RX_COUNT, 1) + BT_BUF_ACL_RX_COUNT_EXTRA)
105+
#define BT_BUF_ACL_RX_COUNT \
106+
(MAX(CONFIG_BT_BUF_ACL_RX_COUNT, (CONFIG_BT_MAX_CONN + 1)) + \
107+
CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA)
107108
#else
108-
#define BT_BUF_ACL_RX_COUNT_EXTRA 0
109-
#define BT_BUF_ACL_RX_COUNT 0
109+
#define BT_BUF_ACL_RX_COUNT 0
110110
#endif /* CONFIG_BT_CONN && CONFIG_BT_HCI_HOST */
111111

112112
#if defined(CONFIG_BT_BUF_ACL_RX_COUNT) && CONFIG_BT_BUF_ACL_RX_COUNT > 0
@@ -120,15 +120,10 @@ BUILD_ASSERT(BT_BUF_ACL_RX_COUNT <= BT_BUF_ACL_RX_COUNT_MAX,
120120
#define BT_BUF_RX_SIZE (MAX(MAX(BT_BUF_ACL_RX_SIZE, BT_BUF_EVT_RX_SIZE), \
121121
BT_BUF_ISO_RX_SIZE))
122122

123-
/* Controller can generate up to CONFIG_BT_BUF_ACL_TX_COUNT number of unique HCI Number of Completed
124-
* Packets events.
125-
*/
126-
BUILD_ASSERT(CONFIG_BT_BUF_EVT_RX_COUNT > CONFIG_BT_BUF_ACL_TX_COUNT,
127-
"Increase Event RX buffer count to be greater than ACL TX buffer count");
128-
129-
/** Buffer count needed for HCI ACL or HCI ISO plus Event RX buffers */
130-
#define BT_BUF_RX_COUNT (CONFIG_BT_BUF_EVT_RX_COUNT + \
131-
MAX(BT_BUF_ACL_RX_COUNT, BT_BUF_ISO_RX_COUNT))
123+
/** Buffer count needed for HCI ACL, HCI ISO or Event RX buffers */
124+
#define BT_BUF_RX_COUNT (MAX(MAX(CONFIG_BT_BUF_EVT_RX_COUNT, \
125+
BT_BUF_ACL_RX_COUNT), \
126+
BT_BUF_ISO_RX_COUNT))
132127

133128
/** Data size needed for HCI Command buffers. */
134129
#define BT_BUF_CMD_TX_SIZE BT_BUF_CMD_SIZE(CONFIG_BT_BUF_CMD_TX_SIZE)

samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ CONFIG_BT_HCI_RAW=y
1313
CONFIG_BT_HCI_RAW_RESERVE=1
1414
CONFIG_BT_MAX_CONN=2
1515

16+
# Workaround: Unable to allocate command buffer when using K_NO_WAIT since
17+
# Host number of completed commands does not follow normal flow control.
18+
CONFIG_BT_BUF_CMD_TX_COUNT=10
19+
1620
CONFIG_BT_BUF_EVT_RX_COUNT=16
21+
1722
CONFIG_BT_BUF_EVT_RX_SIZE=255
1823
CONFIG_BT_BUF_ACL_RX_SIZE=255
1924
CONFIG_BT_BUF_ACL_TX_SIZE=251

samples/bluetooth/hci_ipc/nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ CONFIG_BT_HCI_RAW=y
1111
CONFIG_BT_HCI_RAW_RESERVE=1
1212
CONFIG_BT_MAX_CONN=16
1313

14+
15+
# Workaround: Unable to allocate command buffer when using K_NO_WAIT since
16+
# Host number of completed commands does not follow normal flow control.
17+
CONFIG_BT_BUF_CMD_TX_COUNT=10
18+
1419
# Controller
1520
CONFIG_BT_LL_SW_SPLIT=y
1621

samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ CONFIG_BT_HCI_RAW=y
1313
CONFIG_BT_HCI_RAW_RESERVE=1
1414
CONFIG_BT_MAX_CONN=2
1515

16+
# Workaround: Unable to allocate command buffer when using K_NO_WAIT since
17+
# Host number of completed commands does not follow normal flow control.
18+
CONFIG_BT_BUF_CMD_TX_COUNT=10
19+
1620
CONFIG_BT_BUF_EVT_RX_COUNT=16
21+
1722
CONFIG_BT_BUF_EVT_RX_SIZE=255
1823
CONFIG_BT_BUF_ACL_RX_SIZE=255
1924
CONFIG_BT_BUF_ACL_TX_SIZE=251

samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ CONFIG_BT_HCI_RAW=y
1313
CONFIG_BT_HCI_RAW_RESERVE=1
1414
CONFIG_BT_MAX_CONN=2
1515

16+
# Workaround: Unable to allocate command buffer when using K_NO_WAIT since
17+
# Host number of completed commands does not follow normal flow control.
18+
CONFIG_BT_BUF_CMD_TX_COUNT=10
19+
1620
CONFIG_BT_BUF_EVT_RX_COUNT=16
21+
1722
CONFIG_BT_BUF_EVT_RX_SIZE=255
1823
CONFIG_BT_BUF_ACL_RX_SIZE=255
1924
CONFIG_BT_BUF_ACL_TX_SIZE=251

samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ CONFIG_BT_HCI_RAW=y
1313
CONFIG_BT_HCI_RAW_RESERVE=1
1414
CONFIG_BT_MAX_CONN=2
1515

16+
# Workaround: Unable to allocate command buffer when using K_NO_WAIT since
17+
# Host number of completed commands does not follow normal flow control.
18+
CONFIG_BT_BUF_CMD_TX_COUNT=10
19+
1620
CONFIG_BT_BUF_EVT_RX_COUNT=16
21+
1722
CONFIG_BT_BUF_EVT_RX_SIZE=255
1823
CONFIG_BT_BUF_ACL_RX_SIZE=255
1924
CONFIG_BT_BUF_ACL_TX_SIZE=251

samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ CONFIG_BT=y
1212
CONFIG_BT_HCI_RAW=y
1313
CONFIG_BT_HCI_RAW_RESERVE=1
1414

15+
# Workaround: Unable to allocate command buffer when using K_NO_WAIT since
16+
# Host number of completed commands does not follow normal flow control.
17+
CONFIG_BT_BUF_CMD_TX_COUNT=10
18+
1519
CONFIG_BT_BUF_EVT_RX_SIZE=255
1620
CONFIG_BT_BUF_ACL_RX_SIZE=255
1721
CONFIG_BT_BUF_ACL_TX_SIZE=251

samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ CONFIG_BT=y
1212
CONFIG_BT_HCI_RAW=y
1313
CONFIG_BT_HCI_RAW_RESERVE=1
1414

15+
# Workaround: Unable to allocate command buffer when using K_NO_WAIT since
16+
# Host number of completed commands does not follow normal flow control.
17+
CONFIG_BT_BUF_CMD_TX_COUNT=10
18+
1519
CONFIG_BT_BUF_EVT_RX_SIZE=255
1620
CONFIG_BT_BUF_ACL_RX_SIZE=255
1721
CONFIG_BT_BUF_ACL_TX_SIZE=251

samples/bluetooth/hci_ipc/prj.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ CONFIG_BT_HCI_RAW=y
1111
CONFIG_BT_HCI_RAW_RESERVE=1
1212
CONFIG_BT_MAX_CONN=16
1313

14+
15+
# Workaround: Unable to allocate command buffer when using K_NO_WAIT since
16+
# Host number of completed commands does not follow normal flow control.
17+
CONFIG_BT_BUF_CMD_TX_COUNT=10
18+
1419
# Enable and adjust the below value as necessary
1520
# CONFIG_BT_BUF_EVT_RX_COUNT=16
1621
# CONFIG_BT_BUF_EVT_RX_SIZE=255

samples/bluetooth/hci_uart/prj.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ CONFIG_BT_TINYCRYPT_ECC=n
1717
CONFIG_BT_CTLR_DTM_HCI=y
1818

1919
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
20+
21+
# Workaround: Unable to allocate command buffer when using K_NO_WAIT since
22+
# Host number of completed commands does not follow normal flow control.
23+
CONFIG_BT_BUF_CMD_TX_COUNT=10

0 commit comments

Comments
 (0)