diff options
| author | Jason Wang <jasowang@redhat.com> | 2025-12-30 09:46:45 +0300 |
|---|---|---|
| committer | Michael S. Tsirkin <mst@redhat.com> | 2025-12-31 13:39:18 +0300 |
| commit | c623106c79c811816614dcb687ed5d08b25d5fe5 (patch) | |
| tree | cb27e3b069a321b46c2e3799b3e20c1e771c2884 | |
| parent | 03f05c4eeb7bc5019deb25f7415a7af8dc3fdd3f (diff) | |
| download | linux-c623106c79c811816614dcb687ed5d08b25d5fe5.tar.xz | |
virtio_ring: factor out core logic of buffer detaching
Factor out core logic of buffer detaching and leave the free list
management to the caller so in_order can just call the core logic.
Acked-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20251230064649.55597-16-jasowang@redhat.com>
| -rw-r--r-- | drivers/virtio/virtio_ring.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index e55b26a03037..27f69859ccf3 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -1665,8 +1665,8 @@ out: return needs_kick; } -static void detach_buf_packed(struct vring_virtqueue *vq, - unsigned int id, void **ctx) +static void detach_buf_packed_in_order(struct vring_virtqueue *vq, + unsigned int id, void **ctx) { struct vring_desc_state_packed *state = NULL; struct vring_packed_desc *desc; @@ -1677,8 +1677,6 @@ static void detach_buf_packed(struct vring_virtqueue *vq, /* Clear data ptr. */ state->data = NULL; - vq->packed.desc_extra[state->last].next = vq->free_head; - vq->free_head = id; vq->vq.num_free += state->num; if (unlikely(vq->use_map_api)) { @@ -1715,6 +1713,17 @@ static void detach_buf_packed(struct vring_virtqueue *vq, } } +static void detach_buf_packed(struct vring_virtqueue *vq, + unsigned int id, void **ctx) +{ + struct vring_desc_state_packed *state = &vq->packed.desc_state[id]; + + vq->packed.desc_extra[state->last].next = vq->free_head; + vq->free_head = id; + + detach_buf_packed_in_order(vq, id, ctx); +} + static inline bool is_used_desc_packed(const struct vring_virtqueue *vq, u16 idx, bool used_wrap_counter) { |
