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 1145EA00C2 for ; Wed, 9 Nov 2022 23:30:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0A9F040156; Wed, 9 Nov 2022 23:30:03 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2041.outbound.protection.outlook.com [40.107.243.41]) by mails.dpdk.org (Postfix) with ESMTP id 66856400D4; Wed, 9 Nov 2022 23:30:01 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cMZUyJJSrkyHDI9CsBPHVrvVnAKcaB4561QI9fsxtbMzNj+XDq9dAYbeVSOCYJt9Aaz46tfDqh0Wo6MgNTiVjzDyw3RygMkOKGJuS74iyhGqPJOXMqZUOMfVG9sZ7abG/IQKBKew+E/vAfGlg9OwErsbxwdE+cvu0TdgXRIqTc+QoaD8KhyGyJmcQMicMHkaerCIRpGtmKbIGoZM0QItT/x1sDPHt2LZNUQ4afnbpHn7f9Sro9rUy43kDQbTiW2nv7XsKNTDP8KgL0oF1qXI0yIqgHNOayMZhuIYThM577L5QqGBweeFkncAk8QISC+9cHmRScGqdhEHBMb6s20vKA== 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=gOIYtmloeFjTQ0Q+ZNadgqOV9ARWYbFvkoS8W31gb9A=; b=HdlV/b/hPY3URhSmU4HudAPo6Lpn50P71oPvDWBUNCv9YnbZNMxemY0j3jm8k7K9XqcCKzptvS2Z22NSespCwpkBFmudg9ZQoYEXYVAc4D8f+XclAJX1iVPeaxFZjoqgxCIPrt9Aoa66f5UDKWvnZvI/lNJv1uIUHSiekkNjHO3imbaV6M3CDCnZaNzH1G1RzYwvM3JfK4el0i28Yc7xKDzZP8SgTqYJISyGza9sZRYz4LmPTl6qIgBZRBvhpFY+p5dqNN5cNdqbH1NVvAh21hoawKOjowcmwvXis/PSp4MlDd46sIIcVZzHkKXjN0cyPRwXRDNnij9pKaEcFu0UmQ== 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 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=gOIYtmloeFjTQ0Q+ZNadgqOV9ARWYbFvkoS8W31gb9A=; b=GWcQtCUs3Xor5dsCLgtv4hBMuMnZQ1kQNz6btik1+nPdvlROHO+Wsj92Hv3mBuYqtkhtv0mySPLsnmbmxEYsOuH9J1NUcrxdbgMz135UMa069MUhrXJgsLHQ5onxXgvXn72Fu+i8zIYFr3+UgoFjVsH/WpBxp7dkI9YDDmLQOwHrYVwAMXht2O4pWFMfIarycyI+XXZACIgi0lUDCf0fVz1/OezDGb4jBMNdEGvzYcnZBvnXqZY8Ess6J7pU1kt3dWKuI0izh7w/VJOmTDLWjK0ntLP6M7x2/GpmuRLfOX+HaP8BMkasjY047WWd0wl4x3l9MYPM0MFF/ZU/p/ZrUg== Received: from BN8PR07CA0009.namprd07.prod.outlook.com (2603:10b6:408:ac::22) by PH7PR12MB5595.namprd12.prod.outlook.com (2603:10b6:510:135::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Wed, 9 Nov 2022 22:29:59 +0000 Received: from BN8NAM11FT094.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ac:cafe::42) by BN8PR07CA0009.outlook.office365.com (2603:10b6:408:ac::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27 via Frontend Transport; Wed, 9 Nov 2022 22:29:59 +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 BN8NAM11FT094.mail.protection.outlook.com (10.13.176.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12 via Frontend Transport; Wed, 9 Nov 2022 22:29:59 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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.26; Wed, 9 Nov 2022 14:29:45 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail204.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.986.36; Wed, 9 Nov 2022 14:29:44 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36 via Frontend Transport; Wed, 9 Nov 2022 14:29:43 -0800 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , , Subject: [PATCH v2] net/mlx5: fix port's event cleaning order Date: Thu, 10 Nov 2022 00:29:38 +0200 Message-ID: <20221109222938.266140-1-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221109221802.264768-1-michaelba@nvidia.com> References: <20221109221802.264768-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT094:EE_|PH7PR12MB5595:EE_ X-MS-Office365-Filtering-Correlation-Id: f1b0f167-58bc-4fcd-7b87-08dac2a1efb9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hn8jhU2TIVmSdNsbyJEjl5KbpWUuT7UzvbaDeOgdqtdLVzSkRXeM39tVXV47nl5Sla0OsInJUvNu7E5VKqktZVBo6N0NCrjWSG07fFPTA/Tfd78PQADRiZeszCmY8o05gHE7achEiTXdLQiLIfm0jmzfQxDhTEQTxgdzXlIZ9R1oH4xTv4EQhb3xpIbHDsabhbPEjChJgFFoPzwNcx7Pvj4c8+u0Ak1lLHUI6cCq8U7B2pGy5IzSunXwt4ni64BWbGfC0tZ1ZgcpLJnxzZLlOI/guap6SRYJqP6bXBIU1sDs7sDDHgQoHCOmMX5ycIfQFgqk44LvtmtkpR+UGmyMaOnZhhxzUFbH/Tg2FW8scKg7tTGQmnB/Ic7w3843ypuNe0o4n4RHLs6w/Y5CMjVPmdqejHdYHZzrk415SjP9WD52GBfsVgqKIXQvjsoVDG91oupb6UqLg4POpgv7sUIOuywMNz++2Sd4uP94J5p0eEWycwcLttmse+bGwbVBHWYFRKGBsCx78mGFBfbs07XC6fdeI+/DECziVgQzkMIroRCsnGVEalqh1f19RY8H3q9wPq+XvPxL1tnDFkrFGgVoaTp2WdIT5MkqvmortIvpd8a2pCc+Uu8ow9rDD7GYmQKcf82nHHS5ZgRLeOIsAJ1Eik1ajadY43xxf+WasglP1Wyan0bWVqKqKwRdMpGe1B38s1GYmgq8kztx2571R9wZCTxJ7OOqw3XzCO45lJsehc8VuQuPiBHuU92QSo2myD58K6GlZErEYT1WY/P+X9/j9w== 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:(13230022)(4636009)(346002)(39860400002)(376002)(396003)(136003)(451199015)(40470700004)(46966006)(36840700001)(5660300002)(86362001)(83380400001)(47076005)(336012)(7696005)(426003)(6666004)(478600001)(316002)(6916009)(54906003)(40460700003)(6286002)(8936002)(36756003)(7636003)(2616005)(8676002)(26005)(36860700001)(186003)(70586007)(1076003)(4326008)(450100002)(40480700001)(55016003)(41300700001)(70206006)(356005)(82740400003)(2906002)(82310400005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 22:29:59.1748 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1b0f167-58bc-4fcd-7b87-08dac2a1efb9 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: BN8NAM11FT094.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5595 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 shared IB device (sh) has per port data with filed for interrupt handler port_id. It used by shared interrupt handler to find the corresponding rte_eth device by IB port index. If value is equal or greater RTE_MAX_ETHPORTS it means there is no subhandler installed for specified IB port index. When a few ports are created under same sh, the sh is created with the first port and the interrupt handler port_id is initialized to RTE_MAX_ETHPORTS for each port. In port creation, the interrupt handler port_id is updated with the correct value. Since this updating, the mlx5_dev_interrupt_nl_cb function uses this port and its priv structure. However, when the ports are closed, this filed isn't updated and the interrupt handler continue working until it is uninstalled in SH destruction. If mlx5_dev_interrupt_nl_cb is called between port closing and SH destruction, it uses invalid port causing a crash. This patch adds interrupt handler port_id updating to the close function and add memory barrier to make sure it is done before priv reset. Fixes: 655c3c26c11e ("net/mlx5: fix initial link status detection") Cc: dkozlyuk@nvidia.com Cc: stable@dpdk.org Signed-off-by: Michael Baum Acked-by: Matan Azrad --- v2: fix typo in commit message. drivers/net/mlx5/linux/mlx5_os.c | 3 +++ drivers/net/mlx5/mlx5.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 2b6741396d..a71474c90a 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1676,6 +1676,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, return eth_dev; error: if (priv) { + priv->sh->port[priv->dev_port - 1].nl_ih_port_id = + RTE_MAX_ETHPORTS; + rte_io_wmb(); #ifdef HAVE_MLX5_HWS_SUPPORT if (eth_dev && priv->sh && diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 1cf6df6049..95b0151fbc 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -2137,6 +2137,12 @@ mlx5_dev_close(struct rte_eth_dev *dev) if (!c) claim_zero(rte_eth_switch_domain_free(priv->domain_id)); } + priv->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. + */ + rte_io_wmb(); memset(priv, 0, sizeof(*priv)); priv->domain_id = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID; /* -- 2.25.1