Skip to content

Commit

Permalink
remoteproc_virtio: add shm_io for remoteproc virtio
Browse files Browse the repository at this point in the history
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 <wangbowen6@xiaomi.com>
  • Loading branch information
CV-Bowen committed Dec 4, 2023
1 parent b33183f commit 42c52ce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/include/openamp/remoteproc_virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
*
Expand Down
14 changes: 14 additions & 0 deletions lib/remoteproc/remoteproc_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 42c52ce

Please sign in to comment.