]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
virtio: Add helper functions to attach/detach vring descriptors
authorWill Deacon <willdeacon@google.com>
Wed, 29 Mar 2023 14:24:58 +0000 (22:24 +0800)
committerTom Rini <trini@konsulko.com>
Tue, 25 Apr 2023 15:53:15 +0000 (11:53 -0400)
Move the attach and detach logic for manipulating vring descriptors
out into their own functions so that we can later extend these to
bounce the data for devices with VIRTIO_F_IOMMU_PLATFORM set.

Signed-off-by: Will Deacon <willdeacon@google.com>
[ Paul: pick from the Android tree. Rebase to the upstream ]
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Link: https://android.googlesource.com/platform/external/u-boot/+/f73258a4bfe968c5f935db45f2ec5cc0104ee796
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/virtio/virtio_ring.c

index 5aeb13fd59796a5b9700b85d9432242f80bd3ba6..1bd19add758b8b81bba571db4bd6c250acc38933 100644 (file)
@@ -47,6 +47,10 @@ static unsigned int virtqueue_attach_desc(struct virtqueue *vq, unsigned int i,
        return desc_shadow->next;
 }
 
+static void virtqueue_detach_desc(struct virtqueue *vq, unsigned int idx)
+{
+}
+
 int virtqueue_add(struct virtqueue *vq, struct virtio_sg *sgs[],
                  unsigned int out_sgs, unsigned int in_sgs)
 {
@@ -165,10 +169,12 @@ static void detach_buf(struct virtqueue *vq, unsigned int head)
        i = head;
 
        while (vq->vring_desc_shadow[i].flags & VRING_DESC_F_NEXT) {
+               virtqueue_detach_desc(vq, i);
                i = vq->vring_desc_shadow[i].next;
                vq->num_free++;
        }
 
+       virtqueue_detach_desc(vq, i);
        vq->vring_desc_shadow[i].next = vq->free_head;
        vq->free_head = head;