Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpmsg_virtio: fix the rpmsg_get_tx/rx_buffer() api #630

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 6 additions & 28 deletions lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,22 +714,11 @@ int rpmsg_virtio_get_tx_buffer_size(struct rpmsg_device *rdev)
metal_mutex_acquire(&rdev->lock);
rvdev = (struct rpmsg_virtio_device *)rdev;

if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) {
/*
* If device role is host then buffers are provided by us,
* so just provide the macro.
*/
if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev))
size = rvdev->config.h2r_buf_size - sizeof(struct rpmsg_hdr);
}

if (VIRTIO_ROLE_IS_DEVICE(rvdev->vdev)) {
/*
* If other core is host then buffers are provided by it,
* so get the buffer size from the virtqueue.
*/
size = (int)virtqueue_get_desc_size(rvdev->svq) -
sizeof(struct rpmsg_hdr);
}
if (VIRTIO_ROLE_IS_DEVICE(rvdev->vdev))
size = rvdev->config.r2h_buf_size - sizeof(struct rpmsg_hdr);

if (size <= 0)
size = RPMSG_ERR_NO_BUFF;
Expand All @@ -750,22 +739,11 @@ int rpmsg_virtio_get_rx_buffer_size(struct rpmsg_device *rdev)
metal_mutex_acquire(&rdev->lock);
rvdev = (struct rpmsg_virtio_device *)rdev;

if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) {
/*
* If device role is host then buffers are provided by us,
* so just provide the macro.
*/
if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev))
size = rvdev->config.r2h_buf_size - sizeof(struct rpmsg_hdr);
}

if (VIRTIO_ROLE_IS_DEVICE(rvdev->vdev)) {
/*
* If other core is host then buffers are provided by it,
* so get the buffer size from the virtqueue.
*/
size = (int)virtqueue_get_desc_size(rvdev->rvq) -
sizeof(struct rpmsg_hdr);
}
if (VIRTIO_ROLE_IS_DEVICE(rvdev->vdev))
size = rvdev->config.h2r_buf_size - sizeof(struct rpmsg_hdr);

if (size <= 0)
size = RPMSG_ERR_NO_BUFF;
Expand Down