From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 4A6C61B1EF for ; Wed, 3 Apr 2019 16:15:04 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 3 Apr 2019 17:15:01 +0300 Received: from pegasus12.mtr.labs.mlnx. (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x33EF1ue029866; Wed, 3 Apr 2019 17:15:01 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: shahafs@mellanox.com Date: Wed, 3 Apr 2019 14:14:57 +0000 Message-Id: <1554300897-24032-1-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH 1/1] net/mlx5: fix sharing context destroy order X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 14:15:04 -0000 At the mlx5 device closing the shared IB context was destroyed before cleanup routines completion. As it was found on some setups (Netlink fails with old kernel drivers and we have to use sysfs to retrieve interface index, this requires IB device name, which is stored in shared context) the mlx5_nl_mac_addr_flush() requires IB device name, and if shared context is removed it causes the segmentation fault. Fixes: 17e19bc4dde7 ("net/mlx5: add IB shared context alloc/free functions") Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 9aa5f0b..570640d 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -543,9 +543,6 @@ struct mlx5_dev_spawn_data { #ifdef HAVE_MLX5DV_DR mlx5_free_shared_dv(priv); #endif - if (priv->sh) - mlx5_free_shared_ibctx(priv->sh); - priv->sh = NULL; if (priv->rss_conf.rss_key != NULL) rte_free(priv->rss_conf.rss_key); if (priv->reta_idx != NULL) @@ -560,6 +557,16 @@ struct mlx5_dev_spawn_data { close(priv->nl_socket_rdma); if (priv->tcf_context) mlx5_flow_tcf_context_destroy(priv->tcf_context); + if (priv->sh) { + /* + * Free the shared context in last turn, because the cleanup + * routines above may use some shared fields, like + * mlx5_nl_mac_addr_flush() uses ibdev_path for retrieveing + * ifindex if Netlink fails. + */ + mlx5_free_shared_ibctx(priv->sh); + priv->sh = NULL; + } ret = mlx5_hrxq_ibv_verify(dev); if (ret) DRV_LOG(WARNING, "port %u some hash Rx queue still remain", -- 1.8.3.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 0BC4BA0679 for ; Wed, 3 Apr 2019 16:15:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A35411B1F4; Wed, 3 Apr 2019 16:15:06 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 4A6C61B1EF for ; Wed, 3 Apr 2019 16:15:04 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 3 Apr 2019 17:15:01 +0300 Received: from pegasus12.mtr.labs.mlnx. (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x33EF1ue029866; Wed, 3 Apr 2019 17:15:01 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: shahafs@mellanox.com Date: Wed, 3 Apr 2019 14:14:57 +0000 Message-Id: <1554300897-24032-1-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH 1/1] net/mlx5: fix sharing context destroy order X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190403141457.E5zDgzDOTi9-tqYXQ_T8UaYw7-4deYXePMmxA6yPhbY@z> At the mlx5 device closing the shared IB context was destroyed before cleanup routines completion. As it was found on some setups (Netlink fails with old kernel drivers and we have to use sysfs to retrieve interface index, this requires IB device name, which is stored in shared context) the mlx5_nl_mac_addr_flush() requires IB device name, and if shared context is removed it causes the segmentation fault. Fixes: 17e19bc4dde7 ("net/mlx5: add IB shared context alloc/free functions") Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 9aa5f0b..570640d 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -543,9 +543,6 @@ struct mlx5_dev_spawn_data { #ifdef HAVE_MLX5DV_DR mlx5_free_shared_dv(priv); #endif - if (priv->sh) - mlx5_free_shared_ibctx(priv->sh); - priv->sh = NULL; if (priv->rss_conf.rss_key != NULL) rte_free(priv->rss_conf.rss_key); if (priv->reta_idx != NULL) @@ -560,6 +557,16 @@ struct mlx5_dev_spawn_data { close(priv->nl_socket_rdma); if (priv->tcf_context) mlx5_flow_tcf_context_destroy(priv->tcf_context); + if (priv->sh) { + /* + * Free the shared context in last turn, because the cleanup + * routines above may use some shared fields, like + * mlx5_nl_mac_addr_flush() uses ibdev_path for retrieveing + * ifindex if Netlink fails. + */ + mlx5_free_shared_ibctx(priv->sh); + priv->sh = NULL; + } ret = mlx5_hrxq_ibv_verify(dev); if (ret) DRV_LOG(WARNING, "port %u some hash Rx queue still remain", -- 1.8.3.1