Skip to content

Commit

Permalink
rpmsg_virtio: Return error code if waiting for remote fails
Browse files Browse the repository at this point in the history
If we cannot finish waiting for the remote to be ready to start RPMsg
communication then return and propagate an error.

Signed-off-by: Andrew Davis <afd@ti.com>
  • Loading branch information
glneo authored and arnopo committed Apr 2, 2024
1 parent 2427641 commit d13dd90
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions lib/rpmsg/rpmsg_virtio.c
Expand Up @@ -269,21 +269,32 @@ static void *rpmsg_virtio_get_rx_buffer(struct rpmsg_virtio_device *rvdev,
}

#ifndef VIRTIO_DRIVER_ONLY
/*
* check if the remote is ready to start RPMsg communication
/**
* @internal
*
* @brief Check if the remote is ready to start RPMsg communication
*
* @param rvdev Pointer to rpmsg_virtio device
*
* @return 0 on success, otherwise error code.
*/
static int rpmsg_virtio_wait_remote_ready(struct rpmsg_virtio_device *rvdev)
{
uint8_t status;
int ret;

while (1) {
virtio_get_status(rvdev->vdev, &status);
ret = virtio_get_status(rvdev->vdev, &status);
if (ret)
return ret;
/* Busy wait until the remote is ready */
if (status & VIRTIO_CONFIG_STATUS_NEEDS_RESET) {
virtio_set_status(rvdev->vdev, 0);
ret = virtio_set_status(rvdev->vdev, 0);
if (ret)
return ret;
/* TODO notify remote processor */
} else if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK) {
return true;
return 0;
}
/* TODO: clarify metal_cpu_yield usage*/
metal_cpu_yield();
Expand Down Expand Up @@ -856,7 +867,9 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
#ifndef VIRTIO_DRIVER_ONLY
if (role == RPMSG_REMOTE) {
/* wait synchro with the host */
rpmsg_virtio_wait_remote_ready(rvdev);
status = rpmsg_virtio_wait_remote_ready(rvdev);
if (status)
return status;
}
#endif /*!VIRTIO_DRIVER_ONLY*/
status = virtio_get_features(rvdev->vdev, &features);
Expand Down

0 comments on commit d13dd90

Please sign in to comment.