diff options
author | Jean-Philippe Brucker <jean-philippe@linaro.org> | 2023-06-06 14:04:14 +0100 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2023-06-08 22:39:03 +0100 |
commit | 13e7d626e00fb723b9f469b7b5bc12193dba9835 (patch) | |
tree | 3d327e406a216d803dbe09da89364758f8bfd3ed | |
parent | 029cd2bb789837641aad4b43b6370ff0fecfca28 (diff) | |
download | kvmtool-13e7d626e00fb723b9f469b7b5bc12193dba9835.tar.gz |
virtio/scsi: Move VHOST_SCSI_SET_ENDPOINT to device start
The vhost driver expects virtqueues to be operational by the time we
call SET_ENDPOINT. We currently do it too early. Device start, which
happens when the driver writes the DRIVER_OK status, is a good time to
do this.
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Link: https://lore.kernel.org/r/20230606130426.978945-6-jean-philippe@linaro.org
Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r-- | virtio/scsi.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/virtio/scsi.c b/virtio/scsi.c index 708fb23a..8249a9cd 100644 --- a/virtio/scsi.c +++ b/virtio/scsi.c @@ -57,6 +57,13 @@ static void notify_status(struct kvm *kvm, void *dev, u32 status) struct virtio_scsi_config *conf = &sdev->config; u16 endian = vdev->endian; + if (status & VIRTIO__STATUS_START) { + int r = ioctl(sdev->vhost_fd, VHOST_SCSI_SET_ENDPOINT, + &sdev->target); + if (r != 0) + die("VHOST_SCSI_SET_ENDPOINT failed %d", errno); + } + if (!(status & VIRTIO__STATUS_CONFIG)) return; @@ -91,20 +98,12 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq) static void notify_vq_gsi(struct kvm *kvm, void *dev, u32 vq, u32 gsi) { struct scsi_dev *sdev = dev; - int r; if (sdev->vhost_fd == 0) return; virtio_vhost_set_vring_call(kvm, sdev->vhost_fd, vq, gsi, &sdev->vqs[vq]); - - if (vq > 0) - return; - - r = ioctl(sdev->vhost_fd, VHOST_SCSI_SET_ENDPOINT, &sdev->target); - if (r != 0) - die("VHOST_SCSI_SET_ENDPOINT failed %d", errno); } static void notify_vq_eventfd(struct kvm *kvm, void *dev, u32 vq, u32 efd) |