Blame SOURCES/0001-vhost-remove-pending-IOTLB-entry-if-miss-request-fai.patch

a6040a
From 82b9c1540348b6be7996203065e10421e953cea9 Mon Sep 17 00:00:00 2001
a6040a
From: Maxime Coquelin <maxime.coquelin@redhat.com>
a6040a
Date: Mon, 5 Feb 2018 16:04:57 +0100
a6040a
Subject: [PATCH] vhost: remove pending IOTLB entry if miss request failed
a6040a
a6040a
In case vhost_user_iotlb_miss returns an error, the pending IOTLB
a6040a
entry has to be removed from the list as no IOTLB update will be
a6040a
received.
a6040a
a6040a
Fixes: fed67a20ac94 ("vhost: introduce guest IOVA to backend VA helper")
a6040a
Cc: stable@dpdk.org
a6040a
a6040a
Suggested-by: Tiwei Bie <tiwei.bie@intel.com>
a6040a
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
a6040a
---
a6040a
 lib/librte_vhost/iotlb.c |  2 +-
a6040a
 lib/librte_vhost/iotlb.h |  3 +++
a6040a
 lib/librte_vhost/vhost.c | 13 ++++++++++---
a6040a
 3 files changed, 14 insertions(+), 4 deletions(-)
a6040a
a6040a
diff --git a/lib/librte_vhost/iotlb.c b/lib/librte_vhost/iotlb.c
a6040a
index 72cd27df8..c11ebcaac 100644
a6040a
--- a/lib/librte_vhost/iotlb.c
a6040a
+++ b/lib/librte_vhost/iotlb.c
a6040a
@@ -120,7 +120,7 @@ vhost_user_iotlb_pending_insert(struct vhost_virtqueue *vq,
a6040a
 	rte_rwlock_write_unlock(&vq->iotlb_pending_lock);
a6040a
 }
a6040a
 
a6040a
-static void
a6040a
+void
a6040a
 vhost_user_iotlb_pending_remove(struct vhost_virtqueue *vq,
a6040a
 				uint64_t iova, uint64_t size, uint8_t perm)
a6040a
 {
a6040a
diff --git a/lib/librte_vhost/iotlb.h b/lib/librte_vhost/iotlb.h
a6040a
index f1a050e44..e7083e37b 100644
a6040a
--- a/lib/librte_vhost/iotlb.h
a6040a
+++ b/lib/librte_vhost/iotlb.h
a6040a
@@ -71,6 +71,9 @@ bool vhost_user_iotlb_pending_miss(struct vhost_virtqueue *vq, uint64_t iova,
a6040a
 						uint8_t perm);
a6040a
 void vhost_user_iotlb_pending_insert(struct vhost_virtqueue *vq, uint64_t iova,
a6040a
 						uint8_t perm);
a6040a
+void vhost_user_iotlb_pending_remove(struct vhost_virtqueue *vq, uint64_t iova,
a6040a
+						uint64_t size, uint8_t perm);
a6040a
+
a6040a
 int vhost_user_iotlb_init(struct virtio_net *dev, int vq_index);
a6040a
 
a6040a
 #endif /* _VHOST_IOTLB_H_ */
a6040a
diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
a6040a
index a31ca5002..a407067e2 100644
a6040a
--- a/lib/librte_vhost/vhost.c
a6040a
+++ b/lib/librte_vhost/vhost.c
a6040a
@@ -42,7 +42,9 @@ __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
a6040a
 	if (tmp_size == size)
a6040a
 		return vva;
a6040a
 
a6040a
-	if (!vhost_user_iotlb_pending_miss(vq, iova + tmp_size, perm)) {
a6040a
+	iova += tmp_size;
a6040a
+
a6040a
+	if (!vhost_user_iotlb_pending_miss(vq, iova, perm)) {
a6040a
 		/*
a6040a
 		 * iotlb_lock is read-locked for a full burst,
a6040a
 		 * but it only protects the iotlb cache.
a6040a
@@ -52,8 +54,13 @@ __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
a6040a
 		 */
a6040a
 		vhost_user_iotlb_rd_unlock(vq);
a6040a
 
a6040a
-		vhost_user_iotlb_pending_insert(vq, iova + tmp_size, perm);
a6040a
-		vhost_user_iotlb_miss(dev, iova + tmp_size, perm);
a6040a
+		vhost_user_iotlb_pending_insert(vq, iova, perm);
a6040a
+		if (vhost_user_iotlb_miss(dev, iova, perm)) {
a6040a
+			RTE_LOG(ERR, VHOST_CONFIG,
a6040a
+				"IOTLB miss req failed for IOVA 0x%" PRIx64 "\n",
a6040a
+				iova);
a6040a
+			vhost_user_iotlb_pending_remove(vq, iova, 1, perm);
a6040a
+		}
a6040a
 
a6040a
 		vhost_user_iotlb_rd_lock(vq);
a6040a
 	}
a6040a
-- 
a6040a
2.14.3
a6040a