[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/25] virtio: device/driver area size calculation refactor for sp
From: |
Michael S. Tsirkin |
Subject: |
[PULL 02/25] virtio: device/driver area size calculation refactor for split ring |
Date: |
Sat, 26 Oct 2019 15:39:15 -0400 |
From: Wei Xu <address@hidden>
There is slight size difference between split/packed rings.
This is the refactor of split ring as well as a helper to expanding
device and driver area size calculation for packed ring.
Signed-off-by: Wei Xu <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
Signed-off-by: Eugenio PĂ©rez <address@hidden>
Reviewed-by: Jens Freimann <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/virtio/virtio.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index fdac203cdf..74cc10fad9 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -159,10 +159,8 @@ static void virtio_init_region_cache(VirtIODevice *vdev,
int n)
VRingMemoryRegionCaches *old = vq->vring.caches;
VRingMemoryRegionCaches *new = NULL;
hwaddr addr, size;
- int event_size;
int64_t len;
- event_size = virtio_vdev_has_feature(vq->vdev, VIRTIO_RING_F_EVENT_IDX) ?
2 : 0;
addr = vq->vring.desc;
if (!addr) {
@@ -177,7 +175,7 @@ static void virtio_init_region_cache(VirtIODevice *vdev,
int n)
goto err_desc;
}
- size = virtio_queue_get_used_size(vdev, n) + event_size;
+ size = virtio_queue_get_used_size(vdev, n);
len = address_space_cache_init(&new->used, vdev->dma_as,
vq->vring.used, size, true);
if (len < size) {
@@ -185,7 +183,7 @@ static void virtio_init_region_cache(VirtIODevice *vdev,
int n)
goto err_used;
}
- size = virtio_queue_get_avail_size(vdev, n) + event_size;
+ size = virtio_queue_get_avail_size(vdev, n);
len = address_space_cache_init(&new->avail, vdev->dma_as,
vq->vring.avail, size, false);
if (len < size) {
@@ -2414,14 +2412,20 @@ hwaddr virtio_queue_get_desc_size(VirtIODevice *vdev,
int n)
hwaddr virtio_queue_get_avail_size(VirtIODevice *vdev, int n)
{
+ int s;
+
+ 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;
+ sizeof(uint16_t) * vdev->vq[n].vring.num + s;
}
hwaddr virtio_queue_get_used_size(VirtIODevice *vdev, int n)
{
+ int s;
+
+ s = virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
return offsetof(VRingUsed, ring) +
- sizeof(VRingUsedElem) * vdev->vq[n].vring.num;
+ sizeof(VRingUsedElem) * vdev->vq[n].vring.num + s;
}
uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n)
--
MST
- [PULL 00/25] virtio: features, tests, Michael S. Tsirkin, 2019/10/26
- [PULL 01/25] virtio: basic structure for packed ring, Michael S. Tsirkin, 2019/10/26
- [PULL 02/25] virtio: device/driver area size calculation refactor for split ring,
Michael S. Tsirkin <=
- [PULL 03/25] virtio: Free blk virqueues at unrealize(), Michael S. Tsirkin, 2019/10/26
- [PULL 04/25] virtio: Free rnd virqueue at unrealize(), Michael S. Tsirkin, 2019/10/26
- [PULL 05/25] virtio: basic packed virtqueue support, Michael S. Tsirkin, 2019/10/26
- [PULL 06/25] virtio: event suppression support for packed ring, Michael S. Tsirkin, 2019/10/26
- [PULL 07/25] vhost_net: enable packed ring support, Michael S. Tsirkin, 2019/10/26
- [PULL 08/25] virtio: add property to enable packed virtqueue, Michael S. Tsirkin, 2019/10/26
- [PULL 09/25] tests/virtio-blk-test: read config space after feature negotiation, Michael S. Tsirkin, 2019/10/26
- [PULL 10/25] libqos: read QVIRTIO_MMIO_VERSION register, Michael S. Tsirkin, 2019/10/26
- [PULL 11/25] libqos: extend feature bits to 64-bit, Michael S. Tsirkin, 2019/10/26
- [PULL 16/25] libqos: implement VIRTIO 1.0 FEATURES_OK step, Michael S. Tsirkin, 2019/10/26