105 lines
3.8 KiB
Diff
105 lines
3.8 KiB
Diff
|
|
From f5d338d28758db5066f199c35d56e0953edcc5d9 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Longpeng <longpeng2@huawei.com>
|
||
|
|
Date: Sat, 24 Dec 2022 19:48:47 +0800
|
||
|
|
Subject: [PATCH] vdpa-dev: get iova range explicitly
|
||
|
|
|
||
|
|
In commit a585fad26b ("vdpa: request iova_range only once") we remove
|
||
|
|
GET_IOVA_RANGE form vhost_vdpa_init, the generic vdpa device will start
|
||
|
|
without iova_range populated, so the device won't work. Let's call
|
||
|
|
GET_IOVA_RANGE ioctl explicitly.
|
||
|
|
|
||
|
|
Fixes: a585fad26b2e6ccc ("vdpa: request iova_range only once")
|
||
|
|
Signed-off-by: Longpeng <longpeng2@huawei.com>
|
||
|
|
Message-Id: <20221224114848.3062-2-longpeng2@huawei.com>
|
||
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||
|
|
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||
|
|
Acked-by: Jason Wang <jasowang@redhat.com>
|
||
|
|
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
||
|
|
---
|
||
|
|
hw/virtio/vdpa-dev.c | 9 +++++++++
|
||
|
|
hw/virtio/vhost-vdpa.c | 7 +++++++
|
||
|
|
include/hw/virtio/vhost-vdpa.h | 2 ++
|
||
|
|
net/vhost-vdpa.c | 8 --------
|
||
|
|
4 files changed, 18 insertions(+), 8 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c
|
||
|
|
index 465b08c0e3..254a213117 100644
|
||
|
|
--- a/hw/virtio/vdpa-dev.c
|
||
|
|
+++ b/hw/virtio/vdpa-dev.c
|
||
|
|
@@ -53,6 +53,7 @@ static void vhost_vdpa_device_realize(DeviceState *dev, Error **errp)
|
||
|
|
{
|
||
|
|
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
|
||
|
|
VhostVdpaDevice *v = VHOST_VDPA_DEVICE(vdev);
|
||
|
|
+ struct vhost_vdpa_iova_range iova_range;
|
||
|
|
uint16_t max_queue_size;
|
||
|
|
struct vhost_virtqueue *vqs;
|
||
|
|
int i, ret;
|
||
|
|
@@ -108,6 +109,14 @@ static void vhost_vdpa_device_realize(DeviceState *dev, Error **errp)
|
||
|
|
v->dev.backend_features = 0;
|
||
|
|
v->started = false;
|
||
|
|
|
||
|
|
+ ret = vhost_vdpa_get_iova_range(v->vhostfd, &iova_range);
|
||
|
|
+ if (ret < 0) {
|
||
|
|
+ error_setg(errp, "vhost-vdpa-device: get iova range failed: %s",
|
||
|
|
+ strerror(-ret));
|
||
|
|
+ goto free_vqs;
|
||
|
|
+ }
|
||
|
|
+ v->vdpa.iova_range = iova_range;
|
||
|
|
+
|
||
|
|
ret = vhost_dev_init(&v->dev, &v->vdpa, VHOST_BACKEND_TYPE_VDPA, 0, NULL);
|
||
|
|
if (ret < 0) {
|
||
|
|
error_setg(errp, "vhost-vdpa-device: vhost initialization failed: %s",
|
||
|
|
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
|
||
|
|
index c9289e2c01..f93fac538c 100644
|
||
|
|
--- a/hw/virtio/vhost-vdpa.c
|
||
|
|
+++ b/hw/virtio/vhost-vdpa.c
|
||
|
|
@@ -380,6 +380,13 @@ static int vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status)
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
+int vhost_vdpa_get_iova_range(int fd, struct vhost_vdpa_iova_range *iova_range)
|
||
|
|
+{
|
||
|
|
+ int ret = ioctl(fd, VHOST_VDPA_GET_IOVA_RANGE, iova_range);
|
||
|
|
+
|
||
|
|
+ return ret < 0 ? -errno : 0;
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
/*
|
||
|
|
* The use of this function is for requests that only need to be
|
||
|
|
* applied once. Typically such request occurs at the beginning
|
||
|
|
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
|
||
|
|
index 45b969a311..7997f09a8d 100644
|
||
|
|
--- a/include/hw/virtio/vhost-vdpa.h
|
||
|
|
+++ b/include/hw/virtio/vhost-vdpa.h
|
||
|
|
@@ -51,6 +51,8 @@ typedef struct vhost_vdpa {
|
||
|
|
VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX];
|
||
|
|
} VhostVDPA;
|
||
|
|
|
||
|
|
+int vhost_vdpa_get_iova_range(int fd, struct vhost_vdpa_iova_range *iova_range);
|
||
|
|
+
|
||
|
|
int vhost_vdpa_dma_map(struct vhost_vdpa *v, uint32_t asid, hwaddr iova,
|
||
|
|
hwaddr size, void *vaddr, bool readonly);
|
||
|
|
int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, uint32_t asid, hwaddr iova,
|
||
|
|
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
|
||
|
|
index 3dcf341722..3c370f2dc5 100644
|
||
|
|
--- a/net/vhost-vdpa.c
|
||
|
|
+++ b/net/vhost-vdpa.c
|
||
|
|
@@ -717,14 +717,6 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
|
||
|
|
return nc;
|
||
|
|
}
|
||
|
|
|
||
|
|
-static int vhost_vdpa_get_iova_range(int fd,
|
||
|
|
- struct vhost_vdpa_iova_range *iova_range)
|
||
|
|
-{
|
||
|
|
- int ret = ioctl(fd, VHOST_VDPA_GET_IOVA_RANGE, iova_range);
|
||
|
|
-
|
||
|
|
- return ret < 0 ? -errno : 0;
|
||
|
|
-}
|
||
|
|
-
|
||
|
|
static int vhost_vdpa_get_features(int fd, uint64_t *features, Error **errp)
|
||
|
|
{
|
||
|
|
int ret = ioctl(fd, VHOST_GET_FEATURES, features);
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|