From d43f672dbd80e259ea759ffd719f77262e01bde1 Mon Sep 17 00:00:00 2001 From: Tanmay Shah Date: Tue, 28 Apr 2026 16:04:04 -0700 Subject: [PATCH 1/3] legacy_apps: zynqmp_r5: introduce rpmsg vdev config space vdev config space can be used for various rpmsg virtio configurations such as rpmsg tx and rx single buf size. Signed-off-by: Tanmay Shah --- .../legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c | 13 +++++++++++-- .../legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c b/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c index 04519df4..fd026b6b 100644 --- a/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c +++ b/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c @@ -58,14 +58,23 @@ struct remote_resource_table __resource resources = { /* Virtio device entry */ .rpmsg_vdev = { - RSC_VDEV, VIRTIO_ID_RPMSG_, 31, RPMSG_VDEV_DFEATURES, 0, 0, 0, + RSC_VDEV, VIRTIO_ID_RPMSG_, 31, RPMSG_VDEV_DFEATURES, 0, + /* vdev config space len */ + sizeof(struct rpmsg_virtio_config), 0, NUM_VRINGS, {0, 0}, }, /* Vring rsc entry - part of vdev rsc entry */ {RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0}, {RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0}, - + /* vdev config space */ + .vdev_config = { + .version = 1, + .size = (uint16_t)sizeof(struct rpmsg_virtio_config) + .h2r_buf_size = 256, /* host to remote, i.e. tx for host */ + .r2h_buf_size = 128, /* remote to host, i.e. rx for host */ + .split_shpool = false + }, /* trace buffer for logs, accessible via debugfs */ .rsc_trace = { .type = RSC_TRACE, diff --git a/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.h b/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.h index 7d61ac09..cf120496 100644 --- a/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.h +++ b/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.h @@ -34,6 +34,7 @@ struct remote_resource_table { struct fw_rsc_vdev rpmsg_vdev; struct fw_rsc_vdev_vring rpmsg_vring0; struct fw_rsc_vdev_vring rpmsg_vring1; + struct rpmsg_virtio_config vdev_config; struct fw_rsc_trace rsc_trace; }__attribute__((packed, aligned(0x100))); From 10e2dd8b64ee833a51877d3ee44e81df2c93c8bc Mon Sep 17 00:00:00 2001 From: Tanmay Shah Date: Tue, 28 Apr 2026 20:19:53 -0700 Subject: [PATCH 2/3] legacy_apps: zynqmp_r5: init rpmsg vdev with config Current rpmsg device is not initialized with the config space. Initialze the rpmsg device with the vdev config parameters from the resource table. This configures tx and rx buffer size. Host can read this configuration and configure tx and rx buffer size accordingly. Signed-off-by: Tanmay Shah --- .../machine/xlnx/zynqmp_r5/platform_info.c | 9 ++++++--- .../legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c | 11 ++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/legacy_apps/machine/xlnx/zynqmp_r5/platform_info.c b/examples/legacy_apps/machine/xlnx/zynqmp_r5/platform_info.c index f2f0a813..5f776147 100644 --- a/examples/legacy_apps/machine/xlnx/zynqmp_r5/platform_info.c +++ b/examples/legacy_apps/machine/xlnx/zynqmp_r5/platform_info.c @@ -408,6 +408,7 @@ platform_create_rpmsg_vdev(void *platform, unsigned int vdev_index, void (*rst_cb)(struct virtio_device *vdev), rpmsg_ns_bind_cb ns_bind_cb) { + struct remote_resource_table *rsc_tbl; struct remoteproc *rproc = platform; struct rpmsg_virtio_device *rpmsg_vdev; struct virtio_device *vdev; @@ -417,6 +418,8 @@ platform_create_rpmsg_vdev(void *platform, unsigned int vdev_index, restore_initial_rsc_table(); + rsc_tbl = rproc->rsc_table; + rpmsg_vdev = metal_allocate_memory(sizeof(*rpmsg_vdev)); if (!rpmsg_vdev) return NULL; @@ -440,9 +443,9 @@ platform_create_rpmsg_vdev(void *platform, unsigned int vdev_index, metal_dbg("initializing rpmsg vdev\r\n"); /* RPMsg virtio device can set shared buffers pool argument to NULL */ - ret = rpmsg_init_vdev(rpmsg_vdev, vdev, ns_bind_cb, - shbuf_io, - &shpool); + ret = rpmsg_init_vdev_with_config(rpmsg_vdev, vdev, ns_bind_cb, + shbuf_io, &shpool, + &rsc_tbl->vdev_config); if (ret) { metal_err("failed rpmsg_init_vdev\r\n"); goto err2; diff --git a/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c b/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c index fd026b6b..26809946 100644 --- a/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c +++ b/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c @@ -21,8 +21,9 @@ #define RSC_TBL_XLNX_MAGIC ((uint32_t)'x' << 24 | (uint32_t)'a' << 16 | \ (uint32_t)'m' << 8 | (uint32_t)'p') - -#define RPMSG_VDEV_DFEATURES (1 << VIRTIO_RPMSG_F_NS) + +#define RPMSG_VDEV_DFEATURES (1 << VIRTIO_RPMSG_F_NS | \ + 1 << VIRTIO_RPMSG_F_BUFSZ) /* VirtIO rpmsg device id */ #define VIRTIO_ID_RPMSG_ 7 @@ -70,9 +71,9 @@ struct remote_resource_table __resource resources = { /* vdev config space */ .vdev_config = { .version = 1, - .size = (uint16_t)sizeof(struct rpmsg_virtio_config) - .h2r_buf_size = 256, /* host to remote, i.e. tx for host */ - .r2h_buf_size = 128, /* remote to host, i.e. rx for host */ + .size = (uint16_t)sizeof(struct rpmsg_virtio_config), + .h2r_buf_size = 512, /* host to remote, i.e. tx for host */ + .r2h_buf_size = 512, /* remote to host, i.e. rx for host */ .split_shpool = false }, /* trace buffer for logs, accessible via debugfs */ From 85ce487816584beb521c85b2092c107183dee582 Mon Sep 17 00:00:00 2001 From: Tanmay Shah Date: Tue, 28 Apr 2026 20:18:38 -0700 Subject: [PATCH 3/3] legacy_apps: echo: print tx and rx buffer size Convert debug logs to info logs that prints tx and rx buffer size of the rpmsg buffer. Signed-off-by: Tanmay Shah --- examples/legacy_apps/examples/echo/rpmsg-echo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/legacy_apps/examples/echo/rpmsg-echo.c b/examples/legacy_apps/examples/echo/rpmsg-echo.c index 329c53ad..d18a87ff 100644 --- a/examples/legacy_apps/examples/echo/rpmsg-echo.c +++ b/examples/legacy_apps/examples/echo/rpmsg-echo.c @@ -79,8 +79,8 @@ int rpmsg_echo_app(struct rpmsg_device *rdev, void *priv) "created rpmsg channel %s, src=0x%x, dst=0x%x\r\n", RPMSG_SERVICE_NAME, lept.addr, lept.dest_addr); - metal_dbg("RPMsg device TX buffer size: %#x\r\n", rpmsg_get_tx_buffer_size(&lept)); - metal_dbg("RPMsg device RX buffer size: %#x\r\n", rpmsg_get_rx_buffer_size(&lept)); + metal_info("RPMsg device TX buffer size: %d\r\n", rpmsg_get_tx_buffer_size(&lept)); + metal_info("RPMsg device RX buffer size: %d\r\n", rpmsg_get_rx_buffer_size(&lept)); while(1) { platform_poll(priv);