Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio_pci: Revert "virtio_pci: support the arg sizes of find_vqs()"

This reverts commit cdb44806fca2d0ad29ca644cbf1505433902ee0c: the legacy
path is wrong and in fact can not support the proposed API since for a
legacy device we never communicate the vq size to the hypervisor.

Reported-by: Andres Freund <andres@anarazel.de>
Fixes: cdb44806fca2 ("virtio_pci: support the arg sizes of find_vqs()")
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20220816053602.173815-5-mst@redhat.com>

+12 -23
+8 -10
drivers/virtio/virtio_pci_common.c
··· 174 174 static struct virtqueue *vp_setup_vq(struct virtio_device *vdev, unsigned int index, 175 175 void (*callback)(struct virtqueue *vq), 176 176 const char *name, 177 - u32 size, 178 177 bool ctx, 179 178 u16 msix_vec) 180 179 { ··· 186 187 if (!info) 187 188 return ERR_PTR(-ENOMEM); 188 189 189 - vq = vp_dev->setup_vq(vp_dev, info, index, callback, name, size, ctx, 190 + vq = vp_dev->setup_vq(vp_dev, info, index, callback, name, ctx, 190 191 msix_vec); 191 192 if (IS_ERR(vq)) 192 193 goto out_info; ··· 283 284 284 285 static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned int nvqs, 285 286 struct virtqueue *vqs[], vq_callback_t *callbacks[], 286 - const char * const names[], u32 sizes[], bool per_vq_vectors, 287 + const char * const names[], bool per_vq_vectors, 287 288 const bool *ctx, 288 289 struct irq_affinity *desc) 289 290 { ··· 326 327 else 327 328 msix_vec = VP_MSIX_VQ_VECTOR; 328 329 vqs[i] = vp_setup_vq(vdev, queue_idx++, callbacks[i], names[i], 329 - sizes ? sizes[i] : 0, 330 - ctx ? ctx[i] : false, msix_vec); 330 + ctx ? ctx[i] : false, 331 + msix_vec); 331 332 if (IS_ERR(vqs[i])) { 332 333 err = PTR_ERR(vqs[i]); 333 334 goto error_find; ··· 357 358 358 359 static int vp_find_vqs_intx(struct virtio_device *vdev, unsigned int nvqs, 359 360 struct virtqueue *vqs[], vq_callback_t *callbacks[], 360 - const char * const names[], u32 sizes[], const bool *ctx) 361 + const char * const names[], const bool *ctx) 361 362 { 362 363 struct virtio_pci_device *vp_dev = to_vp_device(vdev); 363 364 int i, err, queue_idx = 0; ··· 379 380 continue; 380 381 } 381 382 vqs[i] = vp_setup_vq(vdev, queue_idx++, callbacks[i], names[i], 382 - sizes ? sizes[i] : 0, 383 383 ctx ? ctx[i] : false, 384 384 VIRTIO_MSI_NO_VECTOR); 385 385 if (IS_ERR(vqs[i])) { ··· 402 404 int err; 403 405 404 406 /* Try MSI-X with one vector per queue. */ 405 - err = vp_find_vqs_msix(vdev, nvqs, vqs, callbacks, names, sizes, true, ctx, desc); 407 + err = vp_find_vqs_msix(vdev, nvqs, vqs, callbacks, names, true, ctx, desc); 406 408 if (!err) 407 409 return 0; 408 410 /* Fallback: MSI-X with one vector for config, one shared for queues. */ 409 - err = vp_find_vqs_msix(vdev, nvqs, vqs, callbacks, names, sizes, false, ctx, desc); 411 + err = vp_find_vqs_msix(vdev, nvqs, vqs, callbacks, names, false, ctx, desc); 410 412 if (!err) 411 413 return 0; 412 414 /* Finally fall back to regular interrupts. */ 413 - return vp_find_vqs_intx(vdev, nvqs, vqs, callbacks, names, sizes, ctx); 415 + return vp_find_vqs_intx(vdev, nvqs, vqs, callbacks, names, ctx); 414 416 } 415 417 416 418 const char *vp_bus_name(struct virtio_device *vdev)
-1
drivers/virtio/virtio_pci_common.h
··· 80 80 unsigned int idx, 81 81 void (*callback)(struct virtqueue *vq), 82 82 const char *name, 83 - u32 size, 84 83 bool ctx, 85 84 u16 msix_vec); 86 85 void (*del_vq)(struct virtio_pci_vq_info *info);
+1 -5
drivers/virtio/virtio_pci_legacy.c
··· 112 112 unsigned int index, 113 113 void (*callback)(struct virtqueue *vq), 114 114 const char *name, 115 - u32 size, 116 115 bool ctx, 117 116 u16 msix_vec) 118 117 { ··· 125 126 if (!num || vp_legacy_get_queue_enable(&vp_dev->ldev, index)) 126 127 return ERR_PTR(-ENOENT); 127 128 128 - if (!size || size > num) 129 - size = num; 130 - 131 129 info->msix_vector = msix_vec; 132 130 133 131 /* create the vring */ 134 - vq = vring_create_virtqueue(index, size, 132 + vq = vring_create_virtqueue(index, num, 135 133 VIRTIO_PCI_VRING_ALIGN, &vp_dev->vdev, 136 134 true, false, ctx, 137 135 vp_notify, callback, name);
+3 -7
drivers/virtio/virtio_pci_modern.c
··· 293 293 unsigned int index, 294 294 void (*callback)(struct virtqueue *vq), 295 295 const char *name, 296 - u32 size, 297 296 bool ctx, 298 297 u16 msix_vec) 299 298 { ··· 310 311 if (!num || vp_modern_get_queue_enable(mdev, index)) 311 312 return ERR_PTR(-ENOENT); 312 313 313 - if (!size || size > num) 314 - size = num; 315 - 316 - if (size & (size - 1)) { 317 - dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", size); 314 + if (num & (num - 1)) { 315 + dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", num); 318 316 return ERR_PTR(-EINVAL); 319 317 } 320 318 321 319 info->msix_vector = msix_vec; 322 320 323 321 /* create the vring */ 324 - vq = vring_create_virtqueue(index, size, 322 + vq = vring_create_virtqueue(index, num, 325 323 SMP_CACHE_BYTES, &vp_dev->vdev, 326 324 true, true, ctx, 327 325 vp_notify, callback, name);