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 2F8D043E83 for ; Tue, 16 Apr 2024 17:31:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6D0DA4069F; Tue, 16 Apr 2024 17:31:51 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2049.outbound.protection.outlook.com [40.107.220.49]) by mails.dpdk.org (Postfix) with ESMTP id A5D1D40268; Tue, 16 Apr 2024 17:31:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EDGXOhMgBNQvdEb/eCedKuAkKmKfnvZ0OBVLw7NOjvcn3r2jS5E93/sS+vtxNl+MShh21EKIS4BdjP2yJ9+QZT3jDwNBH3RsZQl9t8HK32L2UoJTaYFVXl9N4AuuubZVQU8gknDxNimI/ebmJ3mQFnZyqw/2j7wdDaV/ty8ZaJCkakEqtoGxpjPbTzSQ3icN3GAWyzGZiOs0jKZv14mAYFIJVJa/y0eAGlfFq04ies56IA0qFuq0cm2NaRMPO3BqyvONCUgIElh2OCN8MLrBQIcsrIcV5P8jrI/2SXdlW6Pr7K0kYutPCgcjlW3b9kmD0bCQeXvPhnuge633uWpBzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UpE4L0kdHJH3wmLmjh5sk6EOpppS5kKzfWc8ZSKhA4U=; b=GsImQxZgmZ3umzKLsDr2GMfVQZyHpkMj42XdVWLp1bBsX+oG305GSAHhKd/DXCYzoL1Lsv9czoUywsM1ItZuP5prdyBscSKtxkBmaQb+fWLiRd25FKX+/fvORTdrJBVmoV8u6yJALJYoK2vTIrKs7Pl1DoZXFdKGlw/g+2uhgqRXrHy5R2Az2pJl1kCXUbvyW5risaMbbGRLt7IjSHLsJOOSQLl0aWELGoPDynxMuNRHoWRGX+PgIQrZEBSIfWAUhNRh/beyQi69jU38w6j/+3O34qmz8zripKeT0te1dFUjSuyb0lTjs+v8oie07pAvjNpXn+kMk9hHNyU+3Lo+VQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UpE4L0kdHJH3wmLmjh5sk6EOpppS5kKzfWc8ZSKhA4U=; b=RRF5vSxrPyX7n5/Ct8cxCICpaeLa5+aLtEdUgbkbuLCbMwzoPiq/GoOiEt3s85y8oXnGwigy+CZXFR3MMQQOoqHAmDr5Wf0ITm3GFKqSfT7RPDGEs2UBl2oULrZksbeTh/nb7qqFFNrd3uSRbNeYa5aPsBZxeOk9+TywaAmZAIOcDdvXE9INYBPk3NN//zB79qE+kXwe0g8MzSFbqlxq2MLfNvPAkmPI44uoBIcfWWGDdgSE1pkRVi4k64oPgEPMWV2OJ0Sxq76YptThQ4V0aEdOZpCgaV7mi/dAGaq/R/rqyXYR8fD5YwlaaZqNe4ywkeXaG9lmvLdifuzM71Bk+A== Received: from SA1P222CA0135.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c2::13) by IA1PR12MB6329.namprd12.prod.outlook.com (2603:10b6:208:3e5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.50; Tue, 16 Apr 2024 15:31:44 +0000 Received: from SA2PEPF00001508.namprd04.prod.outlook.com (2603:10b6:806:3c2:cafe::ce) by SA1P222CA0135.outlook.office365.com (2603:10b6:806:3c2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.34 via Frontend Transport; Tue, 16 Apr 2024 15:31:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00001508.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Tue, 16 Apr 2024 15:31:43 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 16 Apr 2024 08:31:06 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 16 Apr 2024 08:31:06 -0700 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12 via Frontend Transport; Tue, 16 Apr 2024 08:31:03 -0700 From: Michael Baum To: CC: Matan Azrad , Dariusz Sosnowski , Raslan Darawsheh , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , , Subject: [PATCH 1/4] net/mlx5: fix secondary process port close Date: Tue, 16 Apr 2024 18:30:51 +0300 Message-ID: <20240416153054.3216706-2-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240416153054.3216706-1-michaelba@nvidia.com> References: <20240416153054.3216706-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001508:EE_|IA1PR12MB6329:EE_ X-MS-Office365-Filtering-Correlation-Id: e11f8a35-68b1-4b98-54e2-08dc5e2a5222 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 33YXn1AOQ7fjNrv1rOPPKJI72FNFWlx7tMUF7NxhriMFOdTcZmbwn6jqbH7ql/1xKIR2PJV0jQFmZwlyq7ka6jmLq9xR63g2xLAfVLM8l11Jae9s/V1fio8Jg4Nc95OTk1P/AeIHffuyeBIxRtCoxOqNbo35hPg4cz/rHeHz+uCq7IxVk+aJJwclWptJvMDSLdoyxTmZFfaPbANt6+xzLWyMdcCT53W1b02tuAUr/quXmWm+XXSaoveAB/SIMNRWrmqgg4FL0fa77mI3/x68gLb6HSUna7Vfq9SMzwckHSQU8um9cp8Uf2AC1lakYHLAnEBlUU7LKTUK0JqoutkIPDErWekVLgBFVfIKPl3AVi/Krr3jG21S5dkV02Vwc/NBynM2nNoH8JWYzsldzswQPWJFYnbgXGWfsxfRG5u4ZgYhgyo68InZlrsYtOCkTmEaA/zLYMUxKnbCASxrNnOjxtwih+dtDQk/gPbEAFcnY/9GTgLMmd68uT5/aPCZ6v9YylDi/TvIG7GFOaTO/HvG9nf7GCSYq98WRYWZIzxyRL0w3dL9Q4YZFFdHWCYz8Qlr2WdycfFy73InrlFJNyOBZvmaJmmsZ2gBcIoK/tN+EBZd1IQrobzZPUreY0vVCIzyKJ9cTB6GPtdjxAxgTYmmu7v1mjIThLVD6/+QWKGtugEemEMexG/K2a7u4JF5LQDVEnfL+f0oUGYk7Y+sjb2bb53Zc63v/HNxD91z+dT+C5Z5RgrYFZaaowIkkNz4c+Co X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(36860700004)(376005)(82310400014)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2024 15:31:43.7980 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e11f8a35-68b1-4b98-54e2-08dc5e2a5222 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001508.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6329 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 The "mlx5_dev_close()" function is used for both primary and secondary processes. If secondary process use this function after primary process is closed, the priv structure isn't valid anymore. The function is accessing priv structure to get "sh" pointer in part shared between processes causing a crash for secondary. This patch avoids this access and print warning in this case. Fixes: f5177bdc8b76 ("net/mlx5: add GENEVE TLV options parser API") Cc: michaelba@nvidia.com Cc: stable@dpdk.org Signed-off-by: Michael Baum Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index d1a63822a5..585b4d5497 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2295,11 +2295,13 @@ int mlx5_dev_close(struct rte_eth_dev *dev) { struct mlx5_priv *priv = dev->data->dev_private; - struct mlx5_dev_ctx_shared *sh = priv->sh; + struct mlx5_dev_ctx_shared *sh; unsigned int i; int ret; if (rte_eal_process_type() == RTE_PROC_SECONDARY) { + if (!priv) + DRV_LOG(WARNING, "primary process is already closed"); /* Check if process_private released. */ if (!dev->process_private) return 0; @@ -2308,6 +2310,7 @@ mlx5_dev_close(struct rte_eth_dev *dev) rte_eth_dev_release_port(dev); return 0; } + sh = priv->sh; if (!sh) return 0; if (priv->shared_refcnt) { @@ -2326,9 +2329,7 @@ mlx5_dev_close(struct rte_eth_dev *dev) } #endif DRV_LOG(DEBUG, "port %u closing device \"%s\"", - dev->data->port_id, - ((priv->sh->cdev->ctx != NULL) ? - mlx5_os_get_ctx_device_name(priv->sh->cdev->ctx) : "")); + dev->data->port_id, sh->ibdev_name); /* * If default mreg copy action is removed at the stop stage, * the search will return none and nothing will be done anymore. @@ -2402,7 +2403,7 @@ mlx5_dev_close(struct rte_eth_dev *dev) mlx5_free(priv->rss_conf.rss_key); if (priv->reta_idx != NULL) mlx5_free(priv->reta_idx); - if (priv->sh->dev_cap.vf) + if (sh->dev_cap.vf) mlx5_os_mac_addr_flush(dev); if (priv->nl_socket_route >= 0) close(priv->nl_socket_route); @@ -2445,7 +2446,7 @@ mlx5_dev_close(struct rte_eth_dev *dev) if (priv->hrxqs) mlx5_list_destroy(priv->hrxqs); mlx5_free(priv->ext_rxqs); - priv->sh->port[priv->dev_port - 1].nl_ih_port_id = RTE_MAX_ETHPORTS; + sh->port[priv->dev_port - 1].nl_ih_port_id = RTE_MAX_ETHPORTS; /* * The interrupt handler port id must be reset before priv is reset * since 'mlx5_dev_interrupt_nl_cb' uses priv. @@ -2457,7 +2458,7 @@ mlx5_dev_close(struct rte_eth_dev *dev) * mlx5_os_mac_addr_flush() uses ibdev_path for retrieving * ifindex if Netlink fails. */ - mlx5_free_shared_dev_ctx(priv->sh); + mlx5_free_shared_dev_ctx(sh); if (priv->domain_id != RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID) { unsigned int c = 0; uint16_t port_id; -- 2.25.1