thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ed5979
From 63a45add7c9f7bb2b7775ae4cb2d7df22f7f2033 Mon Sep 17 00:00:00 2001
ed5979
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
ed5979
Date: Thu, 15 Dec 2022 12:31:39 +0100
ed5979
Subject: [PATCH 07/14] vdpa: move SVQ vring features check to net/
ed5979
MIME-Version: 1.0
ed5979
Content-Type: text/plain; charset=UTF-8
ed5979
Content-Transfer-Encoding: 8bit
ed5979
ed5979
RH-Author: Eugenio Pérez <eperezma@redhat.com>
ed5979
RH-MergeRequest: 136: vDPA ASID support in Qemu
ed5979
RH-Bugzilla: 2104412
ed5979
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
ed5979
RH-Acked-by: Cindy Lu <lulu@redhat.com>
ed5979
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
ed5979
RH-Commit: [7/13] a24189aea4dbde3ed4486f685d0d88aeee1a0ee7 (eperezmartin/qemu-kvm)
ed5979
ed5979
The next patches will start control SVQ if possible. However, we don't
ed5979
know if that will be possible at qemu boot anymore.
ed5979
ed5979
Since the moved checks will be already evaluated at net/ to know if it
ed5979
is ok to shadow CVQ, move them.
ed5979
ed5979
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
ed5979
Acked-by: Jason Wang <jasowang@redhat.com>
ed5979
Message-Id: <20221215113144.322011-8-eperezma@redhat.com>
ed5979
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
ed5979
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
ed5979
(cherry picked from commit 258a03941fd23108a322d09abc9c55341e09688d)
ed5979
---
ed5979
 hw/virtio/vhost-vdpa.c | 32 ++------------------------------
ed5979
 net/vhost-vdpa.c       |  3 ++-
ed5979
 2 files changed, 4 insertions(+), 31 deletions(-)
ed5979
ed5979
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
ed5979
index 9e7cbf1776..84218ce078 100644
ed5979
--- a/hw/virtio/vhost-vdpa.c
ed5979
+++ b/hw/virtio/vhost-vdpa.c
ed5979
@@ -389,29 +389,9 @@ static int vhost_vdpa_get_dev_features(struct vhost_dev *dev,
ed5979
     return ret;
ed5979
 }
ed5979
 
ed5979
-static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v,
ed5979
-                               Error **errp)
ed5979
+static void vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v)
ed5979
 {
ed5979
     g_autoptr(GPtrArray) shadow_vqs = NULL;
ed5979
-    uint64_t dev_features, svq_features;
ed5979
-    int r;
ed5979
-    bool ok;
ed5979
-
ed5979
-    if (!v->shadow_vqs_enabled) {
ed5979
-        return 0;
ed5979
-    }
ed5979
-
ed5979
-    r = vhost_vdpa_get_dev_features(hdev, &dev_features);
ed5979
-    if (r != 0) {
ed5979
-        error_setg_errno(errp, -r, "Can't get vdpa device features");
ed5979
-        return r;
ed5979
-    }
ed5979
-
ed5979
-    svq_features = dev_features;
ed5979
-    ok = vhost_svq_valid_features(svq_features, errp);
ed5979
-    if (unlikely(!ok)) {
ed5979
-        return -1;
ed5979
-    }
ed5979
 
ed5979
     shadow_vqs = g_ptr_array_new_full(hdev->nvqs, vhost_svq_free);
ed5979
     for (unsigned n = 0; n < hdev->nvqs; ++n) {
ed5979
@@ -422,7 +402,6 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v,
ed5979
     }
ed5979
 
ed5979
     v->shadow_vqs = g_steal_pointer(&shadow_vqs);
ed5979
-    return 0;
ed5979
 }
ed5979
 
ed5979
 static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
ed5979
@@ -447,10 +426,7 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
ed5979
     dev->opaque =  opaque ;
ed5979
     v->listener = vhost_vdpa_memory_listener;
ed5979
     v->msg_type = VHOST_IOTLB_MSG_V2;
ed5979
-    ret = vhost_vdpa_init_svq(dev, v, errp);
ed5979
-    if (ret) {
ed5979
-        goto err;
ed5979
-    }
ed5979
+    vhost_vdpa_init_svq(dev, v);
ed5979
 
ed5979
     if (!vhost_vdpa_first_dev(dev)) {
ed5979
         return 0;
ed5979
@@ -460,10 +436,6 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
ed5979
                                VIRTIO_CONFIG_S_DRIVER);
ed5979
 
ed5979
     return 0;
ed5979
-
ed5979
-err:
ed5979
-    ram_block_discard_disable(false);
ed5979
-    return ret;
ed5979
 }
ed5979
 
ed5979
 static void vhost_vdpa_host_notifier_uninit(struct vhost_dev *dev,
ed5979
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
ed5979
index 8d3ed095d0..85aa0da39a 100644
ed5979
--- a/net/vhost-vdpa.c
ed5979
+++ b/net/vhost-vdpa.c
ed5979
@@ -117,9 +117,10 @@ static bool vhost_vdpa_net_valid_svq_features(uint64_t features, Error **errp)
ed5979
     if (invalid_dev_features) {
ed5979
         error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64,
ed5979
                    invalid_dev_features);
ed5979
+        return false;
ed5979
     }
ed5979
 
ed5979
-    return !invalid_dev_features;
ed5979
+    return vhost_svq_valid_features(features, errp);
ed5979
 }
ed5979
 
ed5979
 static int vhost_vdpa_net_check_device_id(struct vhost_net *net)
ed5979
-- 
ed5979
2.31.1
ed5979