Coalesce multiple map or unmap operations to just one so that all mapping setup or teardown can occur in a single DMA batch.
Signed-off-by: Si-Wei Liu <si-wei....@oracle.com> --- hw/virtio/vhost-vdpa.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 68dc01b..d98704a 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1288,6 +1288,7 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev) return true; } + vhost_vdpa_dma_batch_begin_once(v->shared, v->address_space_id); for (i = 0; i < v->shadow_vqs->len; ++i) { VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i); VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i); @@ -1315,6 +1316,7 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev) goto err_set_addr; } } + vhost_vdpa_dma_batch_end_once(v->shared, v->address_space_id); return true; @@ -1323,6 +1325,7 @@ err_set_addr: err_map: vhost_svq_stop(g_ptr_array_index(v->shadow_vqs, i)); + vhost_vdpa_dma_batch_end_once(v->shared, v->address_space_id); err: error_reportf_err(err, "Cannot setup SVQ %u: ", i); @@ -1343,6 +1346,7 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *dev) return; } + vhost_vdpa_dma_batch_begin_once(v->shared, v->address_space_id); for (unsigned i = 0; i < v->shadow_vqs->len; ++i) { VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i); @@ -1352,6 +1356,7 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *dev) event_notifier_cleanup(&svq->hdev_kick); event_notifier_cleanup(&svq->hdev_call); } + vhost_vdpa_dma_batch_end_once(v->shared, v->address_space_id); } static void vhost_vdpa_suspend(struct vhost_dev *dev) -- 1.8.3.1