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

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