From 5d8e63f2efe5337ca1f3a612dee9ac37e1b8d2a8 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 19 Apr 2024 08:55:28 -0500 Subject: [PATCH] rpmsg_virtio: Deprecate RPMSG_HOST and RPMSG_REMOTE definitions For all cases when the role is checked in rpmsg_virtio, what is being checked is the role of the underlying virtio layer. As such, we should be matching against the role definitions for the virtio layer (VIRTIO_DEV_DEVICE and VIRTIO_DEV_DRIVER). Fix this here. While the underlying virtio layer may be asymmetric, the RPMSG layer generally is symmetrical. There is no need to define a HOST or REMOTE role specific to the RPMSG layer. And as there are now no more internal users of these definitions, deprecate them here. Signed-off-by: Andrew Davis --- lib/rpmsg/rpmsg_virtio.c | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/rpmsg/rpmsg_virtio.c b/lib/rpmsg/rpmsg_virtio.c index 494f2d4a5..6130a4621 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ b/lib/rpmsg/rpmsg_virtio.c @@ -114,7 +114,7 @@ static void rpmsg_virtio_return_buffer(struct rpmsg_virtio_device *rvdev, BUFFER_INVALIDATE(buffer, len); - if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { + if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == VIRTIO_DEV_DRIVER) { struct virtqueue_buf vqbuf; (void)idx; @@ -125,7 +125,7 @@ static void rpmsg_virtio_return_buffer(struct rpmsg_virtio_device *rvdev, RPMSG_ASSERT(ret == VQUEUE_SUCCESS, "add buffer failed\r\n"); } - if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { + if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == VIRTIO_DEV_DEVICE) { (void)buffer; ret = virtqueue_add_consumed_buffer(rvdev->rvq, idx, len); RPMSG_ASSERT(ret == VQUEUE_SUCCESS, "add consumed buffer failed\r\n"); @@ -152,7 +152,7 @@ static int rpmsg_virtio_enqueue_buffer(struct rpmsg_virtio_device *rvdev, BUFFER_FLUSH(buffer, len); - if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { + if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == VIRTIO_DEV_DRIVER) { struct virtqueue_buf vqbuf; (void)idx; @@ -162,7 +162,7 @@ static int rpmsg_virtio_enqueue_buffer(struct rpmsg_virtio_device *rvdev, return virtqueue_add_buffer(rvdev->svq, &vqbuf, 1, 0, buffer); } - if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { + if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == VIRTIO_DEV_DEVICE) { (void)buffer; return virtqueue_add_consumed_buffer(rvdev->svq, idx, len); } @@ -197,11 +197,11 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev, data = r_desc; *idx = r_desc->idx; - if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) + if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == VIRTIO_DEV_DRIVER) *len = rvdev->config.h2r_buf_size; - if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) + if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == VIRTIO_DEV_DEVICE) *len = virtqueue_get_buffer_length(rvdev->svq, *idx); - } else if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { + } else if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == VIRTIO_DEV_DRIVER) { data = virtqueue_get_buffer(rvdev->svq, len, idx); if (!data && rvdev->svq->vq_free_cnt) { data = rpmsg_virtio_shm_pool_get_buffer(rvdev->shpool, @@ -209,7 +209,7 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev, *len = rvdev->config.h2r_buf_size; *idx = 0; } - } else if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { + } else if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == VIRTIO_DEV_DEVICE) { data = virtqueue_get_available_buffer(rvdev->svq, idx, len); } @@ -233,11 +233,11 @@ static void *rpmsg_virtio_get_rx_buffer(struct rpmsg_virtio_device *rvdev, unsigned int role = rpmsg_virtio_get_role(rvdev); void *data = NULL; - if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { + if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == VIRTIO_DEV_DRIVER) { data = virtqueue_get_buffer(rvdev->rvq, len, idx); } - if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { + if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == VIRTIO_DEV_DEVICE) { data = virtqueue_get_available_buffer(rvdev->rvq, idx, len); } @@ -451,7 +451,7 @@ static int rpmsg_virtio_send_offchannel_nocopy(struct rpmsg_device *rdev, metal_mutex_acquire(&rdev->lock); - if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && rpmsg_virtio_get_role(rvdev) == RPMSG_HOST) + if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && rpmsg_virtio_get_role(rvdev) == VIRTIO_DEV_DRIVER) buff_len = rvdev->config.h2r_buf_size; else buff_len = virtqueue_get_buffer_length(rvdev->svq, idx); @@ -709,7 +709,7 @@ int rpmsg_virtio_get_tx_buffer_size(struct rpmsg_device *rdev) rvdev = (struct rpmsg_virtio_device *)rdev; role = rpmsg_virtio_get_role(rvdev); - if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { + if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == VIRTIO_DEV_DRIVER) { /* * If device role is host then buffers are provided by us, * so just provide the macro. @@ -717,7 +717,7 @@ int rpmsg_virtio_get_tx_buffer_size(struct rpmsg_device *rdev) size = rvdev->config.h2r_buf_size - sizeof(struct rpmsg_hdr); } - if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { + if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == VIRTIO_DEV_DEVICE) { /* * If other core is host then buffers are provided by it, * so get the buffer size from the virtqueue. @@ -747,7 +747,7 @@ int rpmsg_virtio_get_rx_buffer_size(struct rpmsg_device *rdev) rvdev = (struct rpmsg_virtio_device *)rdev; role = rpmsg_virtio_get_role(rvdev); - if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { + if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == VIRTIO_DEV_DRIVER) { /* * If device role is host then buffers are provided by us, * so just provide the macro. @@ -755,7 +755,7 @@ int rpmsg_virtio_get_rx_buffer_size(struct rpmsg_device *rdev) size = rvdev->config.r2h_buf_size - sizeof(struct rpmsg_hdr); } - if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { + if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == VIRTIO_DEV_DEVICE) { /* * If other core is host then buffers are provided by it, * so get the buffer size from the virtqueue. @@ -816,7 +816,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, rdev->ops.get_tx_buffer_size = rpmsg_virtio_get_tx_buffer_size; role = rpmsg_virtio_get_role(rvdev); - if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { + if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == VIRTIO_DEV_DRIVER) { /* * The virtio configuration contains only options applicable to * a virtio driver, implying rpmsg host role. @@ -827,7 +827,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, rvdev->config = *config; } - if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { + if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == VIRTIO_DEV_DEVICE) { /* wait synchro with the host */ status = rpmsg_virtio_wait_remote_ready(rvdev); if (status) @@ -839,7 +839,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, return status; rdev->support_ns = !!(features & (1 << VIRTIO_RPMSG_F_NS)); - if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { + if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == VIRTIO_DEV_DRIVER) { /* * Since device is RPMSG Remote so we need to manage the * shared buffers. Create shared memory pool to handle buffers. @@ -856,7 +856,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, callback[1] = rpmsg_virtio_tx_callback; } - if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { + if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == VIRTIO_DEV_DEVICE) { vq_names[0] = "tx_vq"; vq_names[1] = "rx_vq"; callback[0] = rpmsg_virtio_tx_callback; @@ -873,12 +873,12 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, return status; /* Create virtqueue success, assign back the virtqueue */ - if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { + if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == VIRTIO_DEV_DRIVER) { rvdev->rvq = vdev->vrings_info[0].vq; rvdev->svq = vdev->vrings_info[1].vq; } - if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == RPMSG_REMOTE) { + if (VIRTIO_ENABLED(VIRTIO_DEVICE_SUPPORT) && role == VIRTIO_DEV_DEVICE) { rvdev->rvq = vdev->vrings_info[1].vq; rvdev->svq = vdev->vrings_info[0].vq; } @@ -897,7 +897,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, vq->shm_io = shm_io; } - if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { + if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == VIRTIO_DEV_DRIVER) { struct virtqueue_buf vqbuf; unsigned int idx; void *buffer; @@ -942,7 +942,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, rpmsg_virtio_ns_callback, NULL, rvdev); } - if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == RPMSG_HOST) { + if (VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT) && role == VIRTIO_DEV_DRIVER) { status = virtio_set_status(rvdev->vdev, VIRTIO_CONFIG_STATUS_DRIVER_OK); if (status) goto err;