You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2020/09/10 07:49:43 UTC
[mynewt-core] 03/03: hw/ipc_nrf5340: Make IPC write blocking
This is an automated email from the ASF dual-hosted git repository.
janc pushed a commit to branch nrf53_ipc
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 6039db69fb46d9ac7d3cd009dc78ea29adcdf88e
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Thu Sep 10 09:28:59 2020 +0200
hw/ipc_nrf5340: Make IPC write blocking
It is expected that other CPU is reading from ring buffer so blocking
shouldn't take long. Also add sysconfig option to configure this
behavior.
---
hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c | 8 ++++++--
hw/drivers/ipc_nrf5340/syscfg.yml | 6 ++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c b/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
index 14bb4e3..a0c02c9 100644
--- a/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
+++ b/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
@@ -51,13 +51,17 @@ static int
ipc_nrf5340_shm_write(struct ipc_shm *shm, const void *data, uint16_t data_len)
{
uint16_t head = shm->head;
- uint16_t tail = shm->tail;
uint16_t len;
+#if MYNEWT_VAL(IPC_NRF5340_BLOCKING_WRITE)
+ /* Wait until there is space in ringbuffer */
+ while (data_len + ipc_nrf5340_shm_get_data_length(head, shm->tail) >= IPC_BUF_SIZE);
+#else
/* check if data will fit */
- if (data_len + ipc_nrf5340_shm_get_data_length(head, tail) >= IPC_BUF_SIZE) {
+ if (data_len + ipc_nrf5340_shm_get_data_length(head, shm->tail) >= IPC_BUF_SIZE) {
return -ENOMEM;
}
+#endif
len = min(data_len, IPC_BUF_SIZE - head);
memcpy(shm->buf + head, data, len);
diff --git a/hw/drivers/ipc_nrf5340/syscfg.yml b/hw/drivers/ipc_nrf5340/syscfg.yml
index 57189cd..6977a26 100644
--- a/hw/drivers/ipc_nrf5340/syscfg.yml
+++ b/hw/drivers/ipc_nrf5340/syscfg.yml
@@ -29,6 +29,12 @@ syscfg.defs:
It is recommended to use size which is power of two.
value: 256
+ IPC_NRF5340_BLOCKING_WRITE:
+ description: >
+ If this is set IPC write will block instead of returning and error
+ if ringbuffer is full.
+ value: 1
+
IPC_NRF5340_SYSINIT_STAGE:
description: >
Sysinit stage for nRF53 IPC