Skip to content

Commit 13aa8c6

Browse files
committed
virtio_pci: Revert "virtio_pci: support the arg sizes of find_vqs()"
This reverts commit cdb4480: 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 <[email protected]> Fixes: cdb4480 ("virtio_pci: support the arg sizes of find_vqs()") Signed-off-by: Michael S. Tsirkin <[email protected]> Message-Id: <[email protected]>
1 parent c62f61b commit 13aa8c6

File tree

4 files changed

+12
-23
lines changed

4 files changed

+12
-23
lines changed

drivers/virtio/virtio_pci_common.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
174174
static struct virtqueue *vp_setup_vq(struct virtio_device *vdev, unsigned int index,
175175
void (*callback)(struct virtqueue *vq),
176176
const char *name,
177-
u32 size,
178177
bool ctx,
179178
u16 msix_vec)
180179
{
@@ -187,7 +186,7 @@ static struct virtqueue *vp_setup_vq(struct virtio_device *vdev, unsigned int in
187186
if (!info)
188187
return ERR_PTR(-ENOMEM);
189188

190-
vq = vp_dev->setup_vq(vp_dev, info, index, callback, name, size, ctx,
189+
vq = vp_dev->setup_vq(vp_dev, info, index, callback, name, ctx,
191190
msix_vec);
192191
if (IS_ERR(vq))
193192
goto out_info;
@@ -284,7 +283,7 @@ void vp_del_vqs(struct virtio_device *vdev)
284283

285284
static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned int nvqs,
286285
struct virtqueue *vqs[], vq_callback_t *callbacks[],
287-
const char * const names[], u32 sizes[], bool per_vq_vectors,
286+
const char * const names[], bool per_vq_vectors,
288287
const bool *ctx,
289288
struct irq_affinity *desc)
290289
{
@@ -327,8 +326,8 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned int nvqs,
327326
else
328327
msix_vec = VP_MSIX_VQ_VECTOR;
329328
vqs[i] = vp_setup_vq(vdev, queue_idx++, callbacks[i], names[i],
330-
sizes ? sizes[i] : 0,
331-
ctx ? ctx[i] : false, msix_vec);
329+
ctx ? ctx[i] : false,
330+
msix_vec);
332331
if (IS_ERR(vqs[i])) {
333332
err = PTR_ERR(vqs[i]);
334333
goto error_find;
@@ -358,7 +357,7 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned int nvqs,
358357

359358
static int vp_find_vqs_intx(struct virtio_device *vdev, unsigned int nvqs,
360359
struct virtqueue *vqs[], vq_callback_t *callbacks[],
361-
const char * const names[], u32 sizes[], const bool *ctx)
360+
const char * const names[], const bool *ctx)
362361
{
363362
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
364363
int i, err, queue_idx = 0;
@@ -380,7 +379,6 @@ static int vp_find_vqs_intx(struct virtio_device *vdev, unsigned int nvqs,
380379
continue;
381380
}
382381
vqs[i] = vp_setup_vq(vdev, queue_idx++, callbacks[i], names[i],
383-
sizes ? sizes[i] : 0,
384382
ctx ? ctx[i] : false,
385383
VIRTIO_MSI_NO_VECTOR);
386384
if (IS_ERR(vqs[i])) {
@@ -404,15 +402,15 @@ int vp_find_vqs(struct virtio_device *vdev, unsigned int nvqs,
404402
int err;
405403

406404
/* Try MSI-X with one vector per queue. */
407-
err = vp_find_vqs_msix(vdev, nvqs, vqs, callbacks, names, sizes, true, ctx, desc);
405+
err = vp_find_vqs_msix(vdev, nvqs, vqs, callbacks, names, true, ctx, desc);
408406
if (!err)
409407
return 0;
410408
/* Fallback: MSI-X with one vector for config, one shared for queues. */
411-
err = vp_find_vqs_msix(vdev, nvqs, vqs, callbacks, names, sizes, false, ctx, desc);
409+
err = vp_find_vqs_msix(vdev, nvqs, vqs, callbacks, names, false, ctx, desc);
412410
if (!err)
413411
return 0;
414412
/* Finally fall back to regular interrupts. */
415-
return vp_find_vqs_intx(vdev, nvqs, vqs, callbacks, names, sizes, ctx);
413+
return vp_find_vqs_intx(vdev, nvqs, vqs, callbacks, names, ctx);
416414
}
417415

418416
const char *vp_bus_name(struct virtio_device *vdev)

drivers/virtio/virtio_pci_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ struct virtio_pci_device {
8080
unsigned int idx,
8181
void (*callback)(struct virtqueue *vq),
8282
const char *name,
83-
u32 size,
8483
bool ctx,
8584
u16 msix_vec);
8685
void (*del_vq)(struct virtio_pci_vq_info *info);

drivers/virtio/virtio_pci_legacy.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
112112
unsigned int index,
113113
void (*callback)(struct virtqueue *vq),
114114
const char *name,
115-
u32 size,
116115
bool ctx,
117116
u16 msix_vec)
118117
{
@@ -126,13 +125,10 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
126125
if (!num || vp_legacy_get_queue_enable(&vp_dev->ldev, index))
127126
return ERR_PTR(-ENOENT);
128127

129-
if (!size || size > num)
130-
size = num;
131-
132128
info->msix_vector = msix_vec;
133129

134130
/* create the vring */
135-
vq = vring_create_virtqueue(index, size,
131+
vq = vring_create_virtqueue(index, num,
136132
VIRTIO_PCI_VRING_ALIGN, &vp_dev->vdev,
137133
true, false, ctx,
138134
vp_notify, callback, name);

drivers/virtio/virtio_pci_modern.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
293293
unsigned int index,
294294
void (*callback)(struct virtqueue *vq),
295295
const char *name,
296-
u32 size,
297296
bool ctx,
298297
u16 msix_vec)
299298
{
@@ -311,18 +310,15 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
311310
if (!num || vp_modern_get_queue_enable(mdev, index))
312311
return ERR_PTR(-ENOENT);
313312

314-
if (!size || size > num)
315-
size = num;
316-
317-
if (size & (size - 1)) {
318-
dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", size);
313+
if (num & (num - 1)) {
314+
dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", num);
319315
return ERR_PTR(-EINVAL);
320316
}
321317

322318
info->msix_vector = msix_vec;
323319

324320
/* create the vring */
325-
vq = vring_create_virtqueue(index, size,
321+
vq = vring_create_virtqueue(index, num,
326322
SMP_CACHE_BYTES, &vp_dev->vdev,
327323
true, true, ctx,
328324
vp_notify, callback, name);

0 commit comments

Comments
 (0)