|
|
a83cc2 |
From 0ca53acb7ee0a3b3b72685f47df1fb2466989d6c Mon Sep 17 00:00:00 2001
|
|
|
a83cc2 |
From: Greg Kurz <groug@kaod.org>
|
|
|
a83cc2 |
Date: Wed, 26 May 2021 09:03:53 -0400
|
|
|
a83cc2 |
Subject: [PATCH 13/15] virtio-scsi: Set host notifiers and callbacks
|
|
|
a83cc2 |
separately
|
|
|
a83cc2 |
|
|
|
a83cc2 |
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a83cc2 |
RH-MergeRequest: 5: Synchronize RHEL-AV 8.5 release 18 to RHEL 9 Beta
|
|
|
a83cc2 |
RH-Commit: [10/12] 61f873b494c52dc34eb60a705046bfead08532da (mrezanin/centos-src-qemu-kvm)
|
|
|
a83cc2 |
RH-Bugzilla: 1957194
|
|
|
a83cc2 |
RH-Acked-by: Danilo Cesar Lemes de Paula <ddepaula@redhat.com>
|
|
|
a83cc2 |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
a83cc2 |
RH-Acked-by: Greg Kurz <gkurz@redhat.com>
|
|
|
a83cc2 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Host notifiers are guaranteed to be idle until the callbacks are
|
|
|
a83cc2 |
hooked up with virtio_queue_aio_set_host_notifier_handler(). They
|
|
|
a83cc2 |
thus don't need to be set or unset with the AioContext lock held.
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Do this outside the critical section, like virtio-blk already
|
|
|
a83cc2 |
does : basically downgrading virtio_scsi_vring_init() to only
|
|
|
a83cc2 |
setup the host notifier and set the callback in the caller.
|
|
|
a83cc2 |
|
|
|
a83cc2 |
This will allow to batch addition/deletion of ioeventds in
|
|
|
a83cc2 |
a single memory transaction, which is expected to greatly
|
|
|
a83cc2 |
improve initialization time.
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Signed-off-by: Greg Kurz <groug@kaod.org>
|
|
|
a83cc2 |
Message-Id: <20210407143501.244343-4-groug@kaod.org>
|
|
|
a83cc2 |
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
a83cc2 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
a83cc2 |
(cherry picked from commit 61fc57bfc464c3584bd7ab810c86833661f0188c)
|
|
|
a83cc2 |
Signed-off-by: Greg Kurz <gkurz@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a83cc2 |
---
|
|
|
a83cc2 |
hw/scsi/virtio-scsi-dataplane.c | 40 ++++++++++++++++++---------------
|
|
|
a83cc2 |
1 file changed, 22 insertions(+), 18 deletions(-)
|
|
|
a83cc2 |
|
|
|
a83cc2 |
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
|
|
|
a83cc2 |
index 4ad8793406..b2cb3d9dcc 100644
|
|
|
a83cc2 |
--- a/hw/scsi/virtio-scsi-dataplane.c
|
|
|
a83cc2 |
+++ b/hw/scsi/virtio-scsi-dataplane.c
|
|
|
a83cc2 |
@@ -94,8 +94,7 @@ static bool virtio_scsi_data_plane_handle_event(VirtIODevice *vdev,
|
|
|
a83cc2 |
return progress;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
|
|
|
a83cc2 |
-static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n,
|
|
|
a83cc2 |
- VirtIOHandleAIOOutput fn)
|
|
|
a83cc2 |
+static int virtio_scsi_set_host_notifier(VirtIOSCSI *s, VirtQueue *vq, int n)
|
|
|
a83cc2 |
{
|
|
|
a83cc2 |
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
|
|
|
a83cc2 |
int rc;
|
|
|
a83cc2 |
@@ -109,7 +108,6 @@ static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n,
|
|
|
a83cc2 |
return rc;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
|
|
|
a83cc2 |
- virtio_queue_aio_set_host_notifier_handler(vq, s->ctx, fn);
|
|
|
a83cc2 |
return 0;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
|
|
|
a83cc2 |
@@ -154,38 +152,44 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
|
|
|
a83cc2 |
goto fail_guest_notifiers;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
|
|
|
a83cc2 |
- aio_context_acquire(s->ctx);
|
|
|
a83cc2 |
- rc = virtio_scsi_vring_init(s, vs->ctrl_vq, 0,
|
|
|
a83cc2 |
- virtio_scsi_data_plane_handle_ctrl);
|
|
|
a83cc2 |
- if (rc) {
|
|
|
a83cc2 |
- goto fail_vrings;
|
|
|
a83cc2 |
+ rc = virtio_scsi_set_host_notifier(s, vs->ctrl_vq, 0);
|
|
|
a83cc2 |
+ if (rc != 0) {
|
|
|
a83cc2 |
+ goto fail_host_notifiers;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
|
|
|
a83cc2 |
vq_init_count++;
|
|
|
a83cc2 |
- rc = virtio_scsi_vring_init(s, vs->event_vq, 1,
|
|
|
a83cc2 |
- virtio_scsi_data_plane_handle_event);
|
|
|
a83cc2 |
- if (rc) {
|
|
|
a83cc2 |
- goto fail_vrings;
|
|
|
a83cc2 |
+ rc = virtio_scsi_set_host_notifier(s, vs->event_vq, 1);
|
|
|
a83cc2 |
+ if (rc != 0) {
|
|
|
a83cc2 |
+ goto fail_host_notifiers;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
|
|
|
a83cc2 |
vq_init_count++;
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
for (i = 0; i < vs->conf.num_queues; i++) {
|
|
|
a83cc2 |
- rc = virtio_scsi_vring_init(s, vs->cmd_vqs[i], i + 2,
|
|
|
a83cc2 |
- virtio_scsi_data_plane_handle_cmd);
|
|
|
a83cc2 |
+ rc = virtio_scsi_set_host_notifier(s, vs->cmd_vqs[i], i + 2);
|
|
|
a83cc2 |
if (rc) {
|
|
|
a83cc2 |
- goto fail_vrings;
|
|
|
a83cc2 |
+ goto fail_host_notifiers;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
vq_init_count++;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
|
|
|
a83cc2 |
+ aio_context_acquire(s->ctx);
|
|
|
a83cc2 |
+ virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx,
|
|
|
a83cc2 |
+ virtio_scsi_data_plane_handle_ctrl);
|
|
|
a83cc2 |
+ virtio_queue_aio_set_host_notifier_handler(vs->event_vq, s->ctx,
|
|
|
a83cc2 |
+ virtio_scsi_data_plane_handle_event);
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
+ for (i = 0; i < vs->conf.num_queues; i++) {
|
|
|
a83cc2 |
+ virtio_queue_aio_set_host_notifier_handler(vs->cmd_vqs[i], s->ctx,
|
|
|
a83cc2 |
+ virtio_scsi_data_plane_handle_cmd);
|
|
|
a83cc2 |
+ }
|
|
|
a83cc2 |
+
|
|
|
a83cc2 |
s->dataplane_starting = false;
|
|
|
a83cc2 |
s->dataplane_started = true;
|
|
|
a83cc2 |
aio_context_release(s->ctx);
|
|
|
a83cc2 |
return 0;
|
|
|
a83cc2 |
|
|
|
a83cc2 |
-fail_vrings:
|
|
|
a83cc2 |
- aio_wait_bh_oneshot(s->ctx, virtio_scsi_dataplane_stop_bh, s);
|
|
|
a83cc2 |
- aio_context_release(s->ctx);
|
|
|
a83cc2 |
+fail_host_notifiers:
|
|
|
a83cc2 |
for (i = 0; i < vq_init_count; i++) {
|
|
|
a83cc2 |
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
|
|
|
a83cc2 |
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
|
|
|
a83cc2 |
--
|
|
|
a83cc2 |
2.27.0
|
|
|
a83cc2 |
|