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 E6B32A00C2 for ; Thu, 24 Nov 2022 08:53:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E2A3742DAA; Thu, 24 Nov 2022 08:53:45 +0100 (CET) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2047.outbound.protection.outlook.com [40.107.101.47]) by mails.dpdk.org (Postfix) with ESMTP id 8104F42C4D for ; Thu, 24 Nov 2022 08:53:44 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ga9oBX+DIgBj/1Suq0+B/Q8bDUyW7yKffOyUh2zV6ya6INW4rRNjkdxPQDxM1AfPvXrmmrLh7TDCbP34gnz3m6h0Yxmm8QMEs805aIf/wJE89oVimrThl5lMZTz3I5VeexjjyQq6RUF+CX7HcNJt+/bOUyQPm6HafsyBCZUb8Ja4954pSFEt9jyDWSmxAiCIdJjX6Qa+wH5UY6beOPUInXzSGO7UVT0E/z/qA7zeXH3KpNE/TNCWxGDJDYIZQcUoK5yo/1js26j6DkYsSOMUBNsS8nJML2oBnG1VdC1IZxzUqKvPZ/2iHZ0x2EbyhbQlxyB3FP0eJCHN2dIuSAq3oQ== 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=ZmqtUUGJMt7mZNdztaxbhJpYjh9Io+f0QWfmqiSHBxw=; b=R9oCM9qxaVEXNG6XHJQ3EnlKppzyYgT11etk551hzNMzxkOb5FEcj2570EBTntq5Kpn8FPqkjR4ljA1Y+TSaMtF238itPd2Xi7XA5vdOf0zAB3eAXEQq/B/NJrdps/Gz/aXFSTMQu/BHNfd/xVB7RCXChNlSMuEoQt/MOG9Th2+uthGS2ayJ/Y17BPw1ZrofoHhOsxti0qzVFZJtrdxn2p5AA0nK2Ur5uRK6AArX4LkpVx2tNisPoiq+6ZITyD3nc/GvlSMul5HKxAmjTvRlx0u7FPs2eBXX9Xk9cjoTTTv8cvUbLiySfq8ghKCEXvR7j7lG9pAizBEemCIs/X12/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=ZmqtUUGJMt7mZNdztaxbhJpYjh9Io+f0QWfmqiSHBxw=; b=XgQVrYGkzVeuLwD40j/xnMBXkRe1GtgmDsgFA27rBExaq0ieenR7LMuMPJxx7i1t+O7Npl0ECDz+KJGM0Jxxx8Iem7FrA2gcHLd1wsD2coLO2Ud/httPXpdnXRRYimRbuGICfkmgm2LUUarlw2D+jkJDJT5JbK0GctjZ8GIb4yUzqj39i0MFfD+DTDIGANbB4xAWwzhxfrthHjw9jM1kviV0c8ENlMf2+B7AN7xvcm9rdePHo2sHZlIRXw2AfYbRczF9LldzATDStgW0SLnUBogSy4qhN5otJS5IUAQwoc2nvyKVdOV0FW5C638MEUVmCH2Vx/5L1Uu1N0XwDF7S4g== Received: from MW4P220CA0005.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::10) by MN0PR12MB6004.namprd12.prod.outlook.com (2603:10b6:208:380::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17; Thu, 24 Nov 2022 07:53:42 +0000 Received: from CO1NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:303:115:cafe::88) by MW4P220CA0005.outlook.office365.com (2603:10b6:303:115::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.19 via Frontend Transport; Thu, 24 Nov 2022 07:53:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CO1NAM11FT010.mail.protection.outlook.com (10.13.175.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.18 via Frontend Transport; Thu, 24 Nov 2022 07:53:41 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 23 Nov 2022 23:53:29 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) 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, 23 Nov 2022 23:53:29 -0800 Received: from nvidia.com (10.127.8.13) by mail.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 via Frontend Transport; Wed, 23 Nov 2022 23:53:28 -0800 From: Michael Baum To: CC: Matan Azrad , Viacheslav Ovsiienko , Kevin Traynor Subject: [PATCH 21.11 2/2] net/mlx5: fix port event cleaning order Date: Thu, 24 Nov 2022 09:53:20 +0200 Message-ID: <20221124075320.2026822-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124075320.2026822-1-michaelba@nvidia.com> References: <20221124075320.2026822-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: CO1NAM11FT010:EE_|MN0PR12MB6004:EE_ X-MS-Office365-Filtering-Correlation-Id: 9df07f3a-d14b-43dc-5a4d-08dacdf10154 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ng9e8R5JhqbMgmPo6uulxBVaA4QSfLRA78mLWI3wwUqZwW4swzihnR0NROrUFg/lWqy1/4BjdEZ2u/RjDZu3dnoN3jazUYqdPTpuVaXTqfB+DrjwM0c/X+XdBDUpFaql3WqsnxhcWs8QhxPTguMupWZcHz341Hgux6iFJ/PNm9p+b8Y31Mg1QPkmb0b++3oVKFtrN0rD9KlkYCcly3VTSQTiR4Qh5grcAfT4vL2ZKS/61zV/tSS4vymXIdnE+Hh5YjrUwk893ymiEupjybwefY20cw8UnJVgTrvqcwE0aVnRAz5ZI12xLi4MXc1uuH6Cq1D9URo7fTFAEyD5Lb5fOeprHdXRbxAqUbih3ZcUPiYOAO1NYO36d925jzkzLU+6iGGPwqftCdpLmuC37sMrdYwELB1bVp+FDd5Me1YaWxwmgQkryYiKkjNsjVcGo0z0pY/oce1pDYNWNv2viIvd4P5+q7JQD78Xcdom3ax/7X8wyJwpOfH1fzY3FkBVT3ezHkuEREMAmdoOMgK0S9ke382UJwsGz7XUSp9Mj4Kzh4oBIxfwk4Ca15jWnq0f0L1Mxq0t5M+Q88rQTKQFg/Hbe+izrDQTXm1M7sVaF0YckcNhL1bsVNLRblhyzuL9Nbqe8qIBy/2etYviGhK40wt98n7ErHt2bZqLM09oqpAPbJm1PLACDbERf3AWvDp1WjXO+OSDp+IFet31aQW6vm056w== X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(136003)(376002)(346002)(396003)(451199015)(40470700004)(36840700001)(46966006)(86362001)(36756003)(55016003)(40480700001)(70206006)(186003)(2616005)(70586007)(41300700001)(40460700003)(1076003)(47076005)(4326008)(336012)(5660300002)(426003)(6666004)(8936002)(8676002)(316002)(26005)(6286002)(478600001)(7696005)(6916009)(7636003)(82740400003)(356005)(82310400005)(54906003)(83380400001)(2906002)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2022 07:53:41.8370 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9df07f3a-d14b-43dc-5a4d-08dacdf10154 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.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6004 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 13c5c093905c09bb6207ee1c6a4f05d39f8badcd ] 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: 3a5e1aaee4cd ("net/mlx5: fix initial link status detection") Signed-off-by: Michael Baum Acked-by: Matan Azrad --- 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 4197ec424e..2fee13d50f 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1802,6 +1802,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(); if (priv->mreg_cp_tbl) mlx5_hlist_destroy(priv->mreg_cp_tbl); if (priv->sh) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index f79e71fe1a..c5f2db1e4a 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1656,6 +1656,12 @@ mlx5_dev_close(struct rte_eth_dev *dev) dev->data->port_id); if (priv->hrxqs) mlx5_list_destroy(priv->hrxqs); + 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(); /* * Free the shared context in last turn, because the cleanup * routines above may use some shared fields, like -- 2.25.1