Skip to content

Commit

Permalink
rpmsg_virtio: Move get RX buffer into receive loop
Browse files Browse the repository at this point in the history
This allows us to only need to call rpmsg_virtio_get_rx_buffer() once
at the start of the loop and is easier to comprehend.

Signed-off-by: Andrew Davis <afd@ti.com>
  • Loading branch information
glneo authored and arnopo committed May 16, 2024
1 parent 40820be commit bf87228
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,16 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
uint16_t idx;
int status;

metal_mutex_acquire(&rdev->lock);

/* Process the received data from remote node */
rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
while (1) {
/* Process the received data from remote node */
metal_mutex_acquire(&rdev->lock);
rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
metal_mutex_release(&rdev->lock);

metal_mutex_release(&rdev->lock);
/* No more filled rx buffers */
if (!rp_hdr)
break;

while (rp_hdr) {
rp_hdr->reserved = idx;

/* Get the channel node from the remote device channels list. */
Expand Down Expand Up @@ -605,8 +607,6 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
rpmsg_ept_decref(ept);
if (rpmsg_virtio_buf_held_dec_test(rp_hdr))
rpmsg_virtio_release_rx_buffer_nolock(rvdev, rp_hdr);

rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
metal_mutex_release(&rdev->lock);
}
}
Expand Down

0 comments on commit bf87228

Please sign in to comment.