diff mbox series

[4/6] virtio: Add helper functions to attach/detach vring descriptors

Message ID 20230329142500.682922-5-paul.liu@linaro.org
State New
Headers show
Series virtio: Use bounce buffers when VIRTIO_F_IOMMU_PLATFORM set | expand

Commit Message

Paul Liu March 29, 2023, 2:24 p.m. UTC
From: Will Deacon <willdeacon@google.com>

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
---
 drivers/virtio/virtio_ring.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Simon Glass April 1, 2023, 6:32 a.m. UTC | #1
On Thu, 30 Mar 2023 at 03:26, Ying-Chun Liu (PaulLiu)
<paul.liu@linaro.org> wrote:
>
> From: Will Deacon <willdeacon@google.com>
>
> 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
> ---
>  drivers/virtio/virtio_ring.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 5aeb13fd59..1bd19add75 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -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;