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 90294A055B for ; Wed, 16 Nov 2022 13:13:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8A58840F16; Wed, 16 Nov 2022 13:13:39 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2054.outbound.protection.outlook.com [40.107.244.54]) by mails.dpdk.org (Postfix) with ESMTP id E74EC40E03 for ; Wed, 16 Nov 2022 13:13:37 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SancMrxKG3nx1udB9Cj20Qc9T1/CPGE6L/oWFhkw1Cv6aRH0IJBGZ4IavyABN9Ce5y8lMtmZ3puhHG4VKZD/EJjcYJbHWOyO1TNfZL3N9ClaGZI9PY4SsNcCu0P7SnZhf71ImOJ+hqk1w78d2ctwWZTEYyuCSyJKIwtodiFx9THcoaLy+OogBRyI2ST88mqb6dEgvPZRKB/HZ6snYFvKxXYC8gQOpAkx+qfusL5eO5rbwASYotWuIe5J5EaVP37j8ExdiyCajQzRv/Kur5zXSuvbqXTS84eaJ7NnT4kY7lofiNy8ujRognNmV2VBLpHELOmWpla9eczA39+LQuVpWQ== 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=UEq39hZAH9BF+A2q/BHxtNg6mDZZA7Cwx7LXF3QP+mY=; b=WyjtsLPzdOqSC5tlwlhgpYYolPwaGVGwjDAQe15YGm7y0k/i5tob18LhyVKDwkrsD5dcRV27sJseUR25ifr2M/548AMBY/0HliG74hrM6IcEIdh3YFlX07s0g3qO1jKSHqceHuf8EL2uoOF9WekT2Qs0YTCup05qFMnv551Mpgg+VbRKCtwIPJrQJoj6G0NiNHHdf4BwIIZlb5bfYpfBeeRsHhd8iXafKiQneEEoKiIZrls/b0lUxwFj/qZTRG8rUee0v4ogCxUDxJ1BVGxTRNXg+CCwQ/xrCIcHJdD21NxaF1bbnta088pSGBWQpAjeihTZwe4PJOcl5SXIZ3D5QQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=UEq39hZAH9BF+A2q/BHxtNg6mDZZA7Cwx7LXF3QP+mY=; b=UAjGtsJSQuK7OSzYSFut+J8nls7e8ZuErToS7FIetNMmVWlWDe3DBPiNGJFmVD8XD/Wn7wn+S81unVxPphZ9HK0InRvwu8IMcnsdwuGqsyyc5oAR8Tfla2OGcnHhJs3de6LvT9CsM212baT2hCNCs4rKRZiPR6fXK6y9LdyG7HLH4bRTBS2CA7NAQ+uN96hplvWxkupyuXy4IC9bXJugCJQTTKKLUwGMha0jxA/YYsdxB6yKgmZxOGw+lr0K8QFZsAK+G4XLE0+Z2O1C4FLJcFFbIEqnm9QtjExkx+UWhDGEPz0bXluSu7W9gRREoBZ1dgo/c10+IsfLIFmK5CtVEw== Received: from DM6PR13CA0070.namprd13.prod.outlook.com (2603:10b6:5:134::47) by MN0PR12MB6295.namprd12.prod.outlook.com (2603:10b6:208:3c0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.16; Wed, 16 Nov 2022 12:13:35 +0000 Received: from DM6NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:5:134:cafe::1e) by DM6PR13CA0070.outlook.office365.com (2603:10b6:5:134::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Wed, 16 Nov 2022 12:13:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DM6NAM11FT037.mail.protection.outlook.com (10.13.172.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.8 via Frontend Transport; Wed, 16 Nov 2022 12:13:35 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 16 Nov 2022 04:13:34 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 16 Nov 2022 04:13:34 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) 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, 16 Nov 2022 04:13:33 -0800 From: Michael Baum To: CC: Matan Azrad , Viacheslav Ovsiienko , Christian Ehrhardt Subject: [PATCH 19.11] net/mlx5: fix port event cleaning order Date: Wed, 16 Nov 2022 14:13:28 +0200 Message-ID: <20221116121328.935537-1-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT037:EE_|MN0PR12MB6295:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a89c539-817e-4dc5-4eb9-08dac7cbfc85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e0YqM1vAvUDv/np0b2+7+Kiwu4W2E+VSIZ+r9NB+qizPuId8lAc7nHAMTlr8Q1yzrC7/A6rP/K+fgvBVZ76WQCrF1nE4dNS/PpFFe3hBaNu6v4t2GPoF9oQZO6vtpWE5DB+1lDz48r04Zv/l2wT0dQCBaLc8wNZH9UUxXriav394KqzR534NxQ1/5gCrjQObi6s2BHKRWSuFBaPBUdq51kvGZuCC4BKUdU4m3NdN4ecWNUEWbRcazz1JciesRWAolf3BmawU55xE6cYnK3v98DYB0Lyp7H016ffhky+evgq7yx8rmTR6EWacqiQZjQ3Q20rCkWpNkNaBPN8eKuqwC0HjMcHmj/9T1wRd1lKip9hxRZJmcoJv0GxNV0Yn2Z7w1fRBYc0of1GW9AgetDoFgIBeE7cy4YlNSm+k6B1STlrSFUUe9pMLS06tJSWzZn7votUwsf6WA8oRoaaAJU+4MBYPveBAb7LUY54WKTUTy/YuS0Tc9KE0mtKjUgsKpoWN6PKCskO8Cd0bMsdihm7Wb+pWXenpJBEU5j+ezciUO2UqrcdLYBwhgoXjIWKQ/fKPZFNkxi7wR1zT+UY6wSUStHYLekEq5BeeN5h8GY+xDqJatFm3liN60V66QH+rA7aHYAWPEQMZYWjduD4eb5Nolxtj5yNawzwDRcyaY6X3NXgVX+q3jUcpJOm3opDC/sQtWLI6/DuiCLuHIJfMp8V0C2ATuXELdsiEfI9HL3kT0aSCeWDEO5KDdRfP+6I9YqTsBr45sMHDJBSeaY2RP/dDPQ== X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(346002)(376002)(136003)(396003)(451199015)(36840700001)(46966006)(40470700004)(82310400005)(70586007)(40460700003)(8936002)(70206006)(36756003)(5660300002)(4326008)(41300700001)(8676002)(86362001)(36860700001)(478600001)(6286002)(47076005)(83380400001)(186003)(1076003)(2616005)(426003)(336012)(6666004)(7636003)(26005)(55016003)(7696005)(356005)(54906003)(316002)(6916009)(40480700001)(2906002)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2022 12:13:35.3667 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a89c539-817e-4dc5-4eb9-08dac7cbfc85 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6295 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 [ upstream commit 7ba5320baa3285bf8beca96cc025ff56b494060d ] 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: 0906b984ff1f ("net/mlx5: fix initial link status detection") Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index dee018bbba..ae3ba1885e 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1458,6 +1458,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->ibv_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; /* @@ -2883,6 +2889,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, return eth_dev; error: if (priv) { + priv->sh->port[priv->ibv_port - 1].nl_ih_port_id = + RTE_MAX_ETHPORTS; + rte_io_wmb(); if (priv->mreg_cp_tbl) mlx5_hlist_destroy(priv->mreg_cp_tbl, NULL, NULL); if (priv->sh) -- 2.25.1