patch 'net/mlx5: fix errno update in shared context creation' has been queued to stable release 21.11.1

Kevin Traynor ktraynor at redhat.com
Tue Mar 1 11:42:24 CET 2022


Hi,

FYI, your patch has been queued to stable release 21.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 03/06/22. 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://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/036993974f3a885c6ace0b9edd736cd21734b814

Thanks.

Kevin

---
>From 036993974f3a885c6ace0b9edd736cd21734b814 Mon Sep 17 00:00:00 2001
From: Michael Baum <michaelba at nvidia.com>
Date: Mon, 14 Feb 2022 11:34:55 +0200
Subject: [PATCH] net/mlx5: fix errno update in shared context creation

[ upstream commit 6be4c57add872cfd5f430977a1be2701a951ef90 ]

The mlx5_alloc_shared_dev_ctx() function has a local variable named
"err" which contains the errno value in case of failure.

When functions called by this function are failed, this variable is
updated with their return value (that should be a positive errno value).
However, some functions doesn't update errno value by themselves or
return negative errno value. If one of them fails, the "err" variable
contains negative value what cause to assertion failure.

This patch updates all functions uses by mlx5_alloc_shared_dev_ctx()
function to update rte_errno and take this value instead of "err" value.

Fixes: 5dfa003db53f ("common/mlx5: fix post doorbell barrier")
Fixes: 5d55a494f4e6 ("net/mlx5: split multi-thread flow handling per OS")

Signed-off-by: Michael Baum <michaelba at nvidia.com>
Acked-by: Matan Azrad <matan at nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_flow_os.c   |  3 ++-
 drivers/net/mlx5/linux/mlx5_os.c        | 16 ++++++++++------
 drivers/net/mlx5/mlx5.c                 | 24 +++++++++++-------------
 drivers/net/mlx5/windows/mlx5_flow_os.c |  2 +-
 drivers/net/mlx5/windows/mlx5_os.c      | 24 ++++++++++++------------
 5 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.c b/drivers/net/mlx5/linux/mlx5_flow_os.c
index 893f00b824..a5956c255a 100644
--- a/drivers/net/mlx5/linux/mlx5_flow_os.c
+++ b/drivers/net/mlx5/linux/mlx5_flow_os.c
@@ -15,5 +15,6 @@ mlx5_flow_os_init_workspace_once(void)
 	if (rte_thread_key_create(&key_workspace, flow_release_workspace)) {
 		DRV_LOG(ERR, "Can't create flow workspace data thread key.");
-		return -ENOMEM;
+		rte_errno = ENOMEM;
+		return -rte_errno;
 	}
 	return 0;
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index e45e56f4b6..f587a47f6e 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -139,5 +139,5 @@ mlx5_os_set_nonblock_channel_fd(int fd)
  *
  * @return
- *   0 on success, non zero error number otherwise
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 int
@@ -151,6 +151,8 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
 	memset(device_attr, 0, sizeof(*device_attr));
 	err = mlx5_glue->query_device_ex(ctx, NULL, &attr_ex);
-	if (err)
-		return err;
+	if (err) {
+		rte_errno = errno;
+		return -rte_errno;
+	}
 	device_attr->device_cap_flags_ex = attr_ex.device_cap_flags_ex;
 	device_attr->max_qp_wr = attr_ex.orig_attr.max_qp_wr;
@@ -171,6 +173,8 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
 	struct mlx5dv_context dv_attr = { .comp_mask = 0 };
 	err = mlx5_glue->dv_query_device(ctx, &dv_attr);
-	if (err)
-		return err;
+	if (err) {
+		rte_errno = errno;
+		return -rte_errno;
+	}
 
 	device_attr->flags = dv_attr.flags;
@@ -196,5 +200,5 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
 		sizeof(device_attr->fw_ver));
 
