|
|
9ae3a8 |
From 9d3ccec3b8323f7cfbce932f8c6530aa4105ba02 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Ladi Prosek <lprosek@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 5 Oct 2016 17:22:23 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 1/8] virtio: introduce virtqueue_unmap_sg()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Ladi Prosek <lprosek@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1475666548-9186-2-git-send-email-lprosek@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 72480
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.4 qemu-kvm v2 PATCH 1/6] virtio: introduce virtqueue_unmap_sg()
|
|
|
9ae3a8 |
Bugzilla: 1377968
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Jason Wang <jasowang@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Factor out sg unmapping logic. This will be reused by the patch that
|
|
|
9ae3a8 |
can discard descriptor.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Cc: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Cc: Andrew James <andrew.james@hpe.com>
|
|
|
9ae3a8 |
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit ce317461573bac12b10d67699b4ddf1f97cf066c)
|
|
|
9ae3a8 |
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/virtio/virtio.c | 14 ++++++++++----
|
|
|
9ae3a8 |
1 file changed, 10 insertions(+), 4 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
|
|
|
9ae3a8 |
index 0df4ed3..5ee899a 100644
|
|
|
9ae3a8 |
--- a/hw/virtio/virtio.c
|
|
|
9ae3a8 |
+++ b/hw/virtio/virtio.c
|
|
|
9ae3a8 |
@@ -228,14 +228,12 @@ int virtio_queue_empty(VirtQueue *vq)
|
|
|
9ae3a8 |
return vring_avail_idx(vq) == vq->last_avail_idx;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
|
|
|
9ae3a8 |
- unsigned int len, unsigned int idx)
|
|
|
9ae3a8 |
+static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem,
|
|
|
9ae3a8 |
+ unsigned int len)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
unsigned int offset;
|
|
|
9ae3a8 |
int i;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- trace_virtqueue_fill(vq, elem, len, idx);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
offset = 0;
|
|
|
9ae3a8 |
for (i = 0; i < elem->in_num; i++) {
|
|
|
9ae3a8 |
size_t size = MIN(len - offset, elem->in_sg[i].iov_len);
|
|
|
9ae3a8 |
@@ -251,6 +249,14 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
|
|
|
9ae3a8 |
cpu_physical_memory_unmap(elem->out_sg[i].iov_base,
|
|
|
9ae3a8 |
elem->out_sg[i].iov_len,
|
|
|
9ae3a8 |
0, elem->out_sg[i].iov_len);
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
|
|
|
9ae3a8 |
+ unsigned int len, unsigned int idx)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ trace_virtqueue_fill(vq, elem, len, idx);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ virtqueue_unmap_sg(vq, elem, len);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
idx = (idx + vring_used_idx(vq)) % vq->vring.num;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|