openamp: update openmap lib version to 2022.04.0

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2022-08-02 16:44:59 +08:00 committed by Xiang Xiao
parent 306431d16f
commit 546889d524
18 changed files with 813 additions and 688 deletions

View file

@ -1,42 +1,40 @@
From 03217b06dfc9fd23b33401cec689cfdbe373770d Mon Sep 17 00:00:00 2001
From: ligd <liguiding1@xiaomi.com>
From 57afc457bc16cca04762391f77d22b9219cb0e5f Mon Sep 17 00:00:00 2001
From: Guiding Li <liguiding1@xiaomi.com>
Date: Tue, 20 Jul 2021 17:52:13 +0800
Subject: [PATCH] openamp: add ns_unbind_notify support
Subject: [PATCH 01/12] openamp: add ns_unbind_notify support
neededby:826344
This is for notify rdev unbind event
Change-Id: Ie4301e8b774158baf8aa1299f8eb6748dd09b1d9
Signed-off-by: ligd <liguiding1@xiaomi.com>
(cherry picked from commit 85818f5857d340635e81680a98924f2bb715c97f)
Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
---
lib/include/openamp/rpmsg.h | 1 +
lib/rpmsg/rpmsg_virtio.c | 2 ++
2 files changed, 3 insertions(+)
lib/rpmsg/rpmsg_virtio.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
index 93aeec6..4ebb141 100644
index 8b8ec2e..e6acce8 100644
--- a/lib/include/openamp/rpmsg.h
+++ open-amp/lib/include/openamp/rpmsg.h
@@ -129,6 +129,7 @@ struct rpmsg_device {
@@ -118,6 +118,7 @@ struct rpmsg_device {
unsigned long bitmap[metal_bitmap_longs(RPMSG_ADDR_BMP_SIZE)];
metal_mutex_t lock;
rpmsg_ns_bind_cb ns_bind_cb;
+ rpmsg_ns_bind_cb ns_unbind_cb;
struct rpmsg_device_ops ops;
bool support_ns;
bool support_ack;
};
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index 51c2565..2687320 100644
index 57a2083..d5f168c 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -553,6 +553,8 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
@@ -585,6 +585,9 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
metal_mutex_release(&rdev->lock);
if (_ept && _ept->ns_unbind_cb)
_ept->ns_unbind_cb(_ept);
+ if (rdev->ns_unbind_cb)
+ rdev->ns_unbind_cb(rdev, name, dest);
} else if (ns_msg->flags == RPMSG_NS_CREATE) {
+
} else {
if (!_ept) {
/*
--

View file

@ -1,153 +0,0 @@
From effea71e4d59797cd6149a81b2c6b88dc550d972 Mon Sep 17 00:00:00 2001
From: Chao An <anchao@pinecone.net>
Date: Mon, 10 Dec 2018 16:26:39 +0800
Subject: [PATCH 2/3] Negotiate individual buffer size dynamically
If slave support VIRTIO_RPMSG_F_BUFSZ(0x04) feature, master
determine the buffer size from config space(first 8 bytes),
otherwise the default size(512 bytes) will be used.
Signed-off-by: Chao An <anchao@pinecone.net>
---
lib/include/openamp/remoteproc.h | 17 +++++++++++++++++
lib/include/openamp/rpmsg_virtio.h | 4 ++++
lib/rpmsg/rpmsg_virtio.c | 21 +++++++++++++++------
3 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/lib/include/openamp/remoteproc.h open-amp/lib/include/openamp/remoteproc.h
index f558846..a71327b 100644
--- a/lib/include/openamp/remoteproc.h
+++ open-amp/lib/include/openamp/remoteproc.h
@@ -303,6 +303,23 @@ struct fw_rsc_vdev {
struct fw_rsc_vdev_vring vring[0];
} METAL_PACKED_END;
+/**
+ * struct fw_rsc_config - configuration space declaration
+ * @txbuf_size: the tx buffer size
+ * @rxbuf_size: the rx buffer size
+ * @reserved: reserved (must be zero)
+ *
+ * This structure immediately follow fw_rsc_vdev to provide the config info.
+ */
+METAL_PACKED_BEGIN
+struct fw_rsc_config {
+ /* The tx/rx individual buffer size(if VIRTIO_RPMSG_F_BUFSZ) */
+ uint32_t txbuf_size;
+ uint32_t rxbuf_size;
+ uint32_t reserved[14]; /* Reserve for the future use */
+ /* Put the customize config here */
+} METAL_PACKED_END;
+
/**
* struct fw_rsc_vendor - remote processor vendor specific resource
* @len: length of the resource
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
index 4d3093b..e552b96 100644
--- a/lib/include/openamp/rpmsg_virtio.h
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
@@ -16,6 +16,7 @@
#include <metal/mutex.h>
#include <openamp/rpmsg.h>
#include <openamp/virtio.h>
+#include <openamp/remoteproc.h>
#if defined __cplusplus
extern "C" {
@@ -29,6 +30,7 @@ extern "C" {
/* The feature bitmap for virtio rpmsg */
#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
#define VIRTIO_RPMSG_F_ACK 1 /* RP supports name service acknowledge */
+#define VIRTIO_RPMSG_F_BUFSZ 2 /* RP supports buffer size negotiation */
/**
* struct rpmsg_virtio_shm_pool - shared memory pool used for rpmsg buffers
@@ -45,6 +47,7 @@ struct rpmsg_virtio_shm_pool {
/**
* struct rpmsg_virtio_device - representation of a rpmsg device based on virtio
* @rdev: rpmsg device, first property in the struct
+ * @config: rpmsg config information
* @vdev: pointer to the virtio device
* @rvq: pointer to receive virtqueue
* @svq: pointer to send virtqueue
@@ -53,6 +56,7 @@ struct rpmsg_virtio_shm_pool {
*/
struct rpmsg_virtio_device {
struct rpmsg_device rdev;
+ struct fw_rsc_config config;
struct virtio_device *vdev;
struct virtqueue *rvq;
struct virtqueue *svq;
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index 640240a..164dc70 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -145,8 +145,8 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev,
data = virtqueue_get_buffer(rvdev->svq, len, idx);
if (!data && rvdev->svq->vq_free_cnt) {
data = rpmsg_virtio_shm_pool_get_buffer(rvdev->shpool,
- RPMSG_BUFFER_SIZE);
- *len = RPMSG_BUFFER_SIZE;
+ rvdev->config.rxbuf_size);
+ *len = rvdev->config.rxbuf_size;
*idx = 0;
}
}
@@ -239,7 +239,7 @@ static int _rpmsg_virtio_get_buffer_size(struct rpmsg_virtio_device *rvdev)
* If device role is Master then buffers are provided by us,
* so just provide the macro.
*/
- length = RPMSG_BUFFER_SIZE - sizeof(struct rpmsg_hdr);
+ length = rvdev->config.rxbuf_size - sizeof(struct rpmsg_hdr);
}
#endif /*!VIRTIO_SLAVE_ONLY*/
@@ -619,6 +619,8 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
rvdev->vdev = vdev;
rdev->ns_bind_cb = ns_bind_cb;
vdev->priv = rvdev;
+ rvdev->config.txbuf_size = RPMSG_BUFFER_SIZE;
+ rvdev->config.rxbuf_size = RPMSG_BUFFER_SIZE;
rdev->ops.send_offchannel_raw = rpmsg_virtio_send_offchannel_raw;
rdev->ops.hold_rx_buffer = rpmsg_virtio_hold_rx_buffer;
rdev->ops.release_rx_buffer = rpmsg_virtio_release_rx_buffer;
@@ -636,6 +638,13 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
rdev->support_ns = !!(vdev->features & (1 << VIRTIO_RPMSG_F_NS));
rdev->support_ack = !!(vdev->features & (1 << VIRTIO_RPMSG_F_ACK));
+ if (vdev->features & (1 << VIRTIO_RPMSG_F_BUFSZ)) {
+ rpmsg_virtio_read_config(rvdev,
+ 0,
+ &rvdev->config,
+ sizeof(rvdev->config));
+ }
+
#ifndef VIRTIO_SLAVE_ONLY
if (role == RPMSG_MASTER) {
/*
@@ -696,11 +705,11 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
unsigned int idx;
void *buffer;
- vqbuf.len = RPMSG_BUFFER_SIZE;
+ vqbuf.len = rvdev->config.txbuf_size;
for (idx = 0; idx < rvdev->rvq->vq_nentries; idx++) {
/* Initialize TX virtqueue buffers for remote device */
buffer = rpmsg_virtio_shm_pool_get_buffer(shpool,
- RPMSG_BUFFER_SIZE);
+ rvdev->config.txbuf_size);
if (!buffer) {
return RPMSG_ERR_NO_BUFF;
@@ -711,7 +720,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
metal_io_block_set(shm_io,
metal_io_virt_to_offset(shm_io,
buffer),
- 0x00, RPMSG_BUFFER_SIZE);
+ 0x00, rvdev->config.txbuf_size);
status =
virtqueue_add_buffer(rvdev->rvq, &vqbuf, 0, 1,
buffer);
--
2.17.1

