Skip to content

Commit

Permalink
rpmsg_virtio.c: virtqueue_kick after all rx buffer release
Browse files Browse the repository at this point in the history
virtqueue_kick after all rx buffer release to improve performance

Signed-off-by: Yongrong Wang <[email protected]>
  • Loading branch information
wyr-7 committed Sep 19, 2024
1 parent c468328 commit 2ef37d4
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ static bool rpmsg_virtio_release_rx_buffer_nolock(struct rpmsg_virtio_device *rv
/* Return buffer on virtqueue. */
len = virtqueue_get_buffer_length(rvdev->rvq, idx);
rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx);
/* Tell peer we returned an rx buffer */
virtqueue_kick(rvdev->rvq);

return true;
}
Expand All @@ -337,8 +335,11 @@ static void rpmsg_virtio_release_rx_buffer(struct rpmsg_device *rdev,
rp_hdr = RPMSG_LOCATE_HDR(rxbuf);

metal_mutex_acquire(&rdev->lock);
if (rpmsg_virtio_buf_held_dec_test(rp_hdr))
if (rpmsg_virtio_buf_held_dec_test(rp_hdr)) {
rpmsg_virtio_release_rx_buffer_nolock(rvdev, rp_hdr);
/* Tell peer we returned an rx buffer */
virtqueue_kick(rvdev->rvq);
}
metal_mutex_release(&rdev->lock);
}

Expand Down Expand Up @@ -560,6 +561,7 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
struct rpmsg_device *rdev = &rvdev->rdev;
struct rpmsg_endpoint *ept;
struct rpmsg_hdr *rp_hdr;
bool release = false;
uint32_t len;
uint16_t idx;
int status;
Expand All @@ -571,8 +573,13 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
metal_mutex_release(&rdev->lock);

/* No more filled rx buffers */
if (!rp_hdr)
if (!rp_hdr) {
/* Tell peer we returned some rx buffer */
if (release) {
virtqueue_kick(rvdev->rvq);
}
break;
}

rp_hdr->reserved = idx;

Expand Down Expand Up @@ -600,8 +607,10 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)

metal_mutex_acquire(&rdev->lock);
rpmsg_ept_decref(ept);
if (rpmsg_virtio_buf_held_dec_test(rp_hdr))
if (rpmsg_virtio_buf_held_dec_test(rp_hdr)) {
rpmsg_virtio_release_rx_buffer_nolock(rvdev, rp_hdr);
release = true;
}
metal_mutex_release(&rdev->lock);
}
}
Expand Down

0 comments on commit 2ef37d4

Please sign in to comment.