nuttx/openamp/0006-openamp-divide-shram-to-TX-shram-RX-shram-by-config-.patch

80 lines
3.3 KiB
Diff
Raw Normal View History

From bcaa279299ecd4194faffae71867c0371bf4f4a4 Mon Sep 17 00:00:00 2001
From: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Date: Fri, 6 May 2022 10:41:57 +0800
Subject: [PATCH 06/12] openamp: divide shram to TX shram & RX shram by
config:txrx_shpool
In the multi core of lower power device, when one of core enters sleep,
it needs to put its corresponding share memory into retention mode to
save power consumption. Based on the limitations of the chip design,
when the CPU to which share memory belongs goes to sleep, the share
memory enters the retention mode, and other cores will not be able
to access it. When the share memory divides tx shm and rx shm
and the core of tx shm and rx shm are different, so that when one
CPU sleeps, the other CPU can still access its own tx shm.
Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
---
lib/include/openamp/rpmsg_virtio.h | 10 ++++++++--
lib/rpmsg/rpmsg_virtio.c | 5 +++--
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
index 3ec0b0f..c81b404 100644
--- a/lib/include/openamp/rpmsg_virtio.h
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
@@ -56,6 +56,7 @@ struct rpmsg_virtio_shm_pool {
struct rpmsg_virtio_config {
uint32_t h2r_buf_size;
uint32_t r2h_buf_size;
+ bool split_shpool;
};
/**
@@ -208,8 +209,13 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
* @param ns_bind_cb - callback handler for name service announcement without
* local endpoints waiting to bind.
* @param shm_io - pointer to the share memory I/O region.
- * @param shpool - pointer to shared memory pool. rpmsg_virtio_init_shm_pool has
- * to be called first to fill this structure.
+ * @param shpool - pointer to shared memory pool array.
+ * If the config->split_shpool is turn on, the array will contain
+ * two elements, the shpool of txshpool and rxshpool, Otherwise,
+ * the array has only one element, and txshpool rxshpool shares
+ * a shpool.
+ * And rpmsg_virtio_init_shm_pool has to be called first to fill
+ * each shpool in this array.
* @param config - pointer to configuration structure
*
* @return - status of function execution
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index c555101..adc3dbc 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -24,6 +24,7 @@
(&(const struct rpmsg_virtio_config) { \
.h2r_buf_size = RPMSG_BUFFER_SIZE, \
.r2h_buf_size = RPMSG_BUFFER_SIZE, \
+ .split_shpool = false, \
})
#else
#define RPMSG_VIRTIO_DEFAULT_CONFIG NULL
@@ -705,11 +706,11 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
* Since device is RPMSG Remote so we need to manage the
* shared buffers. Create shared memory pool to handle buffers.
*/
+ rvdev->shpool = config->split_shpool ? shpool + 1 : shpool;
if (!shpool)
return RPMSG_ERR_PARAM;
- if (!shpool->size)
+ if (!shpool->size || !rvdev->shpool->size)
return RPMSG_ERR_NO_BUFF;
- rvdev->shpool = shpool;
vq_names[0] = "rx_vq";
vq_names[1] = "tx_vq";
--
2.25.1