virtio_vdpa: create vqs with the actual size

The size of a virtqueue is a per vq configuration,
this commit allows virtio_vdpa to create
virtqueues with the actual size of a specific
vq size that supported by the backend device.

Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
Message-Id: <20240202163905.8834-9-lingshan.zhu@intel.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Zhu Lingshan 2024-02-03 00:39:03 +08:00 committed by Michael S. Tsirkin
parent 47e62e6d62
commit 273ae08fa0

View File

@ -183,8 +183,11 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
info = kmalloc(sizeof(*info), GFP_KERNEL); info = kmalloc(sizeof(*info), GFP_KERNEL);
if (!info) if (!info)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
if (ops->get_vq_size)
max_num = ops->get_vq_size(vdpa, index);
else
max_num = ops->get_vq_num_max(vdpa);
max_num = ops->get_vq_num_max(vdpa);
if (max_num == 0) { if (max_num == 0) {
err = -ENOENT; err = -ENOENT;
goto error_new_virtqueue; goto error_new_virtqueue;