Coalesce map or unmap operations to exact one DMA
batch to reduce potential impact on performance.
Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
---
net/vhost-vdpa.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index bc72345..1c1d61f 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -715,10 +715,11 @@ out:
v->shared->iova_range.last);
}
+ vhost_vdpa_dma_batch_begin_once(v->shared, v->address_space_id);
r = vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer,
vhost_vdpa_net_cvq_cmd_page_len(), false);
if (unlikely(r < 0)) {
- return r;
+ goto err;
}
r = vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, s->status,
@@ -727,18 +728,23 @@ out:
vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer);
}
+err:
+ vhost_vdpa_dma_batch_end_once(v->shared, v->address_space_id);
return r;
}
static void vhost_vdpa_net_cvq_stop(NetClientState *nc)
{
VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
+ struct vhost_vdpa *v = &s->vhost_vdpa;
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA);
if (s->vhost_vdpa.shadow_vqs_enabled) {
+ vhost_vdpa_dma_batch_begin_once(v->shared, v->address_space_id);
vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer);
vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->status);
+ vhost_vdpa_dma_batch_end_once(v->shared, v->address_space_id);
}
vhost_vdpa_net_client_stop(nc);
--
1.8.3.1