Commit a6da214b authored by Jiri Pirko's avatar Jiri Pirko Committed by Michael S. Tsirkin

scsi: virtio_scsi: convert to use virtio_find_vqs_info()

Instead of passing separate names and callbacks arrays
to virtio_find_vqs(), allocate one of virtual_queue_info structs and
pass it to virtio_find_vqs_info().
Suggested-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Message-Id: <20240708074814.1739223-15-jiri@resnulli.us>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent c2c6325e
......@@ -841,19 +841,16 @@ static int virtscsi_init(struct virtio_device *vdev,
int err;
u32 i;
u32 num_vqs, num_poll_vqs, num_req_vqs;
vq_callback_t **callbacks;
const char **names;
struct virtqueue_info *vqs_info;
struct virtqueue **vqs;
struct irq_affinity desc = { .pre_vectors = 2 };
num_req_vqs = vscsi->num_queues;
num_vqs = num_req_vqs + VIRTIO_SCSI_VQ_BASE;
vqs = kmalloc_array(num_vqs, sizeof(struct virtqueue *), GFP_KERNEL);
callbacks = kmalloc_array(num_vqs, sizeof(vq_callback_t *),
GFP_KERNEL);
names = kmalloc_array(num_vqs, sizeof(char *), GFP_KERNEL);
vqs_info = kcalloc(num_vqs, sizeof(*vqs_info), GFP_KERNEL);
if (!callbacks || !vqs || !names) {
if (!vqs || !vqs_info) {
err = -ENOMEM;
goto out;
}
......@@ -869,22 +866,20 @@ static int virtscsi_init(struct virtio_device *vdev,
vscsi->io_queues[HCTX_TYPE_READ],
vscsi->io_queues[HCTX_TYPE_POLL]);
callbacks[0] = virtscsi_ctrl_done;
callbacks[1] = virtscsi_event_done;
names[0] = "control";
names[1] = "event";
vqs_info[0].callback = virtscsi_ctrl_done;
vqs_info[0].name = "control";
vqs_info[1].callback = virtscsi_event_done;
vqs_info[1].name = "event";
for (i = VIRTIO_SCSI_VQ_BASE; i < num_vqs - num_poll_vqs; i++) {
callbacks[i] = virtscsi_req_done;
names[i] = "request";
vqs_info[i].callback = virtscsi_req_done;
vqs_info[i].name = "request";
}
for (; i < num_vqs; i++) {
callbacks[i] = NULL;
names[i] = "request_poll";
}
for (; i < num_vqs; i++)
vqs_info[i].name = "request_poll";
/* Discover virtqueues and write information to configuration. */
err = virtio_find_vqs(vdev, num_vqs, vqs, callbacks, names, &desc);
err = virtio_find_vqs_info(vdev, num_vqs, vqs, vqs_info, &desc);
if (err)
goto out;
......@@ -900,8 +895,7 @@ static int virtscsi_init(struct virtio_device *vdev,
err = 0;
out:
kfree(names);
kfree(callbacks);
kfree(vqs_info);
kfree(vqs);
if (err)
virtscsi_remove_vqs(vdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment