586cba
From 8e36feb4d3480b7c09d9dcbde18c9db1e8063f18 Mon Sep 17 00:00:00 2001
586cba
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
586cba
Date: Tue, 23 Aug 2022 20:20:06 +0200
586cba
Subject: [PATCH 08/23] vdpa: Make SVQ vring unmapping return void
586cba
MIME-Version: 1.0
586cba
Content-Type: text/plain; charset=UTF-8
586cba
Content-Transfer-Encoding: 8bit
586cba
586cba
RH-Author: Eugenio Pérez <eperezma@redhat.com>
586cba
RH-MergeRequest: 116: vdpa: Restore device state on destination
586cba
RH-Bugzilla: 2114060
586cba
RH-Acked-by: Cindy Lu <lulu@redhat.com>
586cba
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
586cba
RH-Commit: [7/21] 3366340dc7ae65f83894f5d0da0d1e0f64713751 (eperezmartin/qemu-kvm)
586cba
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2114060
586cba
Upstream status: git@github.com:jasowang/qemu.git net-next
586cba
586cba
Nothing actually reads the return value, but an error in cleaning some
586cba
entries could cause device stop to abort, making a restart impossible.
586cba
Better ignore explicitely the return value.
586cba
586cba
Reported-by: Lei Yang <leiyang@redhat.com>
586cba
Fixes: 34e3c94eda ("vdpa: Add custom IOTLB translations to SVQ")
586cba
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
586cba
Acked-by: Jason Wang <jasowang@redhat.com>
586cba
Signed-off-by: Jason Wang <jasowang@redhat.com>
586cba
(cherry picked from commit bb5cf89ef2338ab6be946ede6821c3f61347eb1b)
586cba
---
586cba
 hw/virtio/vhost-vdpa.c | 32 ++++++++++----------------------
586cba
 1 file changed, 10 insertions(+), 22 deletions(-)
586cba
586cba
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
586cba
index e5c264fb29..8eddf39f2a 100644
586cba
--- a/hw/virtio/vhost-vdpa.c
586cba
+++ b/hw/virtio/vhost-vdpa.c
586cba
@@ -882,7 +882,7 @@ static int vhost_vdpa_svq_set_fds(struct vhost_dev *dev,
586cba
 /**
586cba
  * Unmap a SVQ area in the device
586cba
  */
586cba
-static bool vhost_vdpa_svq_unmap_ring(struct vhost_vdpa *v,
586cba
+static void vhost_vdpa_svq_unmap_ring(struct vhost_vdpa *v,
586cba
                                       const DMAMap *needle)
586cba
 {
586cba
     const DMAMap *result = vhost_iova_tree_find_iova(v->iova_tree, needle);
586cba
@@ -891,38 +891,33 @@ static bool vhost_vdpa_svq_unmap_ring(struct vhost_vdpa *v,
586cba
 
586cba
     if (unlikely(!result)) {
586cba
         error_report("Unable to find SVQ address to unmap");
586cba
-        return false;
586cba
+        return;
586cba
     }
586cba
 
586cba
     size = ROUND_UP(result->size, qemu_real_host_page_size);
586cba
     r = vhost_vdpa_dma_unmap(v, result->iova, size);
586cba
     if (unlikely(r < 0)) {
586cba
         error_report("Unable to unmap SVQ vring: %s (%d)", g_strerror(-r), -r);
586cba
-        return false;
586cba
+        return;
586cba
     }
586cba
 
586cba
     vhost_iova_tree_remove(v->iova_tree, *result);
586cba
-    return r == 0;
586cba
 }
586cba
 
586cba
-static bool vhost_vdpa_svq_unmap_rings(struct vhost_dev *dev,
586cba
+static void vhost_vdpa_svq_unmap_rings(struct vhost_dev *dev,
586cba
                                        const VhostShadowVirtqueue *svq)
586cba
 {
586cba
     DMAMap needle = {};
586cba
     struct vhost_vdpa *v = dev->opaque;
586cba
     struct vhost_vring_addr svq_addr;
586cba
-    bool ok;
586cba
 
586cba
     vhost_svq_get_vring_addr(svq, &svq_addr);
586cba
 
586cba
     needle.translated_addr = svq_addr.desc_user_addr;
586cba
-    ok = vhost_vdpa_svq_unmap_ring(v, &needle);
586cba
-    if (unlikely(!ok)) {
586cba
-        return false;
586cba
-    }
586cba
+    vhost_vdpa_svq_unmap_ring(v, &needle);
586cba
 
586cba
     needle.translated_addr = svq_addr.used_user_addr;
586cba
-    return vhost_vdpa_svq_unmap_ring(v, &needle);
586cba
+    vhost_vdpa_svq_unmap_ring(v, &needle);
586cba
 }
586cba
 
586cba
 /**
586cba
@@ -1093,26 +1088,22 @@ err:
586cba
     return false;
586cba
 }
586cba
 
586cba
-static bool vhost_vdpa_svqs_stop(struct vhost_dev *dev)
586cba
+static void vhost_vdpa_svqs_stop(struct vhost_dev *dev)
586cba
 {
586cba
     struct vhost_vdpa *v = dev->opaque;
586cba
 
586cba
     if (!v->shadow_vqs) {
586cba
-        return true;
586cba
+        return;
586cba
     }
586cba
 
586cba
     for (unsigned i = 0; i < v->shadow_vqs->len; ++i) {
586cba
         VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
586cba
-        bool ok = vhost_vdpa_svq_unmap_rings(dev, svq);
586cba
-        if (unlikely(!ok)) {
586cba
-            return false;
586cba
-        }
586cba
+        vhost_vdpa_svq_unmap_rings(dev, svq);
586cba
     }
586cba
 
586cba
     if (v->migration_blocker) {
586cba
         migrate_del_blocker(v->migration_blocker);
586cba
     }
586cba
-    return true;
586cba
 }
586cba
 
586cba
 static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)
586cba
@@ -1129,10 +1120,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started)
586cba
         }
586cba
         vhost_vdpa_set_vring_ready(dev);
586cba
     } else {
586cba
-        ok = vhost_vdpa_svqs_stop(dev);
586cba
-        if (unlikely(!ok)) {
586cba
-            return -1;
586cba
-        }
586cba
+        vhost_vdpa_svqs_stop(dev);
586cba
         vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs);
586cba
     }
586cba
 
586cba
-- 
586cba
2.31.1
586cba