Skip to content

Commit

Permalink
rpmsg_virtio: Move returned buffer kick to common location
Browse files Browse the repository at this point in the history
After returning a buffer we kick the other side. This is done after both
call sites of the function that returns the buffer. Move this kick call
into that function to reduce code duplication and prevent it from not
being done after returning the buffer.

Signed-off-by: Andrew Davis <afd@ti.com>
  • Loading branch information
glneo authored and arnopo committed May 16, 2024
1 parent 7257dea commit 40820be
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ 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 @@ -340,11 +342,8 @@ 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 return some rx buffers */
virtqueue_kick(rvdev->rvq);
}
metal_mutex_release(&rdev->lock);
}

Expand Down Expand Up @@ -608,10 +607,6 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
rpmsg_virtio_release_rx_buffer_nolock(rvdev, rp_hdr);

rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
if (!rp_hdr) {
/* tell peer we return some rx buffer */
virtqueue_kick(rvdev->rvq);
}
metal_mutex_release(&rdev->lock);
}
}
Expand Down

0 comments on commit 40820be

Please sign in to comment.