summaryrefslogtreecommitdiffstats
path: root/drivers/virtio/virtio_pci_modern.c
diff options
context:
space:
mode:
authorXuan Zhuo <xuanzhuo@linux.alibaba.com>2022-08-01 08:38:54 +0200
committerMichael S. Tsirkin <mst@redhat.com>2022-08-11 10:06:41 +0200
commitcdb44806fca2d0ad29ca644cbf1505433902ee0c (patch)
treeb1889baa03a2ff0a827bde1ab3f997cf9689d4da /drivers/virtio/virtio_pci_modern.c
parentvirtio: find_vqs() add arg sizes (diff)
downloadlinux-cdb44806fca2d0ad29ca644cbf1505433902ee0c.tar.xz
linux-cdb44806fca2d0ad29ca644cbf1505433902ee0c.zip
virtio_pci: support the arg sizes of find_vqs()
Virtio PCI supports new parameter sizes of find_vqs(). Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Jason Wang <jasowang@redhat.com> Message-Id: <20220801063902.129329-35-xuanzhuo@linux.alibaba.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/virtio/virtio_pci_modern.c')
-rw-r--r--drivers/virtio/virtio_pci_modern.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index be51ec849252..f7965c5dd36b 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -293,6 +293,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
unsigned int index,
void (*callback)(struct virtqueue *vq),
const char *name,
+ u32 size,
bool ctx,
u16 msix_vec)
{
@@ -310,15 +311,18 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
if (!num || vp_modern_get_queue_enable(mdev, index))
return ERR_PTR(-ENOENT);
- if (num & (num - 1)) {
- dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", num);
+ if (!size || size > num)
+ size = num;
+
+ if (size & (size - 1)) {
+ dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", size);
return ERR_PTR(-EINVAL);
}
info->msix_vector = msix_vec;
/* create the vring */
- vq = vring_create_virtqueue(index, num,
+ vq = vring_create_virtqueue(index, size,
SMP_CACHE_BYTES, &vp_dev->vdev,
true, true, ctx,
vp_notify, callback, name);