2024-10-08 15:30:21 +08:00
|
|
|
From a12f4359e3d4382e31a0f6f6983184b635fd0611 Mon Sep 17 00:00:00 2001
|
|
|
|
From: anchao <anchao@pinecone.net>
|
2022-08-02 16:44:59 +08:00
|
|
|
Date: Mon, 10 Dec 2018 16:26:39 +0800
|
2024-10-08 15:30:21 +08:00
|
|
|
Subject: [PATCH 02/14] Negotiate individual buffer size dynamically
|
2022-08-02 16:44:59 +08:00
|
|
|
|
2024-10-08 15:30:21 +08:00
|
|
|
Change config type from fw_rsc_config to rpmsg_virtio_config
|
|
|
|
to avoid rpmsg_vitio.h couple with remoteproc.h.
|
2022-08-02 16:44:59 +08:00
|
|
|
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.
|
|
|
|
|
2024-10-08 15:30:21 +08:00
|
|
|
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>
|
2022-08-02 16:44:59 +08:00
|
|
|
---
|
2024-10-08 15:30:21 +08:00
|
|
|
lib/include/openamp/remoteproc.h | 15 +++++++++++++++
|
|
|
|
lib/include/openamp/rpmsg_virtio.h | 1 +
|
|
|
|
lib/rpmsg/rpmsg_virtio.c | 7 +++++++
|
|
|
|
3 files changed, 23 insertions(+)
|
2022-08-02 16:44:59 +08:00
|
|
|
|
|
|
|
diff --git a/lib/include/openamp/remoteproc.h open-amp/lib/include/openamp/remoteproc.h
|
2024-10-08 15:30:21 +08:00
|
|
|
index 84bf233..abc5481 100644
|
2022-08-02 16:44:59 +08:00
|
|
|
--- a/lib/include/openamp/remoteproc.h
|
|
|
|
+++ open-amp/lib/include/openamp/remoteproc.h
|
2024-10-08 15:30:21 +08:00
|
|
|
@@ -361,6 +361,21 @@ struct fw_rsc_vendor {
|
|
|
|
uint32_t len;
|
2022-08-02 16:44:59 +08:00
|
|
|
} METAL_PACKED_END;
|
|
|
|
|
2024-10-08 15:30:21 +08:00
|
|
|
+/** @brief Configuration space declaration ((if VIRTIO_RPMSG_F_BUFSZ)) */
|
2022-08-02 16:44:59 +08:00
|
|
|
+METAL_PACKED_BEGIN
|
|
|
|
+struct fw_rsc_config {
|
2024-10-08 15:30:21 +08:00
|
|
|
+ /** The host to remote buffer size */
|
2022-08-02 16:44:59 +08:00
|
|
|
+ uint32_t h2r_buf_size;
|
2024-10-08 15:30:21 +08:00
|
|
|
+
|
|
|
|
+ /** The remote to host buffer size */
|
2022-08-02 16:44:59 +08:00
|
|
|
+ uint32_t r2h_buf_size;
|
2024-10-08 15:30:21 +08:00
|
|
|
+
|
|
|
|
+ /** Reserve for the future use */
|
|
|
|
+ uint32_t reserved[14];
|
|
|
|
+
|
|
|
|
+ /** Put the customize config here */
|
2022-08-02 16:44:59 +08:00
|
|
|
+} METAL_PACKED_END;
|
|
|
|
+
|
2024-10-08 15:30:21 +08:00
|
|
|
struct loader_ops;
|
|
|
|
struct image_store_ops;
|
|
|
|
struct remoteproc_ops;
|
2022-08-02 16:44:59 +08:00
|
|
|
diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h
|
2024-10-08 15:30:21 +08:00
|
|
|
index 6d6925f..d9cfa9b 100644
|
2022-08-02 16:44:59 +08:00
|
|
|
--- a/lib/include/openamp/rpmsg_virtio.h
|
|
|
|
+++ open-amp/lib/include/openamp/rpmsg_virtio.h
|
2024-10-08 15:30:21 +08:00
|
|
|
@@ -30,6 +30,7 @@ extern "C" {
|
2022-08-02 16:44:59 +08:00
|
|
|
/* 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 */
|
2024-10-08 15:30:21 +08:00
|
|
|
+#define VIRTIO_RPMSG_F_BUFSZ 2 /* RP supports get buffer size from config space */
|
2022-08-02 16:44:59 +08:00
|
|
|
|
2024-10-08 15:30:21 +08:00
|
|
|
#ifdef VIRTIO_CACHED_BUFFERS
|
|
|
|
#warning "VIRTIO_CACHED_BUFFERS is deprecated, please use VIRTIO_USE_DCACHE"
|
2022-08-02 16:44:59 +08:00
|
|
|
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
|
2024-10-08 15:30:21 +08:00
|
|
|
index 820227e..94c4b95 100644
|
2022-08-02 16:44:59 +08:00
|
|
|
--- a/lib/rpmsg/rpmsg_virtio.c
|
|
|
|
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
|
2024-10-08 15:30:21 +08:00
|
|
|
@@ -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>
|
2022-08-02 16:44:59 +08:00
|
|
|
|
2024-10-08 15:30:21 +08:00
|
|
|
#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;
|
2022-08-02 16:44:59 +08:00
|
|
|
+ }
|
2024-10-08 15:30:21 +08:00
|
|
|
|
|
|
|
if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) {
|
2022-08-02 16:44:59 +08:00
|
|
|
/*
|
|
|
|
--
|
2024-10-08 15:30:21 +08:00
|
|
|
2.34.1
|
2022-08-02 16:44:59 +08:00
|
|
|
|