From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 230EBA034F for ; Tue, 1 Mar 2022 11:45:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1DD6040DF6; Tue, 1 Mar 2022 11:45:31 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id DEAAB426ED for ; Tue, 1 Mar 2022 11:45:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646131528; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cleud3U5OWOMMo1j8wyDxAXgILhM0ot7Cm9hXhvFAPA=; b=Mur7eVa01HRjFzgOvPYrD5Ryc0z6VH+qVc0diaxYyxMxnZNE9GkdByHBHzTG6RyGNfNgoh +lcCqXWQuYDq+1tY/NcxQD3A3iUVuteM0d+P4Bh/GUm3jetO+ifsxGoLIOZq0jJlh8zvsj YrypxPTXPHGxdjNL//KliXWkYm9i/oI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-117-HrERwXK1M_S_ctVPgUAtKQ-1; Tue, 01 Mar 2022 05:45:24 -0500 X-MC-Unique: HrERwXK1M_S_ctVPgUAtKQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36FC9801AB2; Tue, 1 Mar 2022 10:45:23 +0000 (UTC) Received: from rh.Home (unknown [10.39.194.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25F046FB08; Tue, 1 Mar 2022 10:45:21 +0000 (UTC) From: Kevin Traynor To: Michael Baum Cc: Matan Azrad , dpdk stable Subject: patch 'net/mlx5: fix errno update in shared context creation' has been queued to stable release 21.11.1 Date: Tue, 1 Mar 2022 10:42:24 +0000 Message-Id: <20220301104300.334382-68-ktraynor@redhat.com> In-Reply-To: <20220301104300.334382-1-ktraynor@redhat.com> References: <20220301104300.334382-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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 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 Acked-by: Matan Azrad --- 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@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,