From 42c52ce0ca18ad8dd593629ff9283e1c87991695 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Mon, 30 Oct 2023 18:43:19 +0800 Subject: [PATCH] remoteproc_virtio: add shm_io for remoteproc virtio Now the rpmsg device need pass a share memory io region to rpmsg_init_vdev(). I think every virtio device need a share memory io to access the share memory and this region should be provided by the transport layer. Like the MMIO transport layer did in OpenAMP. So I add shm_io in the remoteproc virtio device and also provide a API to set it. Signed-off-by: Bowen Wang --- lib/include/openamp/remoteproc_virtio.h | 14 ++++++++++++++ lib/remoteproc/remoteproc_virtio.c | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lib/include/openamp/remoteproc_virtio.h b/lib/include/openamp/remoteproc_virtio.h index 0b747cacc..fd1dd7c45 100644 --- a/lib/include/openamp/remoteproc_virtio.h +++ b/lib/include/openamp/remoteproc_virtio.h @@ -50,6 +50,9 @@ struct remoteproc_virtio { /** Metal I/O region of vdev_info, can be NULL */ struct metal_io_region *vdev_rsc_io; + /** Metal I/O region of vdev share memory */ + struct metal_io_region *shm_io; + /** Notification function */ rpvdev_notify_func notify; @@ -88,6 +91,17 @@ rproc_virtio_create_vdev(unsigned int role, unsigned int notifyid, */ void rproc_virtio_remove_vdev(struct virtio_device *vdev); +/** + * @brief Set the remoteproc virtio device share memory I/O region + * + * @param vdev Pointer to the virtio device + * @param shm_io Metal I/O region to set + * + * @return 0 for success, negative value for failure. + */ +int rproc_virtio_set_shm_io(struct virtio_device *vdev, + struct metal_io_region *shm_io); + /** * @brief Initialize rproc virtio vring * diff --git a/lib/remoteproc/remoteproc_virtio.c b/lib/remoteproc/remoteproc_virtio.c index 7ef1064d8..46d9d335c 100644 --- a/lib/remoteproc/remoteproc_virtio.c +++ b/lib/remoteproc/remoteproc_virtio.c @@ -280,6 +280,20 @@ rproc_virtio_create_vdev(unsigned int role, unsigned int notifyid, return NULL; } +int rproc_virtio_set_shm_io(struct virtio_device *vdev, + struct metal_io_region *shm_io) +{ + struct remoteproc_virtio *rpvdev; + + if (!vdev || !shm_io) + return -RPROC_EINVAL; + + rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev); + rpvdev->shm_io = shm_io; + + return 0; +} + void rproc_virtio_remove_vdev(struct virtio_device *vdev) { struct remoteproc_virtio *rpvdev;