Skip to content

Commit

Permalink
rpmsg_vritio: INVALIDATE cache in calculate buffer nused
Browse files Browse the repository at this point in the history
optimize buffer nused calculation

Signed-off-by: Yongrong Wang <[email protected]>
  • Loading branch information
wyr-7 committed Jan 13, 2025
1 parent 60de459 commit 724e67d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,18 @@ static int rpmsg_virtio_buffer_nused(FAR struct rpmsg_virtio_device *rvdev,
{
FAR struct virtqueue *vq = rx ? rvdev->rvq : rvdev->svq;
uint16_t nused = vq->vq_ring.avail->idx - vq->vq_ring.used->idx;
bool is_host = rpmsg_virtio_get_role(rvdev) == RPMSG_HOST;

if ((rpmsg_virtio_get_role(rvdev) == RPMSG_HOST) ^ rx)
if (is_host)
{
RPMSG_VIRTIO_INVALIDATE(vq->vq_ring.used->idx);
}
else
{
RPMSG_VIRTIO_INVALIDATE(vq->vq_ring.avail->idx);
}

if (is_host ^ rx)
{
return nused;
}
Expand Down

0 comments on commit 724e67d

Please sign in to comment.