From 40820be22369fb96c6ead4a7b17a506aa0d16745 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Tue, 12 Mar 2024 15:53:59 -0500 Subject: [PATCH] rpmsg_virtio: Move returned buffer kick to common location 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 --- lib/rpmsg/rpmsg_virtio.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/rpmsg/rpmsg_virtio.c b/lib/rpmsg/rpmsg_virtio.c index 7796f744..eb7945ee 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ b/lib/rpmsg/rpmsg_virtio.c @@ -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; } @@ -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); } @@ -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); } }