mirror of
https://github.com/apache/nuttx.git
synced 2025-01-12 23:18:36 +08:00
openamp: sync the openamp and libmetal to the last commit
Upgrade the openamp is a troublesome thing, so diretly sync the open-amp and libmetal the newest commit. We can update the commit and remove the patch when this patch has been merged in the OpenAMP repo. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
parent
264252497c
commit
8b4376683a
46 changed files with 1286 additions and 2101 deletions
29
openamp/0001-lib-errno.h-fix-compile-error.patch
Normal file
29
openamp/0001-lib-errno.h-fix-compile-error.patch
Normal file
|
@ -0,0 +1,29 @@
|
|||
From b7eaa824f0f660825a7c2d601940d59141fb4f83 Mon Sep 17 00:00:00 2001
|
||||
From: wangyongrong <wangyongrong@xiaomi.com>
|
||||
Date: Tue, 2 Jul 2024 10:27:44 +0800
|
||||
Subject: [PATCH 1/5] lib/errno.h: fix compile error
|
||||
|
||||
lib/errno.h: delete defined(__arm__) for use GCC compile
|
||||
|
||||
Change-Id: I00f93740810c1cb8875fc2e27bac478aecaf28d5
|
||||
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
|
||||
---
|
||||
lib/errno.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/errno.h libmetal/lib/errno.h
|
||||
index 2fc4f77..e84a2bc 100644
|
||||
--- a/lib/errno.h
|
||||
+++ libmetal/lib/errno.h
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
# include <metal/compiler/iar/errno.h>
|
||||
-#elif defined(__CC_ARM) || defined(__arm__)
|
||||
+#elif defined(__CC_ARM)
|
||||
# include <metal/compiler/armcc/errno.h>
|
||||
#else
|
||||
# include <errno.h>
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
From f06b90cdc478124eba45b3be4f3630e8a729c51b Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Tue, 25 Jul 2023 14:25:58 +0800
|
||||
Subject: [PATCH] libmetal: add metal_list_for_each_safe() support
|
||||
|
||||
Signed-off-by: ligd <liguiding1@xiaomi.com>
|
||||
---
|
||||
lib/list.h | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/lib/list.h libmetal/lib/list.h
|
||||
index eb0e7b3..3e8d17f 100644
|
||||
--- a/lib/list.h
|
||||
+++ libmetal/lib/list.h
|
||||
@@ -98,6 +98,10 @@ static inline struct metal_list *metal_list_first(struct metal_list *list)
|
||||
(node) != (list); \
|
||||
(node) = (node)->next)
|
||||
|
||||
+#define metal_list_for_each_safe(list, node, temp) \
|
||||
+ for(node = (list)->next, temp = node->next; \
|
||||
+ node != (list); node = temp, temp = node->next)
|
||||
+
|
||||
static inline bool metal_list_find_node(struct metal_list *list,
|
||||
struct metal_list *node)
|
||||
{
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,50 +1,54 @@
|
|||
From 1e43e60aa7ae118309cf256c50bd17f313540eba Mon Sep 17 00:00:00 2001
|
||||
From 5f90973cb572ec8df29ea03550eef29afa48015b Mon Sep 17 00:00:00 2001
|
||||
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
||||
Date: Mon, 7 Jan 2019 02:15:42 +0800
|
||||
Subject: [PATCH 01/10] ns: acknowledge the received creation message
|
||||
Subject: [PATCH 01/14] 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.
|
||||
|
||||
Change-Id: I3289120a4e0d2291ba8b39de98d97de9e15880d0
|
||||
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
|
||||
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/rpmsg.h | 1 +
|
||||
lib/include/openamp/rpmsg.h | 3 +++
|
||||
lib/include/openamp/rpmsg_virtio.h | 1 +
|
||||
lib/rpmsg/rpmsg.c | 5 ++++-
|
||||
lib/rpmsg/rpmsg_internal.h | 4 ++--
|
||||
lib/rpmsg/rpmsg_virtio.c | 15 ++++++++++++---
|
||||
5 files changed, 20 insertions(+), 6 deletions(-)
|
||||
lib/rpmsg/rpmsg_internal.h | 2 ++
|
||||
lib/rpmsg/rpmsg_virtio.c | 14 +++++++++++---
|
||||
5 files changed, 21 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
||||
index 64678cfc..ff3ff8fb 100644
|
||||
index f994e1d..b2a9b17 100644
|
||||
--- a/lib/include/openamp/rpmsg.h
|
||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
||||
@@ -126,6 +126,7 @@ struct rpmsg_device {
|
||||
rpmsg_ns_bind_cb ns_unbind_cb;
|
||||
struct rpmsg_device_ops ops;
|
||||
@@ -155,6 +155,9 @@ struct rpmsg_device {
|
||||
|
||||
/** Create/destroy namespace message */
|
||||
bool support_ns;
|
||||
+
|
||||
+ /** Ack namespace message */
|
||||
+ bool support_ack;
|
||||
};
|
||||
|
||||
/**
|
||||
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||
index 80ce9981..874c9723 100644
|
||||
index 44ac4c0..6d6925f 100644
|
||||
--- a/lib/include/openamp/rpmsg_virtio.h
|
||||
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||
@@ -28,6 +28,7 @@ extern "C" {
|
||||
@@ -29,6 +29,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 */
|
||||
|
||||
/**
|
||||
* struct rpmsg_virtio_shm_pool - shared memory pool used for rpmsg buffers
|
||||
#ifdef VIRTIO_CACHED_BUFFERS
|
||||
#warning "VIRTIO_CACHED_BUFFERS is deprecated, please use VIRTIO_USE_DCACHE"
|
||||
diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c
|
||||
index 0d3e1d03..e8757d80 100644
|
||||
index 39774bc..8ab59e1 100644
|
||||
--- a/lib/rpmsg/rpmsg.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg.c
|
||||
@@ -317,10 +317,13 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
|
||||
rpmsg_register_endpoint(rdev, ept, name, addr, dest, cb, unbind_cb);
|
||||
@@ -357,10 +357,13 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
|
||||
rpmsg_register_endpoint(rdev, ept, name, addr, dest, cb, unbind_cb, ept->priv);
|
||||
metal_mutex_release(&rdev->lock);
|
||||
|
||||
- /* Send NS announcement to remote processor */
|
||||
|
@ -59,53 +63,46 @@ index 0d3e1d03..e8757d80 100644
|
|||
if (status)
|
||||
rpmsg_unregister_endpoint(ept);
|
||||
diff --git a/lib/rpmsg/rpmsg_internal.h open-amp/lib/rpmsg/rpmsg_internal.h
|
||||
index ab6e0f29..3e6ae37f 100644
|
||||
index 27b0f0d..1011b42 100644
|
||||
--- a/lib/rpmsg/rpmsg_internal.h
|
||||
+++ open-amp/lib/rpmsg/rpmsg_internal.h
|
||||
@@ -39,12 +39,12 @@ extern "C" {
|
||||
*
|
||||
* @RPMSG_NS_CREATE: a new remote service was just created
|
||||
* @RPMSG_NS_DESTROY: a known remote service was just destroyed
|
||||
- * @RPMSG_NS_CREATE_WITH_ACK: a new remote service was just created waiting
|
||||
- * acknowledgment.
|
||||
+ * @RPMSG_NS_CREATE_ACK: acknowledge the previous creation message
|
||||
*/
|
||||
enum rpmsg_ns_flags {
|
||||
@@ -44,6 +44,8 @@ enum rpmsg_ns_flags {
|
||||
RPMSG_NS_CREATE = 0,
|
||||
/** A known remote service was just destroyed */
|
||||
RPMSG_NS_DESTROY = 1,
|
||||
+ /** Aknowledge the previous creation message*/
|
||||
+ RPMSG_NS_CREATE_ACK = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index cab72e68..5726c2ca 100644
|
||||
index 7baaedd..820227e 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -638,7 +638,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);
|
||||
@@ -656,7 +656,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
|
||||
*/
|
||||
ept_to_release = _ept && _ept->release_cb;
|
||||
|
||||
- if (ns_msg->flags & RPMSG_NS_DESTROY) {
|
||||
+ if (ns_msg->flags == RPMSG_NS_DESTROY) {
|
||||
if (_ept)
|
||||
_ept->dest_addr = RPMSG_ADDR_ANY;
|
||||
metal_mutex_release(&rdev->lock);
|
||||
@@ -646,7 +646,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);
|
||||
if (ept_to_release)
|
||||
@@ -671,7 +671,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
|
||||
rpmsg_ept_decref(_ept);
|
||||
metal_mutex_release(&rdev->lock);
|
||||
}
|
||||
- } else {
|
||||
+ } else if (ns_msg->flags == RPMSG_NS_CREATE) {
|
||||
if (!_ept) {
|
||||
/*
|
||||
* send callback to application, that can
|
||||
@@ -660,7 +660,15 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
|
||||
@@ -685,7 +685,14 @@ 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 */
|
||||
|
@ -115,15 +112,15 @@ index cab72e68..5726c2ca 100644
|
|||
}
|
||||
|
||||
return RPMSG_SUCCESS;
|
||||
@@ -745,6 +753,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));
|
||||
@@ -828,6 +835,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
||||
if (status)
|
||||
return status;
|
||||
rdev->support_ns = !!(features & (1 << VIRTIO_RPMSG_F_NS));
|
||||
+ rdev->support_ack = !!(features & (1 << VIRTIO_RPMSG_F_ACK));
|
||||
|
||||
#ifndef VIRTIO_DEVICE_ONLY
|
||||
if (role == RPMSG_HOST) {
|
||||
@@ -841,7 +850,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
||||
if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) {
|
||||
/*
|
||||
@@ -926,7 +934,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
||||
* Create name service announcement endpoint if device supports name
|
||||
* service announcement feature.
|
||||
*/
|
||||
|
@ -131,7 +128,7 @@ index cab72e68..5726c2ca 100644
|
|||
+ if (rdev->support_ns || rdev->support_ack) {
|
||||
rpmsg_register_endpoint(rdev, &rdev->ns_ept, "NS",
|
||||
RPMSG_NS_EPT_ADDR, RPMSG_NS_EPT_ADDR,
|
||||
rpmsg_virtio_ns_callback, NULL);
|
||||
rpmsg_virtio_ns_callback, NULL, rvdev);
|
||||
--
|
||||
2.25.1
|
||||
2.34.1
|
||||
|
||||
|
|
|
@ -1,104 +1,94 @@
|
|||
From 285e4d359458ef09d397a41de04ada9a6b8d48e7 Mon Sep 17 00:00:00 2001
|
||||
From: Chao An <anchao@pinecone.net>
|
||||
From a12f4359e3d4382e31a0f6f6983184b635fd0611 Mon Sep 17 00:00:00 2001
|
||||
From: anchao <anchao@pinecone.net>
|
||||
Date: Mon, 10 Dec 2018 16:26:39 +0800
|
||||
Subject: [PATCH 02/10] Negotiate individual buffer size dynamically
|
||||
Subject: [PATCH 02/14] Negotiate individual buffer size dynamically
|
||||
|
||||
Change config type from fw_rsc_config to rpmsg_virtio_config
|
||||
to avoid rpmsg_vitio.h couple with remoteproc.h.
|
||||
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>
|
||||
Change-Id: Ief68ed298495296a9eff38448ce5661f188300c2
|
||||
Signed-off-by: anchao <anchao@pinecone.net>
|
||||
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
|
||||
Signed-off-by: wangyongrong <wangyongrong@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(-)
|
||||
lib/include/openamp/remoteproc.h | 15 +++++++++++++++
|
||||
lib/include/openamp/rpmsg_virtio.h | 1 +
|
||||
lib/rpmsg/rpmsg_virtio.c | 7 +++++++
|
||||
3 files changed, 23 insertions(+)
|
||||
|
||||
diff --git a/lib/include/openamp/remoteproc.h open-amp/lib/include/openamp/remoteproc.h
|
||||
index 7c79a292..d1efab85 100644
|
||||
index 84bf233..abc5481 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];
|
||||
@@ -361,6 +361,21 @@ struct fw_rsc_vendor {
|
||||
uint32_t len;
|
||||
} 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.
|
||||
+ */
|
||||
+/** @brief Configuration space declaration ((if VIRTIO_RPMSG_F_BUFSZ)) */
|
||||
+METAL_PACKED_BEGIN
|
||||
+struct fw_rsc_config {
|
||||
+ /* The individual buffer size(if VIRTIO_RPMSG_F_BUFSZ) */
|
||||
+ /** The host to remote buffer size */
|
||||
+ uint32_t h2r_buf_size;
|
||||
+
|
||||
+ /** The remote to host buffer size */
|
||||
+ uint32_t r2h_buf_size;
|
||||
+ uint32_t reserved[14]; /* Reserve for the future use */
|
||||
+ /* Put the customize config here */
|
||||
+
|
||||
+ /** Reserve for the future use */
|
||||
+ uint32_t reserved[14];
|
||||
+
|
||||
+ /** Put the customize config here */
|
||||
+} METAL_PACKED_END;
|
||||
+
|
||||
/**
|
||||
* struct fw_rsc_vendor - remote processor vendor specific resource
|
||||
* @len: length of the resource
|
||||
struct loader_ops;
|
||||
struct image_store_ops;
|
||||
struct remoteproc_ops;
|
||||
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||
index 874c9723..0b22e840 100644
|
||||
index 6d6925f..d9cfa9b 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" {
|
||||
@@ -30,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 */
|
||||
+#define VIRTIO_RPMSG_F_BUFSZ 2 /* RP supports get buffer size from config space */
|
||||
|
||||
/**
|
||||
* struct rpmsg_virtio_shm_pool - shared memory pool used for rpmsg buffers
|
||||
@@ -72,7 +74,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;
|
||||
#ifdef VIRTIO_CACHED_BUFFERS
|
||||
#warning "VIRTIO_CACHED_BUFFERS is deprecated, please use VIRTIO_USE_DCACHE"
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index 5726c2ca..69537399 100644
|
||||
index 820227e..94c4b95 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -737,7 +737,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. */
|
||||
@@ -755,6 +756,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));
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <metal/sleep.h>
|
||||
#include <metal/utilities.h>
|
||||
#include <openamp/rpmsg_virtio.h>
|
||||
+#include <openamp/remoteproc.h>
|
||||
#include <openamp/virtqueue.h>
|
||||
|
||||
+ if (vdev->features & (1 << VIRTIO_RPMSG_F_BUFSZ)) {
|
||||
+ rpmsg_virtio_read_config(rvdev,
|
||||
+ 0,
|
||||
+ &rvdev->config,
|
||||
+ sizeof(rvdev->config));
|
||||
#include "rpmsg_internal.h"
|
||||
@@ -790,6 +791,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
||||
struct rpmsg_device *rdev;
|
||||
const char *vq_names[RPMSG_NUM_VRINGS];
|
||||
vq_callback callback[RPMSG_NUM_VRINGS];
|
||||
+ struct fw_rsc_config fw_config;
|
||||
uint32_t features;
|
||||
int status;
|
||||
unsigned int i;
|
||||
@@ -836,6 +838,11 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
||||
return status;
|
||||
rdev->support_ns = !!(features & (1 << VIRTIO_RPMSG_F_NS));
|
||||
rdev->support_ack = !!(features & (1 << VIRTIO_RPMSG_F_ACK));
|
||||
+ if (features & (1 << VIRTIO_RPMSG_F_BUFSZ)) {
|
||||
+ virtio_read_config(rvdev->vdev, 0, &fw_config, sizeof(fw_config));
|
||||
+ rvdev->config.h2r_buf_size = fw_config.h2r_buf_size;
|
||||
+ rvdev->config.r2h_buf_size = fw_config.r2h_buf_size;
|
||||
+ }
|
||||
+
|
||||
#ifndef VIRTIO_DEVICE_ONLY
|
||||
if (role == RPMSG_HOST) {
|
||||
|
||||
if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) {
|
||||
/*
|
||||
--
|
||||
2.25.1
|
||||
2.34.1
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
From f17ee493475793be52b364b0ad7cd7042bc27ffe Mon Sep 17 00:00:00 2001
|
||||
From 61756465a3dc241297b7a12d5500ac36a5ffa070 Mon Sep 17 00:00:00 2001
|
||||
From: chao an <anchao@lixiang.com>
|
||||
Date: Sat, 29 Jun 2024 09:40:26 +0800
|
||||
Subject: [PATCH] libmetal/atomic: enable 64-bit atomic by toolchain builtin
|
||||
flags
|
||||
Subject: [PATCH 2/5] libmetal/atomic: enable 64-bit atomic by toolchain
|
||||
builtin flags
|
||||
|
||||
Fix compile error:
|
||||
arm-none-eabi-ld: (remoteproc_virtio.o): in function `metal_io_read':
|
||||
|
@ -18,27 +18,26 @@ toolchains have built-in properties to indicate whether support atomic64:
|
|||
| #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
|
||||
| #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
|
||||
|
||||
Change-Id: Iab9f7df0a9d21e29c8b8d131006cb4817414ebdc
|
||||
Signed-off-by: chao an <anchao@lixiang.com>
|
||||
---
|
||||
openamp/libmetal/lib/io.h | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
lib/io.h | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/io.h libmetal/lib/io.h
|
||||
index ba416dd505..8cd03e41db 100644
|
||||
index ba416dd..81105e2 100644
|
||||
--- a/lib/io.h
|
||||
+++ libmetal/lib/io.h
|
||||
@@ -30,8 +30,9 @@ extern "C" {
|
||||
@@ -30,7 +30,8 @@ extern "C" {
|
||||
* @{
|
||||
*/
|
||||
|
||||
-#ifdef __MICROBLAZE__
|
||||
-#define NO_ATOMIC_64_SUPPORT
|
||||
+#if defined(__MICROBLAZE__) || \
|
||||
+ (defined(__GNUC__) && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8))
|
||||
+# define NO_ATOMIC_64_SUPPORT
|
||||
+(defined(__GNUC__) && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8))
|
||||
#define NO_ATOMIC_64_SUPPORT
|
||||
#endif
|
||||
|
||||
struct metal_io_region;
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
From af3de6cd042c89ae2e8d07d503e0a07129e1296c Mon Sep 17 00:00:00 2001
|
||||
From: Bowen Wang <wangbowen6@xiaomi.com>
|
||||
Date: Thu, 16 Nov 2023 14:52:48 +0800
|
||||
Subject: [PATCH] libmetal/nuttx/io.c: align access when read/write size = 1,
|
||||
2, 4, 8
|
||||
|
||||
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
|
||||
---
|
||||
lib/system/nuttx/io.c | 25 +++++++++++++++++++++++--
|
||||
1 file changed, 23 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/system/nuttx/io.c libmetal/lib/system/nuttx/io.c
|
||||
index 4fa4727..3ce9cbe 100644
|
||||
--- a/lib/system/nuttx/io.c
|
||||
+++ libmetal/lib/system/nuttx/io.c
|
||||
@@ -37,7 +37,17 @@ static int metal_io_block_read_(struct metal_io_region *io,
|
||||
void *va = metal_io_virt(io, offset);
|
||||
|
||||
metal_cache_invalidate(va, len);
|
||||
- memcpy(dst, va, len);
|
||||
+ if (len == 1)
|
||||
+ *(uint8_t *)dst = *(uint8_t *)va;
|
||||
+ else if (len == 2)
|
||||
+ *(uint16_t *)dst = *(uint16_t *)va;
|
||||
+ else if (len == 4)
|
||||
+ *(uint32_t *)dst = *(uint32_t *)va;
|
||||
+ else if (len == 8) {
|
||||
+ *(uint32_t *)dst = *(uint32_t *)va;
|
||||
+ *(uint32_t *)(dst + 4) = *(uint32_t *)(va + 4);
|
||||
+ } else
|
||||
+ memcpy(dst, va, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -50,7 +60,18 @@ static int metal_io_block_write_(struct metal_io_region *io,
|
||||
{
|
||||
void *va = metal_io_virt(io, offset);
|
||||
|
||||
- memcpy(va, src, len);
|
||||
+ if (len == 1)
|
||||
+ *(uint8_t *)va = *(uint8_t *)src;
|
||||
+ else if (len == 2)
|
||||
+ *(uint16_t *)va = *(uint16_t *)src;
|
||||
+ else if (len == 4)
|
||||
+ *(uint32_t *)va = *(uint32_t *)src;
|
||||
+ else if (len == 8) {
|
||||
+ *(uint32_t *)va = *(uint32_t *)src;
|
||||
+ *(uint32_t *)(va + 4) = *(uint32_t *)(src + 4);
|
||||
+ } else
|
||||
+ memcpy(va, src, len);
|
||||
+
|
||||
metal_cache_flush(va, len);
|
||||
|
||||
return len;
|
||||
--
|
||||
2.34.1
|
||||
|
52
openamp/0003-atomic.h-fix-compiler-error.patch
Normal file
52
openamp/0003-atomic.h-fix-compiler-error.patch
Normal file
|
@ -0,0 +1,52 @@
|
|||
From 6842947d3cd08748b8d44fd771a53a86ddfc8dac Mon Sep 17 00:00:00 2001
|
||||
From: Yongrong Wang <wangyongrong@xiaomi.com>
|
||||
Date: Fri, 19 Jul 2024 17:40:51 +0800
|
||||
Subject: [PATCH 3/5] atomic.h: fix compiler error
|
||||
|
||||
/home/wyr/work/code/velasim/upgrade/nuttx/include/metal/compiler/gcc/atomic.h:19:13: error: conflicting type qualifiers for 'atomic_flag'
|
||||
19 | typedef int atomic_flag;
|
||||
| ^~~~~~~~~~~
|
||||
In file included from /home/wyr/work/code/velasim/upgrade/nuttx/include/nuttx/net/netdev_lowerhalf.h:38,
|
||||
from virtio/virtio-net.c:33:
|
||||
/home/wyr/work/code/velasim/upgrade/prebuilts/gcc/linux/arm/lib/gcc/arm-none-eabi/13.2.1/include/stdatomic.h:233:3: note: previous declaration of 'atomic_flag' with type 'atomic_flag'
|
||||
233 | } atomic_flag;
|
||||
| ^~~~~~~~~~~
|
||||
/home/wyr/work/code/velasim/upgrade/nuttx/include/metal/compiler/gcc/atomic.h:20:14: error: conflicting type qualifiers for 'atomic_char'
|
||||
20 | typedef char atomic_char;
|
||||
| ^~~~~~~~~~~
|
||||
/home/wyr/work/code/velasim/upgrade/prebuilts/gcc/linux/arm/lib/gcc/arm-none-eabi/13.2.1/include/stdatomic.h:41:22: note: previous declaration of 'atomic_char' with type 'atomic_char' {aka '_Atomic char'}
|
||||
41 | typedef _Atomic char atomic_char;
|
||||
| ^~~~~~~~~~~
|
||||
/home/wyr/work/code/velasim/upgrade/nuttx/include/metal/compiler/gcc/atomic.h:21:23: error: conflicting type qualifiers for 'atomic_uchar'
|
||||
21 | typedef unsigned char atomic_uchar;
|
||||
| ^~~~~~~~~~~~
|
||||
/home/wyr/work/code/velasim/upgrade/prebuilts/gcc/linux/arm/lib/gcc/arm-none-eabi/13.2.1/include/stdatomic.h:43:31: note: previous declaration of 'atomic_uchar' with type 'atomic_uchar' {aka '_Atomic unsigned char'}
|
||||
43 | typedef _Atomic unsigned char atomic_uchar;
|
||||
| ^~~~~~~~~~~~
|
||||
/home/wyr/work/code/velasim/upgrade/nuttx/include/metal/compiler/gcc/atomic.h:22:15: error: conflicting type qualifiers for 'atomic_short'
|
||||
22 | typedef short atomic_short;
|
||||
|
||||
Change-Id: Ic4e920c27e0f8a263136eb9ecb5350edd157195d
|
||||
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
|
||||
---
|
||||
lib/atomic.h | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/atomic.h libmetal/lib/atomic.h
|
||||
index 2f4ab04..fe2c1e0 100644
|
||||
--- a/lib/atomic.h
|
||||
+++ libmetal/lib/atomic.h
|
||||
@@ -100,8 +100,8 @@ using std::atomic_fetch_and_explicit;
|
||||
using std::atomic_thread_fence;
|
||||
using std::atomic_signal_fence;
|
||||
|
||||
-#elif defined(HAVE_STDATOMIC_H) && !defined(__CC_ARM) && !defined(__arm__) && \
|
||||
- !defined(__STDC_NO_ATOMICS__)
|
||||
+#elif defined(HAVE_STDATOMIC_H) && !defined(__STDC_NO_ATOMICS__) && \
|
||||
+ ((!defined(__CC_ARM) && !defined(__arm__)) || defined(__GNUC__))
|
||||
# include <stdint.h>
|
||||
# include <stdatomic.h>
|
||||
#elif defined(__GNUC__)
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
From 59e2764f9d0598ad0135286d4a0ee1ac95893bba Mon Sep 17 00:00:00 2001
|
||||
From: Jukka Laitinen <jukkax@ssrc.tii.ae>
|
||||
Date: Mon, 12 Feb 2024 13:27:13 +0200
|
||||
Subject: [PATCH] libmetal/nuttx/io.c: Fix void pointer arithmetic in access
|
||||
alignment
|
||||
|
||||
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
|
||||
---
|
||||
libmetal/lib/system/nuttx/io.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/system/nuttx/io.c libmetal/lib/system/nuttx/io.c
|
||||
index 3ce9cbe..ab9bc6a 100644
|
||||
--- a/lib/system/nuttx/io.c
|
||||
+++ libmetal/lib/system/nuttx/io.c
|
||||
@@ -45,7 +45,7 @@ static int metal_io_block_read_(struct metal_io_region *io,
|
||||
*(uint32_t *)dst = *(uint32_t *)va;
|
||||
else if (len == 8) {
|
||||
*(uint32_t *)dst = *(uint32_t *)va;
|
||||
- *(uint32_t *)(dst + 4) = *(uint32_t *)(va + 4);
|
||||
+ *((uint32_t *)dst + 1) = *((uint32_t *)va + 1);
|
||||
} else
|
||||
memcpy(dst, va, len);
|
||||
|
||||
@@ -68,7 +68,7 @@ static int metal_io_block_write_(struct metal_io_region *io,
|
||||
*(uint32_t *)va = *(uint32_t *)src;
|
||||
else if (len == 8) {
|
||||
*(uint32_t *)va = *(uint32_t *)src;
|
||||
- *(uint32_t *)(va + 4) = *(uint32_t *)(src + 4);
|
||||
+ *((uint32_t *)va + 1) = *((uint32_t *)src + 1);
|
||||
} else
|
||||
memcpy(va, src, len);
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
From ccedce5807709d184a9fe89529e611a556f0bf23 Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Tue, 19 Oct 2021 19:45:14 +0800
|
||||
Subject: [PATCH 03/14] rpmsg: notify the user when the remote address is
|
||||
received
|
||||
|
||||
Change-Id: I1085e98aa0bd50746b624ec3fce1e3ca407c17e3
|
||||
Signed-off-by: ligd <liguiding1@xiaomi.com>
|
||||
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/rpmsg.h | 4 ++++
|
||||
lib/rpmsg/rpmsg_virtio.c | 17 ++++++++++++++---
|
||||
2 files changed, 18 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
||||
index b2a9b17..bb1c160 100644
|
||||
--- a/lib/include/openamp/rpmsg.h
|
||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
||||
@@ -52,6 +52,7 @@ struct rpmsg_device;
|
||||
typedef int (*rpmsg_ept_cb)(struct rpmsg_endpoint *ept, void *data,
|
||||
size_t len, uint32_t src, void *priv);
|
||||
typedef void (*rpmsg_ept_release_cb)(struct rpmsg_endpoint *ept);
|
||||
+typedef void (*rpmsg_ns_bound_cb)(struct rpmsg_endpoint *ept);
|
||||
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);
|
||||
@@ -87,6 +88,9 @@ struct rpmsg_endpoint {
|
||||
*/
|
||||
rpmsg_ept_cb cb;
|
||||
|
||||
+ /** Endpoint service bound callback, called when remote ept address is received */
|
||||
+ rpmsg_ns_bound_cb ns_bound_cb;
|
||||
+
|
||||
/** Endpoint service unbind callback, called when remote ept is destroyed */
|
||||
rpmsg_ns_unbind_cb ns_unbind_cb;
|
||||
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index 94c4b95..ad9a730 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -683,17 +683,28 @@ 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)
|
||||
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);
|
||||
}
|
||||
+ 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);
|
||||
+ 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.34.1
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
From f003d671f816b319ad0f8d017022c93b438b78b3 Mon Sep 17 00:00:00 2001
|
||||
From: Yongrong Wang <wangyongrong@xiaomi.com>
|
||||
Date: Mon, 9 Sep 2024 19:46:37 +0800
|
||||
Subject: [PATCH 4/5] lib/system/nuttx: fix unused parameter compile error
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
/home/wyr/work/code/project/cardev/nuttx/openamp/libmetal/lib/system/nuttx/device.c:16:22: error: 'io' undeclared (first use in this function)
|
||||
16 | metal_unused(io);
|
||||
/home/wyr/work/code/project/cardev/nuttx/openamp/libmetal/lib/system/nuttx/device.c:14:53: error: unused parameter 'dev' [-Werror=unused-parameter]
|
||||
14 | int metal_generic_dev_sys_open(struct metal_device *dev)
|
||||
|
||||
error: unused parameter ‘addr’ [-Werror=unused-parameter]
|
||||
25 | static inline void __metal_cache_flush(void *addr, unsigned int len)
|
||||
| ~~~~~~^~~~
|
||||
error: unused parameter ‘len’ [-Werror=unused-parameter]
|
||||
25 | static inline void __metal_cache_flush(void *addr, unsigned int len)
|
||||
| ~~~~~~~~~~~~~^~~
|
||||
|
||||
Change-Id: Ic4515da151d90fd1f87d94d5523144967a7ca688
|
||||
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
|
||||
---
|
||||
lib/system/nuttx/cache.h | 5 +++++
|
||||
lib/system/nuttx/device.c | 1 +
|
||||
lib/system/nuttx/init.c | 1 +
|
||||
lib/system/nuttx/io.c | 6 ++++++
|
||||
lib/system/nuttx/io.h | 3 +++
|
||||
5 files changed, 16 insertions(+)
|
||||
|
||||
diff --git a/lib/system/nuttx/cache.h libmetal/lib/system/nuttx/cache.h
|
||||
index e3b6052..22b94b4 100644
|
||||
--- a/lib/system/nuttx/cache.h
|
||||
+++ libmetal/lib/system/nuttx/cache.h
|
||||
@@ -16,6 +16,7 @@
|
||||
#ifndef __METAL_NUTTX_CACHE__H__
|
||||
#define __METAL_NUTTX_CACHE__H__
|
||||
|
||||
+#include <metal/utilities.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -24,11 +25,15 @@ extern "C" {
|
||||
|
||||
static inline void __metal_cache_flush(void *addr, unsigned int len)
|
||||
{
|
||||
+ metal_unused(addr);
|
||||
+ metal_unused(len);
|
||||
up_clean_dcache((uintptr_t)addr, (uintptr_t)addr + len);
|
||||
}
|
||||
|
||||
static inline void __metal_cache_invalidate(void *addr, unsigned int len)
|
||||
{
|
||||
+ metal_unused(addr);
|
||||
+ metal_unused(len);
|
||||
up_invalidate_dcache((uintptr_t)addr, (uintptr_t)addr + len);
|
||||
}
|
||||
|
||||
diff --git a/lib/system/nuttx/device.c libmetal/lib/system/nuttx/device.c
|
||||
index 7e66ab3..2c828ab 100644
|
||||
--- a/lib/system/nuttx/device.c
|
||||
+++ libmetal/lib/system/nuttx/device.c
|
||||
@@ -13,5 +13,6 @@
|
||||
|
||||
int metal_generic_dev_sys_open(struct metal_device *dev)
|
||||
{
|
||||
+ metal_unused(dev);
|
||||
return 0;
|
||||
}
|
||||
diff --git a/lib/system/nuttx/init.c libmetal/lib/system/nuttx/init.c
|
||||
index 8d59784..2519dc6 100644
|
||||
--- a/lib/system/nuttx/init.c
|
||||
+++ libmetal/lib/system/nuttx/init.c
|
||||
@@ -19,6 +19,7 @@ int metal_sys_init(const struct metal_init_params *params)
|
||||
{
|
||||
int ret = metal_cntr_irq_init();
|
||||
|
||||
+ metal_unused(params);
|
||||
if (ret >= 0)
|
||||
ret = metal_bus_register(&metal_generic_bus);
|
||||
return ret;
|
||||
diff --git a/lib/system/nuttx/io.c libmetal/lib/system/nuttx/io.c
|
||||
index ab9bc6a..41697a7 100644
|
||||
--- a/lib/system/nuttx/io.c
|
||||
+++ libmetal/lib/system/nuttx/io.c
|
||||
@@ -15,6 +15,7 @@ static uint64_t metal_io_read_(struct metal_io_region *io,
|
||||
{
|
||||
uint64_t value = 0;
|
||||
|
||||
+ metal_unused(order);
|
||||
metal_io_block_read(io, offset, &value, width);
|
||||
return value;
|
||||
}
|
||||
@@ -25,6 +26,7 @@ static void metal_io_write_(struct metal_io_region *io,
|
||||
memory_order order,
|
||||
int width)
|
||||
{
|
||||
+ metal_unused(order);
|
||||
metal_io_block_write(io, offset, &value, width);
|
||||
}
|
||||
|
||||
@@ -36,6 +38,7 @@ static int metal_io_block_read_(struct metal_io_region *io,
|
||||
{
|
||||
void *va = metal_io_virt(io, offset);
|
||||
|
||||
+ metal_unused(order);
|
||||
metal_cache_invalidate(va, len);
|
||||
if (len == 1)
|
||||
*(uint8_t *)dst = *(uint8_t *)va;
|
||||
@@ -60,6 +63,7 @@ static int metal_io_block_write_(struct metal_io_region *io,
|
||||
{
|
||||
void *va = metal_io_virt(io, offset);
|
||||
|
||||
+ metal_unused(order);
|
||||
if (len == 1)
|
||||
*(uint8_t *)va = *(uint8_t *)src;
|
||||
else if (len == 2)
|
||||
@@ -85,12 +89,14 @@ static void metal_io_block_set_(struct metal_io_region *io,
|
||||
{
|
||||
void *va = metal_io_virt(io, offset);
|
||||
|
||||
+ metal_unused(order);
|
||||
memset(va, value, len);
|
||||
metal_cache_flush(va, len);
|
||||
}
|
||||
|
||||
static void metal_io_close_(struct metal_io_region *io)
|
||||
{
|
||||
+ metal_unused(io);
|
||||
}
|
||||
|
||||
static metal_phys_addr_t metal_io_offset_to_phys_(struct metal_io_region *io,
|
||||
diff --git a/lib/system/nuttx/io.h libmetal/lib/system/nuttx/io.h
|
||||
index 7f6508d..743b7b1 100644
|
||||
--- a/lib/system/nuttx/io.h
|
||||
+++ libmetal/lib/system/nuttx/io.h
|
||||
@@ -16,6 +16,8 @@
|
||||
#ifndef __METAL_NUTTX_IO__H__
|
||||
#define __METAL_NUTTX_IO__H__
|
||||
|
||||
+#include <metal/utilities.h>
|
||||
+
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -39,6 +41,7 @@ struct metal_io_region *metal_io_get_region(void);
|
||||
*/
|
||||
static inline void metal_sys_io_mem_map(struct metal_io_region *io)
|
||||
{
|
||||
+ metal_unused(io);
|
||||
}
|
||||
#endif
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,189 +0,0 @@
|
|||
From ddc209c9475a2822ffe5d18441bd01718acdbc11 Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Fri, 29 Jul 2022 22:57:23 +0800
|
||||
Subject: [PATCH 04/10] openamp: add new ops notify_wait() support
|
||||
|
||||
This can avoid looping check tx buffer
|
||||
|
||||
Change-Id: Ie340ed06c306ce978ff165aacaf5b830e3645af8
|
||||
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 d1efab85..f6554404 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 6609a1fd..e65488d5 100644
|
||||
--- a/lib/include/openamp/remoteproc_virtio.h
|
||||
+++ open-amp/lib/include/openamp/remoteproc_virtio.h
|
||||
@@ -25,6 +25,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
|
||||
@@ -40,6 +41,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 dbe42ea6..14440e20 100644
|
||||
--- a/lib/include/openamp/rpmsg.h
|
||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
||||
@@ -50,6 +50,7 @@ extern "C" {
|
||||
#define RPMSG_ERR_INIT (RPMSG_ERROR_BASE - 6)
|
||||
#define RPMSG_ERR_ADDR (RPMSG_ERROR_BASE - 7)
|
||||
#define RPMSG_ERR_PERM (RPMSG_ERROR_BASE - 8)
|
||||
+#define RPMSG_ERR_NXIO (RPMSG_ERROR_BASE - 9)
|
||||
|
||||
struct rpmsg_endpoint;
|
||||
struct rpmsg_device;
|
||||
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||
index 0b22e840..11cb6df9 100644
|
||||
--- a/lib/include/openamp/rpmsg_virtio.h
|
||||
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||
@@ -148,6 +148,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 916132b4..0303a5b3 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 f7f9f2df..001b11bf 100644
|
||||
--- a/lib/remoteproc/remoteproc.c
|
||||
+++ open-amp/lib/remoteproc/remoteproc.c
|
||||
@@ -899,6 +899,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,
|
||||
@@ -957,6 +967,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 169e5b5f..4375c4c3 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 c56e0cea..4960aa8a 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -373,6 +373,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
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
From 17ca934563b3d62f950f5d1693d89556495d150f Mon Sep 17 00:00:00 2001
|
||||
From: wangyongrong <wangyongrong@xiaomi.com>
|
||||
Date: Tue, 2 Jul 2024 16:33:32 +0800
|
||||
Subject: [PATCH 04/14] openamp/virtio.h: negotiate_features also can be call
|
||||
when final_features is NULL
|
||||
|
||||
Change-Id: I41774d6c8b3c8b7487dc4b640fa60f4061ad3694
|
||||
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/virtio.h | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h
|
||||
index c4d4927..278d2da 100644
|
||||
--- a/lib/include/openamp/virtio.h
|
||||
+++ open-amp/lib/include/openamp/virtio.h
|
||||
@@ -468,13 +468,15 @@ static inline int virtio_negotiate_features(struct virtio_device *vdev,
|
||||
uint32_t features,
|
||||
uint32_t *final_features)
|
||||
{
|
||||
- if (!vdev || !final_features)
|
||||
+ if (!vdev)
|
||||
return -EINVAL;
|
||||
|
||||
if (!vdev->func || !vdev->func->negotiate_features)
|
||||
return -ENXIO;
|
||||
|
||||
- *final_features = vdev->func->negotiate_features(vdev, features);
|
||||
+ vdev->features = vdev->func->negotiate_features(vdev, features);
|
||||
+ if (final_features)
|
||||
+ *final_features = vdev->features;
|
||||
return 0;
|
||||
}
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
From 2b9bd97db33d95c4d6d40e6f0ec1fa388fac3ab0 Mon Sep 17 00:00:00 2001
|
||||
From: xuxin19 <xuxin19@xiaomi.com>
|
||||
Date: Fri, 6 Sep 2024 10:56:49 +0800
|
||||
Subject: [PATCH 5/5] libmetal(cmake):set HAVE_STDATOMIC_H default true in
|
||||
NuttX platform
|
||||
|
||||
Change-Id: I84e6fdd03753a16a9c296e87ab121cb8c16f3c61
|
||||
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
|
||||
---
|
||||
cmake/depends.cmake | 10 ++++++++--
|
||||
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/cmake/depends.cmake libmetal/cmake/depends.cmake
|
||||
index 60b9739..15683f8 100644
|
||||
--- a/cmake/depends.cmake
|
||||
+++ libmetal/cmake/depends.cmake
|
||||
@@ -24,7 +24,13 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
find_package(LibRt REQUIRED)
|
||||
collect (PROJECT_LIB_DEPS "${LIBRT_LIBRARIES}")
|
||||
|
||||
-else ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
+elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "NuttX")
|
||||
+
|
||||
+ # there is no need to use cmake include detection
|
||||
+ # under NuttX platform
|
||||
+ set(HAVE_STDATOMIC_H true)
|
||||
+
|
||||
+else ()
|
||||
|
||||
# TODO: fix for find_path() to detect stdatomic.h
|
||||
# find_path (HAVE_STDATOMIC_H stdatomic.h)
|
||||
@@ -33,5 +39,5 @@ else ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
check_include_files (stdatomic.h HAVE_STDATOMIC_H)
|
||||
set (CMAKE_REQUIRED_FLAGS ${_saved_cmake_required_flags})
|
||||
|
||||
-endif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
+endif ()
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
From 8892766fc72db6d607e2057be0cf7386ee7fea14 Mon Sep 17 00:00:00 2001
|
||||
From: wangyongrong <wangyongrong@xiaomi.com>
|
||||
Date: Wed, 3 Jul 2024 10:00:34 +0800
|
||||
Subject: [PATCH 05/14] remoteproc/rpmsg_virtio: change sched_yeild to usleep
|
||||
|
||||
Change-Id: I4246185cb1d2f363df170e2aa03a1901b0a296a8
|
||||
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
|
||||
---
|
||||
lib/remoteproc/remoteproc_virtio.c | 3 ++-
|
||||
lib/rpmsg/rpmsg_virtio.c | 3 +--
|
||||
2 files changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/lib/remoteproc/remoteproc_virtio.c open-amp/lib/remoteproc/remoteproc_virtio.c
|
||||
index ef39c49..aae026c 100644
|
||||
--- a/lib/remoteproc/remoteproc_virtio.c
|
||||
+++ open-amp/lib/remoteproc/remoteproc_virtio.c
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <metal/cpu.h>
|
||||
#include <metal/utilities.h>
|
||||
#include <metal/alloc.h>
|
||||
+#include <metal/sleep.h>
|
||||
|
||||
static void rproc_virtio_delete_virtqueues(struct virtio_device *vdev)
|
||||
{
|
||||
@@ -412,6 +413,6 @@ void rproc_virtio_wait_remote_ready(struct virtio_device *vdev)
|
||||
status = rproc_virtio_get_status(vdev);
|
||||
if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK)
|
||||
return;
|
||||
- metal_cpu_yield();
|
||||
+ metal_sleep_usec(1000);
|
||||
}
|
||||
}
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index ad9a730..db3392e 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -272,8 +272,7 @@ static int rpmsg_virtio_wait_remote_ready(struct rpmsg_virtio_device *rvdev)
|
||||
} else if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK) {
|
||||
return 0;
|
||||
}
|
||||
- /* TODO: clarify metal_cpu_yield usage*/
|
||||
- metal_cpu_yield();
|
||||
+ metal_sleep_usec(1000);
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
From 5a9d63c1ce2878aa792c49a1205ebb73dbe6258f Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Mon, 28 Feb 2022 16:31:54 +0800
|
||||
Subject: [PATCH 05/10] rpmsg_virtio: don't need check status when
|
||||
get_tx_payload
|
||||
|
||||
VELAOS-21
|
||||
|
||||
Change-Id: Icb01034dfab146b3a02ea2c70dbdf197d8ed419f
|
||||
Signed-off-by: ligd <liguiding1@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 4960aa8a..1f6ce593 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -356,11 +356,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
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
From b9181b30e8fc1c7ee058b34e6cfe2f54c43af665 Mon Sep 17 00:00:00 2001
|
||||
From: Bowen Wang <wangbowen6@xiaomi.com>
|
||||
Date: Wed, 9 Oct 2024 20:54:56 +0800
|
||||
Subject: [PATCH 6/6] lib/system/nuttx/io.c: include <stddef.h> in nuttx/io.c
|
||||
|
||||
Because nuttx/io.c use NULL and NULL is defined in <stddef.h>
|
||||
|
||||
Change-Id: I98af56739e6beb6f165ef165e700c3ed8305d1d1
|
||||
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
|
||||
---
|
||||
lib/system/nuttx/io.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/lib/system/nuttx/io.c libmetal/lib/system/nuttx/io.c
|
||||
index 41697a7..cc5e0a7 100644
|
||||
--- a/lib/system/nuttx/io.c
|
||||
+++ libmetal/lib/system/nuttx/io.c
|
||||
@@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
+#include <stddef.h>
|
||||
#include <metal/cache.h>
|
||||
#include <metal/io.h>
|
||||
#include <nuttx/arch.h>
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
From a2c9d79f9b77f057d89ede1395559c0645169b7a Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Tue, 19 Oct 2021 19:45:14 +0800
|
||||
Subject: [PATCH 06/10] 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(+)
|
||||
|
||||
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
||||
index 14440e20..fbd7f619 100644
|
||||
--- a/lib/include/openamp/rpmsg.h
|
||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
||||
@@ -58,6 +58,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);
|
||||
+typedef void (*rpmsg_ns_bound_cb)(struct rpmsg_endpoint *ept);
|
||||
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);
|
||||
@@ -70,6 +71,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.
|
||||
+ * @ns_bound_cb: end point service bound callback, called when remote
|
||||
+ * ept address is received.
|
||||
* @ns_unbind_cb: end point service unbind callback, called when remote
|
||||
* ept is destroyed.
|
||||
* @node: end point node.
|
||||
@@ -84,6 +87,7 @@ struct rpmsg_endpoint {
|
||||
uint32_t addr;
|
||||
uint32_t dest_addr;
|
||||
rpmsg_ept_cb cb;
|
||||
+ rpmsg_ns_bound_cb ns_bound_cb;
|
||||
rpmsg_ns_unbind_cb ns_unbind_cb;
|
||||
struct metal_list node;
|
||||
void *priv;
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index 1f6ce593..efbcd68d 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -658,12 +658,18 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
|
||||
if (_ept->name[0] && rdev->support_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);
|
||||
}
|
||||
} else { /* RPMSG_NS_CREATE_ACK */
|
||||
/* save the received destination address */
|
||||
if (_ept)
|
||||
_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);
|
||||
}
|
||||
|
||||
return RPMSG_SUCCESS;
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,19 +1,20 @@
|
|||
From 931cd95ab99550befa75703cc36d5e6f6964b63e Mon Sep 17 00:00:00 2001
|
||||
From: Guiding Li <liguiding@pinecone.net>
|
||||
From 9ed3332f08c9877deb4dcabb7447b634abe8845e Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding@pinecone.net>
|
||||
Date: Wed, 20 Feb 2019 11:36:57 +0800
|
||||
Subject: [PATCH 03/10] rpmsg: wait endpoint ready in rpmsg_send and
|
||||
rpmsg_send_nocopy
|
||||
Subject: [PATCH 06/14] rpmsg: wait ept ready in rpmsg_send
|
||||
|
||||
because the remote need time to return the destination address
|
||||
since the destination address need time to return from peer
|
||||
|
||||
Signed-off-by: Guiding Li <liguiding@pinecone.net>
|
||||
Change-Id: I1a518c15cd375205b07861c7d39670de555eaaed
|
||||
Signed-off-by: ligd <liguiding@pinecone.net>
|
||||
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/rpmsg.h | 59 ++++++++++++++++++++++++++-----------
|
||||
lib/rpmsg/rpmsg_virtio.c | 7 -----
|
||||
2 files changed, 42 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
||||
index ff3ff8fb..dbe42ea6 100644
|
||||
index bb1c160..cb1a648 100644
|
||||
--- a/lib/include/openamp/rpmsg.h
|
||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
||||
@@ -15,6 +15,7 @@
|
||||
|
@ -37,12 +38,12 @@ index ff3ff8fb..dbe42ea6 100644
|
|||
/* Error macros. */
|
||||
#define RPMSG_SUCCESS 0
|
||||
#define RPMSG_ERROR_BASE -2000
|
||||
@@ -147,6 +154,19 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
|
||||
@@ -186,6 +193,19 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
|
||||
uint32_t dst, const void *data, int len,
|
||||
int wait);
|
||||
|
||||
+/**
|
||||
+ * is_rpmsg_ept_ready - check if the rpmsg endpoint ready to send
|
||||
+ * @brief Check if the rpmsg endpoint ready to send
|
||||
+ *
|
||||
+ * @ept: pointer to rpmsg endpoint
|
||||
+ *
|
||||
|
@ -55,9 +56,9 @@ index ff3ff8fb..dbe42ea6 100644
|
|||
+}
|
||||
+
|
||||
/**
|
||||
* rpmsg_send() - send a message across to the remote processor
|
||||
* @ept: the rpmsg endpoint
|
||||
@@ -165,11 +185,20 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
|
||||
* @brief Send a message across to the remote processor
|
||||
*
|
||||
@@ -205,11 +225,20 @@ 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)
|
||||
{
|
||||
|
@ -80,7 +81,7 @@ index ff3ff8fb..dbe42ea6 100644
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -476,11 +505,20 @@ static inline int rpmsg_sendto_nocopy(struct rpmsg_endpoint *ept,
|
||||
@@ -545,11 +574,20 @@ 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)
|
||||
{
|
||||
|
@ -103,16 +104,16 @@ index ff3ff8fb..dbe42ea6 100644
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -524,19 +562,6 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
|
||||
@@ -594,19 +632,6 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
|
||||
*/
|
||||
void rpmsg_destroy_ept(struct rpmsg_endpoint *ept);
|
||||
|
||||
-/**
|
||||
- * is_rpmsg_ept_ready - check if the rpmsg endpoint ready to send
|
||||
- * @brief Check if the rpmsg endpoint ready to send
|
||||
- *
|
||||
- * @ept: pointer to rpmsg endpoint
|
||||
- * @param ept Pointer to rpmsg endpoint
|
||||
- *
|
||||
- * Returns 1 if the rpmsg endpoint has both local addr and destination
|
||||
- * @return 1 if the rpmsg endpoint has both local addr and destination
|
||||
- * addr set, 0 otherwise
|
||||
- */
|
||||
-static inline unsigned int is_rpmsg_ept_ready(struct rpmsg_endpoint *ept)
|
||||
|
@ -124,17 +125,17 @@ index ff3ff8fb..dbe42ea6 100644
|
|||
}
|
||||
#endif
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index 69537399..c56e0cea 100644
|
||||
index db3392e..e6a4969 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -10,7 +10,6 @@
|
||||
@@ -9,7 +9,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>
|
||||
#include <openamp/remoteproc.h>
|
||||
@@ -19,12 +18,6 @@
|
||||
|
||||
#define RPMSG_NUM_VRINGS 2
|
||||
|
@ -145,9 +146,9 @@ index 69537399..c56e0cea 100644
|
|||
-/* Time to wait - In multiple of 1 msecs. */
|
||||
-#define RPMSG_TICKS_PER_INTERVAL 1000
|
||||
-
|
||||
/**
|
||||
* struct vbuff_reclaimer_t - vring buffer recycler
|
||||
*
|
||||
/*
|
||||
* Get the buffer held counter value.
|
||||
* If 0 the buffer can be released
|
||||
--
|
||||
2.25.1
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
From 9a8e63285c30026a8fabaf0ed8af323eafd07539 Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Thu, 23 Jun 2022 00:41:13 +0800
|
||||
Subject: [PATCH 07/14] openamp: add VIRTIO_RING_F_MUST_NOTIFY event
|
||||
|
||||
Change-Id: I455c4a5427fbcc60c6f61707c4304c12aa13ee58
|
||||
Signed-off-by: ligd <liguiding1@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/virtqueue.h | 3 +++
|
||||
lib/virtio/virtqueue.c | 3 +++
|
||||
2 files changed, 6 insertions(+)
|
||||
|
||||
diff --git a/lib/include/openamp/virtqueue.h open-amp/lib/include/openamp/virtqueue.h
|
||||
index 8194398..dd42c3a 100644
|
||||
--- a/lib/include/openamp/virtqueue.h
|
||||
+++ open-amp/lib/include/openamp/virtqueue.h
|
||||
@@ -48,6 +48,9 @@ extern "C" {
|
||||
/* Support to suppress interrupt until specific index is reached. */
|
||||
#define VIRTIO_RING_F_EVENT_IDX (1 << 29)
|
||||
|
||||
+/* Support to can't suppress interrupt. */
|
||||
+#define VIRTIO_RING_F_MUST_NOTIFY (1 << 30)
|
||||
+
|
||||
/* cache invalidation helpers */
|
||||
#define CACHE_FLUSH(x, s) metal_cache_flush(x, s)
|
||||
#define CACHE_INVALIDATE(x, s) metal_cache_invalidate(x, s)
|
||||
diff --git a/lib/virtio/virtqueue.c open-amp/lib/virtio/virtqueue.c
|
||||
index 363fda8..7ffe569 100644
|
||||
--- a/lib/virtio/virtqueue.c
|
||||
+++ open-amp/lib/virtio/virtqueue.c
|
||||
@@ -609,6 +609,9 @@ static int vq_ring_must_notify(struct virtqueue *vq)
|
||||
{
|
||||
uint16_t new_idx, prev_idx, event_idx;
|
||||
|
||||
+ if (vq->vq_dev->features & VIRTIO_RING_F_MUST_NOTIFY)
|
||||
+ return 1;
|
||||
+
|
||||
if (vq->vq_dev->features & VIRTIO_RING_F_EVENT_IDX) {
|
||||
if (VIRTIO_ROLE_IS_DRIVER(vq->vq_dev)) {
|
||||
/* CACHE: no need to invalidate avail */
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
From 0e77783658066c02903cc6693460f3bb577e3030 Mon Sep 17 00:00:00 2001
|
||||
From: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
|
||||
Date: Mon, 11 Apr 2022 13:31:35 +0800
|
||||
Subject: [PATCH 07/10] 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 efbcd68d..49817799 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -652,7 +652,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)
|
||||
@@ -662,14 +662,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
|
||||
|
|
@ -1,195 +0,0 @@
|
|||
From bcd10078fe4266cadbc437b130832dd90c00df33 Mon Sep 17 00:00:00 2001
|
||||
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
||||
Date: Fri, 15 Nov 2019 19:01:49 +0800
|
||||
Subject: [PATCH 08/10] 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 e7dda748..916a23f9 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 c90b8d46..ffb253fb 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
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
From b092024f77f34c679b0537f6481947d297bca281 Mon Sep 17 00:00:00 2001
|
||||
From: wangyongrong <wangyongrong@xiaomi.com>
|
||||
Date: Wed, 3 Jul 2024 10:28:31 +0800
|
||||
Subject: [PATCH 08/14] rpmsg_virtio: don't need check status when
|
||||
get_tx_payload
|
||||
|
||||
Change-Id: I6c0632a6924dafeb0c01ec0b16c9f53d2fbc6810
|
||||
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 e6a4969..9dd14b6 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -352,7 +352,6 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev,
|
||||
{
|
||||
struct rpmsg_virtio_device *rvdev;
|
||||
struct rpmsg_hdr *rp_hdr;
|
||||
- uint8_t virtio_status;
|
||||
uint16_t idx;
|
||||
int tick_count;
|
||||
int status;
|
||||
@@ -360,11 +359,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 = virtio_get_status(rvdev->vdev, &virtio_status);
|
||||
- if (status || !(virtio_status & VIRTIO_CONFIG_STATUS_DRIVER_OK))
|
||||
- return NULL;
|
||||
-
|
||||
if (wait)
|
||||
tick_count = RPMSG_TICK_COUNT / RPMSG_TICKS_PER_INTERVAL;
|
||||
else
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
From e33b3fa0b6f111b54648f682102266b077a0c285 Mon Sep 17 00:00:00 2001
|
||||
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
||||
Date: Sun, 6 Nov 2022 00:51:35 +0800
|
||||
Subject: [PATCH 09/10] Fix warn: declaration of 'vring_rsc' shadows a previous
|
||||
local
|
||||
|
||||
regressed by commit 03c80a13417f67f94852cf7d5cb160f1bdf8271e
|
||||
Author: Tammy Leino <tammy_leino@mentor.com>
|
||||
Date: Mon Sep 26 08:14:35 2022 -0700
|
||||
|
||||
handle_vdev_rsc must return error if notifyid cannot be assigned
|
||||
|
||||
Updated handle_vdev_rsc to return error if a unique id cannot be assigned
|
||||
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
|
||||
|
||||
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
|
||||
---
|
||||
lib/remoteproc/rsc_table_parser.c | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
diff --git a/lib/remoteproc/rsc_table_parser.c open-amp/lib/remoteproc/rsc_table_parser.c
|
||||
index 80879380..4cccf4f1 100644
|
||||
--- a/lib/remoteproc/rsc_table_parser.c
|
||||
+++ open-amp/lib/remoteproc/rsc_table_parser.c
|
||||
@@ -144,8 +144,6 @@ int handle_vdev_rsc(struct remoteproc *rproc, void *rsc)
|
||||
|
||||
num_vrings = vdev_rsc->num_of_vrings;
|
||||
for (i = 0; i < num_vrings; i++) {
|
||||
- struct fw_rsc_vdev_vring *vring_rsc;
|
||||
-
|
||||
vring_rsc = &vdev_rsc->vring[i];
|
||||
notifyid = vring_rsc->notifyid;
|
||||
notifyid = remoteproc_allocate_id(rproc,
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
From fc935c6e5abcd0a96e5c3ca3bd5ec272543abc1a Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Fri, 7 Apr 2023 12:42:09 +0800
|
||||
Subject: [PATCH 09/14] openamp: swap get_rx_buffer & return_rx_buffer to
|
||||
resolve remote low power.
|
||||
|
||||
Change-Id: I84e8b3a7a6796b5865da482db0408d5a08c55c2a
|
||||
Signed-off-by: ligd <liguiding1@xiaomi.com>
|
||||
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
|
||||
---
|
||||
lib/rpmsg/rpmsg_virtio.c | 16 +++++++++++++---
|
||||
1 file changed, 13 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index 9dd14b6..dfd36e3 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -545,17 +545,26 @@ 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_hdr *next_hdr = NULL;
|
||||
struct rpmsg_endpoint *ept;
|
||||
struct rpmsg_hdr *rp_hdr;
|
||||
+ uint32_t next_len;
|
||||
+ uint16_t next_idx;
|
||||
uint32_t len;
|
||||
uint16_t idx;
|
||||
int status;
|
||||
|
||||
while (1) {
|
||||
/* Process the received data from remote node */
|
||||
- metal_mutex_acquire(&rdev->lock);
|
||||
- rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
|
||||
- metal_mutex_release(&rdev->lock);
|
||||
+ if (!next_hdr) {
|
||||
+ metal_mutex_acquire(&rdev->lock);
|
||||
+ rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
|
||||
+ metal_mutex_release(&rdev->lock);
|
||||
+ } else {
|
||||
+ rp_hdr = next_hdr;
|
||||
+ len = next_len;
|
||||
+ idx = next_idx;
|
||||
+ }
|
||||
|
||||
/* No more filled rx buffers */
|
||||
if (!rp_hdr)
|
||||
@@ -587,6 +596,7 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
|
||||
|
||||
metal_mutex_acquire(&rdev->lock);
|
||||
rpmsg_ept_decref(ept);
|
||||
+ next_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &next_len, &next_idx);
|
||||
if (rpmsg_virtio_buf_held_dec_test(rp_hdr))
|
||||
rpmsg_virtio_release_rx_buffer_nolock(rvdev, rp_hdr);
|
||||
metal_mutex_release(&rdev->lock);
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
From 76fd1e2c7e967ec979a24a49ce1c9626a4279f21 Mon Sep 17 00:00:00 2001
|
||||
From: Yongrong Wang <wangyongrong@xiaomi.com>
|
||||
Date: Wed, 10 Jul 2024 15:02:01 +0800
|
||||
Subject: [PATCH 10/14] rpmsg_virtio.c: virtqueue_kick after all rx buffer
|
||||
release
|
||||
|
||||
Only kick once when all the rx buffers has been returned to decrease
|
||||
the interrupt times to improve the performance
|
||||
|
||||
Change-Id: I158e3a63063e8eff7b97a02660f2d7a6c812c493
|
||||
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
|
||||
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
|
||||
---
|
||||
lib/rpmsg/rpmsg_virtio.c | 20 +++++++++++++-------
|
||||
1 file changed, 13 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index dfd36e3..bdf9046 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -314,8 +314,6 @@ static bool rpmsg_virtio_release_rx_buffer_nolock(struct rpmsg_virtio_device *rv
|
||||
/* Return buffer on virtqueue. */
|
||||
len = virtqueue_get_buffer_length(rvdev->rvq, idx);
|
||||
rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx);
|
||||
- /* Tell peer we returned an rx buffer */
|
||||
- virtqueue_kick(rvdev->rvq);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -330,8 +328,11 @@ static void rpmsg_virtio_release_rx_buffer(struct rpmsg_device *rdev,
|
||||
rp_hdr = RPMSG_LOCATE_HDR(rxbuf);
|
||||
|
||||
metal_mutex_acquire(&rdev->lock);
|
||||
- if (rpmsg_virtio_buf_held_dec_test(rp_hdr))
|
||||
+ if (rpmsg_virtio_buf_held_dec_test(rp_hdr)) {
|
||||
rpmsg_virtio_release_rx_buffer_nolock(rvdev, rp_hdr);
|
||||
+ /* Tell peer we returned an rx buffer */
|
||||
+ virtqueue_kick(rvdev->rvq);
|
||||
+ }
|
||||
metal_mutex_release(&rdev->lock);
|
||||
}
|
||||
|
||||
@@ -560,16 +561,21 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
|
||||
metal_mutex_acquire(&rdev->lock);
|
||||
rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
|
||||
metal_mutex_release(&rdev->lock);
|
||||
+ if (!rp_hdr)
|
||||
+ break;
|
||||
} else {
|
||||
+ /* No more filled rx buffers */
|
||||
+ if (!next_hdr) {
|
||||
+ /* Tell peer we returned some rx buffer */
|
||||
+ virtqueue_kick(rvdev->rvq);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
rp_hdr = next_hdr;
|
||||
len = next_len;
|
||||
idx = next_idx;
|
||||
}
|
||||
|
||||
- /* No more filled rx buffers */
|
||||
- if (!rp_hdr)
|
||||
- break;
|
||||
-
|
||||
rp_hdr->reserved = idx;
|
||||
|
||||
/* Get the channel node from the remote device channels list. */
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
From 160e7ee44228668074347226e9c0d9068c480d98 Mon Sep 17 00:00:00 2001
|
||||
From: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
|
||||
Date: Thu, 11 Aug 2022 21:54:53 +0800
|
||||
Subject: [PATCH 10/10] rptun: fix rptun don't wait issue when get tx patyload
|
||||
buffer
|
||||
|
||||
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
|
||||
Signed-off-by: ligd <liguiding1@xiaomi.com>
|
||||
---
|
||||
lib/rpmsg/rpmsg_virtio.c | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index 49817799..06c6890b 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -372,8 +372,6 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev,
|
||||
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
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
From 6c7a71ed16d86638141566fa7457e2aa36112202 Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Fri, 6 Jan 2023 22:13:49 +0800
|
||||
Subject: [PATCH 1/6] rpmsg: fix rpmsg_virtio_get_tx_buffer no idx return
|
||||
|
||||
Change-Id: Ib7004b9039403156ec39f01ecf3d29900957c3be
|
||||
Signed-off-by: ligd <liguiding1@xiaomi.com>
|
||||
---
|
||||
lib/rpmsg/rpmsg_virtio.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index 06c6890..fcf24cd 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -176,8 +176,10 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev,
|
||||
data = r_desc;
|
||||
|
||||
#ifndef VIRTIO_DEVICE_ONLY
|
||||
- if (role == RPMSG_HOST)
|
||||
+ if (role == RPMSG_HOST) {
|
||||
+ *idx = r_desc->idx;
|
||||
*len = rvdev->config.h2r_buf_size;
|
||||
+ }
|
||||
#endif /*!VIRTIO_DEVICE_ONLY*/
|
||||
#ifndef VIRTIO_DRIVER_ONLY
|
||||
if (role == RPMSG_REMOTE) {
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -0,0 +1,255 @@
|
|||
From 6d2bf800f07a9584ea2445b4046c2d82cddf0c6f Mon Sep 17 00:00:00 2001
|
||||
From: Yongrong Wang <wangyongrong@xiaomi.com>
|
||||
Date: Wed, 10 Jul 2024 18:47:33 +0800
|
||||
Subject: [PATCH 11/14] virtio: change feature to 64 bit in all virtio_dispatch
|
||||
|
||||
The virtio device feature bit has exceeded 32 bits, so change feautre
|
||||
to 64 bit like linux does to support more features
|
||||
|
||||
Change-Id: I42c016e3e9eaac5fdbfdf19549a906bc51eb6939
|
||||
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/rpmsg_virtio.h | 2 +-
|
||||
lib/include/openamp/virtio.h | 20 ++++++-------
|
||||
lib/remoteproc/remoteproc_virtio.c | 14 +++++-----
|
||||
lib/rpmsg/rpmsg_virtio.c | 2 +-
|
||||
lib/virtio/virtio.c | 2 +-
|
||||
lib/virtio_mmio/virtio_mmio_drv.c | 45 +++++++++++++++---------------
|
||||
6 files changed, 42 insertions(+), 43 deletions(-)
|
||||
|
||||
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||
index d9cfa9b..866e9eb 100644
|
||||
--- a/lib/include/openamp/rpmsg_virtio.h
|
||||
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||
@@ -179,7 +179,7 @@ static inline uint8_t rpmsg_virtio_get_status(struct rpmsg_virtio_device *rvdev)
|
||||
* @return The features supported by both the rpmsg driver and rpmsg device.
|
||||
*/
|
||||
__deprecated
|
||||
-static inline uint32_t
|
||||
+static inline uint64_t
|
||||
rpmsg_virtio_get_features(struct rpmsg_virtio_device *rvdev)
|
||||
{
|
||||
return rvdev->vdev->func->get_features(rvdev->vdev);
|
||||
diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h
|
||||
index 278d2da..dd285ac 100644
|
||||
--- a/lib/include/openamp/virtio.h
|
||||
+++ open-amp/lib/include/openamp/virtio.h
|
||||
@@ -156,7 +156,7 @@ struct virtio_dispatch;
|
||||
/** @brief Device features. */
|
||||
struct virtio_feature_desc {
|
||||
/** Unique feature ID, defined in the virtio specification. */
|
||||
- uint32_t vfd_val;
|
||||
+ uint64_t vfd_val;
|
||||
|
||||
/** Name of the feature (for debug). */
|
||||
const char *vfd_str;
|
||||
@@ -221,7 +221,7 @@ struct virtio_device {
|
||||
const char *virtio_dev_name(uint16_t devid);
|
||||
|
||||
__deprecated void virtio_describe(struct virtio_device *dev, const char *msg,
|
||||
- uint32_t features,
|
||||
+ uint64_t features,
|
||||
struct virtio_feature_desc *feature_desc);
|
||||
|
||||
/**
|
||||
@@ -249,17 +249,17 @@ struct virtio_dispatch {
|
||||
void (*set_status)(struct virtio_device *dev, uint8_t status);
|
||||
|
||||
/** Get the feature exposed by the virtio device. */
|
||||
- uint32_t (*get_features)(struct virtio_device *dev);
|
||||
+ uint64_t (*get_features)(struct virtio_device *dev);
|
||||
|
||||
/** Set the supported `feature` (virtio driver only). */
|
||||
- void (*set_features)(struct virtio_device *dev, uint32_t feature);
|
||||
+ void (*set_features)(struct virtio_device *dev, uint64_t feature);
|
||||
|
||||
/**
|
||||
* Set the supported features negotiate between the `features` parameter and features
|
||||
* supported by the device (virtio driver only).
|
||||
*/
|
||||
- uint32_t (*negotiate_features)(struct virtio_device *dev,
|
||||
- uint32_t features);
|
||||
+ uint64_t (*negotiate_features)(struct virtio_device *dev,
|
||||
+ uint64_t features);
|
||||
|
||||
/**
|
||||
* Read a variable amount from the device specific (ie, network)
|
||||
@@ -422,7 +422,7 @@ static inline int virtio_write_config(struct virtio_device *vdev,
|
||||
* @return 0 on success, otherwise error code.
|
||||
*/
|
||||
static inline int virtio_get_features(struct virtio_device *vdev,
|
||||
- uint32_t *features)
|
||||
+ uint64_t *features)
|
||||
{
|
||||
if (!vdev || !features)
|
||||
return -EINVAL;
|
||||
@@ -443,7 +443,7 @@ static inline int virtio_get_features(struct virtio_device *vdev,
|
||||
* @return 0 on success, otherwise error code.
|
||||
*/
|
||||
static inline int virtio_set_features(struct virtio_device *vdev,
|
||||
- uint32_t features)
|
||||
+ uint64_t features)
|
||||
{
|
||||
if (!vdev)
|
||||
return -EINVAL;
|
||||
@@ -465,8 +465,8 @@ static inline int virtio_set_features(struct virtio_device *vdev,
|
||||
* @return 0 on success, otherwise error code.
|
||||
*/
|
||||
static inline int virtio_negotiate_features(struct virtio_device *vdev,
|
||||
- uint32_t features,
|
||||
- uint32_t *final_features)
|
||||
+ uint64_t features,
|
||||
+ uint64_t *final_features)
|
||||
{
|
||||
if (!vdev)
|
||||
return -EINVAL;
|
||||
diff --git a/lib/remoteproc/remoteproc_virtio.c open-amp/lib/remoteproc/remoteproc_virtio.c
|
||||
index aae026c..902fc41 100644
|
||||
--- a/lib/remoteproc/remoteproc_virtio.c
|
||||
+++ open-amp/lib/remoteproc/remoteproc_virtio.c
|
||||
@@ -165,7 +165,7 @@ static uint32_t rproc_virtio_get_dfeatures(struct virtio_device *vdev)
|
||||
return features;
|
||||
}
|
||||
|
||||
-static uint32_t rproc_virtio_get_features(struct virtio_device *vdev)
|
||||
+static uint64_t rproc_virtio_get_features(struct virtio_device *vdev)
|
||||
{
|
||||
struct remoteproc_virtio *rpvdev;
|
||||
struct fw_rsc_vdev *vdev_rsc;
|
||||
@@ -181,12 +181,12 @@ static uint32_t rproc_virtio_get_features(struct virtio_device *vdev)
|
||||
metal_io_virt_to_offset(io, &vdev_rsc->gfeatures));
|
||||
dfeatures = rproc_virtio_get_dfeatures(vdev);
|
||||
|
||||
- return dfeatures & gfeatures;
|
||||
+ return (uint64_t)(dfeatures & gfeatures);
|
||||
}
|
||||
|
||||
#if VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT)
|
||||
static void rproc_virtio_set_features(struct virtio_device *vdev,
|
||||
- uint32_t features)
|
||||
+ uint64_t features)
|
||||
{
|
||||
struct remoteproc_virtio *rpvdev;
|
||||
struct fw_rsc_vdev *vdev_rsc;
|
||||
@@ -197,17 +197,17 @@ static void rproc_virtio_set_features(struct virtio_device *vdev,
|
||||
io = rpvdev->vdev_rsc_io;
|
||||
metal_io_write32(io,
|
||||
metal_io_virt_to_offset(io, &vdev_rsc->gfeatures),
|
||||
- features);
|
||||
+ (uint32_t)features);
|
||||
RSC_TABLE_FLUSH(vdev_rsc, sizeof(struct fw_rsc_vdev));
|
||||
rpvdev->notify(rpvdev->priv, vdev->notifyid);
|
||||
}
|
||||
|
||||
-static uint32_t rproc_virtio_negotiate_features(struct virtio_device *vdev,
|
||||
- uint32_t features)
|
||||
+static uint64_t rproc_virtio_negotiate_features(struct virtio_device *vdev,
|
||||
+ uint64_t features)
|
||||
{
|
||||
uint32_t dfeatures = rproc_virtio_get_dfeatures(vdev);
|
||||
|
||||
- rproc_virtio_set_features(vdev, dfeatures & features);
|
||||
+ rproc_virtio_set_features(vdev, dfeatures & (uint32_t)features);
|
||||
|
||||
return 0;
|
||||
}
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index bdf9046..e54155f 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -805,7 +805,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
||||
const char *vq_names[RPMSG_NUM_VRINGS];
|
||||
vq_callback callback[RPMSG_NUM_VRINGS];
|
||||
struct fw_rsc_config fw_config;
|
||||
- uint32_t features;
|
||||
+ uint64_t features;
|
||||
int status;
|
||||
unsigned int i;
|
||||
|
||||
diff --git a/lib/virtio/virtio.c open-amp/lib/virtio/virtio.c
|
||||
index a442e52..e2ab3d8 100644
|
||||
--- a/lib/virtio/virtio.c
|
||||
+++ open-amp/lib/virtio/virtio.c
|
||||
@@ -51,7 +51,7 @@ const char *virtio_dev_name(unsigned short devid)
|
||||
}
|
||||
|
||||
__deprecated void virtio_describe(struct virtio_device *dev, const char *msg,
|
||||
- uint32_t features, struct virtio_feature_desc *desc)
|
||||
+ uint64_t features, struct virtio_feature_desc *desc)
|
||||
{
|
||||
(void)dev;
|
||||
(void)msg;
|
||||
diff --git a/lib/virtio_mmio/virtio_mmio_drv.c open-amp/lib/virtio_mmio/virtio_mmio_drv.c
|
||||
index 5700471..34f2b67 100644
|
||||
--- a/lib/virtio_mmio/virtio_mmio_drv.c
|
||||
+++ open-amp/lib/virtio_mmio/virtio_mmio_drv.c
|
||||
@@ -75,44 +75,43 @@ static void virtio_mmio_read_config(struct virtio_device *vdev,
|
||||
d[i] = virtio_mmio_read8(vdev, VIRTIO_MMIO_CONFIG + i);
|
||||
}
|
||||
|
||||
-static uint32_t _virtio_mmio_get_features(struct virtio_device *vdev, int idx)
|
||||
+static uint64_t virtio_mmio_get_features(struct virtio_device *vdev)
|
||||
{
|
||||
- uint32_t hfeatures;
|
||||
+ uint32_t feature_hi;
|
||||
+ uint32_t feature_lo;
|
||||
|
||||
/* Writing selection register VIRTIO_MMIO_DEVICE_FEATURES_SEL. In pure AMP
|
||||
* mode this needs to be followed by a synchronization w/ the device
|
||||
* before reading VIRTIO_MMIO_DEVICE_FEATURES
|
||||
*/
|
||||
- virtio_mmio_write32(vdev, VIRTIO_MMIO_DEVICE_FEATURES_SEL, idx);
|
||||
- hfeatures = virtio_mmio_read32(vdev, VIRTIO_MMIO_DEVICE_FEATURES);
|
||||
- return hfeatures & vdev->features;
|
||||
+ virtio_mmio_write32(vdev, VIRTIO_MMIO_DEVICE_FEATURES_SEL, 0);
|
||||
+ feature_lo = virtio_mmio_read32(vdev, VIRTIO_MMIO_DEVICE_FEATURES);
|
||||
+ virtio_mmio_write32(vdev, VIRTIO_MMIO_DEVICE_FEATURES_SEL, 1);
|
||||
+ feature_hi = virtio_mmio_read32(vdev, VIRTIO_MMIO_DEVICE_FEATURES);
|
||||
+ return (((uint64_t)feature_hi << 32) | (uint64_t)feature_lo) &
|
||||
+ vdev->features;
|
||||
}
|
||||
|
||||
-static uint32_t virtio_mmio_get_features(struct virtio_device *vdev)
|
||||
+static void virtio_mmio_set_features(struct virtio_device *vdev, uint64_t features)
|
||||
{
|
||||
- return _virtio_mmio_get_features(vdev, 0);
|
||||
-}
|
||||
-
|
||||
-/* This is more like negotiate_features */
|
||||
-static void _virtio_mmio_set_features(struct virtio_device *vdev,
|
||||
- uint32_t features, int idx)
|
||||
-{
|
||||
- uint32_t hfeatures;
|
||||
+ uint32_t feature_hi;
|
||||
+ uint32_t feature_lo;
|
||||
|
||||
/* Writing selection register VIRTIO_MMIO_DEVICE_FEATURES_SEL. In pure AMP
|
||||
* mode this needs to be followed by a synchronization w/ the device
|
||||
* before reading VIRTIO_MMIO_DEVICE_FEATURES
|
||||
*/
|
||||
- virtio_mmio_write32(vdev, VIRTIO_MMIO_DEVICE_FEATURES_SEL, idx);
|
||||
- hfeatures = virtio_mmio_read32(vdev, VIRTIO_MMIO_DEVICE_FEATURES);
|
||||
- features &= hfeatures;
|
||||
- virtio_mmio_write32(vdev, VIRTIO_MMIO_DRIVER_FEATURES, features);
|
||||
- vdev->features = features;
|
||||
-}
|
||||
+ virtio_mmio_write32(vdev, VIRTIO_MMIO_DEVICE_FEATURES_SEL, 0);
|
||||
+ feature_lo = virtio_mmio_read32(vdev, VIRTIO_MMIO_DEVICE_FEATURES) &
|
||||
+ (uint32_t)features;
|
||||
+ virtio_mmio_write32(vdev, VIRTIO_MMIO_DRIVER_FEATURES, feature_lo);
|
||||
|
||||
-static void virtio_mmio_set_features(struct virtio_device *vdev, uint32_t features)
|
||||
-{
|
||||
- _virtio_mmio_set_features(vdev, features, 0);
|
||||
+ virtio_mmio_write32(vdev, VIRTIO_MMIO_DEVICE_FEATURES_SEL, 1);
|
||||
+ feature_hi = virtio_mmio_read32(vdev, VIRTIO_MMIO_DEVICE_FEATURES) &
|
||||
+ (uint32_t)(features >> 32);
|
||||
+ virtio_mmio_write32(vdev, VIRTIO_MMIO_DRIVER_FEATURES, feature_hi);
|
||||
+
|
||||
+ vdev->features = ((uint64_t)feature_hi << 32) | (uint64_t)feature_lo;
|
||||
}
|
||||
|
||||
static void virtio_mmio_reset_device(struct virtio_device *vdev)
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
From a541d9d446e5700fd5a74cf5d8296114023b40fb Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Fri, 6 Jan 2023 22:57:02 +0800
|
||||
Subject: [PATCH 2/6] rpmsg: add new API rpdev_release_tx/rx_buffer()
|
||||
|
||||
These API used for release tx/rx buffer from rpmsg_device
|
||||
For case:
|
||||
get_tx_buffer
|
||||
close ept
|
||||
release tx buffer failed
|
||||
|
||||
Change-Id: I74f83ff336415ccbe0191e67315ed27a35be3983
|
||||
Signed-off-by: ligd <liguiding1@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/rpmsg.h | 2 ++
|
||||
lib/rpmsg/rpmsg.c | 32 ++++++++++++++++++++------------
|
||||
2 files changed, 22 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
||||
index fbd7f61..d39a7a4 100644
|
||||
--- a/lib/include/openamp/rpmsg.h
|
||||
+++ open-amp/lib/include/openamp/rpmsg.h
|
||||
@@ -360,6 +360,7 @@ void rpmsg_hold_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf);
|
||||
* @see rpmsg_hold_rx_buffer
|
||||
*/
|
||||
void rpmsg_release_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf);
|
||||
+void rpdev_release_rx_buffer(struct rpmsg_device *rdev, void *rxbuf);
|
||||
|
||||
/**
|
||||
* @brief Gets the tx buffer for message payload.
|
||||
@@ -405,6 +406,7 @@ void *rpmsg_get_tx_payload_buffer(struct rpmsg_endpoint *ept,
|
||||
* @see rpmsg_get_tx_payload_buffer
|
||||
*/
|
||||
int rpmsg_release_tx_buffer(struct rpmsg_endpoint *ept, void *txbuf);
|
||||
+int rpdev_release_tx_buffer(struct rpmsg_device *rdev, void *txbuf);
|
||||
|
||||
/**
|
||||
* rpmsg_send_offchannel_nocopy() - send a message in tx buffer reserved by
|
||||
diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c
|
||||
index 4e7f7da..93a6282 100644
|
||||
--- a/lib/rpmsg/rpmsg.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg.c
|
||||
@@ -157,34 +157,42 @@ void rpmsg_hold_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf)
|
||||
rdev->ops.hold_rx_buffer(rdev, rxbuf);
|
||||
}
|
||||
|
||||
-void rpmsg_release_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf)
|
||||
+void rpdev_release_rx_buffer(struct rpmsg_device *rdev, void *rxbuf)
|
||||
{
|
||||
- struct rpmsg_device *rdev;
|
||||
-
|
||||
- if (!ept || !ept->rdev || !rxbuf)
|
||||
+ if (!rdev || !rxbuf)
|
||||
return;
|
||||
|
||||
- rdev = ept->rdev;
|
||||
-
|
||||
if (rdev->ops.release_rx_buffer)
|
||||
rdev->ops.release_rx_buffer(rdev, rxbuf);
|
||||
}
|
||||
|
||||
-int rpmsg_release_tx_buffer(struct rpmsg_endpoint *ept, void *buf)
|
||||
+void rpmsg_release_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf)
|
||||
{
|
||||
- struct rpmsg_device *rdev;
|
||||
+ if (!ept)
|
||||
+ return;
|
||||
|
||||
- if (!ept || !ept->rdev || !buf)
|
||||
- return RPMSG_ERR_PARAM;
|
||||
+ rpdev_release_rx_buffer(ept->rdev, rxbuf);
|
||||
+}
|
||||
|
||||
- rdev = ept->rdev;
|
||||
+int rpdev_release_tx_buffer(struct rpmsg_device *rdev, void *txbuf)
|
||||
+{
|
||||
+ if (!rdev || !txbuf)
|
||||
+ return RPMSG_ERR_PERM;
|
||||
|
||||
if (rdev->ops.release_tx_buffer)
|
||||
- return rdev->ops.release_tx_buffer(rdev, buf);
|
||||
+ return rdev->ops.release_tx_buffer(rdev, txbuf);
|
||||
|
||||
return RPMSG_ERR_PERM;
|
||||
}
|
||||
|
||||
+int rpmsg_release_tx_buffer(struct rpmsg_endpoint *ept, void *txbuf)
|
||||
+{
|
||||
+ if (!ept)
|
||||
+ return RPMSG_ERR_PARAM;
|
||||
+
|
||||
+ return rpdev_release_tx_buffer(ept->rdev, txbuf);
|
||||
+}
|
||||
+
|
||||
void *rpmsg_get_tx_payload_buffer(struct rpmsg_endpoint *ept,
|
||||
uint32_t *len, int wait)
|
||||
{
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
From 3146340e66f9dae5817c0a9592f8e375c2cf9e77 Mon Sep 17 00:00:00 2001
|
||||
From: Yongrong Wang <wangyongrong@xiaomi.com>
|
||||
Date: Wed, 31 Jul 2024 15:36:43 +0800
|
||||
Subject: [PATCH 12/14] rpmsg_virtio.c: fix get_tx_payload_buffer error
|
||||
|
||||
Always sleep when notify wait return not RPMSG_SUCCESS
|
||||
|
||||
Change-Id: I2fa50e649de36114597fec09dfcf96c7d2d35546
|
||||
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
|
||||
---
|
||||
lib/rpmsg/rpmsg_virtio.c | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index e54155f..7aeec5b 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -378,11 +378,9 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev,
|
||||
* use metal_sleep_usec() method by default.
|
||||
*/
|
||||
status = rpmsg_virtio_notify_wait(rvdev, rvdev->rvq);
|
||||
- if (status == RPMSG_EOPNOTSUPP) {
|
||||
+ if (status != RPMSG_SUCCESS) {
|
||||
metal_sleep_usec(RPMSG_TICKS_PER_INTERVAL);
|
||||
tick_count--;
|
||||
- } else if (status == RPMSG_SUCCESS) {
|
||||
- break;
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
From a2f4672050433811aabfcd8abef206c28397276d Mon Sep 17 00:00:00 2001
|
||||
From: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
|
||||
Date: Mon, 27 May 2024 20:32:46 +0800
|
||||
Subject: [PATCH 13/14] openamp: add assert when get tx buffer failed
|
||||
|
||||
So we can found the error more eaily
|
||||
|
||||
Change-Id: Idade291ac8d8224b1ccbe0c0120bc07c036be17a
|
||||
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
|
||||
---
|
||||
lib/rpmsg/rpmsg_virtio.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index 7aeec5b..33c6c33 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -384,6 +384,8 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev,
|
||||
}
|
||||
}
|
||||
|
||||
+ metal_assert(!wait || rp_hdr != NULL);
|
||||
+
|
||||
if (!rp_hdr)
|
||||
return NULL;
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
From c47e2e05a8402997657bd0680621ffcecaaa9971 Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Fri, 10 Feb 2023 17:05:54 +0800
|
||||
Subject: [PATCH 3/6] openamp: add error log when ept->cb return error
|
||||
|
||||
Change-Id: Id750dc9518a7f861a74965c34a6491e5b3463e95
|
||||
Signed-off-by: ligd <liguiding1@xiaomi.com>
|
||||
---
|
||||
lib/rpmsg/rpmsg_virtio.c | 8 ++++++--
|
||||
1 file changed, 6 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index fcf24cd..357d821 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -571,8 +571,12 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
|
||||
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");
|
||||
+ if (status < 0) {
|
||||
+ metal_log(METAL_LOG_ERROR,
|
||||
+ "ept %s, cb %p, return status %d\r\n",
|
||||
+ ept->name, ept->cb, status);
|
||||
+ RPMSG_ASSERT(0, "unexpected callback status\r\n");
|
||||
+ }
|
||||
}
|
||||
|
||||
metal_mutex_acquire(&rdev->lock);
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
From 0f3f00d2ecb1f7de470e6eaeeb74ba0ba9b66eea Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Mon, 13 Feb 2023 20:34:56 +0800
|
||||
Subject: [PATCH 4/6] rpmsg: add cache flash when hold rx buffer
|
||||
|
||||
Assume we have 2 cpus, and use cached shram buffer
|
||||
|
||||
CPU0 CPU1
|
||||
|
||||
1. send tx bufferX
|
||||
2. recv rx bufferX
|
||||
3. set idx to hdr->reserved
|
||||
4. handled rx bufferX
|
||||
5. return bufferX
|
||||
6. reuse tx bufferX
|
||||
7. dirty cache auto flushed, hdr changed
|
||||
8. buffer X meet error
|
||||
|
||||
Change-Id: If6c347d121ced0c59b6172a490098689b9b7ffd7
|
||||
---
|
||||
lib/rpmsg/rpmsg_virtio.c | 14 ++++++++++----
|
||||
1 file changed, 10 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index fcf24cd..1a510e6 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -321,7 +321,7 @@ static void rpmsg_virtio_hold_rx_buffer(struct rpmsg_device *rdev, void *rxbuf)
|
||||
rp_hdr = RPMSG_LOCATE_HDR(rxbuf);
|
||||
|
||||
/* Set held status to keep buffer */
|
||||
- rp_hdr->reserved |= RPMSG_BUF_HELD;
|
||||
+ rp_hdr->reserved = RPMSG_BUF_HELD;
|
||||
}
|
||||
|
||||
static void rpmsg_virtio_release_rx_buffer(struct rpmsg_device *rdev,
|
||||
@@ -553,8 +553,6 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
|
||||
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);
|
||||
@@ -578,7 +576,15 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
|
||||
metal_mutex_acquire(&rdev->lock);
|
||||
|
||||
/* Check whether callback wants to hold buffer */
|
||||
- if (!(rp_hdr->reserved & RPMSG_BUF_HELD)) {
|
||||
+ if (rp_hdr->reserved & RPMSG_BUF_HELD) {
|
||||
+ /* Yes, save idx. */
|
||||
+ rp_hdr->reserved |= idx;
|
||||
+
|
||||
+#ifdef VIRTIO_CACHED_BUFFERS
|
||||
+ metal_cache_flush(rp_hdr, sizeof(struct rpmsg_hdr));
|
||||
+#endif
|
||||
+
|
||||
+ } else {
|
||||
/* No, return used buffers. */
|
||||
rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx);
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
From 1091cadd99315959303ab3a8227e054884c28770 Mon Sep 17 00:00:00 2001
|
||||
From: Bowen Wang <wangbowen6@xiaomi.com>
|
||||
Date: Mon, 12 Aug 2024 10:15:24 +0800
|
||||
Subject: [PATCH 14/14] virtio.h: add memory operation for virtio device
|
||||
|
||||
To make different virtio device/transport can use it's own memory
|
||||
region.
|
||||
|
||||
Change-Id: I30adcc2c4215cefa8d0f7d81b6ebffd0f3ad74b5
|
||||
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/virtio.h | 42 ++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 42 insertions(+)
|
||||
|
||||
diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h
|
||||
index dd285ac..1099a26 100644
|
||||
--- a/lib/include/openamp/virtio.h
|
||||
+++ open-amp/lib/include/openamp/virtio.h
|
||||
@@ -152,6 +152,7 @@ struct virtio_device_id {
|
||||
typedef void (*virtio_dev_reset_cb)(struct virtio_device *vdev);
|
||||
|
||||
struct virtio_dispatch;
|
||||
+struct virtio_memory_ops;
|
||||
|
||||
/** @brief Device features. */
|
||||
struct virtio_feature_desc {
|
||||
@@ -197,6 +198,9 @@ struct virtio_device {
|
||||
/** Virtio dispatch table */
|
||||
const struct virtio_dispatch *func;
|
||||
|
||||
+ /** Virtio device memory operations */
|
||||
+ const struct virtio_memory_ops *mmops;
|
||||
+
|
||||
/** Private data */
|
||||
void *priv;
|
||||
|
||||
@@ -204,6 +208,7 @@ struct virtio_device {
|
||||
unsigned int vrings_num;
|
||||
|
||||
/** Pointer to the virtio vring structure */
|
||||
+
|
||||
struct virtio_vring_info *vrings_info;
|
||||
};
|
||||
|
||||
@@ -282,6 +287,11 @@ struct virtio_dispatch {
|
||||
void (*notify)(struct virtqueue *vq);
|
||||
};
|
||||
|
||||
+struct virtio_memory_ops {
|
||||
+ void *(*alloc)(struct virtio_device *dev, size_t size, size_t align);
|
||||
+ void (*free)(struct virtio_device *dev, void *buf);
|
||||
+};
|
||||
+
|
||||
/**
|
||||
* @brief Create the virtio device virtqueue.
|
||||
*
|
||||
@@ -499,6 +509,38 @@ static inline int virtio_reset_device(struct virtio_device *vdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * @brief Allocate buffer from the virtio device
|
||||
+ *
|
||||
+ * @param vdev Pointer to virtio device structure.
|
||||
+ * @param size Allocated buffer size.
|
||||
+ * @param align Allocated buffer alignment.
|
||||
+ *
|
||||
+ * @return The allocated buffer address.
|
||||
+ */
|
||||
+static inline void *virtio_alloc_buf(struct virtio_device *vdev,
|
||||
+ size_t size, size_t align)
|
||||
+{
|
||||
+ if (!vdev->mmops->alloc)
|
||||
+ return NULL;
|
||||
+
|
||||
+ return vdev->mmops->alloc(vdev, size, align);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * @brief Free buffer to the virtio device
|
||||
+ *
|
||||
+ * @param vdev Pointer to virtio device structure.
|
||||
+ * @param buf Buffer need to be freed.
|
||||
+ */
|
||||
+static inline void virtio_free_buf(struct virtio_device *vdev, void *buf)
|
||||
+{
|
||||
+ if (!vdev->mmops->free)
|
||||
+ return;
|
||||
+
|
||||
+ vdev->mmops->free(vdev, buf);
|
||||
+}
|
||||
+
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
From 7588713482056dcb8395da1d6fa470559f139e94 Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Thu, 16 Feb 2023 17:41:57 +0800
|
||||
Subject: [PATCH 5/6] rpmsg: do cache_invalidate() when real data returned
|
||||
|
||||
Change-Id: Ib5788c3974e40421deda2d100a46f61348ccafbd
|
||||
Signed-off-by: ligd <liguiding1@xiaomi.com>
|
||||
---
|
||||
lib/rpmsg/rpmsg_virtio.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index 1a510e6..3db86e6 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -239,7 +239,8 @@ static void *rpmsg_virtio_get_rx_buffer(struct rpmsg_virtio_device *rvdev,
|
||||
|
||||
#ifdef VIRTIO_CACHED_BUFFERS
|
||||
/* Invalidate the buffer before returning it */
|
||||
- metal_cache_invalidate(data, *len);
|
||||
+ if (data)
|
||||
+ metal_cache_invalidate(data, *len);
|
||||
#endif /* VIRTIO_CACHED_BUFFERS */
|
||||
|
||||
return data;
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
From b03e398fb8c2016029500f058e1cdaa7cc4cb92f Mon Sep 17 00:00:00 2001
|
||||
From: ligd <liguiding1@xiaomi.com>
|
||||
Date: Mon, 20 Feb 2023 21:08:35 +0800
|
||||
Subject: [PATCH 6/6] openamp: add new API rpmsg_virtio_get_rxbuffer_size()
|
||||
|
||||
Change-Id: If98c7260be8524627cd1c272c164c22a9548198c
|
||||
Signed-off-by: ligd <liguiding1@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/rpmsg_virtio.h | 11 ++++++++++-
|
||||
lib/rpmsg/rpmsg_virtio.c | 25 +++++++++++++++++++++----
|
||||
2 files changed, 31 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||
index 11cb6df..bdc6cc6 100644
|
||||
--- a/lib/include/openamp/rpmsg_virtio.h
|
||||
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||
@@ -158,7 +158,7 @@ rpmsg_virtio_notify_wait(struct rpmsg_virtio_device *rvdev,
|
||||
}
|
||||
|
||||
/**
|
||||
- * rpmsg_virtio_get_buffer_size - get rpmsg virtio buffer size
|
||||
+ * rpmsg_virtio_get_buffer_size - get rpmsg virtio Tx buffer size
|
||||
*
|
||||
* @rdev - pointer to the rpmsg device
|
||||
*
|
||||
@@ -166,6 +166,15 @@ rpmsg_virtio_notify_wait(struct rpmsg_virtio_device *rvdev,
|
||||
*/
|
||||
int rpmsg_virtio_get_buffer_size(struct rpmsg_device *rdev);
|
||||
|
||||
+/**
|
||||
+ * rpmsg_virtio_get_rx_buffer_size - get rpmsg virtio Rx buffer size
|
||||
+ *
|
||||
+ * @rdev - pointer to the rpmsg device
|
||||
+ *
|
||||
+ * @return - next available buffer size for text, negative value for failure
|
||||
+ */
|
||||
+int rpmsg_virtio_get_rx_buffer_size(struct rpmsg_device *rdev);
|
||||
+
|
||||
/**
|
||||
* rpmsg_init_vdev - initialize rpmsg virtio device
|
||||
* Host side:
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index 13fd496..c44b4fd 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -275,11 +275,12 @@ static int rpmsg_virtio_wait_remote_ready(struct rpmsg_virtio_device *rvdev)
|
||||
* Returns buffer size available for sending messages.
|
||||
*
|
||||
* @param rvdev - pointer to rpmsg device
|
||||
+ * tx - tx or rx
|
||||
*
|
||||
* @return - buffer size
|
||||
*
|
||||
*/
|
||||
-static int _rpmsg_virtio_get_buffer_size(struct rpmsg_virtio_device *rvdev)
|
||||
+static int _rpmsg_virtio_get_buffer_size(struct rpmsg_virtio_device *rvdev, bool tx)
|
||||
{
|
||||
unsigned int role = rpmsg_virtio_get_role(rvdev);
|
||||
int length = 0;
|
||||
@@ -290,7 +291,9 @@ static int _rpmsg_virtio_get_buffer_size(struct rpmsg_virtio_device *rvdev)
|
||||
* If device role is host then buffers are provided by us,
|
||||
* so just provide the macro.
|
||||
*/
|
||||
- length = rvdev->config.h2r_buf_size - sizeof(struct rpmsg_hdr);
|
||||
+ length =
|
||||
+ tx ? rvdev->config.h2r_buf_size : rvdev->config.r2h_buf_size
|
||||
+ - sizeof(struct rpmsg_hdr);
|
||||
}
|
||||
#endif /*!VIRTIO_DEVICE_ONLY*/
|
||||
|
||||
@@ -301,7 +304,7 @@ static int _rpmsg_virtio_get_buffer_size(struct rpmsg_virtio_device *rvdev)
|
||||
* so get the buffer size from the virtqueue.
|
||||
*/
|
||||
length =
|
||||
- (int)virtqueue_get_desc_size(rvdev->svq) -
|
||||
+ (int)virtqueue_get_desc_size(tx ? rvdev->svq : rvdev->rvq) -
|
||||
sizeof(struct rpmsg_hdr);
|
||||
}
|
||||
#endif /*!VIRTIO_DRIVER_ONLY*/
|
||||
@@ -700,7 +703,21 @@ int rpmsg_virtio_get_buffer_size(struct rpmsg_device *rdev)
|
||||
return RPMSG_ERR_PARAM;
|
||||
metal_mutex_acquire(&rdev->lock);
|
||||
rvdev = (struct rpmsg_virtio_device *)rdev;
|
||||
- size = _rpmsg_virtio_get_buffer_size(rvdev);
|
||||
+ size = _rpmsg_virtio_get_buffer_size(rvdev, true);
|
||||
+ metal_mutex_release(&rdev->lock);
|
||||
+ return size;
|
||||
+}
|
||||
+
|
||||
+int rpmsg_virtio_get_rx_buffer_size(struct rpmsg_device *rdev)
|
||||
+{
|
||||
+ int size;
|
||||
+ struct rpmsg_virtio_device *rvdev;
|
||||
+
|
||||
+ if (!rdev)
|
||||
+ return RPMSG_ERR_PARAM;
|
||||
+ metal_mutex_acquire(&rdev->lock);
|
||||
+ rvdev = (struct rpmsg_virtio_device *)rdev;
|
||||
+ size = _rpmsg_virtio_get_buffer_size(rvdev, false);
|
||||
metal_mutex_release(&rdev->lock);
|
||||
return size;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
From 61a7811f09b529341351c19ce1644b7e790daa5f Mon Sep 17 00:00:00 2001
|
||||
From: wangbowen6 <wangbowen6@xiaomi.com>
|
||||
Date: Tue, 9 May 2023 11:30:09 +0800
|
||||
Subject: [PATCH 1/2] virtio: follow virtio 1.2 spec, add more virtio status
|
||||
and device
|
||||
|
||||
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/virtio.h | 37 ++++++++++++++++++++++++++----------
|
||||
lib/virtio/virtio.c | 14 ++++++++++++++
|
||||
2 files changed, 41 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h
|
||||
index 0303a5b..3001a06 100644
|
||||
--- a/lib/include/openamp/virtio.h
|
||||
+++ open-amp/lib/include/openamp/virtio.h
|
||||
@@ -15,21 +15,38 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* VirtIO device IDs. */
|
||||
-#define VIRTIO_ID_NETWORK 0x01UL
|
||||
-#define VIRTIO_ID_BLOCK 0x02UL
|
||||
-#define VIRTIO_ID_CONSOLE 0x03UL
|
||||
-#define VIRTIO_ID_ENTROPY 0x04UL
|
||||
-#define VIRTIO_ID_BALLOON 0x05UL
|
||||
-#define VIRTIO_ID_IOMEMORY 0x06UL
|
||||
-#define VIRTIO_ID_RPMSG 0x07UL /* remote processor messaging */
|
||||
-#define VIRTIO_ID_SCSI 0x08UL
|
||||
-#define VIRTIO_ID_9P 0x09UL
|
||||
-#define VIRTIO_DEV_ANY_ID (-1)UL
|
||||
+#define VIRTIO_ID_NETWORK 1UL
|
||||
+#define VIRTIO_ID_BLOCK 2UL
|
||||
+#define VIRTIO_ID_CONSOLE 3UL
|
||||
+#define VIRTIO_ID_ENTROPY 4UL
|
||||
+#define VIRTIO_ID_BALLOON 5UL
|
||||
+#define VIRTIO_ID_IOMEMORY 6UL
|
||||
+#define VIRTIO_ID_RPMSG 7UL /* remote processor messaging */
|
||||
+#define VIRTIO_ID_SCSI 8UL
|
||||
+#define VIRTIO_ID_9P 9UL
|
||||
+#define VIRTIO_ID_RPROC_SERIAL 11UL
|
||||
+#define VIRTIO_ID_GPU 16UL
|
||||
+#define VIRTIO_ID_INPUT 18UL
|
||||
+#define VIRTIO_ID_VSOCK 19UL
|
||||
+#define VIRTIO_ID_CRYPTO 20UL
|
||||
+#define VIRTIO_ID_IOMMU 23UL
|
||||
+#define VIRTIO_ID_MEM 24UL
|
||||
+#define VIRTIO_ID_SOUND 25UL
|
||||
+#define VIRTIO_ID_FS 26UL
|
||||
+#define VIRTIO_ID_PMEM 27UL
|
||||
+#define VIRTIO_ID_RPMB 28UL
|
||||
+#define VIRTIO_ID_SCMI 32UL
|
||||
+#define VIRTIO_ID_I2C_ADAPTER 34UL
|
||||
+#define VIRTIO_ID_BT 40UL
|
||||
+#define VIRTIO_ID_GPIO 41UL
|
||||
+#define VIRTIO_DEV_ANY_ID -1UL
|
||||
|
||||
/* Status byte for guest to report progress. */
|
||||
+#define VIRTIO_CONFIG_STATUS_RESET 0x00
|
||||
#define VIRTIO_CONFIG_STATUS_ACK 0x01
|
||||
#define VIRTIO_CONFIG_STATUS_DRIVER 0x02
|
||||
#define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x04
|
||||
+#define VIRTIO_CONFIG_FEATURES_OK 0x08
|
||||
#define VIRTIO_CONFIG_STATUS_NEEDS_RESET 0x40
|
||||
#define VIRTIO_CONFIG_STATUS_FAILED 0x80
|
||||
|
||||
diff --git a/lib/virtio/virtio.c open-amp/lib/virtio/virtio.c
|
||||
index d205784..d25aec3 100644
|
||||
--- a/lib/virtio/virtio.c
|
||||
+++ open-amp/lib/virtio/virtio.c
|
||||
@@ -26,6 +26,20 @@ static const struct virtio_ident {
|
||||
VIRTIO_ID_IOMEMORY, "IOMemory"}, {
|
||||
VIRTIO_ID_SCSI, "SCSI"}, {
|
||||
VIRTIO_ID_9P, "9P Transport"}, {
|
||||
+ VIRTIO_ID_GPU, "GPU"}, {
|
||||
+ VIRTIO_ID_INPUT, "Input"}, {
|
||||
+ VIRTIO_ID_VSOCK, "Vsock Transport"}, {
|
||||
+ VIRTIO_ID_CRYPTO, "Crypto"}, {
|
||||
+ VIRTIO_ID_IOMMU, "IOMMU"}, {
|
||||
+ VIRTIO_ID_MEM, "Memory"}, {
|
||||
+ VIRTIO_ID_SOUND, "Sound"}, {
|
||||
+ VIRTIO_ID_FS, "File System"}, {
|
||||
+ VIRTIO_ID_PMEM, "Pmem"}, {
|
||||
+ VIRTIO_ID_RPMB, "RPMB"}, {
|
||||
+ VIRTIO_ID_SCMI, "SCMI"}, {
|
||||
+ VIRTIO_ID_I2C_ADAPTER, "I2C Adapter"}, {
|
||||
+ VIRTIO_ID_BT, "Bluetooth"}, {
|
||||
+ VIRTIO_ID_GPIO, "GPIO" }, {
|
||||
0, NULL}
|
||||
};
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,635 +0,0 @@
|
|||
From 3ed768a2ce3b35e64c56cd69eb48e4436bdc4c12 Mon Sep 17 00:00:00 2001
|
||||
From: wangbowen6 <wangbowen6@xiaomi.com>
|
||||
Date: Tue, 9 May 2023 12:53:21 +0800
|
||||
Subject: [PATCH 2/2] virtio: decoupling the transport layer and virtio device
|
||||
layer
|
||||
|
||||
1. Add virtio device api to decouple the transport layer and virtio
|
||||
device layer.
|
||||
2. Move the vrings info and virtqueue allocation/free to the
|
||||
remoteproc transport layer;
|
||||
3. Because 2, modify the rpmsg device also;
|
||||
|
||||
Change-Id: Ideb5fc388dd1626ce4ac1efd4c5120863918057b
|
||||
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/rpmsg_virtio.h | 10 +-
|
||||
lib/include/openamp/virtio.h | 128 +++++++++++++++++++-
|
||||
lib/remoteproc/remoteproc.c | 32 -----
|
||||
lib/remoteproc/remoteproc_virtio.c | 188 +++++++++++++++++++++--------
|
||||
lib/rpmsg/rpmsg_virtio.c | 29 ++++-
|
||||
lib/virtio/virtio.c | 40 ------
|
||||
6 files changed, 293 insertions(+), 134 deletions(-)
|
||||
|
||||
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||
index bdc6cc6..e2d166f 100644
|
||||
--- a/lib/include/openamp/rpmsg_virtio.h
|
||||
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
|
||||
@@ -144,8 +144,14 @@ rpmsg_virtio_create_virtqueues(struct rpmsg_virtio_device *rvdev,
|
||||
const char *names[],
|
||||
vq_callback *callbacks)
|
||||
{
|
||||
- return virtio_create_virtqueues(rvdev->vdev, flags, nvqs, names,
|
||||
- callbacks);
|
||||
+ return rvdev->vdev->func->create_virtqueues(rvdev->vdev, flags, nvqs,
|
||||
+ names, callbacks);
|
||||
+}
|
||||
+
|
||||
+static inline void
|
||||
+rpmsg_virtio_delete_virtqueues(struct rpmsg_virtio_device *rvdev)
|
||||
+{
|
||||
+ rvdev->vdev->func->delete_virtqueues(rvdev->vdev);
|
||||
}
|
||||
|
||||
static inline int
|
||||
diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h
|
||||
index 3001a06..fb68c19 100644
|
||||
--- a/lib/include/openamp/virtio.h
|
||||
+++ open-amp/lib/include/openamp/virtio.h
|
||||
@@ -161,6 +161,11 @@ void virtio_describe(struct virtio_device *dev, const char *msg,
|
||||
*/
|
||||
|
||||
struct virtio_dispatch {
|
||||
+ int (*create_virtqueues)(struct virtio_device *vdev,
|
||||
+ unsigned int flags,
|
||||
+ unsigned int nvqs, const char *names[],
|
||||
+ vq_callback callbacks[]);
|
||||
+ void (*delete_virtqueues)(struct virtio_device *vdev);
|
||||
uint8_t (*get_status)(struct virtio_device *dev);
|
||||
void (*set_status)(struct virtio_device *dev, uint8_t status);
|
||||
uint32_t (*get_features)(struct virtio_device *dev);
|
||||
@@ -182,9 +187,126 @@ struct virtio_dispatch {
|
||||
int (*notify_wait)(struct virtio_device *dev, struct virtqueue *vq);
|
||||
};
|
||||
|
||||
-int virtio_create_virtqueues(struct virtio_device *vdev, unsigned int flags,
|
||||
- unsigned int nvqs, const char *names[],
|
||||
- vq_callback callbacks[]);
|
||||
+/**
|
||||
+ * @brief Create the virtio device virtqueue.
|
||||
+ *
|
||||
+ * @param vdev Pointer to virtio device structure.
|
||||
+ * @param flags Create flag.
|
||||
+ * @param nvqs The virtqueue number.
|
||||
+ * @param names Virtqueue names.
|
||||
+ * @param callbacks Virtqueue callback functions.
|
||||
+ *
|
||||
+ * @return Pointer to virtio device structure.
|
||||
+ */
|
||||
+static inline int virtio_create_virtqueues(struct virtio_device *vdev,
|
||||
+ unsigned int flags,
|
||||
+ unsigned int nvqs,
|
||||
+ const char *names[],
|
||||
+ vq_callback callbacks[])
|
||||
+{
|
||||
+ return vdev->func->create_virtqueues(vdev, flags, nvqs, names,
|
||||
+ callbacks);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * @brief Delete the virtio device virtqueue.
|
||||
+ *
|
||||
+ * @param vdev Pointer to virtio device structure.
|
||||
+ *
|
||||
+ * @return pointer to virtio device structure.
|
||||
+ */
|
||||
+static inline void virtio_delete_virtqueues(struct virtio_device *vdev)
|
||||
+{
|
||||
+ return vdev->func->delete_virtqueues(vdev);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * @brief Retrieve device status.
|
||||
+ *
|
||||
+ * @param dev Pointer to device structure.
|
||||
+ *
|
||||
+ * @return status of the device.
|
||||
+ */
|
||||
+static inline uint8_t virtio_get_status(struct virtio_device *vdev)
|
||||
+{
|
||||
+ return vdev->func->get_status(vdev);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * @brief Set device status.
|
||||
+ *
|
||||
+ * @param dev Pointer to device structure.
|
||||
+ * @param status Value to be set as device status.
|
||||
+ */
|
||||
+static inline void virtio_set_status(struct virtio_device *vdev,
|
||||
+ uint8_t status)
|
||||
+{
|
||||
+ vdev->func->set_status(vdev, status);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * @brief Retrieve configuration data from the device.
|
||||
+ *
|
||||
+ * @param dev Pointer to device structure.
|
||||
+ * @param offset Offset of the data within the configuration area.
|
||||
+ * @param dst Address of the buffer that will hold the data.
|
||||
+ * @param len Length of the data to be retrieved.
|
||||
+ */
|
||||
+static inline void virtio_read_config(struct virtio_device *vdev,
|
||||
+ uint32_t offset, void *dst,
|
||||
+ int length)
|
||||
+{
|
||||
+ vdev->func->read_config(vdev, offset, dst, length);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * @brief Write configuration data to the device.
|
||||
+ *
|
||||
+ * @param dev Pointer to device structure.
|
||||
+ * @param offset Offset of the data within the configuration area.
|
||||
+ * @param src Address of the buffer that holds the data to write.
|
||||
+ * @param len Length of the data to be written.
|
||||
+ */
|
||||
+static inline void virtio_write_config(struct virtio_device *vdev,
|
||||
+ uint32_t offset, void *src,
|
||||
+ int length)
|
||||
+{
|
||||
+ vdev->func->write_config(vdev, offset, src, length);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * @brief Get the virtio device features.
|
||||
+ *
|
||||
+ * @param[in] dev Pointer to device structure.
|
||||
+ *
|
||||
+ * @return Features supported by both the driver and the device as a bitfield.
|
||||
+ */
|
||||
+static inline uint32_t virtio_get_features(struct virtio_device *vdev)
|
||||
+{
|
||||
+ return vdev->func->get_features(vdev);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * @brief Set features supported by the VIRTIO driver.
|
||||
+ *
|
||||
+ * @param dev Pointer to device structure.
|
||||
+ * @param features Features supported by the driver as a bitfield.
|
||||
+ */
|
||||
+static inline void virtio_set_features(struct virtio_device *vdev,
|
||||
+ uint32_t features)
|
||||
+{
|
||||
+ return vdev->func->set_features(vdev, features);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * @brief Reset virtio device.
|
||||
+ *
|
||||
+ * @param vdev Pointer to virtio_device structure.
|
||||
+ */
|
||||
+static inline void virtio_reset_device(struct virtio_device *vdev)
|
||||
+{
|
||||
+ vdev->func->reset_device(vdev);
|
||||
+}
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
diff --git a/lib/remoteproc/remoteproc.c open-amp/lib/remoteproc/remoteproc.c
|
||||
index 001b11b..5a38fe1 100644
|
||||
--- a/lib/remoteproc/remoteproc.c
|
||||
+++ open-amp/lib/remoteproc/remoteproc.c
|
||||
@@ -921,7 +921,6 @@ remoteproc_create_virtio(struct remoteproc *rproc,
|
||||
struct remoteproc_virtio *rpvdev;
|
||||
size_t vdev_rsc_offset;
|
||||
unsigned int notifyid;
|
||||
- unsigned int num_vrings, i;
|
||||
struct metal_list *node;
|
||||
|
||||
#ifdef VIRTIO_DRIVER_ONLY
|
||||
@@ -969,39 +968,8 @@ remoteproc_create_virtio(struct remoteproc *rproc,
|
||||
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;
|
||||
-
|
||||
- /* set the notification id for vrings */
|
||||
- for (i = 0; i < num_vrings; i++) {
|
||||
- struct fw_rsc_vdev_vring *vring_rsc;
|
||||
- metal_phys_addr_t da;
|
||||
- unsigned int num_descs, align;
|
||||
- struct metal_io_region *io;
|
||||
- void *va;
|
||||
- size_t size;
|
||||
- int ret;
|
||||
-
|
||||
- vring_rsc = &vdev_rsc->vring[i];
|
||||
- notifyid = vring_rsc->notifyid;
|
||||
- da = vring_rsc->da;
|
||||
- num_descs = vring_rsc->num;
|
||||
- align = vring_rsc->align;
|
||||
- size = vring_size(num_descs, align);
|
||||
- va = remoteproc_mmap(rproc, NULL, &da, size, 0, &io);
|
||||
- if (!va)
|
||||
- goto err1;
|
||||
- ret = rproc_virtio_init_vring(vdev, i, notifyid,
|
||||
- va, io, num_descs, align);
|
||||
- if (ret)
|
||||
- goto err1;
|
||||
- }
|
||||
metal_mutex_release(&rproc->lock);
|
||||
return vdev;
|
||||
-
|
||||
-err1:
|
||||
- remoteproc_remove_virtio(rproc, vdev);
|
||||
- metal_mutex_release(&rproc->lock);
|
||||
- return NULL;
|
||||
}
|
||||
|
||||
void remoteproc_remove_virtio(struct remoteproc *rproc,
|
||||
diff --git a/lib/remoteproc/remoteproc_virtio.c open-amp/lib/remoteproc/remoteproc_virtio.c
|
||||
index 4375c4c..96767c1 100644
|
||||
--- a/lib/remoteproc/remoteproc_virtio.c
|
||||
+++ open-amp/lib/remoteproc/remoteproc_virtio.c
|
||||
@@ -16,6 +16,139 @@
|
||||
#include <metal/utilities.h>
|
||||
#include <metal/alloc.h>
|
||||
|
||||
+static void rproc_virtio_delete_virtqueues(struct virtio_device *vdev)
|
||||
+{
|
||||
+ struct virtio_vring_info *vring_info;
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ if (vdev->vrings_info != NULL) {
|
||||
+ for (i = 0; i < vdev->vrings_num; i++) {
|
||||
+ vring_info = &vdev->vrings_info[i];
|
||||
+ if (vring_info->vq != NULL) {
|
||||
+ virtqueue_free(vring_info->vq);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ metal_free_memory(vdev->vrings_info);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int rproc_virtio_create_virtqueue(struct virtio_device *vdev,
|
||||
+ unsigned int flags,
|
||||
+ unsigned int i,
|
||||
+ const char *name,
|
||||
+ vq_callback callback)
|
||||
+{
|
||||
+ struct remoteproc_virtio *rpvdev;
|
||||
+ struct fw_rsc_vdev_vring *vring_rsc;
|
||||
+ struct fw_rsc_vdev *vdev_rsc;
|
||||
+ struct remoteproc *rproc;
|
||||
+ struct virtio_vring_info *vring_info;
|
||||
+ struct vring_alloc_info *vring_alloc;
|
||||
+ struct metal_io_region *io;
|
||||
+ metal_phys_addr_t da;
|
||||
+ size_t vringsize;
|
||||
+ void *va;
|
||||
+ int ret;
|
||||
+
|
||||
+ /* Get remoteproc virtio device */
|
||||
+ rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
|
||||
+
|
||||
+ /* Get the remoteproc */
|
||||
+ rproc = rpvdev->priv;
|
||||
+
|
||||
+ /* Get the rsc table */
|
||||
+ vdev_rsc = rpvdev->vdev_rsc;
|
||||
+ vring_rsc = &vdev_rsc->vring[i];
|
||||
+
|
||||
+ /*
|
||||
+ * Initialize the vring information according to the vring resource
|
||||
+ * table.
|
||||
+ */
|
||||
+ da = vring_rsc->da;
|
||||
+ vringsize = vring_size(vring_rsc->num, vring_rsc->align);
|
||||
+ va = remoteproc_mmap(rproc, NULL, &da, vringsize, 0, &io);
|
||||
+ if (!va) {
|
||||
+ return ERROR_VQUEUE_INVLD_PARAM;
|
||||
+ }
|
||||
+
|
||||
+ ret = rproc_virtio_init_vring(vdev, i, vring_rsc->notifyid, va, io,
|
||||
+ vring_rsc->num, vring_rsc->align);
|
||||
+ if (ret) {
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ /* Get the vring information */
|
||||
+ vring_info = &vdev->vrings_info[i];
|
||||
+ vring_alloc = &vring_info->info;
|
||||
+
|
||||
+ /* Alloc the virtqueue and init it */
|
||||
+ vring_info->vq = virtqueue_allocate(vring_alloc->num_descs);
|
||||
+ if (!vring_info->vq) {
|
||||
+ return ERROR_NO_MEM;
|
||||
+ }
|
||||
+
|
||||
+#ifndef VIRTIO_DEVICE_ONLY
|
||||
+ if (vdev->role == VIRTIO_DEV_DRIVER) {
|
||||
+ size_t offset = metal_io_virt_to_offset(vring_info->io,
|
||||
+ vring_alloc->vaddr);
|
||||
+ metal_io_block_set(vring_info->io, offset, 0, vringsize);
|
||||
+ }
|
||||
+#endif
|
||||
+ ret = virtqueue_create(vdev, i, name, vring_alloc, callback,
|
||||
+ vdev->func->notify, vring_info->vq);
|
||||
+ if (ret) {
|
||||
+ return ret;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int rproc_virtio_create_virtqueues(struct virtio_device *vdev,
|
||||
+ unsigned int flags,
|
||||
+ unsigned int nvqs,
|
||||
+ const char *names[],
|
||||
+ vq_callback callbacks[])
|
||||
+{
|
||||
+ struct remoteproc_virtio *rpvdev;
|
||||
+ struct virtio_vring_info *vrings_info;
|
||||
+ struct fw_rsc_vdev *vdev_rsc;
|
||||
+ unsigned int i;
|
||||
+ int ret;
|
||||
+ (void)flags;
|
||||
+
|
||||
+ /* Get remoteproc virtio device, rsc table, remoteproc */
|
||||
+ rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
|
||||
+ vdev_rsc = rpvdev->vdev_rsc;
|
||||
+
|
||||
+ /* Check vrings number */
|
||||
+ if (nvqs > vdev_rsc->num_of_vrings)
|
||||
+ return ERROR_VQUEUE_INVLD_PARAM;
|
||||
+
|
||||
+ /* Alloc vrings info for the virtio device */
|
||||
+ vrings_info = metal_allocate_memory(sizeof(*vrings_info) * nvqs);
|
||||
+ if (!vrings_info) {
|
||||
+ return ERROR_NO_MEM;
|
||||
+ }
|
||||
+
|
||||
+ memset(vrings_info, 0, sizeof(*vrings_info) * nvqs);
|
||||
+ vdev->vrings_info = vrings_info;
|
||||
+ vdev->vrings_num = nvqs;
|
||||
+
|
||||
+ /* set the notification id for vrings */
|
||||
+ for (i = 0; i < nvqs; i++) {
|
||||
+ ret = rproc_virtio_create_virtqueue(vdev, flags, i, names[i],
|
||||
+ callbacks[i]);
|
||||
+ if (ret) {
|
||||
+ goto err;
|
||||
+ }
|
||||
+ }
|
||||
+ return 0;
|
||||
+
|
||||
+err:
|
||||
+ rproc_virtio_delete_virtqueues(vdev);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
static void rproc_virtio_virtqueue_notify(struct virtqueue *vq)
|
||||
{
|
||||
struct remoteproc_virtio *rpvdev;
|
||||
@@ -148,7 +281,7 @@ static void rproc_virtio_read_config(struct virtio_device *vdev,
|
||||
|
||||
rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
|
||||
vdev_rsc = rpvdev->vdev_rsc;
|
||||
- config = (char *)(&vdev_rsc->vring[vdev->vrings_num]);
|
||||
+ config = (char *)(&vdev_rsc->vring[vdev_rsc->num_of_vrings]);
|
||||
io = rpvdev->vdev_rsc_io;
|
||||
|
||||
if (offset + length <= vdev_rsc->config_len)
|
||||
@@ -168,7 +301,7 @@ static void rproc_virtio_write_config(struct virtio_device *vdev,
|
||||
|
||||
rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
|
||||
vdev_rsc = rpvdev->vdev_rsc;
|
||||
- config = (char *)(&vdev_rsc->vring[vdev->vrings_num]);
|
||||
+ config = (char *)(&vdev_rsc->vring[vdev_rsc->num_of_vrings]);
|
||||
io = rpvdev->vdev_rsc_io;
|
||||
|
||||
if (offset + length <= vdev_rsc->config_len) {
|
||||
@@ -188,6 +321,8 @@ static void rproc_virtio_reset_device(struct virtio_device *vdev)
|
||||
#endif
|
||||
|
||||
static const struct virtio_dispatch remoteproc_virtio_dispatch_funcs = {
|
||||
+ .create_virtqueues = rproc_virtio_create_virtqueues,
|
||||
+ .delete_virtqueues = rproc_virtio_delete_virtqueues,
|
||||
.get_status = rproc_virtio_get_status,
|
||||
.get_features = rproc_virtio_get_features,
|
||||
.read_config = rproc_virtio_read_config,
|
||||
@@ -215,44 +350,16 @@ rproc_virtio_create_vdev(unsigned int role, unsigned int notifyid,
|
||||
virtio_dev_reset_cb rst_cb)
|
||||
{
|
||||
struct remoteproc_virtio *rpvdev;
|
||||
- struct virtio_vring_info *vrings_info;
|
||||
struct fw_rsc_vdev *vdev_rsc = rsc;
|
||||
struct virtio_device *vdev;
|
||||
- unsigned int num_vrings = vdev_rsc->num_of_vrings;
|
||||
- unsigned int i;
|
||||
|
||||
rpvdev = metal_allocate_memory(sizeof(*rpvdev));
|
||||
if (!rpvdev)
|
||||
return NULL;
|
||||
- vrings_info = metal_allocate_memory(sizeof(*vrings_info) * num_vrings);
|
||||
- if (!vrings_info)
|
||||
- goto err0;
|
||||
memset(rpvdev, 0, sizeof(*rpvdev));
|
||||
- memset(vrings_info, 0, sizeof(*vrings_info));
|
||||
vdev = &rpvdev->vdev;
|
||||
-
|
||||
- for (i = 0; i < num_vrings; i++) {
|
||||
- struct virtqueue *vq;
|
||||
-#ifndef VIRTIO_DEVICE_ONLY
|
||||
- struct fw_rsc_vdev_vring *vring_rsc;
|
||||
-#endif
|
||||
- unsigned int num_extra_desc = 0;
|
||||
-
|
||||
-#ifndef VIRTIO_DEVICE_ONLY
|
||||
- vring_rsc = &vdev_rsc->vring[i];
|
||||
- if (role == VIRTIO_DEV_DRIVER) {
|
||||
- num_extra_desc = vring_rsc->num;
|
||||
- }
|
||||
-#endif
|
||||
- vq = virtqueue_allocate(num_extra_desc);
|
||||
- if (!vq)
|
||||
- goto err1;
|
||||
- vrings_info[i].vq = vq;
|
||||
- }
|
||||
-
|
||||
rpvdev->notify = notify;
|
||||
rpvdev->priv = priv;
|
||||
- vdev->vrings_info = vrings_info;
|
||||
/* Assuming the shared memory has been mapped and registered if
|
||||
* necessary
|
||||
*/
|
||||
@@ -262,7 +369,6 @@ rproc_virtio_create_vdev(unsigned int role, unsigned int notifyid,
|
||||
vdev->notifyid = notifyid;
|
||||
vdev->role = role;
|
||||
vdev->reset_cb = rst_cb;
|
||||
- vdev->vrings_num = num_vrings;
|
||||
vdev->func = &remoteproc_virtio_dispatch_funcs;
|
||||
|
||||
#ifndef VIRTIO_DEVICE_ONLY
|
||||
@@ -274,35 +380,15 @@ rproc_virtio_create_vdev(unsigned int role, unsigned int notifyid,
|
||||
#endif
|
||||
|
||||
return &rpvdev->vdev;
|
||||
-
|
||||
-err1:
|
||||
- for (i = 0; i < num_vrings; i++) {
|
||||
- if (vrings_info[i].vq)
|
||||
- metal_free_memory(vrings_info[i].vq);
|
||||
- }
|
||||
- metal_free_memory(vrings_info);
|
||||
-err0:
|
||||
- metal_free_memory(rpvdev);
|
||||
- return NULL;
|
||||
}
|
||||
|
||||
void rproc_virtio_remove_vdev(struct virtio_device *vdev)
|
||||
{
|
||||
struct remoteproc_virtio *rpvdev;
|
||||
- unsigned int i;
|
||||
|
||||
if (!vdev)
|
||||
return;
|
||||
rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
|
||||
- for (i = 0; i < vdev->vrings_num; i++) {
|
||||
- struct virtqueue *vq;
|
||||
-
|
||||
- vq = vdev->vrings_info[i].vq;
|
||||
- if (vq)
|
||||
- metal_free_memory(vq);
|
||||
- }
|
||||
- if (vdev->vrings_info)
|
||||
- metal_free_memory(vdev->vrings_info);
|
||||
metal_free_memory(rpvdev);
|
||||
}
|
||||
|
||||
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
index 2f38faa..b30eccc 100644
|
||||
--- a/lib/rpmsg/rpmsg_virtio.c
|
||||
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
||||
@@ -821,8 +821,6 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
||||
vq_names[1] = "tx_vq";
|
||||
callback[0] = rpmsg_virtio_rx_callback;
|
||||
callback[1] = rpmsg_virtio_tx_callback;
|
||||
- rvdev->rvq = vdev->vrings_info[0].vq;
|
||||
- rvdev->svq = vdev->vrings_info[1].vq;
|
||||
}
|
||||
#endif /*!VIRTIO_DEVICE_ONLY*/
|
||||
|
||||
@@ -833,8 +831,6 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
||||
vq_names[1] = "rx_vq";
|
||||
callback[0] = rpmsg_virtio_tx_callback;
|
||||
callback[1] = rpmsg_virtio_rx_callback;
|
||||
- rvdev->rvq = vdev->vrings_info[1].vq;
|
||||
- rvdev->svq = vdev->vrings_info[0].vq;
|
||||
}
|
||||
#endif /*!VIRTIO_DRIVER_ONLY*/
|
||||
rvdev->shbuf_io = shm_io;
|
||||
@@ -846,6 +842,21 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
||||
if (status != RPMSG_SUCCESS)
|
||||
return status;
|
||||
|
||||
+ /* Create virtqueue success, assign back the virtqueue */
|
||||
+#ifndef VIRTIO_DEVICE_ONLY
|
||||
+ if (role == RPMSG_HOST) {
|
||||
+ rvdev->rvq = vdev->vrings_info[0].vq;
|
||||
+ rvdev->svq = vdev->vrings_info[1].vq;
|
||||
+ }
|
||||
+#endif /*!VIRTIO_DEVICE_ONLY*/
|
||||
+
|
||||
+#ifndef VIRTIO_DRIVER_ONLY
|
||||
+ if (role == RPMSG_REMOTE) {
|
||||
+ rvdev->rvq = vdev->vrings_info[1].vq;
|
||||
+ rvdev->svq = vdev->vrings_info[0].vq;
|
||||
+ }
|
||||
+#endif /*!VIRTIO_DRIVER_ONLY*/
|
||||
+
|
||||
/*
|
||||
* Suppress "tx-complete" interrupts
|
||||
* since send method use busy loop when buffer pool exhaust
|
||||
@@ -873,7 +884,8 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
||||
rvdev->config.r2h_buf_size);
|
||||
|
||||
if (!buffer) {
|
||||
- return RPMSG_ERR_NO_BUFF;
|
||||
+ status = RPMSG_ERR_NO_BUFF;
|
||||
+ goto err;
|
||||
}
|
||||
|
||||
vqbuf.buf = buffer;
|
||||
@@ -887,7 +899,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
||||
buffer);
|
||||
|
||||
if (status != RPMSG_SUCCESS) {
|
||||
- return status;
|
||||
+ goto err;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -912,6 +924,10 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
|
||||
#endif /*!VIRTIO_DEVICE_ONLY*/
|
||||
|
||||
return status;
|
||||
+
|
||||
+err:
|
||||
+ rpmsg_virtio_delete_virtqueues(rvdev);
|
||||
+ return status;
|
||||
}
|
||||
|
||||
void rpmsg_deinit_vdev(struct rpmsg_virtio_device *rvdev)
|
||||
@@ -931,6 +947,7 @@ void rpmsg_deinit_vdev(struct rpmsg_virtio_device *rvdev)
|
||||
rvdev->rvq = 0;
|
||||
rvdev->svq = 0;
|
||||
|
||||
+ rpmsg_virtio_delete_virtqueues(rvdev);
|
||||
metal_mutex_deinit(&rdev->lock);
|
||||
}
|
||||
}
|
||||
diff --git a/lib/virtio/virtio.c open-amp/lib/virtio/virtio.c
|
||||
index d25aec3..e67e97d 100644
|
||||
--- a/lib/virtio/virtio.c
|
||||
+++ open-amp/lib/virtio/virtio.c
|
||||
@@ -96,43 +96,3 @@ void virtio_describe(struct virtio_device *dev, const char *msg,
|
||||
/* TODO: Not used currently - keeping it for future use*/
|
||||
virtio_feature_name(0, desc);
|
||||
}
|
||||
-
|
||||
-int virtio_create_virtqueues(struct virtio_device *vdev, unsigned int flags,
|
||||
- unsigned int nvqs, const char *names[],
|
||||
- vq_callback callbacks[])
|
||||
-{
|
||||
- struct virtio_vring_info *vring_info;
|
||||
- struct vring_alloc_info *vring_alloc;
|
||||
- unsigned int num_vrings, i;
|
||||
- int ret;
|
||||
- (void)flags;
|
||||
-
|
||||
- num_vrings = vdev->vrings_num;
|
||||
- if (nvqs > num_vrings)
|
||||
- return ERROR_VQUEUE_INVLD_PARAM;
|
||||
- /* Initialize virtqueue for each vring */
|
||||
- for (i = 0; i < nvqs; i++) {
|
||||
- vring_info = &vdev->vrings_info[i];
|
||||
-
|
||||
- vring_alloc = &vring_info->info;
|
||||
-#ifndef VIRTIO_DEVICE_ONLY
|
||||
- if (vdev->role == VIRTIO_DEV_DRIVER) {
|
||||
- size_t offset;
|
||||
- struct metal_io_region *io = vring_info->io;
|
||||
-
|
||||
- offset = metal_io_virt_to_offset(io,
|
||||
- vring_alloc->vaddr);
|
||||
- metal_io_block_set(io, offset, 0,
|
||||
- vring_size(vring_alloc->num_descs,
|
||||
- vring_alloc->align));
|
||||
- }
|
||||
-#endif
|
||||
- ret = virtqueue_create(vdev, i, names[i], vring_alloc,
|
||||
- callbacks[i], vdev->func->notify,
|
||||
- vring_info->vq);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
- }
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
From 8d69eb3524fd57753ab849ed790777f073242276 Mon Sep 17 00:00:00 2001
|
||||
From: wangbowen6 <wangbowen6@xiaomi.com>
|
||||
Date: Thu, 25 May 2023 21:01:17 +0800
|
||||
Subject: [PATCH] virtio.h: add version in device id table
|
||||
|
||||
support the leagcy mmio transport (version 1)
|
||||
|
||||
Change-Id: I194c587754668d28cb7be4dc1b58fa5ce1393414
|
||||
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/virtio.h | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h
|
||||
index fb68c19..6ef1746 100644
|
||||
--- a/lib/include/openamp/virtio.h
|
||||
+++ open-amp/lib/include/openamp/virtio.h
|
||||
@@ -82,6 +82,7 @@ __deprecated static inline int deprecated_virtio_dev_slave(void)
|
||||
struct virtio_device_id {
|
||||
uint32_t device;
|
||||
uint32_t vendor;
|
||||
+ uint32_t version;
|
||||
};
|
||||
|
||||
/*
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
From 49e9be3fee1c3f56e1891959965420550bbafa92 Mon Sep 17 00:00:00 2001
|
||||
From: liqinhui <liqinhui@xiaomi.com>
|
||||
Date: Mon, 4 Dec 2023 19:35:59 +0800
|
||||
Subject: [PATCH] virtio: Add the virtio_negotiate_features interface.
|
||||
|
||||
Add the interface for the VIRTIO_NET_F_MAC feature.
|
||||
|
||||
Change-Id: I51fcb0e5388a908ebf43912b793c061c9488e226
|
||||
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
|
||||
---
|
||||
lib/include/openamp/virtio.h | 14 ++++++++++++++
|
||||
1 file changed, 14 insertions(+)
|
||||
|
||||
diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h
|
||||
index 6ef1746..e32dc16 100644
|
||||
--- a/lib/include/openamp/virtio.h
|
||||
+++ open-amp/lib/include/openamp/virtio.h
|
||||
@@ -299,6 +299,20 @@ static inline void virtio_set_features(struct virtio_device *vdev,
|
||||
return vdev->func->set_features(vdev, features);
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * @brief Negotiate features between virtio device and driver.
|
||||
+ *
|
||||
+ * @param dev Pointer to device structure.
|
||||
+ * @param features Supported features.
|
||||
+ *
|
||||
+ * @return The final features after negotiate.
|
||||
+ */
|
||||
+static inline uint32_t virtio_negotiate_features(struct virtio_device *vdev,
|
||||
+ uint32_t features)
|
||||
+{
|
||||
+ return vdev->func->negotiate_features(vdev, features);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* @brief Reset virtio device.
|
||||
*
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -21,7 +21,8 @@
|
|||
# ##############################################################################
|
||||
if(CONFIG_OPENAMP)
|
||||
|
||||
set(OPENAMP_VERSION 2022.10.0)
|
||||
set(OPENAMP_COMMIT c468328487a1e0596307a5ef7172756819e15745)
|
||||
set(LIBMETAL_COMMIT a4bce3507502a7eb9e29bafe0eb174ed5c4316e9)
|
||||
|
||||
include(libmetal.cmake)
|
||||
include(open-amp.cmake)
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
|
||||
include $(TOPDIR)/Make.defs
|
||||
|
||||
VERSION ?= 2022.10.0
|
||||
OPENAMP_COMMIT ?= c468328487a1e0596307a5ef7172756819e15745
|
||||
LIBMETAL_COMMIT ?= a4bce3507502a7eb9e29bafe0eb174ed5c4316e9
|
||||
|
||||
include libmetal.defs
|
||||
include open-amp.defs
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libmetal)
|
||||
FetchContent_Declare(
|
||||
libmetal
|
||||
DOWNLOAD_NAME "libmetal-v${OPENAMP_VERSION}.zip"
|
||||
DOWNLOAD_NAME "libmetal-main.zip"
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
|
||||
URL "https://github.com/OpenAMP/libmetal/archive/v${OPENAMP_VERSION}.zip"
|
||||
URL "https://github.com/OpenAMP/libmetal/archive/${LIBMETAL_COMMIT}.zip"
|
||||
SOURCE_DIR
|
||||
${CMAKE_CURRENT_LIST_DIR}/libmetal
|
||||
BINARY_DIR
|
||||
|
@ -37,13 +37,17 @@ if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libmetal)
|
|||
""
|
||||
PATCH_COMMAND
|
||||
patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0001-libmetal-add-metal_list_for_each_safe-support.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0001-lib-errno.h-fix-compile-error.patch &&
|
||||
patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0002-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0002-libmetal-nuttx-io.c-align-access-when-read-write-siz.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0003-atomic.h-fix-compiler-error.patch && patch
|
||||
-p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0004-lib-system-nuttx-fix-unused-parameter-compile-error.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0003-libmetal-nuttx-io.c-Fix-void-pointer-arithmetic-in-a.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0005-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0004-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0006-lib-system-nuttx-io.c-include-stddef.h-in-nuttx-io.c.patch
|
||||
DOWNLOAD_NO_PROGRESS true
|
||||
TIMEOUT 30)
|
||||
|
||||
|
|
|
@ -75,13 +75,15 @@ LIBMETAL_HDRS_SEDEXP := \
|
|||
ifeq ($(wildcard libmetal/.git),)
|
||||
libmetal.zip:
|
||||
# Download and unpack tarball if no git repo found
|
||||
$(call DOWNLOAD,https://github.com/OpenAMP/libmetal/archive,v$(VERSION).zip,libmetal.zip)
|
||||
$(call DOWNLOAD,https://github.com/OpenAMP/libmetal/archive,$(LIBMETAL_COMMIT).zip,libmetal.zip)
|
||||
$(Q) unzip -o libmetal.zip
|
||||
$(Q) mv libmetal-$(VERSION) libmetal
|
||||
$(Q) patch -p0 < 0001-libmetal-add-metal_list_for_each_safe-support.patch
|
||||
$(Q) patch -p0 < 0002-libmetal-nuttx-io.c-align-access-when-read-write-siz.patch
|
||||
$(Q) patch -p0 < 0003-libmetal-nuttx-io.c-Fix-void-pointer-arithmetic-in-a.patch
|
||||
$(Q) patch -p0 < 0004-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch
|
||||
mv libmetal-$(LIBMETAL_COMMIT) libmetal
|
||||
$(Q) patch -p0 < 0001-lib-errno.h-fix-compile-error.patch
|
||||
$(Q) patch -p0 < 0002-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch
|
||||
$(Q) patch -p0 < 0003-atomic.h-fix-compiler-error.patch
|
||||
$(Q) patch -p0 < 0004-lib-system-nuttx-fix-unused-parameter-compile-error.patch
|
||||
$(Q) patch -p0 < 0005-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch
|
||||
$(Q) patch -p0 < 0006-lib-system-nuttx-io.c-include-stddef.h-in-nuttx-io.c.patch
|
||||
|
||||
.libmetal_headers: libmetal.zip
|
||||
else
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/open-amp)
|
||||
FetchContent_Declare(
|
||||
open-amp
|
||||
DOWNLOAD_NAME "libopen-amp-v${OPENAMP_VERSION}.zip"
|
||||
DOWNLOAD_NAME "libopen-amp-main.zip"
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
|
||||
URL "https://github.com/OpenAMP/open-amp/archive/v${OPENAMP_VERSION}.zip"
|
||||
URL "https://github.com/OpenAMP/open-amp/archive/${OPENAMP_COMMIT}.zip"
|
||||
SOURCE_DIR
|
||||
${CMAKE_CURRENT_LIST_DIR}/open-amp
|
||||
BINARY_DIR
|
||||
|
@ -43,41 +43,29 @@ if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/open-amp)
|
|||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0002-Negotiate-individual-buffer-size-dynamically.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0003-rpmsg-wait-endpoint-ready-in-rpmsg_send-and-rpmsg_se.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0003-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0004-openamp-add-new-ops-notify_wait-support.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0004-openamp-virtio.h-negotiate_features-also-can-be-call.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0005-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0005-remoteproc-rpmsg_virtio-change-sched_yeild-to-usleep.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0006-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0006-rpmsg-wait-ept-ready-in-rpmsg_send.patch &&
|
||||
patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0007-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0007-openamp-avoid-double-calling-ns_bound-when-each-othe.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0008-remoteproc-make-all-elf_-functions-static-except-elf.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0009-openamp-swap-get_rx_buffer-return_rx_buffer-to-resol.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0009-Fix-warn-declaration-of-vring_rsc-shadows-a-previous.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0010-rpmsg_virtio.c-virtqueue_kick-after-all-rx-buffer-re.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0010-rptun-fix-rptun-don-t-wait-issue-when-get-tx-patyloa.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0011-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0011-rpmsg-fix-rpmsg_virtio_get_tx_buffer-no-idx-return.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0012-rpmsg_virtio.c-fix-get_tx_payload_buffer-error.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0012-rpmsg-add-new-API-rpdev_release_tx-rx_buffer.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0013-openamp-add-assert-when-get-tx-buffer-failed.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0013-openamp-add-error-log-when-ept-cb-return-error.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0014-rpmsg-add-cache-flash-when-hold-rx-buffer.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0015-rpmsg-do-cache_invalidate-when-real-data-returned.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0016-openamp-add-new-API-rpmsg_virtio_get_rxbuffer_size.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0017-virtio-follow-virtio-1.2-spec-add-more-virtio-status.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0018-virtio-decoupling-the-transport-layer-and-virtio-dev.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0019-virtio.h-add-version-in-device-id-table.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0020-virtio-Add-the-virtio_negotiate_features-interface.patch
|
||||
${CMAKE_CURRENT_LIST_DIR}/0014-virtio.h-add-memory-operation-for-virtio-device.patch
|
||||
DOWNLOAD_NO_PROGRESS true
|
||||
TIMEOUT 30)
|
||||
|
||||
|
|
|
@ -52,31 +52,23 @@ CSRCS += open-amp/lib/virtio/virtqueue.c
|
|||
# Download and unpack tarball if no git repo found
|
||||
ifeq ($(wildcard open-amp/.git),)
|
||||
open-amp.zip:
|
||||
$(call DOWNLOAD,https://github.com/OpenAMP/open-amp/archive,v$(VERSION).zip,open-amp.zip)
|
||||
$(call DOWNLOAD,https://github.com/OpenAMP/open-amp/archive,$(OPENAMP_COMMIT).zip,open-amp.zip)
|
||||
$(Q) unzip -o open-amp.zip
|
||||
$(Q) mv open-amp-$(VERSION) open-amp
|
||||
mv open-amp-$(OPENAMP_COMMIT) 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-new-ops-notify_wait-support.patch
|
||||
$(Q) patch -p0 < 0005-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch
|
||||
$(Q) patch -p0 < 0006-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch
|
||||
$(Q) patch -p0 < 0007-openamp-avoid-double-calling-ns_bound-when-each-othe.patch
|
||||
$(Q) patch -p0 < 0008-remoteproc-make-all-elf_-functions-static-except-elf.patch
|
||||
$(Q) patch -p0 < 0009-Fix-warn-declaration-of-vring_rsc-shadows-a-previous.patch
|
||||
$(Q) patch -p0 < 0010-rptun-fix-rptun-don-t-wait-issue-when-get-tx-patyloa.patch
|
||||
$(Q) patch -p0 < 0011-rpmsg-fix-rpmsg_virtio_get_tx_buffer-no-idx-return.patch
|
||||
$(Q) patch -p0 < 0012-rpmsg-add-new-API-rpdev_release_tx-rx_buffer.patch
|
||||
$(Q) patch -p0 < 0013-openamp-add-error-log-when-ept-cb-return-error.patch
|
||||
$(Q) patch -p0 < 0014-rpmsg-add-cache-flash-when-hold-rx-buffer.patch
|
||||
$(Q) patch -p0 < 0015-rpmsg-do-cache_invalidate-when-real-data-returned.patch
|
||||
$(Q) patch -p0 < 0016-openamp-add-new-API-rpmsg_virtio_get_rxbuffer_size.patch
|
||||
$(Q) patch -p0 < 0017-virtio-follow-virtio-1.2-spec-add-more-virtio-status.patch
|
||||
$(Q) patch -p0 < 0018-virtio-decoupling-the-transport-layer-and-virtio-dev.patch
|
||||
$(Q) patch -p0 < 0019-virtio.h-add-version-in-device-id-table.patch
|
||||
$(Q) patch -p0 < 0020-virtio-Add-the-virtio_negotiate_features-interface.patch
|
||||
|
||||
|
||||
$(Q) patch -p0 < 0003-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch
|
||||
$(Q) patch -p0 < 0004-openamp-virtio.h-negotiate_features-also-can-be-call.patch
|
||||
$(Q) patch -p0 < 0005-remoteproc-rpmsg_virtio-change-sched_yeild-to-usleep.patch
|
||||
$(Q) patch -p0 < 0006-rpmsg-wait-ept-ready-in-rpmsg_send.patch
|
||||
$(Q) patch -p0 < 0007-openamp-add-VIRTIO_RING_F_MUST_NOTIFY-event.patch
|
||||
$(Q) patch -p0 < 0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch
|
||||
$(Q) patch -p0 < 0009-openamp-swap-get_rx_buffer-return_rx_buffer-to-resol.patch
|
||||
$(Q) patch -p0 < 0010-rpmsg_virtio.c-virtqueue_kick-after-all-rx-buffer-re.patch
|
||||
$(Q) patch -p0 < 0011-virtio-change-feature-to-64-bit-in-all-virtio_dispat.patch
|
||||
$(Q) patch -p0 < 0012-rpmsg_virtio.c-fix-get_tx_payload_buffer-error.patch
|
||||
$(Q) patch -p0 < 0013-openamp-add-assert-when-get-tx-buffer-failed.patch
|
||||
$(Q) patch -p0 < 0014-virtio.h-add-memory-operation-for-virtio-device.patch
|
||||
|
||||
.openamp_headers: open-amp.zip
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue