[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/11] virtio: initialize packed ring region
From: |
wexu |
Subject: |
[Qemu-devel] [PATCH 03/11] virtio: initialize packed ring region |
Date: |
Wed, 13 Feb 2019 08:25:38 -0500 |
From: Wei Xu <address@hidden>
Initialize packed ring memory region with correct size and attribute.
Signed-off-by: Wei Xu <address@hidden>
---
hw/virtio/virtio.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 6769e54..1a98e61 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -156,7 +156,7 @@ static void virtio_init_region_cache(VirtIODevice *vdev,
int n)
VRingMemoryRegionCaches *new = NULL;
hwaddr addr, size;
int64_t len;
-
+ bool attr;
addr = vq->vring.desc;
if (!addr) {
@@ -164,8 +164,10 @@ static void virtio_init_region_cache(VirtIODevice *vdev,
int n)
}
new = g_new0(VRingMemoryRegionCaches, 1);
size = virtio_queue_get_desc_size(vdev, n);
+ attr = virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED) ?
+ true : false;
len = address_space_cache_init(&new->desc, vdev->dma_as,
- addr, size, false);
+ addr, size, attr);
if (len < size) {
virtio_error(vdev, "Cannot map desc");
goto err_desc;
@@ -2335,6 +2337,10 @@ hwaddr virtio_queue_get_avail_size(VirtIODevice *vdev,
int n)
{
int s;
+ if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) {
+ return sizeof(struct VRingPackedDescEvent);
+ }
+
s = virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
return offsetof(VRingAvail, ring) +
sizeof(uint16_t) * vdev->vq[n].vring.num + s;
@@ -2344,6 +2350,10 @@ hwaddr virtio_queue_get_used_size(VirtIODevice *vdev,
int n)
{
int s;
+ if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) {
+ return sizeof(struct VRingPackedDescEvent);
+ }
+
s = virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
return offsetof(VRingUsed, ring) +
sizeof(VRingUsedElem) * vdev->vq[n].vring.num + s;
--
1.8.3.1
- [Qemu-devel] [PATCH v3 00/11] packed ring virtio-net backends support, wexu, 2019/02/13
- [Qemu-devel] [PATCH 01/11] virtio: rename structure for packed ring, wexu, 2019/02/13
- [Qemu-devel] [PATCH 09/11] virtio-net: update the head descriptor in a chain lastly, wexu, 2019/02/13
- [Qemu-devel] [PATCH 07/11] virtio: fill/flush/pop for packed ring, wexu, 2019/02/13
- [Qemu-devel] [PATCH 04/11] virtio: initialize wrap counter for packed ring, wexu, 2019/02/13
- [Qemu-devel] [PATCH 03/11] virtio: initialize packed ring region,
wexu <=
- [Qemu-devel] [PATCH 02/11] virtio: device/driver area size calculation helper for split ring, wexu, 2019/02/13
- [Qemu-devel] [PATCH 06/11] virtio: get avail bytes check for packed ring, wexu, 2019/02/13
- [Qemu-devel] [PATCH 05/11] virtio: queue/descriptor check helpers for packed ring, wexu, 2019/02/13
- [Qemu-devel] [PATCH 08/11] virtio: event suppression support for packed ring, wexu, 2019/02/13
- [Qemu-devel] [PATCH 11/11] virtio: CLI and provide packed ring feature bit by default, wexu, 2019/02/13
- [Qemu-devel] [PATCH 10/11] virtio: migration support for packed ring, wexu, 2019/02/13
- Re: [Qemu-devel] [PATCH v3 00/11] packed ring virtio-net backends support, Michael S. Tsirkin, 2019/02/13