| 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/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: anchao <anchao@pinecone.net> |
| Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> |
| Signed-off-by: wangyongrong <wangyongrong@xiaomi.com> |
| --- |
| 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 84bf233..abc5481 100644 |
| --- a/lib/include/openamp/remoteproc.h |
| +++ open-amp/lib/include/openamp/remoteproc.h |
| @@ -361,6 +361,21 @@ struct fw_rsc_vendor { |
| uint32_t len; |
| } METAL_PACKED_END; |
| |
| +/** @brief Configuration space declaration ((if VIRTIO_RPMSG_F_BUFSZ)) */ |
| +METAL_PACKED_BEGIN |
| +struct fw_rsc_config { |
| + /** The host to remote buffer size */ |
| + uint32_t h2r_buf_size; |
| + |
| + /** The remote to host buffer size */ |
| + uint32_t r2h_buf_size; |
| + |
| + /** Reserve for the future use */ |
| + uint32_t reserved[14]; |
| + |
| + /** Put the customize config here */ |
| +} METAL_PACKED_END; |
| + |
| 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 6d6925f..d9cfa9b 100644 |
| --- a/lib/include/openamp/rpmsg_virtio.h |
| +++ open-amp/lib/include/openamp/rpmsg_virtio.h |
| @@ -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 get buffer size from config space */ |
| |
| #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 820227e..94c4b95 100644 |
| --- a/lib/rpmsg/rpmsg_virtio.c |
| +++ open-amp/lib/rpmsg/rpmsg_virtio.c |
| @@ -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> |
| |
| #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; |
| + } |
| |
| if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) { |
| /* |
| -- |
| 2.34.1 |
| |