Skip to content

Commit 9f58b7c

Browse files
committed
openamp: divide shram to TX shram & RX shram by config:split_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>
1 parent afed3bd commit 9f58b7c

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

lib/include/openamp/rpmsg_virtio.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ struct rpmsg_virtio_shm_pool {
4949
*
5050
* @h2r_buf_size: the size of the buffer used to send data from host to remote
5151
* @r2h_buf_size: the size of the buffer used to send data from remote to host
52+
* @split_shpool: the flag that spliting share memory pool to TX and RX
5253
*/
5354
struct rpmsg_virtio_config {
5455
uint32_t h2r_buf_size;
5556
uint32_t r2h_buf_size;
57+
bool split_shpool;
5658
};
5759

5860
/**
@@ -196,8 +198,13 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
196198
* @param ns_bind_cb - callback handler for name service announcement without
197199
* local endpoints waiting to bind.
198200
* @param shm_io - pointer to the share memory I/O region.
199-
* @param shpool - pointer to shared memory pool. rpmsg_virtio_init_shm_pool has
200-
* to be called first to fill this structure.
201+
* @param shpool - pointer to shared memory pool array.
202+
* If the config->split_shpool is turn on, the array will contain
203+
* two elements, the shpool of txshpool and rxshpool, Otherwise,
204+
* the array has only one element, and txshpool rxshpool shares
205+
* a shpool.
206+
* And rpmsg_virtio_init_shm_pool has to be called first to fill
207+
* each shpool in this array.
201208
* @param config - pointer to configuration structure
202209
*
203210
* @return - status of function execution

lib/rpmsg/rpmsg_virtio.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
(&(const struct rpmsg_virtio_config) { \
3333
.h2r_buf_size = RPMSG_BUFFER_SIZE, \
3434
.r2h_buf_size = RPMSG_BUFFER_SIZE, \
35+
.split_shpool = false, \
3536
})
3637
#else
3738
#define RPMSG_VIRTIO_DEFAULT_CONFIG NULL
@@ -689,11 +690,11 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
689690
* Since device is RPMSG Remote so we need to manage the
690691
* shared buffers. Create shared memory pool to handle buffers.
691692
*/
693+
rvdev->shpool = config->split_shpool ? shpool + 1 : shpool;
692694
if (!shpool)
693695
return RPMSG_ERR_PARAM;
694-
if (!shpool->size)
696+
if (!shpool->size || !rvdev->shpool->size)
695697
return RPMSG_ERR_NO_BUFF;
696-
rvdev->shpool = shpool;
697698

698699
vq_names[0] = "rx_vq";
699700
vq_names[1] = "tx_vq";

0 commit comments

Comments
 (0)