Commit a1baedb1 authored by Jason Wang's avatar Jason Wang Committed by Michael S. Tsirkin
Browse files

virtio-vdpa: support per vq dma device



This patch adds the support of per vq dma device for virito-vDPA. vDPA
parents then are allowed to use different DMA devices. This is useful
for the parents that have software or emulated virtqueues.

Reviewed-by: default avatarEli Cohen <elic@nvidia.com>
Tested-by: default avatarEli Cohen <elic@nvidia.com>
Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
Message-Id: <20230119061525.75068-4-jasowang@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 25da258f
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
{
	struct virtio_vdpa_device *vd_dev = to_virtio_vdpa_device(vdev);
	struct vdpa_device *vdpa = vd_get_vdpa(vdev);
	struct device *dma_dev;
	const struct vdpa_config_ops *ops = vdpa->config;
	struct virtio_vdpa_vq_info *info;
	struct vdpa_callback cb;
@@ -175,9 +176,15 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,

	/* Create the vring */
	align = ops->get_vq_align(vdpa);
	vq = vring_create_virtqueue(index, max_num, align, vdev,

	if (ops->get_vq_dma_dev)
		dma_dev = ops->get_vq_dma_dev(vdpa, index);
	else
		dma_dev = vdpa_get_dma_dev(vdpa);
	vq = vring_create_virtqueue_dma(index, max_num, align, vdev,
					true, may_reduce_num, ctx,
				    virtio_vdpa_notify, callback, name);
					virtio_vdpa_notify, callback,
					name, dma_dev);
	if (!vq) {
		err = -ENOMEM;
		goto error_new_virtqueue;