Skip to content

Commit 99e8927

Browse files
Bo Liumstsirkin
authored andcommitted
virtio_vdpa: support the arg sizes of find_vqs()
Virtio vdpa support the new parameter sizes of find_vqs(). Signed-off-by: Bo Liu <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent ebe6a35 commit 99e8927

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/virtio/virtio_vdpa.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static irqreturn_t virtio_vdpa_virtqueue_cb(void *private)
131131
static struct virtqueue *
132132
virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
133133
void (*callback)(struct virtqueue *vq),
134-
const char *name, bool ctx)
134+
const char *name, u32 size, bool ctx)
135135
{
136136
struct virtio_vdpa_device *vd_dev = to_virtio_vdpa_device(vdev);
137137
struct vdpa_device *vdpa = vd_get_vdpa(vdev);
@@ -168,14 +168,17 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
168168
goto error_new_virtqueue;
169169
}
170170

171+
if (!size || size > max_num)
172+
size = max_num;
173+
171174
if (ops->get_vq_num_min)
172175
min_num = ops->get_vq_num_min(vdpa);
173176

174-
may_reduce_num = (max_num == min_num) ? false : true;
177+
may_reduce_num = (size == min_num) ? false : true;
175178

176179
/* Create the vring */
177180
align = ops->get_vq_align(vdpa);
178-
vq = vring_create_virtqueue(index, max_num, align, vdev,
181+
vq = vring_create_virtqueue(index, size, align, vdev,
179182
true, may_reduce_num, ctx,
180183
virtio_vdpa_notify, callback, name);
181184
if (!vq) {
@@ -285,9 +288,9 @@ static int virtio_vdpa_find_vqs(struct virtio_device *vdev, unsigned int nvqs,
285288
continue;
286289
}
287290

288-
vqs[i] = virtio_vdpa_setup_vq(vdev, queue_idx++,
289-
callbacks[i], names[i], ctx ?
290-
ctx[i] : false);
291+
vqs[i] = virtio_vdpa_setup_vq(vdev, queue_idx++, callbacks[i],
292+
names[i], sizes ? sizes[i] : 0,
293+
ctx ? ctx[i] : false);
291294
if (IS_ERR(vqs[i])) {
292295
err = PTR_ERR(vqs[i]);
293296
goto err_setup_vq;

0 commit comments

Comments
 (0)