From 4d8ad6d44240ebb593f8ebf454849abf71792293 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Sat, 2 Nov 2024 05:57:04 +0100 Subject: [PATCH] samples: Bluetooth: hci_ipc: Fix Newton's Cradle, reduce RAM usage The required ISO Tx buffers have to match the Read Buffer Size values, otherwise the difference in the value cause a similar amount of buffers to be stalled in the IPC driver. Use reduced HEAP size to make room for increase in RAM usage. (cherry picked from commit 398b91543f18c887c31a11115408e2ba421ca46c) Original-Signed-off-by: Vinayak Kariappa Chettimada GitOrigin-RevId: 398b91543f18c887c31a11115408e2ba421ca46c Cr-Build-Id: 8730286630880259329 Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8730286630880259329 Copybot-Job-Name: zephyr-main-copybot-downstream Change-Id: I12922cb9de9b2d20966caebc4c0cfc8f007b3c09 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/6045785 Reviewed-by: Fabio Baltieri Tested-by: ChromeOS Prod (Robot) Commit-Queue: Fabio Baltieri --- .../nrf5340_cpunet_bis-bt_ll_sw_split.conf | 8 ++++++-- .../nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf | 2 +- .../nrf5340_cpunet_cis-bt_ll_sw_split.conf | 10 +++++++--- .../nrf5340_cpunet_df-bt_ll_sw_split.conf | 2 +- .../nrf5340_cpunet_iso-bt_ll_sw_split.conf | 18 +++++++++++------- ...40_cpunet_iso_broadcast-bt_ll_sw_split.conf | 13 ++++++++++--- ...5340_cpunet_iso_central-bt_ll_sw_split.conf | 10 +++++++--- ...0_cpunet_iso_peripheral-bt_ll_sw_split.conf | 10 +++++++--- ...5340_cpunet_iso_receive-bt_ll_sw_split.conf | 2 +- ..._cpunet_iso_nrf21540_ek-bt_ll_sw_split.conf | 8 +++++--- 10 files changed, 56 insertions(+), 27 deletions(-) diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf index a7487118694..13b4268e165 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y @@ -40,7 +40,11 @@ CONFIG_BT_ISO_PERIPHERAL=n # ISO Streams CONFIG_BT_ISO_MAX_CHAN=4 -CONFIG_BT_ISO_TX_BUF_COUNT=1 +# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count +# is used in the context of IPC which falls into a "Newton's Cradle" effect +# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT) +# buffers get throttled. Hence, always have the value equal or greater. +CONFIG_BT_ISO_TX_BUF_COUNT=12 CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf index 0d78cf862ee..8cc6ac936c9 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf @@ -1,7 +1,7 @@ CONFIG_IPC_SERVICE=y CONFIG_MBOX=y -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf index f7e1f8fc673..19b78f03302 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y @@ -39,7 +39,11 @@ CONFIG_BT_ISO_PERIPHERAL=y # ISO Streams CONFIG_BT_ISO_MAX_CHAN=4 -CONFIG_BT_ISO_TX_BUF_COUNT=1 +# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count +# is used in the context of IPC which falls into a "Newton's Cradle" effect +# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT) +# buffers get throttled. Hence, always have the value equal or greater. +CONFIG_BT_ISO_TX_BUF_COUNT=12 CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller @@ -82,8 +86,8 @@ CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM=6 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=y CONFIG_BT_CTLR_PERIPHERAL_ISO=y -CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf index b183a4c9825..3859fc011f8 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf index 925eac8e34e..5f10718be24 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_CBPRINTF_REDUCED_INTEGRAL=y CONFIG_ISR_TABLES_LOCAL_DECLARATION=y @@ -46,7 +46,11 @@ CONFIG_BT_ISO_PERIPHERAL=y CONFIG_BT_ISO_TX_MTU=310 CONFIG_BT_ISO_RX_MTU=310 CONFIG_BT_ISO_MAX_CHAN=4 -CONFIG_BT_ISO_TX_BUF_COUNT=1 +# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count +# is used in the context of IPC which falls into a "Newton's Cradle" effect +# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT) +# buffers get throttled. Hence, always have the value equal or greater. +CONFIG_BT_ISO_TX_BUF_COUNT=8 CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller @@ -100,8 +104,8 @@ CONFIG_BT_CTLR_ADV_EXT=y CONFIG_BT_CTLR_ADV_PERIODIC=y CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER=y CONFIG_BT_CTLR_ADV_ISO=y -CONFIG_BT_CTLR_ADV_ISO_SET=2 -CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=4 +CONFIG_BT_CTLR_ADV_ISO_SET=1 +CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=2 CONFIG_BT_CTLR_ADV_ISO_STREAM_MAX=2 CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=247 @@ -118,16 +122,16 @@ CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=y CONFIG_BT_CTLR_PERIPHERAL_ISO=y -CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 CONFIG_BT_CTLR_CONN_ISO_LOW_LATENCY_POLICY=y # ISO Transmissions -CONFIG_BT_CTLR_ISOAL_SOURCES=4 -CONFIG_BT_CTLR_ISO_TX_BUFFERS=12 +CONFIG_BT_CTLR_ISOAL_SOURCES=2 +CONFIG_BT_CTLR_ISO_TX_BUFFERS=8 CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 # ISO Receptions diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf index 67c5854c9c0..8bcce089c6e 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y @@ -20,11 +20,18 @@ CONFIG_BT_OBSERVER=n CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y CONFIG_BT_ISO_BROADCASTER=y -CONFIG_BT_ISO_MAX_CHAN=4 -CONFIG_BT_ISO_TX_BUF_COUNT=1 CONFIG_BT_CENTRAL=n CONFIG_BT_PERIPHERAL=n +# ISO Streams +CONFIG_BT_ISO_MAX_CHAN=4 +# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count +# is used in the context of IPC which falls into a "Newton's Cradle" effect +# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT) +# buffers get throttled. Hence, always have the value equal or greater. +CONFIG_BT_ISO_TX_BUF_COUNT=12 +CONFIG_BT_ISO_RX_BUF_COUNT=1 + # ISO Broadcast Controller CONFIG_BT_LL_SW_SPLIT=y CONFIG_BT_CTLR_ADV_PERIODIC=y diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf index 505b9d352ba..2a450dfdf2e 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y @@ -35,7 +35,11 @@ CONFIG_BT_ISO_PERIPHERAL=n # ISO Streams CONFIG_BT_ISO_MAX_CHAN=2 -CONFIG_BT_ISO_TX_BUF_COUNT=1 +# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count +# is used in the context of IPC which falls into a "Newton's Cradle" effect +# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT) +# buffers get throttled. Hence, always have the value equal or greater. +CONFIG_BT_ISO_TX_BUF_COUNT=12 CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller @@ -46,8 +50,8 @@ CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=y CONFIG_BT_CTLR_PERIPHERAL_ISO=n -CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf index 05c9a9d3903..31eb9f6669e 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y @@ -35,7 +35,11 @@ CONFIG_BT_ISO_PERIPHERAL=y # ISO Streams CONFIG_BT_ISO_MAX_CHAN=2 -CONFIG_BT_ISO_TX_BUF_COUNT=1 +# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count +# is used in the context of IPC which falls into a "Newton's Cradle" effect +# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT) +# buffers get throttled. Hence, always have the value equal or greater. +CONFIG_BT_ISO_TX_BUF_COUNT=12 CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller @@ -46,8 +50,8 @@ CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=191 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=n CONFIG_BT_CTLR_PERIPHERAL_ISO=y -CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf index 51ca53e83f2..872da8f681b 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y diff --git a/samples/bluetooth/hci_ipc/overlay-nrf5340_cpunet_iso_nrf21540_ek-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/overlay-nrf5340_cpunet_iso_nrf21540_ek-bt_ll_sw_split.conf index daea503621a..12ab4e53eb9 100644 --- a/samples/bluetooth/hci_ipc/overlay-nrf5340_cpunet_iso_nrf21540_ek-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/overlay-nrf5340_cpunet_iso_nrf21540_ek-bt_ll_sw_split.conf @@ -1,4 +1,6 @@ # Reduce from 310 bytes, in nrf5340_cpunet_iso-bt_ll_sw_split.conf -# to be able to fit in 64KB RAM. -CONFIG_BT_ISO_TX_MTU=247 -CONFIG_BT_ISO_RX_MTU=251 +# to be able to fit in 64KB RAM, in case needed in the future. + +# Example: +# CONFIG_BT_ISO_TX_MTU=247 +# CONFIG_BT_ISO_RX_MTU=251