patch 'net/virtio-user: fix shadow control queue notification init' has been queued to stable release 23.11.2

Xueming Li xuemingl at nvidia.com
Fri Jul 12 12:44:40 CEST 2024


Hi,

FYI, your patch has been queued to stable release 23.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 07/14/24. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=23.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=f745eb9e509c326cce0f240319b374d3de9a4a62

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From f745eb9e509c326cce0f240319b374d3de9a4a62 Mon Sep 17 00:00:00 2001
From: Maxime Coquelin <maxime.coquelin at redhat.com>
Date: Thu, 28 Mar 2024 14:08:12 +0100
Subject: [PATCH] net/virtio-user: fix shadow control queue notification init
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 4de6c17a449ef0fafecae637bd73cd4d03c36d92 ]

The Virtio-user control queue kick and call FDs were not
uninitialized at device stop time.

This patch fixes this using the queues iterator helper for
both initialization and uninitialization.

Fixes: 90966e8e5b67 ("net/virtio-user: send shadow virtqueue info to the backend")

Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
Acked-by: David Marchand <david.marchand at redhat.com>
---
 .../net/virtio/virtio_user/virtio_user_dev.c  | 90 +++++++++----------
 1 file changed, 43 insertions(+), 47 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index ce9e73493d..ef320d3395 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -32,6 +32,45 @@ const char * const virtio_user_backend_strings[] = {
 	[VIRTIO_USER_BACKEND_VHOST_VDPA] = "VHOST_VDPA",
 };
 
+static int
+virtio_user_uninit_notify_queue(struct virtio_user_dev *dev, uint32_t queue_sel)
+{
+	if (dev->kickfds[queue_sel] >= 0) {
+		close(dev->kickfds[queue_sel]);
+		dev->kickfds[queue_sel] = -1;
+	}
+
+	if (dev->callfds[queue_sel] >= 0) {
+		close(dev->callfds[queue_sel]);
+		dev->callfds[queue_sel] = -1;
+	}
+
+	return 0;
+}
+
+static int
+virtio_user_init_notify_queue(struct virtio_user_dev *dev, uint32_t queue_sel)
+{
+	/* May use invalid flag, but some backend uses kickfd and
+	 * callfd as criteria to judge if dev is alive. so finally we
+	 * use real event_fd.
+	 */
+	dev->callfds[queue_sel] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
+	if (dev->callfds[queue_sel] < 0) {
+		PMD_DRV_LOG(ERR, "(%s) Failed to setup callfd for queue %u: %s",
+				dev->path, queue_sel, strerror(errno));
+		return -1;
+	}
+	dev->kickfds[queue_sel] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
+	if (dev->kickfds[queue_sel] < 0) {
+		PMD_DRV_LOG(ERR, "(%s) Failed to setup kickfd for queue %u: %s",
+				dev->path, queue_sel, strerror(errno));
+		return -1;
+	}
+
+	return 0;
+}
+
 static int
 virtio_user_destroy_queue(struct virtio_user_dev *dev, uint32_t queue_sel)
 {
@@ -423,46 +462,13 @@ out:
 static int
 virtio_user_dev_init_notify(struct virtio_user_dev *dev)
 {
-	uint32_t i, j, nr_vq;
-	int callfd;
-	int kickfd;
 
-	nr_vq = dev->max_queue_pairs * 2;
-	if (dev->hw_cvq)
-		nr_vq++;
-
-	for (i = 0; i < nr_vq; i++) {
-		/* May use invalid flag, but some backend uses kickfd and
-		 * callfd as criteria to judge if dev is alive. so finally we
-		 * use real event_fd.
-		 */
-		callfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
-		if (callfd < 0) {
-			PMD_DRV_LOG(ERR, "(%s) callfd error, %s", dev->path, strerror(errno));
-			goto err;
-		}
-		kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
-		if (kickfd < 0) {
-			close(callfd);
-			PMD_DRV_LOG(ERR, "(%s) kickfd error, %s", dev->path, strerror(errno));
-			goto err;
-		}
-		dev->callfds[i] = callfd;
-		dev->kickfds[i] = kickfd;
-	}
+	if (virtio_user_foreach_queue(dev, virtio_user_init_notify_queue) < 0)
+		goto err;
 
 	return 0;
 err:
-	for (j = 0; j < i; j++) {
-		if (dev->kickfds[j] >= 0) {
-			close(dev->kickfds[j]);
-			dev->kickfds[j] = -1;
-		}
-		if (dev->callfds[j] >= 0) {
-			close(dev->callfds[j]);
-			dev->callfds[j] = -1;
-		}
-	}
+	virtio_user_foreach_queue(dev, virtio_user_uninit_notify_queue);
 
 	return -1;
 }
@@ -470,18 +476,8 @@ err:
 static void
 virtio_user_dev_uninit_notify(struct virtio_user_dev *dev)
 {
-	uint32_t i;
+	virtio_user_foreach_queue(dev, virtio_user_uninit_notify_queue);
 
-	for (i = 0; i < dev->max_queue_pairs * 2; ++i) {
-		if (dev->kickfds[i] >= 0) {
-			close(dev->kickfds[i]);
-			dev->kickfds[i] = -1;
-		}
-		if (dev->callfds[i] >= 0) {
-			close(dev->callfds[i]);
-			dev->callfds[i] = -1;
-		}
-	}
 }
 
 static int
-- 
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-07-12 18:40:16.684180917 +0800
+++ 0054-net-virtio-user-fix-shadow-control-queue-notificatio.patch	2024-07-12 18:40:14.106594227 +0800
@@ -1 +1 @@
-From 4de6c17a449ef0fafecae637bd73cd4d03c36d92 Mon Sep 17 00:00:00 2001
+From f745eb9e509c326cce0f240319b374d3de9a4a62 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 4de6c17a449ef0fafecae637bd73cd4d03c36d92 ]
@@ -13 +15,0 @@
-Cc: stable at dpdk.org
@@ -22 +24 @@
-index 07f45984fe..ba067d6d9c 100644
+index ce9e73493d..ef320d3395 100644
@@ -25 +27 @@
-@@ -33,6 +33,45 @@ const char * const virtio_user_backend_strings[] = {
+@@ -32,6 +32,45 @@ const char * const virtio_user_backend_strings[] = {
@@ -71 +73 @@
-@@ -423,33 +462,9 @@ out:
+@@ -423,46 +462,13 @@ out:
@@ -78 +80 @@
--
+ 
@@ -82 +84 @@
- 
+-
@@ -105,4 +106,0 @@
- 	if (dev->device_features & (1ULL << VIRTIO_F_NOTIFICATION_DATA))
- 		if (dev->ops->map_notification_area &&
-@@ -458,16 +473,7 @@ virtio_user_dev_init_notify(struct virtio_user_dev *dev)
- 
@@ -125 +123 @@
-@@ -475,18 +481,8 @@ err:
+@@ -470,18 +476,8 @@ err:
@@ -142,2 +139,0 @@
- 	if (dev->ops->unmap_notification_area && dev->notify_area)
- 		dev->ops->unmap_notification_area(dev);
@@ -144,0 +141,2 @@
+ 
+ static int


More information about the stable mailing list