You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2024/09/02 10:36:00 UTC
(mynewt-nimble) branch master updated: nimble/transport: Fix race in nrf5340 IPC transport
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new d007e11cb nimble/transport: Fix race in nrf5340 IPC transport
d007e11cb is described below
commit d007e11cbd9fb2064452a1fb654285ad8a0ba07c
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Aug 30 16:27:06 2024 +0200
nimble/transport: Fix race in nrf5340 IPC transport
The HCI transport is initialized after LL task is initialized, but the
IPC itself is initialized before LL task. If host on appcore starts
before HCI transport is initialized on netcore, it can put HCI Reset in
IPC shm before we can receive it and handle. This causes host to send
2nd HCI Reset which triggers handling of data in IPC shm and will fail
because we cannot handle 2 HCI commands at the same time (i.e. 2x HCI
Reset).
This fixes the problem by triggering read from IPC shm just after HCI
transport is initialized so we can handle command that was sent there
before we were ready to receive it.
---
nimble/transport/nrf5340/src/nrf5340_ble_hci.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/nimble/transport/nrf5340/src/nrf5340_ble_hci.c b/nimble/transport/nrf5340/src/nrf5340_ble_hci.c
index 5da5398a0..679cfb124 100644
--- a/nimble/transport/nrf5340/src/nrf5340_ble_hci.c
+++ b/nimble/transport/nrf5340/src/nrf5340_ble_hci.c
@@ -121,12 +121,18 @@ nrf5340_ble_hci_trans_rx(int channel, void *user_data)
static void
nrf5340_ble_hci_init(void)
{
+ os_sr_t sr;
+
SYSINIT_ASSERT_ACTIVE();
#if MYNEWT_VAL(BLE_TRANSPORT_RX_TASK)
ble_transport_rx_register(rx_func, NULL);
#endif
ipc_nrf5340_recv(IPC_RX_CHANNEL, nrf5340_ble_hci_trans_rx, NULL);
+
+ OS_ENTER_CRITICAL(sr);
+ nrf5340_ble_hci_trans_rx(IPC_RX_CHANNEL, NULL);
+ OS_EXIT_CRITICAL(sr);
}
#if MYNEWT_VAL(BLE_CONTROLLER)