Skip to content

Commit 519b206

Browse files
jasowangmstsirkin
authored andcommitted
virtio_ring: factor out split detaching logic
This patch factors out the split core detaching logic that could be reused by in order feature into a dedicated function. Acked-by: Eugenio Pérez <eperezma@redhat.com> Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Eugenio Pérez <eperezma@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20251230064649.55597-19-jasowang@redhat.com>
1 parent 9dc6b94 commit 519b206

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

drivers/virtio/virtio_ring.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,9 @@ static void detach_indirect_split(struct vring_virtqueue *vq,
805805
vq->split.desc_state[head].indir_desc = NULL;
806806
}
807807

808-
static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head,
809-
void **ctx)
808+
static unsigned detach_buf_split_in_order(struct vring_virtqueue *vq,
809+
unsigned int head,
810+
void **ctx)
810811
{
811812
struct vring_desc_extra *extra;
812813
unsigned int i;
@@ -826,8 +827,6 @@ static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head,
826827
}
827828

828829
vring_unmap_one_split(vq, &extra[i]);
829-
extra[i].next = vq->free_head;
830-
vq->free_head = head;
831830

832831
/* Plus final descriptor */
833832
vq->vq.num_free++;
@@ -836,6 +835,17 @@ static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head,
836835
detach_indirect_split(vq, head);
837836
else if (ctx)
838837
*ctx = vq->split.desc_state[head].indir_desc;
838+
839+
return i;
840+
}
841+
842+
static void detach_buf_split(struct vring_virtqueue *vq, unsigned int head,
843+
void **ctx)
844+
{
845+
unsigned int i = detach_buf_split_in_order(vq, head, ctx);
846+
847+
vq->split.desc_extra[i].next = vq->free_head;
848+
vq->free_head = head;
839849
}
840850

841851
static bool virtqueue_poll_split(const struct vring_virtqueue *vq,

0 commit comments

Comments
 (0)