View file

@ -1,7 +1,7 @@
From 34cacff47da59075d930a5e96b16d003b70d383d Mon Sep 17 00:00:00 2001
From 73d9754ab14a2b5c3e25574ec860489031e32f00 Mon Sep 17 00:00:00 2001
From: Xiang Xiao <xiaoxiang@xiaomi.com>
Date: Mon, 7 Jan 2019 02:15:42 +0800
Subject: [PATCH 1/3] ns: acknowledge the received creation message
Subject: [PATCH 02/12] ns: acknowledge the received creation message
the two phase handsake make the client could initiate the transfer
immediately without the server side send any dummy message first.
@ -12,15 +12,15 @@ Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
lib/include/openamp/rpmsg_virtio.h | 1 +
lib/rpmsg/rpmsg.c | 5 ++++-
lib/rpmsg/rpmsg_internal.h | 4 ++--
lib/rpmsg/rpmsg_virtio.c | 14 +++++++++++---
5 files changed, 19 insertions(+), 6 deletions(-)
lib/rpmsg/rpmsg_virtio.c | 16 ++++++++++++----
5 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
index 8b8ec2e..efdfb2b 100644
index e6acce8..3560bb5 100644
--- a/lib/include/openamp/rpmsg.h
+++ open-amp/lib/include/openamp/rpmsg.h
@@ -120,6 +120,7 @@ struct rpmsg_device {
rpmsg_ns_bind_cb ns_bind_cb;
@@ -121,6 +121,7 @@ struct rpmsg_device {
rpmsg_ns_bind_cb ns_unbind_cb;
struct rpmsg_device_ops ops;
bool support_ns;
+ bool support_ack;
@ -28,7 +28,7 @@ index 8b8ec2e..efdfb2b 100644
/**
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
index 12cb47f..4d3093b 100644
index ff1e171..255396c 100644
--- a/lib/include/openamp/rpmsg_virtio.h
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
@@ -28,6 +28,7 @@ extern "C" {
@ -40,11 +40,11 @@ index 12cb47f..4d3093b 100644
/**
* struct rpmsg_virtio_shm_pool - shared memory pool used for rpmsg buffers
diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c
index 46c3691..e52144b 100644
index 214b2a9..ba2b7a8 100644
--- a/lib/rpmsg/rpmsg.c
+++ open-amp/lib/rpmsg/rpmsg.c
@@ -297,10 +297,13 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
rpmsg_register_endpoint(rdev, ept);
@@ -302,10 +302,13 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
rpmsg_register_endpoint(rdev, ept, name, addr, dest, cb, unbind_cb);
metal_mutex_release(&rdev->lock);
- /* Send NS announcement to remote processor */
@ -59,7 +59,7 @@ index 46c3691..e52144b 100644
if (status)
rpmsg_unregister_endpoint(ept);
diff --git a/lib/rpmsg/rpmsg_internal.h open-amp/lib/rpmsg/rpmsg_internal.h
index d4536d1..e64aeff 100644
index ab6e0f2..3e6ae37 100644
--- a/lib/rpmsg/rpmsg_internal.h
+++ open-amp/lib/rpmsg/rpmsg_internal.h
@@ -39,12 +39,12 @@ extern "C" {
@ -78,10 +78,10 @@ index d4536d1..e64aeff 100644
/**
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index 86a23ad..640240a 100644
index d5f168c..0868f71 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -554,13 +554,13 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
@@ -579,7 +579,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
metal_mutex_acquire(&rdev->lock);
_ept = rpmsg_get_endpoint(rdev, name, RPMSG_ADDR_ANY, dest);
@ -90,19 +90,23 @@ index 86a23ad..640240a 100644
if (_ept)
_ept->dest_addr = RPMSG_ADDR_ANY;
metal_mutex_release(&rdev->lock);
if (_ept && _ept->ns_unbind_cb)
@@ -587,8 +587,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
_ept->ns_unbind_cb(_ept);
if (rdev->ns_unbind_cb)
rdev->ns_unbind_cb(rdev, name, dest);
-
- } else {
+ } else if (ns_msg->flags == RPMSG_NS_CREATE) {
if (!_ept) {
/*
* send callback to application, that can
@@ -574,7 +574,14 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
@@ -602,7 +601,15 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
} else {
_ept->dest_addr = dest;
metal_mutex_release(&rdev->lock);
+ if (_ept->name[0] && rdev->support_ack)
+ rpmsg_send_ns_message(_ept, RPMSG_NS_CREATE_ACK);
+ rpmsg_send_ns_message(_ept,
+ RPMSG_NS_CREATE_ACK);
}
+ } else { /* RPMSG_NS_CREATE_ACK */
+ /* save the received destination address */
@ -112,23 +116,23 @@ index 86a23ad..640240a 100644
}
return RPMSG_SUCCESS;
@@ -627,6 +634,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
#endif /*!VIRTIO_MASTER_ONLY*/
@@ -683,6 +690,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
#endif /*!VIRTIO_DRIVER_ONLY*/
vdev->features = rpmsg_virtio_get_features(rvdev);
rdev->support_ns = !!(vdev->features & (1 << VIRTIO_RPMSG_F_NS));
+ rdev->support_ack = !!(vdev->features & (1 << VIRTIO_RPMSG_F_ACK));
#ifndef VIRTIO_SLAVE_ONLY
if (role == RPMSG_MASTER) {
@@ -722,7 +730,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
#ifndef VIRTIO_DEVICE_ONLY
if (role == RPMSG_HOST) {
@@ -778,7 +786,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
* Create name service announcement endpoint if device supports name
* service announcement feature.
*/
- if (rdev->support_ns) {
+ if (rdev->support_ns || rdev->support_ack) {
rpmsg_initialize_ept(&rdev->ns_ept, "NS",
rpmsg_register_endpoint(rdev, &rdev->ns_ept, "NS",
RPMSG_NS_EPT_ADDR, RPMSG_NS_EPT_ADDR,
rpmsg_virtio_ns_callback, NULL);
--
2.17.1
2.25.1

View file

@ -0,0 +1,105 @@
From c3949d3b4a8883ec54f5db9ae55acac5ada75b81 Mon Sep 17 00:00:00 2001
From: Chao An <anchao@pinecone.net>
Date: Mon, 10 Dec 2018 16:26:39 +0800
Subject: [PATCH 03/12] Negotiate individual buffer size dynamically
If slave support VIRTIO_RPMSG_F_BUFSZ(0x04) feature, master
determine the buffer size from config space(first 8 bytes),
otherwise the default size(512 bytes) will be used.
Signed-off-by: Chao An <anchao@pinecone.net>
Signed-off-by: ligd <liguiding1@xiaomi.com>
---
lib/include/openamp/remoteproc.h | 17 +++++++++++++++++
lib/include/openamp/rpmsg_virtio.h | 4 +++-
lib/rpmsg/rpmsg_virtio.c | 10 +++++++++-
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/lib/include/openamp/remoteproc.h open-amp/lib/include/openamp/remoteproc.h
index 41f5d57..e9111ff 100644
--- a/lib/include/openamp/remoteproc.h
+++ open-amp/lib/include/openamp/remoteproc.h
@@ -303,6 +303,23 @@ struct fw_rsc_vdev {
struct fw_rsc_vdev_vring vring[0];
} METAL_PACKED_END;
+/**
+ * struct fw_rsc_config - configuration space declaration
+ * @h2r_buf_size: the size of the buffer used to send data from host to remote
+ * @r2h_buf_size: the size of the buffer used to send data from remote to host
+ * @reserved: reserved (must be zero)
+ *
+ * This structure immediately follow fw_rsc_vdev to provide the config info.
+ */
+METAL_PACKED_BEGIN
+struct fw_rsc_config {
+ /* The individual buffer size(if VIRTIO_RPMSG_F_BUFSZ) */
+ uint32_t h2r_buf_size;
+ uint32_t r2h_buf_size;
+ uint32_t reserved[14]; /* Reserve for the future use */
+ /* Put the customize config here */
+} METAL_PACKED_END;
+
/**
* struct fw_rsc_vendor - remote processor vendor specific resource
* @len: length of the resource
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
index 255396c..aaba7e1 100644
--- a/lib/include/openamp/rpmsg_virtio.h
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
@@ -16,6 +16,7 @@
#include <metal/mutex.h>
#include <openamp/rpmsg.h>
#include <openamp/virtio.h>
+#include <openamp/remoteproc.h>
#if defined __cplusplus
extern "C" {
@@ -29,6 +30,7 @@ extern "C" {
/* The feature bitmap for virtio rpmsg */
#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
#define VIRTIO_RPMSG_F_ACK 1 /* RP supports name service acknowledge */
+#define VIRTIO_RPMSG_F_BUFSZ 2 /* RP supports buffer size negotiation */
/**
* struct rpmsg_virtio_shm_pool - shared memory pool used for rpmsg buffers
@@ -68,7 +70,7 @@ struct rpmsg_virtio_config {
*/
struct rpmsg_virtio_device {
struct rpmsg_device rdev;
- struct rpmsg_virtio_config config;
+ struct fw_rsc_config config;
struct virtio_device *vdev;
struct virtqueue *rvq;
struct virtqueue *svq;
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index 0868f71..186f23f 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -674,7 +674,8 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
if (config == NULL) {
return RPMSG_ERR_PARAM;
}
- rvdev->config = *config;
+ rvdev->config.h2r_buf_size = config->h2r_buf_size;
+ rvdev->config.r2h_buf_size = config->r2h_buf_size;
}
#else /*!VIRTIO_DEVICE_ONLY*/
/* Ignore passed config in the virtio-device-only configuration. */
@@ -692,6 +693,13 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
rdev->support_ns = !!(vdev->features & (1 << VIRTIO_RPMSG_F_NS));
rdev->support_ack = !!(vdev->features & (1 << VIRTIO_RPMSG_F_ACK));
+ if (vdev->features & (1 << VIRTIO_RPMSG_F_BUFSZ)) {
+ rpmsg_virtio_read_config(rvdev,
+ 0,
+ &rvdev->config,
+ sizeof(rvdev->config));
+ }
+
#ifndef VIRTIO_DEVICE_ONLY
if (role == RPMSG_HOST) {
/*
--
2.25.1

View file

@ -1,7 +1,7 @@
From b84c7f48996a9bbacdddcef9929405f674a73a81 Mon Sep 17 00:00:00 2001
From 415f9cdcf5a93cd018fa920e53a9090d5ec94c37 Mon Sep 17 00:00:00 2001
From: Guiding Li <liguiding@pinecone.net>
Date: Wed, 20 Feb 2019 11:36:57 +0800
Subject: [PATCH 3/3] rpmsg: wait endpoint ready in rpmsg_send and
Subject: [PATCH 04/12] rpmsg: wait endpoint ready in rpmsg_send and
rpmsg_send_nocopy
because the remote need time to return the destination address
@ -9,11 +9,11 @@ because the remote need time to return the destination address
Signed-off-by: Guiding Li <liguiding@pinecone.net>
---
lib/include/openamp/rpmsg.h | 59 ++++++++++++++++++++++++++-----------
lib/rpmsg/rpmsg_virtio.c | 7 -----
2 files changed, 42 insertions(+), 24 deletions(-)
lib/rpmsg/rpmsg_virtio.c | 8 -----
2 files changed, 42 insertions(+), 25 deletions(-)
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
index efdfb2b..5c8b45c 100644
index 3560bb5..11c3ccb 100644
--- a/lib/include/openamp/rpmsg.h
+++ open-amp/lib/include/openamp/rpmsg.h
@@ -15,6 +15,7 @@
@ -37,7 +37,7 @@ index efdfb2b..5c8b45c 100644
/* Error macros. */
#define RPMSG_SUCCESS 0
#define RPMSG_ERROR_BASE -2000
@@ -141,6 +148,19 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
@@ -142,6 +149,19 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
uint32_t dst, const void *data, int len,
int wait);
@ -57,7 +57,7 @@ index efdfb2b..5c8b45c 100644
/**
* rpmsg_send() - send a message across to the remote processor
* @ept: the rpmsg endpoint
@@ -159,8 +179,17 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
@@ -160,8 +180,17 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
static inline int rpmsg_send(struct rpmsg_endpoint *ept, const void *data,
int len)
{
@ -77,7 +77,7 @@ index efdfb2b..5c8b45c 100644
}
/**
@@ -433,8 +462,17 @@ static inline int rpmsg_sendto_nocopy(struct rpmsg_endpoint *ept,
@@ -434,8 +463,17 @@ static inline int rpmsg_sendto_nocopy(struct rpmsg_endpoint *ept,
static inline int rpmsg_send_nocopy(struct rpmsg_endpoint *ept,
const void *data, int len)
{
@ -97,7 +97,7 @@ index efdfb2b..5c8b45c 100644
}
/**
@@ -507,19 +545,6 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
@@ -508,19 +546,6 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
*/
void rpmsg_destroy_ept(struct rpmsg_endpoint *ept);
@ -118,18 +118,18 @@ index efdfb2b..5c8b45c 100644
}
#endif
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index 164dc70..c357ba8 100644
index 186f23f..d19d3b1 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -8,7 +8,6 @@
*/
@@ -10,7 +10,6 @@
#include <metal/alloc.h>
#include <metal/cache.h>
-#include <metal/sleep.h>
#include <metal/utilities.h>
#include <openamp/rpmsg_virtio.h>
#include <openamp/virtqueue.h>
@@ -17,12 +16,6 @@
@@ -19,13 +18,6 @@
#define RPMSG_NUM_VRINGS 2
@ -139,9 +139,10 @@ index 164dc70..c357ba8 100644
-/* Time to wait - In multiple of 1 msecs. */
-#define RPMSG_TICKS_PER_INTERVAL 1000
-
#ifndef VIRTIO_SLAVE_ONLY
metal_weak void *
rpmsg_virtio_shm_pool_get_buffer(struct rpmsg_virtio_shm_pool *shpool,
-
/* Default configuration */
#ifndef VIRTIO_DEVICE_ONLY
#define RPMSG_VIRTIO_DEFAULT_CONFIG \
--
2.17.1
2.25.1

View file

@ -0,0 +1,189 @@
From 2bafe51755ef34f34e1a10eb7bbeb0ef0df878b8 Mon Sep 17 00:00:00 2001
From: Guiding Li <liguiding1@xiaomi.com>
Date: Thu, 18 Nov 2021 20:54:45 +0800
Subject: [PATCH 05/12] openamp: add new ops notify_wait() support
This can avoid looping check tx buffer
Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
---
lib/include/openamp/remoteproc.h | 12 ++++++++++++
lib/include/openamp/remoteproc_virtio.h | 2 ++
lib/include/openamp/rpmsg.h | 1 +
lib/include/openamp/rpmsg_virtio.h | 9 +++++++++
lib/include/openamp/virtio.h | 1 +
lib/remoteproc/remoteproc.c | 11 +++++++++++
lib/remoteproc/remoteproc_virtio.c | 14 ++++++++++++++
lib/rpmsg/rpmsg_virtio.c | 7 +++++++
8 files changed, 57 insertions(+)
diff --git a/lib/include/openamp/remoteproc.h open-amp/lib/include/openamp/remoteproc.h
index e9111ff..d276550 100644
--- a/lib/include/openamp/remoteproc.h
+++ open-amp/lib/include/openamp/remoteproc.h
@@ -428,6 +428,18 @@ struct remoteproc_ops {
int (*stop)(struct remoteproc *rproc);
int (*shutdown)(struct remoteproc *rproc);
int (*notify)(struct remoteproc *rproc, uint32_t id);
+ /**
+ * notify_wait
+ *
+ * Wait for remote notified, when there is no TX buffer anymore.
+ * Set to NULL means use usleep to wait TX buffer available.
+ *
+ * @rproc - pointer to remoteproc instance
+ * @id - the notifyid
+ *
+ * return 0 means there is notify available, otherwise negative value.
+ */
+ int (*notify_wait)(struct remoteproc *rproc, uint32_t id);
/**
* get_mem
*
diff --git a/lib/include/openamp/remoteproc_virtio.h open-amp/lib/include/openamp/remoteproc_virtio.h
index 70cff97..eaca76a 100644
--- a/lib/include/openamp/remoteproc_virtio.h
+++ open-amp/lib/include/openamp/remoteproc_virtio.h
@@ -22,6 +22,7 @@ extern "C" {
/* define vdev notification function user should implement */
typedef int (*rpvdev_notify_func)(void *priv, uint32_t id);
+typedef int (*rpvdev_notify_wait)(void *priv, uint32_t id);
/**
* struct remoteproc_virtio
@@ -37,6 +38,7 @@ struct remoteproc_virtio {
void *vdev_rsc;
struct metal_io_region *vdev_rsc_io;
rpvdev_notify_func notify;
+ rpvdev_notify_wait notify_wait;
struct virtio_device vdev;
struct metal_list node;
};
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
index 11c3ccb..6f546e5 100644
--- a/lib/include/openamp/rpmsg.h
+++ open-amp/lib/include/openamp/rpmsg.h
@@ -49,6 +49,7 @@ extern "C" {
#define RPMSG_ERR_BUFF_SIZE (RPMSG_ERROR_BASE - 5)
#define RPMSG_ERR_INIT (RPMSG_ERROR_BASE - 6)
#define RPMSG_ERR_ADDR (RPMSG_ERROR_BASE - 7)
+#define RPMSG_ERR_NXIO (RPMSG_ERROR_BASE - 8)
struct rpmsg_endpoint;
struct rpmsg_device;
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
index aaba7e1..3ec0b0f 100644
--- a/lib/include/openamp/rpmsg_virtio.h
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
@@ -143,6 +143,15 @@ rpmsg_virtio_create_virtqueues(struct rpmsg_virtio_device *rvdev,
callbacks);
}
+static inline int
+rpmsg_virtio_notify_wait(struct rpmsg_virtio_device *rvdev,
+ struct virtqueue *vq)
+{
+ return rvdev->vdev->func->notify_wait ?
+ rvdev->vdev->func->notify_wait(rvdev->vdev, vq) :
+ RPMSG_ERR_NXIO;
+}
+
/**
* rpmsg_virtio_get_buffer_size - get rpmsg virtio buffer size
*
diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h
index 916132b..0303a5b 100644
--- a/lib/include/openamp/virtio.h
+++ open-amp/lib/include/openamp/virtio.h
@@ -162,6 +162,7 @@ struct virtio_dispatch {
void *src, int length);
void (*reset_device)(struct virtio_device *dev);
void (*notify)(struct virtqueue *vq);
+ int (*notify_wait)(struct virtio_device *dev, struct virtqueue *vq);
};
int virtio_create_virtqueues(struct virtio_device *vdev, unsigned int flags,
diff --git a/lib/remoteproc/remoteproc.c open-amp/lib/remoteproc/remoteproc.c
index 9a0cf3e..4c101db 100644
--- a/lib/remoteproc/remoteproc.c
+++ open-amp/lib/remoteproc/remoteproc.c
@@ -880,6 +880,16 @@ static int remoteproc_virtio_notify(void *priv, uint32_t id)
return 0;
}
+static int remoteproc_virtio_notify_wait(void *priv, uint32_t id)
+{
+ struct remoteproc *rproc = priv;
+
+ if (rproc->ops->notify_wait)
+ return rproc->ops->notify_wait(rproc, id);
+
+ return 0;
+}
+
struct virtio_device *
remoteproc_create_virtio(struct remoteproc *rproc,
int vdev_id, unsigned int role,
@@ -927,6 +937,7 @@ remoteproc_create_virtio(struct remoteproc *rproc,
rproc_virtio_wait_remote_ready(vdev);
rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
+ rpvdev->notify_wait = remoteproc_virtio_notify_wait;
metal_list_add_tail(&rproc->vdevs, &rpvdev->node);
num_vrings = vdev_rsc->num_of_vrings;
diff --git a/lib/remoteproc/remoteproc_virtio.c open-amp/lib/remoteproc/remoteproc_virtio.c
index cbfd966..ef5eef3 100644
--- a/lib/remoteproc/remoteproc_virtio.c
+++ open-amp/lib/remoteproc/remoteproc_virtio.c
@@ -30,6 +30,19 @@ static void rproc_virtio_virtqueue_notify(struct virtqueue *vq)
rpvdev->notify(rpvdev->priv, vring_info->notifyid);
}
+static int rproc_virtio_notify_wait(struct virtio_device *vdev,
+ struct virtqueue *vq)
+{
+ struct remoteproc_virtio *rpvdev;
+ struct virtio_vring_info *vring_info;
+ unsigned int vq_id = vq->vq_queue_index;
+
+ rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
+ vring_info = &vdev->vrings_info[vq_id];
+
+ return rpvdev->notify_wait(rpvdev->priv, vring_info->notifyid);
+}
+
static unsigned char rproc_virtio_get_status(struct virtio_device *vdev)
{
struct remoteproc_virtio *rpvdev;
@@ -179,6 +192,7 @@ static const struct virtio_dispatch remoteproc_virtio_dispatch_funcs = {
.get_features = rproc_virtio_get_features,
.read_config = rproc_virtio_read_config,
.notify = rproc_virtio_virtqueue_notify,
+ .notify_wait = rproc_virtio_notify_wait,
#ifndef VIRTIO_DEVICE_ONLY
/*
* We suppose here that the vdev is in a shared memory so that can
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index d19d3b1..c555101 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -339,6 +339,13 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev,
metal_mutex_release(&rdev->lock);
if (rp_hdr || !tick_count)
break;
+
+ status = rpmsg_virtio_notify_wait(rvdev, rvdev->rvq);
+ if (status == RPMSG_SUCCESS)
+ continue;
+ else if (status != RPMSG_ERR_NXIO)
+ break;
+
metal_sleep_usec(RPMSG_TICKS_PER_INTERVAL);
tick_count--;
}
--
2.25.1

View file

@ -0,0 +1,79 @@
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

View file

@ -1,295 +0,0 @@
From c2b9d18c72eebe558c6a013bf39818c47cffecc3 Mon Sep 17 00:00:00 2001
From: ligd <liguiding1@xiaomi.com>
Date: Thu, 18 Nov 2021 20:54:45 +0800
Subject: [PATCH 1/3] openamp: fix scenario case
description:
There are two CPUs use IPC.
Each cpu has one thread to handle RX callback.
When meet scenario case, both CPU0 & CPU1 can't get tx buffer.
IPC can't do communication any more.
rootcase:
CPU0 CPU1
TX thread0 send msg -->
RX thread get ack <-- RX thread get msg, send ack
<-- TX thread0 send msg
RX thread get msg, send ack --> RX thread get ack
TX thread1 send msg -->
RX thread get ack <-- RX thread get msg, send ack
<-- TX thread1 send msg
RX thread get msg, send ack --> RX thread get ack
TX thread2 send msg -->
TX thread3 send msg -->
....
<-- TX thread2 send msg
<-- TX thread3 send msg
...
when CPU0 & CPU1 msg send too quickly, then CPU0 RX thread can't
get tx buffer(ack), wait CPU1 RX thread return buffer. But at this time,
CPU1 RX thread also can't get tx buffer(ack), wait CPU0 RX thread
return buffer. So, you will find two cpu locked.
last call stack:
CPU0 RX thread: CPU1 RX thread:
wait tx buffer wait tx buffer
can't handle rx buffer can't handle rx buffer
Resolve:
add recursive call rpmsg_virtio_rx_callback() when get_tx_buffer() failed
Signed-off-by: ligd <liguiding1@xiaomi.com>
---
lib/include/openamp/remoteproc.h | 10 +++
lib/include/openamp/rpmsg_virtio.h | 6 ++
lib/include/openamp/virtio.h | 1 +
lib/remoteproc/remoteproc_virtio.c | 12 +++
lib/rpmsg/rpmsg_virtio.c | 134 +++++++++++++++--------------
5 files changed, 97 insertions(+), 66 deletions(-)
diff --git a/lib/include/openamp/remoteproc.h open-amp/lib/include/openamp/remoteproc.h
index a71327b..328ec3f 100644
--- a/lib/include/openamp/remoteproc.h
+++ open-amp/lib/include/openamp/remoteproc.h
@@ -449,6 +449,16 @@ struct remoteproc_ops {
metal_phys_addr_t da,
void *va, size_t size,
struct remoteproc_mem *buf);
+ /**
+ * wait_tx_buffer
+ *
+ * Wait tx buffer available
+ *
+ * @rproc - pointer to remoteproc instance
+ *
+ * return none
+ */
+ int (*wait_tx_buffer)(struct remoteproc *rproc);
};
/* Remoteproc error codes */
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
index e552b96..ac155fb 100644
--- a/lib/include/openamp/rpmsg_virtio.h
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
@@ -114,6 +114,12 @@ rpmsg_virtio_create_virtqueues(struct rpmsg_virtio_device *rvdev,
callbacks);
}
+static inline int rpmsg_virtio_wait_tx_buffer(struct rpmsg_virtio_device *rvdev)
+{
+ return rvdev->vdev->func->wait_tx_buffer ?
+ rvdev->vdev->func->wait_tx_buffer(rvdev->vdev) : -EAGAIN;
+}
+
/**
* rpmsg_virtio_get_buffer_size - get rpmsg virtio buffer size
*
diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h
index 55c8ea5..34bccaa 100644
--- a/lib/include/openamp/virtio.h
+++ open-amp/lib/include/openamp/virtio.h
@@ -137,6 +137,7 @@ struct virtio_dispatch {
void *src, int length);
void (*reset_device)(struct virtio_device *dev);
void (*notify)(struct virtqueue *vq);
+ int (*wait_tx_buffer)(struct virtio_device *dev);
};
int virtio_create_virtqueues(struct virtio_device *vdev, unsigned int flags,
diff --git a/lib/remoteproc/remoteproc_virtio.c open-amp/lib/remoteproc/remoteproc_virtio.c
index ed9f33c..0de31ee 100644
--- a/lib/remoteproc/remoteproc_virtio.c
+++ open-amp/lib/remoteproc/remoteproc_virtio.c
@@ -30,6 +30,17 @@ static void rproc_virtio_virtqueue_notify(struct virtqueue *vq)
rpvdev->notify(rpvdev->priv, vring_info->notifyid);
}
+static int rproc_virtio_wait_tx_buffer(struct virtio_device *vdev)
+{
+ struct remoteproc_virtio *rpvdev;
+ struct remoteproc *rproc;
+
+ rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
+ rproc = rpvdev->priv;
+
+ return rproc->ops->wait_tx_buffer ? rproc->ops->wait_tx_buffer(rproc) : -EAGAIN;
+}
+
static unsigned char rproc_virtio_get_status(struct virtio_device *vdev)
{
struct remoteproc_virtio *rpvdev;
@@ -179,6 +190,7 @@ static const struct virtio_dispatch remoteproc_virtio_dispatch_funcs = {
.get_features = rproc_virtio_get_features,
.read_config = rproc_virtio_read_config,
.notify = rproc_virtio_virtqueue_notify,
+ .wait_tx_buffer = rproc_virtio_wait_tx_buffer,
#ifndef VIRTIO_SLAVE_ONLY
/*
* We suppose here that the vdev is in a shared memory so that can
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index 2687320..30c3ab3 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -286,6 +286,72 @@ static void rpmsg_virtio_release_rx_buffer(struct rpmsg_device *rdev,
metal_mutex_release(&rdev->lock);
}
+/**
+ * rpmsg_virtio_rx_callback
+ *
+ * Rx callback function.
+ *
+ * @param vq - pointer to virtqueue on which messages is received
+ *
+ */
+static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
+{
+ struct virtio_device *vdev = vq->vq_dev;
+ struct rpmsg_virtio_device *rvdev = vdev->priv;
+ struct rpmsg_device *rdev = &rvdev->rdev;
+ struct rpmsg_endpoint *ept;
+ struct rpmsg_hdr *rp_hdr;
+ uint32_t len;
+ uint16_t idx;
+ int status;
+
+ metal_mutex_acquire(&rdev->lock);
+
+ /* Process the received data from remote node */
+ rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
+
+ metal_mutex_release(&rdev->lock);
+
+ while (rp_hdr) {
+ rp_hdr->reserved = idx;
+
+ /* Get the channel node from the remote device channels list. */
+ metal_mutex_acquire(&rdev->lock);
+ ept = rpmsg_get_ept_from_addr(rdev, rp_hdr->dst);
+ metal_mutex_release(&rdev->lock);
+
+ if (ept) {
+ if (ept->dest_addr == RPMSG_ADDR_ANY) {
+ /*
+ * First message received from the remote side,
+ * update channel destination address
+ */
+ ept->dest_addr = rp_hdr->src;
+ }
+ status = ept->cb(ept, RPMSG_LOCATE_DATA(rp_hdr),
+ rp_hdr->len, rp_hdr->src, ept->priv);
+
+ RPMSG_ASSERT(status >= 0,
+ "unexpected callback status\r\n");
+ }
+
+ metal_mutex_acquire(&rdev->lock);
+
+ /* Check whether callback wants to hold buffer */
+ if (!(rp_hdr->reserved & RPMSG_BUF_HELD)) {
+ /* No, return used buffers. */
+ rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx);
+ }
+
+ rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
+ if (!rp_hdr) {
+ /* tell peer we return some rx buffer */
+ virtqueue_kick(rvdev->rvq);
+ }
+ metal_mutex_release(&rdev->lock);
+ }
+}
+
static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev,
uint32_t *len, int wait)
{
@@ -315,6 +381,8 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev,
metal_mutex_release(&rdev->lock);
if (rp_hdr || !tick_count)
break;
+ if (rpmsg_virtio_wait_tx_buffer(rvdev) >= 0)
+ continue;
metal_sleep_usec(RPMSG_TICKS_PER_INTERVAL);
tick_count--;
}
@@ -440,72 +508,6 @@ static void rpmsg_virtio_tx_callback(struct virtqueue *vq)
(void)vq;
}
-/**
- * rpmsg_virtio_rx_callback
- *
- * Rx callback function.
- *
- * @param vq - pointer to virtqueue on which messages is received
- *
- */
-static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
-{
- struct virtio_device *vdev = vq->vq_dev;
- struct rpmsg_virtio_device *rvdev = vdev->priv;
- struct rpmsg_device *rdev = &rvdev->rdev;
- struct rpmsg_endpoint *ept;
- struct rpmsg_hdr *rp_hdr;
- uint32_t len;
- uint16_t idx;
- int status;
-
- metal_mutex_acquire(&rdev->lock);
-
- /* Process the received data from remote node */
- rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
-
- metal_mutex_release(&rdev->lock);
-
- while (rp_hdr) {
- rp_hdr->reserved = idx;
-
- /* Get the channel node from the remote device channels list. */
- metal_mutex_acquire(&rdev->lock);
- ept = rpmsg_get_ept_from_addr(rdev, rp_hdr->dst);
- metal_mutex_release(&rdev->lock);
-
- if (ept) {
- if (ept->dest_addr == RPMSG_ADDR_ANY) {
- /*
- * First message received from the remote side,
- * update channel destination address
- */
- ept->dest_addr = rp_hdr->src;
- }
- status = ept->cb(ept, RPMSG_LOCATE_DATA(rp_hdr),
- rp_hdr->len, rp_hdr->src, ept->priv);
-
- RPMSG_ASSERT(status >= 0,
- "unexpected callback status\r\n");
- }
-
- metal_mutex_acquire(&rdev->lock);
-
- /* Check whether callback wants to hold buffer */
- if (!(rp_hdr->reserved & RPMSG_BUF_HELD)) {
- /* No, return used buffers. */
- rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx);
- }
-
- rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
- if (!rp_hdr) {
- /* tell peer we return some rx buffer */
- virtqueue_kick(rvdev->rvq);
- }
- metal_mutex_release(&rdev->lock);
- }
-}
-
/**
* rpmsg_virtio_ns_callback
*
--
2.25.1

View file

@ -1,130 +0,0 @@
From 0de084b8b7c65502a2339221b59aeaa60edbe8c5 Mon Sep 17 00:00:00 2001
From: ligd <liguiding1@xiaomi.com>
Date: Mon, 7 Feb 2022 20:36:25 +0800
Subject: [PATCH 2/3] openamp: divide shram to TX shram & RX shram
Add new API rpmsg_init_vdev_ext()
Signed-off-by: ligd <liguiding1@xiaomi.com>
Change-Id: I790cdcf27276ed12a633fab9cc8aefff7c7da830
---
lib/include/openamp/rpmsg_virtio.h | 30 +++++++++++++++++++++++++++++
lib/rpmsg/rpmsg_virtio.c | 31 ++++++++++++++++++++----------
2 files changed, 51 insertions(+), 10 deletions(-)
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
index ac155fb..9d6a16e 100644
--- a/lib/include/openamp/rpmsg_virtio.h
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
@@ -156,6 +156,36 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
struct metal_io_region *shm_io,
struct rpmsg_virtio_shm_pool *shpool);
+/**
+ * rpmsg_init_vdev_ext - initialize rpmsg virtio device
+ * Master side:
+ * Initialize RPMsg virtio queues and shared buffers, the address of shm can be
+ * ANY. In this case, function will get shared memory from system shared memory
+ * pools. If the vdev has RPMsg name service feature, this API will create an
+ * name service endpoint.
+ *
+ * Slave side:
+ * This API will not return until the driver ready is set by the master side.
+ *
+ * @param rvdev - pointer to the rpmsg virtio device
+ * @param vdev - pointer to the virtio device
+ * @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 tx_shpool - pointer to tx shared memory pool. rpmsg_virtio_init_shm_pool
+ * has to be called first to fill this structure.
+ * @param rx_shpool - pointer to rx shared memory pool. rpmsg_virtio_init_shm_pool
+ * has to be called first to fill this structure.
+ *
+ * @return - status of function execution
+ */
+int rpmsg_init_vdev_ext(struct rpmsg_virtio_device *rvdev,
+ struct virtio_device *vdev,
+ rpmsg_ns_bind_cb ns_bind_cb,
+ struct metal_io_region *shm_io,
+ struct rpmsg_virtio_shm_pool *tx_shpool,
+ struct rpmsg_virtio_shm_pool *rx_shpool);
+
/**
* rpmsg_deinit_vdev - deinitialize rpmsg virtio device
*
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index 30c3ab3..8a2c795 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -604,11 +604,12 @@ int rpmsg_virtio_get_buffer_size(struct rpmsg_device *rdev)
return size;
}
-int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
- struct virtio_device *vdev,
- rpmsg_ns_bind_cb ns_bind_cb,
- struct metal_io_region *shm_io,
- struct rpmsg_virtio_shm_pool *shpool)
+int rpmsg_init_vdev_ext(struct rpmsg_virtio_device *rvdev,
+ struct virtio_device *vdev,
+ rpmsg_ns_bind_cb ns_bind_cb,
+ struct metal_io_region *shm_io,
+ struct rpmsg_virtio_shm_pool *tx_shpool,
+ struct rpmsg_virtio_shm_pool *rx_shpool)
{
struct rpmsg_device *rdev;
const char *vq_names[RPMSG_NUM_VRINGS];
@@ -654,11 +655,11 @@ int rpmsg_init_vdev(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.
*/
- if (!shpool)
+ if (!tx_shpool || !rx_shpool)
return RPMSG_ERR_PARAM;
- if (!shpool->size)
+ if (!tx_shpool->size || !rx_shpool->size)
return RPMSG_ERR_NO_BUFF;
- rvdev->shpool = shpool;
+ rvdev->shpool = tx_shpool;
vq_names[0] = "rx_vq";
vq_names[1] = "tx_vq";
@@ -670,7 +671,8 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
#endif /*!VIRTIO_SLAVE_ONLY*/
#ifndef VIRTIO_MASTER_ONLY
- (void)shpool;
+ (void)tx_shpool;
+ (void)rx_shpool;
if (role == RPMSG_REMOTE) {
vq_names[0] = "tx_vq";
vq_names[1] = "rx_vq";
@@ -711,7 +713,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
vqbuf.len = rvdev->config.txbuf_size;
for (idx = 0; idx < rvdev->rvq->vq_nentries; idx++) {
/* Initialize TX virtqueue buffers for remote device */
- buffer = rpmsg_virtio_shm_pool_get_buffer(shpool,
+ buffer = rpmsg_virtio_shm_pool_get_buffer(rx_shpool,
rvdev->config.txbuf_size);
if (!buffer) {
@@ -757,6 +759,15 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
return status;
}
+int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
+ struct virtio_device *vdev,
+ rpmsg_ns_bind_cb ns_bind_cb,
+ struct metal_io_region *shm_io,
+ struct rpmsg_virtio_shm_pool *shpool)
+{
+ return rpmsg_init_vdev_ext(rvdev, vdev, ns_bind_cb, shm_io, shpool, shpool);
+}
+
void rpmsg_deinit_vdev(struct rpmsg_virtio_device *rvdev)
{
struct metal_list *node;
--
2.25.1

View file

@ -0,0 +1,32 @@
From 13f72065d4085cebe10687f486edaa014b4adf6c Mon Sep 17 00:00:00 2001
From: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Date: Mon, 18 Apr 2022 15:20:52 +0800
Subject: [PATCH 07/12] openamp: don't need check status when get_tx_payload
Remove redundant check, because this status is already check in
rpmsg_init_vdev_with_config and rpmsg_virtio_wait_remote_ready.
Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
---
lib/rpmsg/rpmsg_virtio.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index adc3dbc..92f5883 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -323,11 +323,6 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev,
/* Get the associated remote device for channel. */
rvdev = metal_container_of(rdev, struct rpmsg_virtio_device, rdev);
- /* Validate device state */
- status = rpmsg_virtio_get_status(rvdev);
- if (!(status & VIRTIO_CONFIG_STATUS_DRIVER_OK))
- return NULL;
-
if (wait)
tick_count = RPMSG_TICK_COUNT / RPMSG_TICKS_PER_INTERVAL;
else
--
2.25.1

View file

@ -0,0 +1,34 @@
From 3ae038f84432e657dff78ed135204210b42a33a9 Mon Sep 17 00:00:00 2001
From: Guiding Li <liguiding1@xiaomi.com>
Date: Tue, 31 May 2022 23:04:01 +0800
Subject: [PATCH 08/12] openamp: add available_idx to dump
Just update debug logs
Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
---
lib/virtio/virtqueue.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/virtio/virtqueue.c open-amp/lib/virtio/virtqueue.c
index d989533..2d243b8 100644
--- a/lib/virtio/virtqueue.c
+++ open-amp/lib/virtio/virtqueue.c
@@ -421,11 +421,11 @@ void virtqueue_dump(struct virtqueue *vq)
VRING_INVALIDATE(vq->vq_ring.used);
metal_log(METAL_LOG_DEBUG,
- "VQ: %s - size=%d; free=%d; queued=%d; "
- "desc_head_idx=%d; avail.idx=%d; used_cons_idx=%d; "
+ "VQ: %s - size=%d; free=%d; queued=%d; desc_head_idx=%d; "
+ "available_idx=%d; avail.idx=%d; used_cons_idx=%d; "
"used.idx=%d; avail.flags=0x%x; used.flags=0x%x\r\n",
vq->vq_name, vq->vq_nentries, vq->vq_free_cnt,
- vq->vq_queued_cnt, vq->vq_desc_head_idx,
+ vq->vq_queued_cnt, vq->vq_desc_head_idx, vq->vq_available_idx,
vq->vq_ring.avail->idx, vq->vq_used_cons_idx,
vq->vq_ring.used->idx, vq->vq_ring.avail->flags,
vq->vq_ring.used->flags);
--
2.25.1

View file

@ -1,34 +0,0 @@
From 0e2e59941d9694e060f8ac06fce6b8284d8e74ec Mon Sep 17 00:00:00 2001
From: ligd <liguiding1@xiaomi.com>
Date: Mon, 28 Feb 2022 16:31:54 +0800
Subject: [PATCH 3/3] rpmsg_virtio: don't need check status when get_tx_payload
Signed-off-by: ligd <liguiding1@xiaomi.com>
---
lib/rpmsg/rpmsg_virtio.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index 8a2c795..b95bf6d 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -359,16 +359,10 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev,
struct rpmsg_hdr *rp_hdr;
uint16_t idx;
int tick_count;
- int status;
/* Get the associated remote device for channel. */
rvdev = metal_container_of(rdev, struct rpmsg_virtio_device, rdev);
- /* Validate device state */
- status = rpmsg_virtio_get_status(rvdev);
- if (!(status & VIRTIO_CONFIG_STATUS_DRIVER_OK))
- return NULL;
-
if (wait)
tick_count = RPMSG_TICK_COUNT / RPMSG_TICKS_PER_INTERVAL;
else
--
2.25.1

View file

@ -0,0 +1,38 @@
From 8aff77d4ceea809da273b68763aea737ed81da38 Mon Sep 17 00:00:00 2001
From: Guiding Li <liguiding1@xiaomi.com>
Date: Tue, 2 Aug 2022 11:12:19 +0800
Subject: [PATCH 09/12] openamp: firstly take all buffer from shram pool
1. the memory already alloced for shram
2. this can help dump the right free cnt
Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
---
lib/rpmsg/rpmsg_virtio.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index 92f5883..4f26b01 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -154,12 +154,13 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev,
#ifndef VIRTIO_DEVICE_ONLY
if (role == RPMSG_HOST) {
- data = virtqueue_get_buffer(rvdev->svq, len, idx);
- if (!data && rvdev->svq->vq_free_cnt) {
- data = rpmsg_virtio_shm_pool_get_buffer(rvdev->shpool,
- rvdev->config.h2r_buf_size);
+ data = rpmsg_virtio_shm_pool_get_buffer(rvdev->shpool,
+ rvdev->config.h2r_buf_size);
+ if (data) {
*len = rvdev->config.h2r_buf_size;
*idx = 0;
+ } else {
+ data = virtqueue_get_buffer(rvdev->svq, len, idx);
}
}
#endif /*!VIRTIO_DEVICE_ONLY*/
--
2.25.1

View file

@ -1,21 +1,21 @@
From 9ebf24a656b42d262e66a96b237cabb15508f4ea Mon Sep 17 00:00:00 2001
From 442ccb015805eb5f7d700f80db9893d319ce5781 Mon Sep 17 00:00:00 2001
From: ligd <liguiding1@xiaomi.com>
Date: Tue, 19 Oct 2021 19:45:14 +0800
Subject: [PATCH 1/2] rpmsg: notify the user when the remote address is
Subject: [PATCH 10/12] rpmsg: notify the user when the remote address is
received
Change-Id: I2f0601fb38944e0cfb8888aa397740161b159e40
Signed-off-by: ligd <liguiding1@xiaomi.com>
---
lib/include/openamp/rpmsg.h | 4 ++++
lib/rpmsg/rpmsg_virtio.c | 6 ++++++
2 files changed, 10 insertions(+)
lib/rpmsg/rpmsg_virtio.c | 9 +++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
index 5c8b45c..93aeec6 100644
index 6f546e5..10d4f5b 100644
--- a/lib/include/openamp/rpmsg.h
+++ open-amp/lib/include/openamp/rpmsg.h
@@ -56,6 +56,7 @@ struct rpmsg_device;
@@ -57,6 +57,7 @@ struct rpmsg_device;
/* Returns positive value on success or negative error value on failure */
typedef int (*rpmsg_ept_cb)(struct rpmsg_endpoint *ept, void *data,
size_t len, uint32_t src, void *priv);
@ -23,7 +23,7 @@ index 5c8b45c..93aeec6 100644
typedef void (*rpmsg_ns_unbind_cb)(struct rpmsg_endpoint *ept);
typedef void (*rpmsg_ns_bind_cb)(struct rpmsg_device *rdev,
const char *name, uint32_t dest);
@@ -68,6 +69,8 @@ typedef void (*rpmsg_ns_bind_cb)(struct rpmsg_device *rdev,
@@ -69,6 +70,8 @@ typedef void (*rpmsg_ns_bind_cb)(struct rpmsg_device *rdev,
* @dest_addr: address of the default remote endpoint binded.
* @cb: user rx callback, return value of this callback is reserved
* for future use, for now, only allow RPMSG_SUCCESS as return value.
@ -32,7 +32,7 @@ index 5c8b45c..93aeec6 100644
* @ns_unbind_cb: end point service unbind callback, called when remote
* ept is destroyed.
* @node: end point node.
@@ -82,6 +85,7 @@ struct rpmsg_endpoint {
@@ -83,6 +86,7 @@ struct rpmsg_endpoint {
uint32_t addr;
uint32_t dest_addr;
rpmsg_ept_cb cb;
@ -41,13 +41,16 @@ index 5c8b45c..93aeec6 100644
struct metal_list node;
void *priv;
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index 2f28a30..51c2565 100644
index 4f26b01..e55e135 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -569,12 +569,18 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
@@ -598,14 +598,19 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
_ept->dest_addr = dest;
metal_mutex_release(&rdev->lock);
if (_ept->name[0] && rdev->support_ack)
rpmsg_send_ns_message(_ept, RPMSG_NS_CREATE_ACK);
- rpmsg_send_ns_message(_ept,
- RPMSG_NS_CREATE_ACK);
+ rpmsg_send_ns_message(_ept, RPMSG_NS_CREATE_ACK);
+ /* notify application that the endpoint has been bound */
+ if (_ept->ns_bound_cb)
+ _ept->ns_bound_cb(_ept);

View file

@ -0,0 +1,55 @@
From 8405b71cb738096a223c5f7ca02b9fa0de5ae0d6 Mon Sep 17 00:00:00 2001
From: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Date: Mon, 11 Apr 2022 13:31:35 +0800
Subject: [PATCH 11/12] openamp: avoid double calling ns_bound when each other
calls create_ept
VELAPLATFO-1522
Change-Id: I78c027e3fcaf54126b75358b91b557e477955964
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
---
lib/rpmsg/rpmsg_virtio.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index e55e135..cd3a13d 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -594,7 +594,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
metal_mutex_release(&rdev->lock);
if (rdev->ns_bind_cb)
rdev->ns_bind_cb(rdev, name, dest);
- } else {
+ } else if (_ept->dest_addr == RPMSG_ADDR_ANY) {
_ept->dest_addr = dest;
metal_mutex_release(&rdev->lock);
if (_ept->name[0] && rdev->support_ack)
@@ -603,14 +603,19 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
if (_ept->ns_bound_cb)
_ept->ns_bound_cb(_ept);
}
+ else
+ metal_mutex_release(&rdev->lock);
} else { /* RPMSG_NS_CREATE_ACK */
/* save the received destination address */
- if (_ept)
+ if (_ept && _ept->dest_addr == RPMSG_ADDR_ANY) {
_ept->dest_addr = dest;
- metal_mutex_release(&rdev->lock);
- /* notify application that the endpoint has been bound */
- if (_ept && _ept->ns_bound_cb)
- _ept->ns_bound_cb(_ept);
+ metal_mutex_release(&rdev->lock);
+ /* notify application that the endpoint has been bound */
+ if (_ept->ns_bound_cb)
+ _ept->ns_bound_cb(_ept);
+ }
+ else
+ metal_mutex_release(&rdev->lock);
}
return RPMSG_SUCCESS;
--
2.25.1

View file

@ -0,0 +1,195 @@
From fb046d85d5e098f58af037322f0de2f663e8f460 Mon Sep 17 00:00:00 2001
From: Xiang Xiao <xiaoxiang@xiaomi.com>
Date: Fri, 15 Nov 2019 19:01:49 +0800
Subject: [PATCH 12/12] remoteproc: make all elf_* functions static except
elf_identify
it's the best practice to reduce the name scope as small as possible
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
---
lib/include/openamp/elf_loader.h | 93 --------------------------------
lib/remoteproc/elf_loader.c | 28 +++++-----
2 files changed, 14 insertions(+), 107 deletions(-)
diff --git a/lib/include/openamp/elf_loader.h open-amp/lib/include/openamp/elf_loader.h
index e7dda74..916a23f 100644
--- a/lib/include/openamp/elf_loader.h
+++ open-amp/lib/include/openamp/elf_loader.h
@@ -323,99 +323,6 @@ extern const struct loader_ops elf_ops;
*/
int elf_identify(const void *img_data, size_t len);
-/**
- * elf_load_header - Load ELF headers
- *
- * It will get the ELF header, the program header, and the section header.
- *
- * @img_data: image data
- * @offset: input image data offset to the start of image file
- * @len: input image data length
- * @img_info: pointer to store image information data
- * @last_load_state: last state return by this function
- * @noffset: pointer to next offset required by loading ELF header
- * @nlen: pointer to next data length required by loading ELF header
- *
- * return ELF loading header state, or negative value for failure
- */
-int elf_load_header(const void *img_data, size_t offset, size_t len,
- void **img_info, int last_load_state,
- size_t *noffset, size_t *nlen);
-
-/**
- * elf_load - load ELF data
- *
- * It will parse the ELF image and return the target device address,
- * offset to the start of the ELF image of the data to load and the
- * length of the data to load.
- *
- * @rproc: pointer to remoteproc instance
- * @img_data: image data which will passed to the function.
- * it can be NULL, if image data doesn't need to be handled
- * by the load function. E.g. binary data which was
- * loaded to the target memory.
- * @offset: last loaded image data offset to the start of image file
- * @len: last loaded image data length
- * @img_info: pointer to store image information data
- * @last_load_state: the returned state of the last function call.
- * @da: target device address, if the data to load is not for target memory
- * the da will be set to ANY.
- * @noffset: pointer to next offset required by loading ELF header
- * @nlen: pointer to next data length required by loading ELF header
- * @padding: value to pad it is possible that a size of a segment in memory
- * is larger than what it is in the ELF image. e.g. a segment
- * can have stack section .bss. It doesn't need to copy image file
- * space, in this case, it will be packed with 0.
- * @nmemsize: pointer to next data target memory size. The size of a segment
- * in the target memory can be larger than the its size in the
- * image file.
- *
- * return 0 for success, otherwise negative value for failure
- */
-int elf_load(struct remoteproc *rproc, const void *img_data,
- size_t offset, size_t len,
- void **img_info, int last_load_state,
- metal_phys_addr_t *da,
- size_t *noffset, size_t *nlen,
- unsigned char *padding, size_t *nmemsize);
-
-/**
- * elf_release - Release ELF image information
- *
- * It will release ELF image information data.
- *
- * @img_info: pointer to ELF image information
- */
-void elf_release(void *img_info);
-
-/**
- * elf_get_entry - Get entry point
- *
- * It will return entry point specified in the ELF file.
- *
- * @img_info: pointer to ELF image information
- *
- * return entry address
- */
-metal_phys_addr_t elf_get_entry(void *img_info);
-
-/**
- * elf_locate_rsc_table - locate the resource table information
- *
- * It will return the length of the resource table, and the device address of
- * the resource table.
- *
- * @img_info: pointer to ELF image information
- * @da: pointer to the device address
- * @offset: pointer to the offset to in the ELF image of the resource
- * table section.
- * @size: pointer to the size of the resource table section.
- *
- * return 0 if successfully locate the resource table, negative value for
- * failure.
- */
-int elf_locate_rsc_table(void *img_info, metal_phys_addr_t *da,
- size_t *offset, size_t *size);
#if defined __cplusplus
}
diff --git a/lib/remoteproc/elf_loader.c open-amp/lib/remoteproc/elf_loader.c
index c90b8d4..ffb253f 100644
--- a/lib/remoteproc/elf_loader.c
+++ open-amp/lib/remoteproc/elf_loader.c
@@ -392,9 +392,9 @@ int elf_identify(const void *img_data, size_t len)
return 0;
}
-int elf_load_header(const void *img_data, size_t offset, size_t len,
- void **img_info, int last_load_state,
- size_t *noffset, size_t *nlen)
+static int elf_load_header(const void *img_data, size_t offset, size_t len,
+ void **img_info, int last_load_state,
+ size_t *noffset, size_t *nlen)
{
int *load_state;
@@ -531,12 +531,12 @@ int elf_load_header(const void *img_data, size_t offset, size_t len,
return last_load_state;
}
-int elf_load(struct remoteproc *rproc,
- const void *img_data, size_t offset, size_t len,
- void **img_info, int last_load_state,
- metal_phys_addr_t *da,
- size_t *noffset, size_t *nlen,
- unsigned char *padding, size_t *nmemsize)
+static int elf_load(struct remoteproc *rproc,
+ const void *img_data, size_t offset, size_t len,
+ void **img_info, int last_load_state,
+ metal_phys_addr_t *da,
+ size_t *noffset, size_t *nlen,
+ unsigned char *padding, size_t *nmemsize)
{
int *load_state;
const void *phdr;
@@ -614,7 +614,7 @@ int elf_load(struct remoteproc *rproc,
return *load_state;
}
-void elf_release(void *img_info)
+static void elf_release(void *img_info)
{
if (!img_info)
return;
@@ -642,7 +642,7 @@ void elf_release(void *img_info)
}
}
-metal_phys_addr_t elf_get_entry(void *elf_info)
+static metal_phys_addr_t elf_get_entry(void *elf_info)
{
if (!elf_info)
return METAL_BAD_PHYS;
@@ -662,8 +662,8 @@ metal_phys_addr_t elf_get_entry(void *elf_info)
}
}
-int elf_locate_rsc_table(void *elf_info, metal_phys_addr_t *da,
- size_t *offset, size_t *size)
+static int elf_locate_rsc_table(void *elf_info, metal_phys_addr_t *da,
+ size_t *offset, size_t *size)
{
char *sect_name = ".resource_table";
void *shdr;
@@ -687,7 +687,7 @@ int elf_locate_rsc_table(void *elf_info, metal_phys_addr_t *da,
return 0;
}
-int elf_get_load_state(void *img_info)
+static int elf_get_load_state(void *img_info)
{
int *load_state;
--
2.25.1

View file

@ -20,7 +20,7 @@
include $(TOPDIR)/Make.defs
VERSION ?= 2021.04.0
VERSION ?= 2022.04.0
include libmetal.defs
include open-amp.defs

View file

@ -33,14 +33,18 @@ open-amp.zip:
$(Q) curl -L https://github.com/OpenAMP/open-amp/archive/v$(VERSION).zip -o open-amp.zip
$(Q) unzip -o open-amp.zip
$(Q) mv open-amp-$(VERSION) open-amp
$(Q) patch -p0 < 0001-ns-acknowledge-the-received-creation-message.patch
$(Q) patch -p0 < 0002-Negotiate-individual-buffer-size-dynamically.patch
$(Q) patch -p0 < 0003-rpmsg-wait-endpoint-ready-in-rpmsg_send-and-rpmsg_se.patch
$(Q) patch -p0 < 0004-openamp-add-ns_unbind_notify-support.patch
$(Q) patch -p0 < 0005-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch
$(Q) patch -p0 < 0006-openamp-fix-scenario-case.patch
$(Q) patch -p0 < 0007-openamp-divide-shram-to-TX-shram-RX-shram.patch
$(Q) patch -p0 < 0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch
$(Q) patch -p0 < 0001-openamp-add-ns_unbind_notify-support.patch
$(Q) patch -p0 < 0002-ns-acknowledge-the-received-creation-message.patch
$(Q) patch -p0 < 0003-Negotiate-individual-buffer-size-dynamically.patch
$(Q) patch -p0 < 0004-rpmsg-wait-endpoint-ready-in-rpmsg_send-and-rpmsg_se.patch
$(Q) patch -p0 < 0005-openamp-add-new-ops-notify_wait-support.patch
$(Q) patch -p0 < 0006-openamp-divide-shram-to-TX-shram-RX-shram-by-config-.patch
$(Q) patch -p0 < 0007-openamp-don-t-need-check-status-when-get_tx_payload.patch
$(Q) patch -p0 < 0008-openamp-add-available_idx-to-dump.patch
$(Q) patch -p0 < 0009-openamp-firstly-take-all-buffer-from-shram-pool.patch
$(Q) patch -p0 < 0010-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch
$(Q) patch -p0 < 0011-openamp-avoid-double-calling-ns_bound-when-each-othe.patch
$(Q) patch -p0 < 0012-remoteproc-make-all-elf_-functions-static-except-elf.patch
.openamp_headers: open-amp.zip
$(eval headers := $(wildcard open-amp/lib/include/openamp/*.h))