Blame SOURCES/kvm-vhost-vdpa-change-name-and-polarity-for-vhost_vdpa_o.patch

24c150
From 0074686ee2de7ffb06b4eb2f9c14a2f7dcea248b Mon Sep 17 00:00:00 2001
24c150
From: Si-Wei Liu <si-wei.liu@oracle.com>
24c150
Date: Fri, 6 May 2022 19:28:17 -0700
24c150
Subject: [PATCH 6/7] vhost-vdpa: change name and polarity for
24c150
 vhost_vdpa_one_time_request()
24c150
MIME-Version: 1.0
24c150
Content-Type: text/plain; charset=UTF-8
24c150
Content-Transfer-Encoding: 8bit
24c150
24c150
RH-Author: Cindy Lu <lulu@redhat.com>
24c150
RH-MergeRequest: 204: vdpa :sync the Multiqueue fixes for vhost-vDPA
24c150
RH-Commit: [6/7] 9cc673a62032fdf8c84e3d82ff504ae4f4100ecf
24c150
RH-Bugzilla: 2095795
24c150
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
24c150
RH-Acked-by: Eugenio PĂ©rez <eperezma@redhat.com>
24c150
RH-Acked-by: Jason Wang <jasowang@redhat.com>
24c150
24c150
The name vhost_vdpa_one_time_request() was confusing. No
24c150
matter whatever it returns, its typical occurrence had
24c150
always been at requests that only need to be applied once.
24c150
And the name didn't suggest what it actually checks for.
24c150
Change it to vhost_vdpa_first_dev() with polarity flipped
24c150
for better readibility of code. That way it is able to
24c150
reflect what the check is really about.
24c150
24c150
This call is applicable to request which performs operation
24c150
only once, before queues are set up, and usually at the beginning
24c150
of the caller function. Document the requirement for it in place.
24c150
24c150
Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
24c150
Message-Id: <1651890498-24478-7-git-send-email-si-wei.liu@oracle.com>
24c150
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24c150
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
24c150
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
24c150
Acked-by: Jason Wang <jasowang@redhat.com>
24c150
(cherry picked from commit d71b0609fc04217e28d17009f04d74b08be6f466)
24c150
Signed-off-by: Cindy Lu <lulu@redhat.com>
24c150
---
24c150
 hw/virtio/vhost-vdpa.c | 23 +++++++++++++++--------
24c150
 1 file changed, 15 insertions(+), 8 deletions(-)
24c150
24c150
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
24c150
index a9be24776a..38bbcb3c18 100644
24c150
--- a/hw/virtio/vhost-vdpa.c
24c150
+++ b/hw/virtio/vhost-vdpa.c
24c150
@@ -319,11 +319,18 @@ static void vhost_vdpa_get_iova_range(struct vhost_vdpa *v)
24c150
                                     v->iova_range.last);
24c150
 }
24c150
 
24c150
-static bool vhost_vdpa_one_time_request(struct vhost_dev *dev)
24c150
+/*
24c150
+ * The use of this function is for requests that only need to be
24c150
+ * applied once. Typically such request occurs at the beginning
24c150
+ * of operation, and before setting up queues. It should not be
24c150
+ * used for request that performs operation until all queues are
24c150
+ * set, which would need to check dev->vq_index_end instead.
24c150
+ */
24c150
+static bool vhost_vdpa_first_dev(struct vhost_dev *dev)
24c150
 {
24c150
     struct vhost_vdpa *v = dev->opaque;
24c150
 
24c150
-    return v->index != 0;
24c150
+    return v->index == 0;
24c150
 }
24c150
 
24c150
 static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
24c150
@@ -351,7 +358,7 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
24c150
 
24c150
     vhost_vdpa_get_iova_range(v);
24c150
 
24c150
-    if (vhost_vdpa_one_time_request(dev)) {
24c150
+    if (!vhost_vdpa_first_dev(dev)) {
24c150
         return 0;
24c150
     }
24c150
 
24c150
@@ -468,7 +475,7 @@ static int vhost_vdpa_memslots_limit(struct vhost_dev *dev)
24c150
 static int vhost_vdpa_set_mem_table(struct vhost_dev *dev,
24c150
                                     struct vhost_memory *mem)
24c150
 {
24c150
-    if (vhost_vdpa_one_time_request(dev)) {
24c150
+    if (!vhost_vdpa_first_dev(dev)) {
24c150
         return 0;
24c150
     }
24c150
 
24c150
@@ -496,7 +503,7 @@ static int vhost_vdpa_set_features(struct vhost_dev *dev,
24c150
 {
24c150
     int ret;
24c150
 
24c150
-    if (vhost_vdpa_one_time_request(dev)) {
24c150
+    if (!vhost_vdpa_first_dev(dev)) {
24c150
         return 0;
24c150
     }
24c150
 
24c150
@@ -525,7 +532,7 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev)
24c150
 
24c150
     features &= f;
24c150
 
24c150
-    if (!vhost_vdpa_one_time_request(dev)) {
24c150
+    if (vhost_vdpa_first_dev(dev)) {
24c150
         r = vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features);
24c150
         if (r) {
24c150
             return -EFAULT;
24c150
@@ -670,7 +677,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)
24c150
 static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base,
24c150
                                      struct vhost_log *log)
24c150
 {
24c150
-    if (vhost_vdpa_one_time_request(dev)) {
24c150
+    if (!vhost_vdpa_first_dev(dev)) {
24c150
         return 0;
24c150
     }
24c150
 
24c150
@@ -739,7 +746,7 @@ static int vhost_vdpa_get_features(struct vhost_dev *dev,
24c150
 
24c150
 static int vhost_vdpa_set_owner(struct vhost_dev *dev)
24c150
 {
24c150
-    if (vhost_vdpa_one_time_request(dev)) {
24c150
+    if (!vhost_vdpa_first_dev(dev)) {
24c150
         return 0;
24c150
     }
24c150
 
24c150
-- 
24c150
2.31.1
24c150