2022-11-05 15:16:58 +01:00
|
|
|
From 931cd95ab99550befa75703cc36d5e6f6964b63e Mon Sep 17 00:00:00 2001
|
2020-11-12 10:56:25 +01:00
|
|
|
From: Guiding Li <liguiding@pinecone.net>
|
2020-04-21 14:37:06 +02:00
|
|
|
Date: Wed, 20 Feb 2019 11:36:57 +0800
|
2022-11-21 04:12:33 +01:00
|
|
|
Subject: [PATCH 03/10] rpmsg: wait endpoint ready in rpmsg_send and
|
2020-11-12 10:56:25 +01:00
|
|
|
rpmsg_send_nocopy
|
2020-04-21 14:37:06 +02:00
|
|
|
|
2020-11-12 10:56:25 +01:00
|
|
|
because the remote need time to return the destination address
|
2020-04-21 14:37:06 +02:00
|
|
|
|
2020-11-12 10:56:25 +01:00
|
|
|
Signed-off-by: Guiding Li <liguiding@pinecone.net>
|
2020-04-21 14:37:06 +02:00
|
|
|
---
|
2020-11-12 10:56:25 +01:00
|
|
|
lib/include/openamp/rpmsg.h | 59 ++++++++++++++++++++++++++-----------
|
2022-11-05 15:16:58 +01:00
|
|
|
lib/rpmsg/rpmsg_virtio.c | 7 -----
|
|
|
|
2 files changed, 42 insertions(+), 24 deletions(-)
|
2020-04-21 14:37:06 +02:00
|
|
|
|
|
|
|
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
|
2022-11-05 15:16:58 +01:00
|
|
|
index ff3ff8fb..dbe42ea6 100644
|
2020-04-21 14:37:06 +02:00
|
|
|
--- a/lib/include/openamp/rpmsg.h
|
|
|
|
+++ open-amp/lib/include/openamp/rpmsg.h
|
|
|
|
@@ -15,6 +15,7 @@
|
|
|
|
#include <metal/compiler.h>
|
|
|
|
#include <metal/mutex.h>
|
|
|
|
#include <metal/list.h>
|
|
|
|
+#include <metal/sleep.h>
|
|
|
|
#include <metal/utilities.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
@@ -32,6 +33,12 @@ extern "C" {
|
|
|
|
#define RPMSG_RESERVED_ADDRESSES (1024)
|
|
|
|
#define RPMSG_ADDR_ANY 0xFFFFFFFF
|
|
|
|
|
|
|
|
+/* Total tick count for 15secs - 1usec tick. */
|
|
|
|
+#define RPMSG_TICK_COUNT 15000000
|
|
|
|
+
|
|
|
|
+/* Time to wait - In multiple of 1 msecs. */
|
|
|
|
+#define RPMSG_TICKS_PER_INTERVAL 1000
|
|
|
|
+
|
|
|
|
/* Error macros. */
|
|
|
|
#define RPMSG_SUCCESS 0
|
|
|
|
#define RPMSG_ERROR_BASE -2000
|
2022-11-05 15:16:58 +01:00
|
|
|
@@ -147,6 +154,19 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
|
2020-11-12 10:56:25 +01:00
|
|
|
uint32_t dst, const void *data, int len,
|
2020-04-21 14:37:06 +02:00
|
|
|
int wait);
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * is_rpmsg_ept_ready - check if the rpmsg endpoint ready to send
|
|
|
|
+ *
|
|
|
|
+ * @ept: pointer to rpmsg endpoint
|
|
|
|
+ *
|
|
|
|
+ * Returns 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)
|
|
|
|
+{
|
2020-11-12 10:56:25 +01:00
|
|
|
+ return ept && ept->rdev && ept->dest_addr != RPMSG_ADDR_ANY;
|
2020-04-21 14:37:06 +02:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
/**
|
|
|
|
* rpmsg_send() - send a message across to the remote processor
|
|
|
|
* @ept: the rpmsg endpoint
|
2022-11-05 15:16:58 +01:00
|
|
|
@@ -165,11 +185,20 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
|
2020-04-21 14:37:06 +02:00
|
|
|
static inline int rpmsg_send(struct rpmsg_endpoint *ept, const void *data,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
+ int tc = 0;
|
|
|
|
+
|
2022-11-05 15:16:58 +01:00
|
|
|
if (!ept)
|
|
|
|
return RPMSG_ERR_PARAM;
|
|
|
|
|
|
|
|
- return rpmsg_send_offchannel_raw(ept, ept->addr, ept->dest_addr, data,
|
|
|
|
- len, true);
|
2020-04-21 14:37:06 +02:00
|
|
|
+ for (; tc < RPMSG_TICK_COUNT; tc += RPMSG_TICKS_PER_INTERVAL) {
|
|
|
|
+ if (is_rpmsg_ept_ready(ept))
|
|
|
|
+ return rpmsg_send_offchannel_raw(ept, ept->addr,
|
|
|
|
+ ept->dest_addr,
|
|
|
|
+ data, len, true);
|
|
|
|
+ metal_sleep_usec(RPMSG_TICKS_PER_INTERVAL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return RPMSG_ERR_ADDR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-11-05 15:16:58 +01:00
|
|
|
@@ -476,11 +505,20 @@ static inline int rpmsg_sendto_nocopy(struct rpmsg_endpoint *ept,
|
2020-11-12 10:56:25 +01:00
|
|
|
static inline int rpmsg_send_nocopy(struct rpmsg_endpoint *ept,
|
|
|
|
const void *data, int len)
|
|
|
|
{
|
|
|
|
+ int tc = 0;
|
|
|
|
+
|
2022-11-05 15:16:58 +01:00
|
|
|
if (!ept)
|
|
|
|
return RPMSG_ERR_PARAM;
|
|
|
|
|
|
|
|
- return rpmsg_send_offchannel_nocopy(ept, ept->addr,
|
|
|
|
- ept->dest_addr, data, len);
|
2020-11-12 10:56:25 +01:00
|
|
|
+ for (; tc < RPMSG_TICK_COUNT; tc += RPMSG_TICKS_PER_INTERVAL) {
|
|
|
|
+ if (is_rpmsg_ept_ready(ept))
|
|
|
|
+ return rpmsg_send_offchannel_nocopy(ept, ept->addr,
|
|
|
|
+ ept->dest_addr,
|
|
|
|
+ data, len);
|
|
|
|
+ metal_sleep_usec(RPMSG_TICKS_PER_INTERVAL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return RPMSG_ERR_ADDR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-11-05 15:16:58 +01:00
|
|
|
@@ -524,19 +562,6 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
|
2020-04-21 14:37:06 +02:00
|
|
|
*/
|
|
|
|
void rpmsg_destroy_ept(struct rpmsg_endpoint *ept);
|
|
|
|
|
|
|
|
-/**
|
|
|
|
- * is_rpmsg_ept_ready - check if the rpmsg endpoint ready to send
|
|
|
|
- *
|
|
|
|
- * @ept: pointer to rpmsg endpoint
|
|
|
|
- *
|
|
|
|
- * Returns 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)
|
|
|
|
-{
|
2020-11-12 10:56:25 +01:00
|
|
|
- return ept && ept->rdev && ept->dest_addr != RPMSG_ADDR_ANY;
|
2020-04-21 14:37:06 +02:00
|
|
|
-}
|
|
|
|
-
|
|
|
|
#if defined __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
2022-11-05 15:16:58 +01:00
|
|
|
index 69537399..c56e0cea 100644
|
2020-04-21 14:37:06 +02:00
|
|
|
--- a/lib/rpmsg/rpmsg_virtio.c
|
|
|
|
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
2022-08-02 10:44:59 +02:00
|
|
|
@@ -10,7 +10,6 @@
|
2020-04-21 14:37:06 +02:00
|
|
|
|
|
|
|
#include <metal/alloc.h>
|
2022-08-02 10:44:59 +02:00
|
|
|
#include <metal/cache.h>
|
2020-04-21 14:37:06 +02:00
|
|
|
-#include <metal/sleep.h>
|
|
|
|
#include <metal/utilities.h>
|
|
|
|
#include <openamp/rpmsg_virtio.h>
|
|
|
|
#include <openamp/virtqueue.h>
|
2022-11-05 15:16:58 +01:00
|
|
|
@@ -19,12 +18,6 @@
|
2020-04-21 14:37:06 +02:00
|
|
|
|
|
|
|
#define RPMSG_NUM_VRINGS 2
|
|
|
|
|
|
|
|
-/* Total tick count for 15secs - 1usec tick. */
|
|
|
|
-#define RPMSG_TICK_COUNT 15000000
|
|
|
|
-
|
|
|
|
-/* Time to wait - In multiple of 1 msecs. */
|
|
|
|
-#define RPMSG_TICKS_PER_INTERVAL 1000
|
|
|
|
-
|
2022-11-05 15:16:58 +01:00
|
|
|
/**
|
|
|
|
* struct vbuff_reclaimer_t - vring buffer recycler
|
|
|
|
*
|
2020-04-21 14:37:06 +02:00
|
|
|
--
|
2022-08-02 10:44:59 +02:00
|
|
|
2.25.1
|
2020-04-21 14:37:06 +02:00
|
|
|
|