-	return err;
+	return 0;
 }
 
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index d1d398f49a..25d4d2082b 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1173,10 +1173,9 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 	sh = mlx5_malloc(MLX5_MEM_ZERO | MLX5_MEM_RTE,
 			 sizeof(struct mlx5_dev_ctx_shared) +
-			 spawn->max_port *
-			 sizeof(struct mlx5_dev_shared_port),
+			 spawn->max_port * sizeof(struct mlx5_dev_shared_port),
 			 RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
 	if (!sh) {
-		DRV_LOG(ERR, "shared context allocation failure");
-		rte_errno  = ENOMEM;
+		DRV_LOG(ERR, "Shared context allocation failure.");
+		rte_errno = ENOMEM;
 		goto exit;
 	}
@@ -1200,7 +1199,6 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 		sizeof(sh->ibdev_path) - 1);
 	/*
-	 * Setting port_id to max unallowed value means
-	 * there is no interrupt subhandler installed for
-	 * the given port index i.
+	 * Setting port_id to max unallowed value means there is no interrupt
+	 * subhandler installed for the given port index i.
 	 */
 	for (i = 0; i < sh->max_port; i++) {
@@ -1212,10 +1210,10 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 		if (!sh->td) {
 			DRV_LOG(ERR, "TD allocation failure");
-			err = ENOMEM;
+			rte_errno = ENOMEM;
 			goto error;
 		}
 		if (mlx5_setup_tis(sh)) {
 			DRV_LOG(ERR, "TIS allocation failure");
-			err = ENOMEM;
+			rte_errno = ENOMEM;
 			goto error;
 		}
@@ -1247,9 +1245,9 @@ exit:
 	return sh;
 error:
+	err = rte_errno;
 	pthread_mutex_destroy(&sh->txpp.mutex);
 	pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
 	MLX5_ASSERT(sh);
-	if (sh->td)
-		claim_zero(mlx5_devx_cmd_destroy(sh->td));
+	mlx5_rxtx_uars_release(sh);
 	i = 0;
 	do {
@@ -1257,7 +1255,7 @@ error:
 			claim_zero(mlx5_devx_cmd_destroy(sh->tis[i]));
 	} while (++i < (uint32_t)sh->bond.n_port);
-	mlx5_rxtx_uars_release(sh);
+	if (sh->td)
+		claim_zero(mlx5_devx_cmd_destroy(sh->td));
 	mlx5_free(sh);
-	MLX5_ASSERT(err > 0);
 	rte_errno = err;
 	return NULL;
diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.c b/drivers/net/mlx5/windows/mlx5_flow_os.c
index 7bb4c4590a..f5e3893ed4 100644
--- a/drivers/net/mlx5/windows/mlx5_flow_os.c
+++ b/drivers/net/mlx5/windows/mlx5_flow_os.c
@@ -373,5 +373,5 @@ mlx5_flow_os_init_workspace_once(void)
 	if (err) {
 		DRV_LOG(ERR, "Can't create flow workspace data thread key.");
-		return err;
+		return -rte_errno;
 	}
 	pthread_mutex_init(&lock_thread_list, NULL);
diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index d358317996..ba99901c5c 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -137,5 +137,5 @@ mlx5_init_once(void)
  *
  * @return
- *   0 on success, non zero error number otherwise.
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 int
@@ -146,8 +146,9 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
 	void *pv_iseg = NULL;
 	u32 cb_iseg = 0;
-	int err = 0;
 
-	if (!cdev || !cdev->ctx)
-		return -EINVAL;
+	if (!cdev || !cdev->ctx) {
+		rte_errno = EINVAL;
+		return -rte_errno;
+	}
 	mlx5_ctx = (struct mlx5_context *)cdev->ctx;
 	memset(device_attr, 0, sizeof(*device_attr));
@@ -172,13 +173,12 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
 	if (pv_iseg == NULL) {
 		DRV_LOG(ERR, "Failed to get device hca_iseg");
-		return errno;
+		rte_errno = errno;
+		return -rte_errno;
 	}
-	if (!err) {
-		snprintf(device_attr->fw_ver, 64, "%x.%x.%04x",
-			MLX5_GET(initial_seg, pv_iseg, fw_rev_major),
-			MLX5_GET(initial_seg, pv_iseg, fw_rev_minor),
-			MLX5_GET(initial_seg, pv_iseg, fw_rev_subminor));
-	}
-	return err;
+	snprintf(device_attr->fw_ver, 64, "%x.%x.%04x",
+		 MLX5_GET(initial_seg, pv_iseg, fw_rev_major),
+		 MLX5_GET(initial_seg, pv_iseg, fw_rev_minor),
+		 MLX5_GET(initial_seg, pv_iseg, fw_rev_subminor));
+	return 0;
 }
 
-- 
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-03-01 10:41:03.264488760 +0000
+++ 0068-net-mlx5-fix-errno-update-in-shared-context-creation.patch	2022-03-01 10:41:01.372244112 +0000
@@ -1 +1 @@
-From 6be4c57add872cfd5f430977a1be2701a951ef90 Mon Sep 17 00:00:00 2001
+From 036993974f3a885c6ace0b9edd736cd21734b814 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 6be4c57add872cfd5f430977a1be2701a951ef90 ]
+
@@ -20 +21,0 @@
-Cc: stable at dpdk.org
@@ -45 +46 @@
-index 69d3e1e3ad..faab310b11 100644
+index e45e56f4b6..f587a47f6e 100644
@@ -85 +86 @@
-index cde8d022cd..0e154b88ed 100644
+index d1d398f49a..25d4d2082b 100644
@@ -159 +160 @@
-index 3db33cd0cf..a9619e5bda 100644
+index d358317996..ba99901c5c 100644
@@ -162 +163 @@
-@@ -153,5 +153,5 @@ mlx5_init_once(void)
+@@ -137,5 +137,5 @@ mlx5_init_once(void)
@@ -169 +170 @@
-@@ -162,8 +162,9 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
+@@ -146,8 +146,9 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
@@ -182 +183 @@
-@@ -188,13 +189,12 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
+@@ -172,13 +173,12 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,



More information about the stable mailing list